pref(托盘界面): 调整托盘界面单网卡显示(story#18148)
This commit is contained in:
parent
a771281f6b
commit
7ce857f0c8
|
@ -38,6 +38,7 @@
|
|||
#define MAINWINDOW_HEIGHT 476
|
||||
#define LAYOUT_MARGINS 0,0,0,0
|
||||
#define LOADING_TRAYICON_TIMER_MS 60
|
||||
#define TABBAR_HEIGHT 30
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define COLOR_THEME "styleName"
|
||||
|
||||
|
@ -174,6 +175,11 @@ void MainWindow::firstlyStart()
|
|||
|
||||
//加载key ring
|
||||
agent_init();
|
||||
|
||||
//单网卡显示
|
||||
setCentralWidgetPages();
|
||||
connect(m_lanWidget, &LanPage::deviceStatusChanged, this, &MainWindow::setCentralWidgetPages);
|
||||
connect(m_wlanWidget, &LanPage::wirelessDeviceStatusChanged, this, &MainWindow::setCentralWidgetPages);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -826,8 +832,56 @@ void MainWindow::onRefreshTrayIconTooltip()
|
|||
m_trayIcon->setToolTip(trayIconToolTip);
|
||||
}
|
||||
|
||||
void MainWindow::setCentralWidgetPages()
|
||||
{
|
||||
bool isChanged = false;
|
||||
if (m_isWiredUsable != m_lanWidget->isWiredDeviceUsable()) {
|
||||
if (m_lanWidget->isWiredDeviceUsable()) {
|
||||
m_centralWidget->insertTab(LANPAGE, m_lanWidget, "");
|
||||
m_isWiredUsable = true;
|
||||
} else {
|
||||
m_centralWidget->removeTab(LANPAGE);
|
||||
m_isWiredUsable = false;
|
||||
}
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (m_isWirelessUsable != m_wlanWidget->isWirelessDeviceUsable()) {
|
||||
if (m_wlanWidget->isWirelessDeviceUsable()) {
|
||||
m_centralWidget->insertTab(WLANPAGE, m_wlanWidget, "");
|
||||
m_isWirelessUsable = true;
|
||||
} else {
|
||||
m_centralWidget->removeTab(WLANPAGE);
|
||||
m_isWirelessUsable = false;
|
||||
}
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (!isChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isWiredUsable && m_isWirelessUsable) {
|
||||
m_centralWidget->tabBar()->show();
|
||||
this->setFixedHeight(MAINWINDOW_HEIGHT);
|
||||
resetWindowPosition();
|
||||
} else {
|
||||
m_centralWidget->tabBar()->hide();
|
||||
this->setFixedHeight(MAINWINDOW_HEIGHT - TABBAR_HEIGHT);
|
||||
resetWindowPosition();
|
||||
}
|
||||
|
||||
if (m_trayIcon) {
|
||||
m_trayIcon->setVisible(m_isWiredUsable || m_isWirelessUsable);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onShowMainWindow(int type)
|
||||
{
|
||||
if (!m_trayIcon->isVisible()) {
|
||||
qWarning() << "no valid network card, do not show kylin-nm mainwindow";
|
||||
return;
|
||||
}
|
||||
if (type == LANPAGE || type == WLANPAGE) {
|
||||
m_centralWidget->setCurrentIndex(type);
|
||||
|
||||
|
|
|
@ -206,6 +206,9 @@ private:
|
|||
|
||||
QString m_display;
|
||||
|
||||
bool m_isWiredUsable = true;
|
||||
bool m_isWirelessUsable = true;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onShowMainWindow(int type);
|
||||
|
||||
|
@ -231,6 +234,8 @@ private Q_SLOTS:
|
|||
void onShowCreateWiredConnectWidgetSlot(QString display, QString devName);
|
||||
//唤起加入其他无线网络界面
|
||||
void onShowAddOtherWlanWidgetSlot(QString display, QString devName);
|
||||
//设置界面显示 单网卡/多网卡
|
||||
void setCentralWidgetPages();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -52,6 +52,10 @@ public:
|
|||
bool lanIsConnected();
|
||||
void getWiredDeviceConnectState(QMap<QString, QString> &map);
|
||||
|
||||
bool isWiredDeviceUsable() {
|
||||
return !m_devList.isEmpty();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
|
|
|
@ -88,6 +88,10 @@ public:
|
|||
return m_currentDevice;
|
||||
}
|
||||
|
||||
bool isWirelessDeviceUsable() {
|
||||
return !m_devList.isEmpty();
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void oneItemExpanded(const QString &ssid);
|
||||
void wlanAdd(QString devName, QStringList info);
|
||||
|
|
Loading…
Reference in New Issue