From 0b7e5e2a40352a771bebe4f1a740bb03ae8ad882 Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Wed, 22 Sep 2021 15:02:40 +0800 Subject: [PATCH 1/6] modify --- src/frontend/tab-pages/wlanpage.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index f1cf0b6f..72a99922 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -724,10 +724,6 @@ void WlanPage::showDetailPage(QString devName, QString ssid) QMap actMap; m_resource->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap); - if (!actMap.contains(devName)) { - qDebug()<<"[WlanPage] " << devName << " is missing when showDetailPage"; - return; - } bool isActive = actMap[devName].contains(ssid); NetDetail *netDetail = new NetDetail(devName, ssid, data.m_connectUuid, isActive, true, false, this); From c20a9a94c6a0cfba4469fd11479ca03abe34990f Mon Sep 17 00:00:00 2001 From: jinxujie Date: Wed, 22 Sep 2021 18:03:06 +0800 Subject: [PATCH 2/6] 1 --- src/frontend/list-items/lanlistitem.h | 1 + src/frontend/list-items/wlanlistitem.cpp | 33 +----- src/frontend/new-mainwindow.cpp | 26 ++++- src/frontend/new-mainwindow.h | 1 + src/frontend/tab-pages/lanpage.cpp | 8 ++ src/frontend/tab-pages/lanpage.h | 5 + src/frontend/tab-pages/tabpage.cpp | 19 ++++ src/frontend/tab-pages/tabpage.h | 4 + src/frontend/tab-pages/wlanpage.cpp | 126 ++++++++++++++++++++++- src/frontend/tab-pages/wlanpage.h | 18 ++++ 10 files changed, 202 insertions(+), 39 deletions(-) diff --git a/src/frontend/list-items/lanlistitem.h b/src/frontend/list-items/lanlistitem.h index bd46ae9e..4c7ff28a 100644 --- a/src/frontend/list-items/lanlistitem.h +++ b/src/frontend/list-items/lanlistitem.h @@ -22,6 +22,7 @@ public: KyConnectResourse *m_connectResource = nullptr; QString deviceName = ""; + void refreshIcon(); protected: void setIcon(bool isOn); diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index 05bfc8b4..7c42e596 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -270,8 +270,8 @@ void WlanListItem::onNetButtonClicked() qDebug()<<"Clicked on connected wifi, it will be inactivated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__; return; } - - if (m_data->m_isConfigured) { +//有配置或者无密码的wifi直接连接 + if (m_data->m_isConfigured || m_hasPwd == false) { m_connoperation->activeWirelessConnect(m_wlanDevice,m_data->m_connectUuid); qDebug()<<"Has configuration, will be activated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__; return; @@ -399,35 +399,6 @@ void WlanListItem::onWlanStatusChange(QString uuid, NetworkManager::ActiveConnec m_netButton->stopLoading(); } } - - //TODO 网络状态改变的通知 -// if (state == NetworkManager::ActiveConnection::State::Activated) { -//// this->showDesktopNotify(tr("WLAN Connected Successfully")); -// } else if (state == NetworkManager::ActiveConnection::State::Deactivated) { -// switch (reason) { -// case NetworkManager::ActiveConnection::Reason::UserDisconnected: -// this->showDesktopNotify(tr("WLAN Disconnected Successfully")); -// break; -// case NetworkManager::ActiveConnection::Reason::ServiceStopped: -// this->showDesktopNotify(tr("The service providing the VPN connection was stopped")); -// break; -// case NetworkManager::ActiveConnection::Reason::IpConfigInvalid: -// this->showDesktopNotify(tr("The IP config of the active connection was invalid")); -// break; -// case NetworkManager::ActiveConnection::Reason::ConnectTimeout: -// this->showDesktopNotify(tr("The connection attempt to the VPN service timed out")); -// break; -// case NetworkManager::ActiveConnection::Reason::NoSecrets: -// this->showDesktopNotify(tr("Necessary secrets for the connection were not provided")); -// break; -// case NetworkManager::ActiveConnection::Reason::LoginFailed: -// this->showDesktopNotify(tr("Authentication to the server failed")); -// break; -// default: -// qDebug() << "Wlan disconnected with unkown reason." << Q_FUNC_INFO << __LINE__; -// break; -// } -// } } void WlanListItem::onMenuTriggered(QAction *action) diff --git a/src/frontend/new-mainwindow.cpp b/src/frontend/new-mainwindow.cpp index 8a897273..91cccea3 100644 --- a/src/frontend/new-mainwindow.cpp +++ b/src/frontend/new-mainwindow.cpp @@ -146,7 +146,7 @@ void MainWindow::initTrayIcon() m_trayIconMenu->addAction(m_showMainwindowAction); m_trayIconMenu->addAction(m_showSettingsAction); m_trayIcon->setContextMenu(m_trayIconMenu); - m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic")); + m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated); connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled); @@ -170,6 +170,7 @@ void MainWindow::initDbusConnnect() connect(m_lanWidget, &LanPage::lanRemove, this, &MainWindow::lanRemove); connect(m_lanWidget, &LanPage::lanUpdate, this, &MainWindow::lanUpdate); connect(m_lanWidget, &LanPage::lanActiveConnectionStateChanged, this, &MainWindow::lanActiveConnectionStateChanged); + connect(m_lanWidget, &LanPage::lanConnectChanged, this, &MainWindow::onGetConnectChangedIcon); connect(m_wlanWidget, &WlanPage::wlanAdd, this, &MainWindow::wlanAdd); @@ -179,6 +180,7 @@ void MainWindow::initDbusConnnect() connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated); connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange); connect(m_wlanWidget, &WlanPage::signalStrengthChange, this, &MainWindow::signalStrengthChange); + connect(m_wlanWidget, &WlanPage::wlanConnectChanged, this, &MainWindow::onGetConnectChangedIcon); } /** @@ -301,7 +303,12 @@ void MainWindow::resetWindowTheme() void MainWindow::showControlCenter() { QProcess process; - process.startDetached("ukui-control-center --netconnect"); + if(m_lanWidget->lanIsConnected == false && m_wlanWidget->wlanIsConnected == true){ + process.startDetached("ukui-control-center --wlanconnect"); + } + else{ + process.startDetached("ukui-control-center --wiredconnect"); + } } /** @@ -338,6 +345,20 @@ void MainWindow::onThemeChanged(const QString &key) } } +void MainWindow::onGetConnectChangedIcon() +{ + if (m_lanWidget->lanIsConnected == true){ + qDebug()<<"11111111111111111111111111"; + m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); + } else if (m_wlanWidget->wlanIsConnected == true && m_lanWidget->lanIsConnected == false){ + qDebug()<<"2222222222222222222"; + m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic")); + } else if (m_wlanWidget->wlanIsConnected == false && m_lanWidget->lanIsConnected == false){ + qDebug()<<"333333333333333333333333"; + m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); + } +} + /** * @brief MainWindow::keyPressEvent 按esc键关闭主界面 * @param event @@ -466,7 +487,6 @@ void MainWindow::activateWired(const QString& devName, const QString& connUuid) { m_lanWidget->activateWired(devName, connUuid); } - void MainWindow::deactivateWired(const QString& devName, const QString& connUuid) { m_lanWidget->deactivateWired(devName, connUuid); diff --git a/src/frontend/new-mainwindow.h b/src/frontend/new-mainwindow.h index 71feb051..ff195d19 100644 --- a/src/frontend/new-mainwindow.h +++ b/src/frontend/new-mainwindow.h @@ -117,6 +117,7 @@ private slots: void onShowMainwindowActionTriggled(); void onShowSettingsActionTriggled(); void onThemeChanged(const QString &key); + void onGetConnectChangedIcon(); }; #endif // MAINWINDOW_H diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 58165e16..8ddff622 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -394,6 +394,7 @@ void LanPage::initUI() // m_inactivatedLanListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //用了listwidget的滚动条 inactiveLanListLayout->addWidget(m_inactivatedLanListWidget); + emit this->lanConnectChanged(); } void LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget) @@ -423,6 +424,7 @@ void LanPage::initList(QString m_deviceName) //程序拉起,初始化显 for (int i = 0; i < m_activedList.size(); i++) { KyConnectItem *activeItemData = m_activedList.at(i); addNewItem(activeItemData, m_activatedLanListWidget); + emit this->lanConnectChanged(); m_activeMap.insert(activeItemData, m_listWidgetItem); } @@ -487,6 +489,7 @@ void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::Stat if (m_item->m_connectUuid == uuid) { m_activatedLanListWidget->removeItemWidget(i.value()); delete(i.value()); + emit this->lanConnectChanged(); break; } } @@ -612,6 +615,11 @@ void LanPage::onLanDataChange(QString uuid) } } +void LanPage::getLanConnectStatus(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason) +{ + +} + void LanPage::setWiredDeviceEnable(const QString& devName, bool enable) { saveDeviceEnableState(devName, enable); diff --git a/src/frontend/tab-pages/lanpage.h b/src/frontend/tab-pages/lanpage.h index 882f9473..effe9d84 100644 --- a/src/frontend/tab-pages/lanpage.h +++ b/src/frontend/tab-pages/lanpage.h @@ -21,6 +21,7 @@ class LanPage : public TabPage public: explicit LanPage(QWidget *parent = nullptr); ~LanPage(); + bool lanIsConnected = false; //for dbus void getWiredList(QMap > &map); @@ -33,6 +34,7 @@ signals: void lanRemove(QString dbusPath); void lanUpdate(QString devName, QStringList info); void lanActiveConnectionStateChanged(QString interface, QString uuid, int status); + void lanConnectChanged(); private: void initDeviceCombox(); void initUI(); @@ -81,6 +83,9 @@ private slots: void onDeviceNameUpdate(QString oldName, QString newName); void onDeviceComboxIndexChanged(int currentIndex); void onLanDataChange(QString uuid); + void getLanConnectStatus(QString uuid, + NetworkManager::ActiveConnection::State state, + NetworkManager::ActiveConnection::Reason reason); }; #endif // LANPAGE_H diff --git a/src/frontend/tab-pages/tabpage.cpp b/src/frontend/tab-pages/tabpage.cpp index 0273fdb6..bfd38925 100644 --- a/src/frontend/tab-pages/tabpage.cpp +++ b/src/frontend/tab-pages/tabpage.cpp @@ -107,6 +107,24 @@ QString TabPage::getDefaultDevice() return m_defaultDevice; } +void TabPage::showDesktopNotify(const QString &message) +{ + QDBusInterface iface("org.freedesktop.Notifications", + "/org/freedesktop/Notifications", + "org.freedesktop.Notifications", + QDBusConnection::sessionBus()); + QList args; + args<<(tr("Kylin NM")) + <<((unsigned int) 0) + < &map) map.clear(); if (!QFile::exists(CONFIG_FILE_PATH)) { qDebug() << "CONFIG_FILE_PATH not exist"; + return; } if (type != WIRED && type != WIRELESS) { qDebug() << "getDeviceEnableState but wrong type"; diff --git a/src/frontend/tab-pages/tabpage.h b/src/frontend/tab-pages/tabpage.h index 2aee84a8..7088fb8c 100644 --- a/src/frontend/tab-pages/tabpage.h +++ b/src/frontend/tab-pages/tabpage.h @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include #include "kylinnetworkdeviceresource.h" #define MAIN_LAYOUT_MARGINS 0,0,0,0 @@ -50,6 +53,7 @@ public: void updateDefaultDevice(QString &deviceName); QString getDefaultDevice(); + static void showDesktopNotify(const QString &message); signals: void deviceStatusChanged(); diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 72a99922..450ceb6e 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -17,6 +17,8 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent) initDevice(); m_wirelessConnectOpreation = new KyWirelessConnectOperation(this); m_connectoperation = new KyConnectOperation(this); + m_settingsLabel->installEventFilter(this); + m_connectResource = new KyActiveConnectResourse(); initWlanUI(); //要在initUI之后调用,保证UI的信号槽顺利绑定 initConnections(); @@ -33,6 +35,10 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent) connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::deactivateConnectionError, this, &WlanPage::deactivateFailed); connect(this, &WlanPage::hiddenWlanClicked, this, &WlanPage::onHiddenWlanClicked); + connect(this, &WlanPage::settingsClicked, this, &WlanPage::showControlCenter); + connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::onWlanStatusChange); + connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::getWlanConnectStatus); + connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::wifinEnabledChanged, this, &WlanPage::onWifinEnabledChanged); } //QString WlanPage::getSsidFromUuid(const QString &uuid) @@ -48,6 +54,7 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e) emit this->hiddenWlanClicked(); } else if (w == m_settingsLabel) { //ZJP_TODO 打开控制面板 + emit this->settingsClicked(); } } return QWidget::eventFilter(w,e); @@ -154,6 +161,11 @@ void WlanPage::initDevice() if (!m_devList.isEmpty()) { deviceName = m_devList.at(0); m_settings->setValue(key, deviceName); + } else { + qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__; + //检测不到无线网卡不再触发click信号 + m_netSwitch->setSwitchStatus(false); + m_netSwitch->setEnabled(false); } updateDefaultDevice(deviceName); qDebug() << "[WlanPage] initDevice defaultDevice = " << deviceName; @@ -217,6 +229,8 @@ void WlanPage::getActiveWlan() QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget); wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height())); m_activatedNetListWidget->addItem(wlanItem); + emit this->wlanConnectChanged(); + qDebug() << "[wlanpage]emit wlanConnectChanged()" << Q_FUNC_INFO << __LINE__ ; m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget); height += wlanItemWidget->height(); } @@ -239,6 +253,8 @@ void WlanPage::appendActiveWlan(const QString &uuid, int &height) QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget); wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height())); m_activatedNetListWidget->addItem(wlanItem); + emit this->wlanConnectChanged(); + qDebug() << "[wlanpage]emit wlanConnectChanged()" << Q_FUNC_INFO << __LINE__ ; m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget); wlanItemWidget->setActive(true); @@ -253,7 +269,7 @@ void WlanPage::getAllWlan() if (!m_inactivatedNetListWidget) { return; } - qDebug() << "Started loading wlan list! time=" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz"); + qDebug() << "Started loading wlan list! time=我的getallwlah" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz"); m_inactivatedNetListWidget->clear(); m_itemsMap.clear(); QList wlanList; @@ -293,8 +309,6 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item) QStringList info; info <setEnabled(true); + m_netSwitch->setSwitchStatus(true); m_devList << deviceName; if (getDefaultDevice().isEmpty()) { @@ -375,6 +391,9 @@ void WlanPage::onDeviceRemove(QString deviceName) m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, list); if (!list.isEmpty()) { newDefaultDevice = list.at(0); + } else { + m_netSwitch->setSwitchStatus(false); + m_netSwitch->setEnabled(false); } updateDefaultDevice(newDefaultDevice); setDefaultDevice(WIRELESS, newDefaultDevice); @@ -469,6 +488,7 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec m_activatedNetListWidget->clear(); int height = 0; appendActiveWlan(uuid, height); + emit this->wlanConnectChanged(); onWlanRemoved(m_defaultDevice, ssid); // this->showDesktopNotify(tr("Connect WLAN succeed")); } else if (state == NetworkManager::ActiveConnection::State::Deactivated && (uuid.isEmpty() || (!uuid.isEmpty() && uuid == m_activatedWlanUuid))) { @@ -525,12 +545,21 @@ void WlanPage::onConnectButtonClicked(KyWirelessConnectSetting &connSettingInfo, void WlanPage::onWlanSwitchClicked() { qDebug() << "On wlan switch button clicked! old state = " << !m_netSwitch->getSwitchStatus() << Q_FUNC_INFO << __LINE__; - m_wirelessConnectOpreation->setWirelessEnabled(m_netSwitch->getSwitchStatus()); + //应该先检测是否有无线网卡可用,才改变开关状态 + m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList); + qDebug()<< "------------应该先检测是否有无线网卡可用,才改变开关状态-------------" <setSwitchStatus(false); + m_netSwitch->setEnabled(false); + }else{ + m_wirelessConnectOpreation->setWirelessEnabled(m_netSwitch->getSwitchStatus()); + } } void WlanPage::onWlanSwitchStatusChanged(const bool &checked) { - m_netSwitch->setSwitchStatus(checked); qDebug() << "On wlan switch status changed! new state = " << m_netSwitch->getSwitchStatus() << Q_FUNC_INFO << __LINE__; onWlanUpdated(); } @@ -553,8 +582,11 @@ void WlanPage::requestScan() { if (!m_wirelessConnectOpreation) { qWarning() << "Scan failed! m_wirelessConnectOpreation is nullptr!" << Q_FUNC_INFO << __LINE__; + return; } + qWarning() << "Scan ------requestScan------刷新列表-----------------------------------" << Q_FUNC_INFO << __LINE__; m_wirelessConnectOpreation->requestWirelessScan(); + getAllWlan(); } void WlanPage::onHiddenWlanClicked() @@ -564,6 +596,51 @@ void WlanPage::onHiddenWlanClicked() netDetail->show(); } +void WlanPage::showControlCenter() +{ + QProcess process; + process.startDetached("ukui-control-center --wlanconnect"); +} + +void WlanPage::getWlanConnectStatus(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason) +{ + //wlanpage函数内持续监听连接状态的变化并记录供其他函数调用获取状态 + QString devName; + NetworkManager::ConnectionSettings::ConnectionType type; + if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) { + if (type != NetworkManager::ConnectionSettings::ConnectionType::Wireless) { + return; + } + } + if(NetworkManager::ActiveConnection::State::Activated == state){ + wlanIsConnected = true; + qDebug() << "111111111111[wlanpage]------------" << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; + } else { + wlanIsConnected = false; + qDebug() << "1111111111111[wlanpage]--------------" << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; + } +} + +void WlanPage::onWifinEnabledChanged(bool isWifiOn) +{ +//监听外部命令导致wifi状态变化,更新界面 + qDebug() <<"------------------------------监听外部命令导致wifi状态变化,更新界面-----------------------------------------"; + //应该先检测是否有无线网卡可用,才改变开关状态 + m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList); + if (m_devList.isEmpty()) { + qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__; + return; + } + if(m_netSwitch->getSwitchStatus() == isWifiOn){ + return; + }else{ + //m_wirelessConnectOpreation->setWirelessEnabled(isWifiOn); + qDebug() << "have no device to use++++++++++++++++ " << Q_FUNC_INFO << __LINE__; + m_netSwitch->setSwitchStatus(isWifiOn); + //外部命令导致连接状态发生变化,通知主界面刷新图标 + emit this->wlanConnectChanged(); + } +} //for dbus void WlanPage::getWirelessList(QMap > &map) @@ -714,6 +791,7 @@ void WlanPage::onMainWindowVisibleChanged(const bool &visible) m_scanTimer->stop(); } } + void WlanPage::showDetailPage(QString devName, QString ssid) { KyWirelessNetItem data; @@ -724,8 +802,46 @@ void WlanPage::showDetailPage(QString devName, QString ssid) QMap actMap; m_resource->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap); + if (!actMap.contains(devName)) { + qDebug()<<"[WlanPage] " << devName << " is missing when showDetailPage"; + return; + } bool isActive = actMap[devName].contains(ssid); NetDetail *netDetail = new NetDetail(devName, ssid, data.m_connectUuid, isActive, true, false, this); netDetail->show(); } + +void WlanPage::onWlanStatusChange(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason) +{ + //弹窗显示wifi连接状况 + QString devName; + NetworkManager::ConnectionSettings::ConnectionType type; + if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) { + if (type != NetworkManager::ConnectionSettings::ConnectionType::Wireless) { + return; + } + } + qDebug() << "[WlanPage] State changed to :" << state << reason << Q_FUNC_INFO <<__LINE__; + QString ssid; + m_resource->getSsidByUuid(uuid, ssid, m_defaultDevice); + if (m_activatedWlanSSid == ssid && state == NetworkManager::ActiveConnection::State::Activated) { + if(activessid != m_activatedWlanSSid){ + activessid = m_activatedWlanSSid; + qDebug() << "[WlanPage] State changed to :" << state << ssid << reason << Q_FUNC_INFO <<__LINE__; + this->showDesktopNotify(tr("WLAN Connected Successfully")); + } + } + if (state == NetworkManager::ActiveConnection::State::Deactivating){ + deactinguuid = uuid; + deactingflag = true; + } + if (state == NetworkManager::ActiveConnection::State::Deactivated && deactinguuid == uuid){ + if(deactingflag){ + deactingflag = false; + this->showDesktopNotify(tr("WLAN Disconnected Successfully")); + qDebug() << "clear the activessid" << Q_FUNC_INFO <<__LINE__; + activessid = ""; + } + } +} diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index a7aceaa1..efc5df17 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -10,6 +10,9 @@ #include "kylinconnectoperation.h" #include #include "netdetails/netdetail.h" +#include +#include "kylinactiveconnectresource.h" +#include "kywirelessnetresource.h" //#define SCROLLAREA_HEIGHT 150 #define MORE_TEXT_MARGINS 16,0,0,0 @@ -21,6 +24,7 @@ class WlanPage : public TabPage public: explicit WlanPage(QWidget *parent = nullptr); ~WlanPage() = default; + bool wlanIsConnected = false; //for dbus void getWirelessList(QMap > &map); @@ -44,9 +48,14 @@ signals: void signalStrengthChange(QString devName, QString ssid, int strength); void secuTypeChange(QString devName, QString ssid, QString secuType); void hiddenWlanClicked(); + void settingsClicked(); + void wlanConnectChanged(); public slots: void onMainWindowVisibleChanged(const bool &visible); + void onWlanStatusChange(QString uuid, + NetworkManager::ActiveConnection::State state, + NetworkManager::ActiveConnection::Reason reason); protected: bool eventFilter(QObject *watched, QEvent *event); @@ -54,6 +63,10 @@ protected: private: void initWlanUI(); void initConnections(); + QString activessid; + QString deactinguuid; + int deacting; + bool deactingflag = false; //定时触发扫描的定时器 void initTimer(); @@ -106,6 +119,11 @@ private slots: void onDeviceComboxIndexChanged(int currentIndex); void requestScan(); void onHiddenWlanClicked(); + void showControlCenter(); + void getWlanConnectStatus(QString uuid, + NetworkManager::ActiveConnection::State state, + NetworkManager::ActiveConnection::Reason reason); + void onWifinEnabledChanged(bool isWifiOn); }; #endif // WLANPAGE_H From 0c739884a69e14fe625fe544855332f9041059c8 Mon Sep 17 00:00:00 2001 From: jinxujie Date: Thu, 23 Sep 2021 09:56:23 +0800 Subject: [PATCH 3/6] wlanpage changed --- src/frontend/new-mainwindow.cpp | 3 --- src/frontend/tab-pages/lanpage.cpp | 18 ++++++++++++++++-- src/frontend/tab-pages/wlanpage.cpp | 16 +++++----------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/frontend/new-mainwindow.cpp b/src/frontend/new-mainwindow.cpp index 91cccea3..fa96a715 100644 --- a/src/frontend/new-mainwindow.cpp +++ b/src/frontend/new-mainwindow.cpp @@ -348,13 +348,10 @@ void MainWindow::onThemeChanged(const QString &key) void MainWindow::onGetConnectChangedIcon() { if (m_lanWidget->lanIsConnected == true){ - qDebug()<<"11111111111111111111111111"; m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); } else if (m_wlanWidget->wlanIsConnected == true && m_lanWidget->lanIsConnected == false){ - qDebug()<<"2222222222222222222"; m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic")); } else if (m_wlanWidget->wlanIsConnected == false && m_lanWidget->lanIsConnected == false){ - qDebug()<<"333333333333333333333333"; m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); } } diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 8ddff622..7243e399 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -394,7 +394,7 @@ void LanPage::initUI() // m_inactivatedLanListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //用了listwidget的滚动条 inactiveLanListLayout->addWidget(m_inactivatedLanListWidget); - emit this->lanConnectChanged(); +// emit this->lanConnectChanged(); } void LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget) @@ -617,7 +617,21 @@ void LanPage::onLanDataChange(QString uuid) void LanPage::getLanConnectStatus(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason) { - + //lanpage函数内持续监听连接状态的变化并记录供其他函数调用获取状态 + QString devName; + NetworkManager::ConnectionSettings::ConnectionType type; + if (m_connectResourse->getInterfaceByUuid(devName, type, uuid)) { + if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) { + return; + } + } + if (NetworkManager::ActiveConnection::State::Activated == state){ + lanIsConnected = true; + qDebug() << "[lanpage]lanIsConnected status : " << lanIsConnected << Q_FUNC_INFO << __LINE__ ; + } else { + lanIsConnected = false; + qDebug() << "=[lanpage]lanIsConnected status : " << lanIsConnected << Q_FUNC_INFO << __LINE__ ; + } } void LanPage::setWiredDeviceEnable(const QString& devName, bool enable) diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 450ceb6e..40407ffb 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -229,8 +229,7 @@ void WlanPage::getActiveWlan() QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget); wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height())); m_activatedNetListWidget->addItem(wlanItem); - emit this->wlanConnectChanged(); - qDebug() << "[wlanpage]emit wlanConnectChanged()" << Q_FUNC_INFO << __LINE__ ; +// emit this->wlanConnectChanged(); m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget); height += wlanItemWidget->height(); } @@ -269,7 +268,7 @@ void WlanPage::getAllWlan() if (!m_inactivatedNetListWidget) { return; } - qDebug() << "Started loading wlan list! time=我的getallwlah" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz"); + qDebug() << "Started loading wlan list!" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz"); m_inactivatedNetListWidget->clear(); m_itemsMap.clear(); QList wlanList; @@ -488,7 +487,7 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec m_activatedNetListWidget->clear(); int height = 0; appendActiveWlan(uuid, height); - emit this->wlanConnectChanged(); +// emit this->wlanConnectChanged(); onWlanRemoved(m_defaultDevice, ssid); // this->showDesktopNotify(tr("Connect WLAN succeed")); } else if (state == NetworkManager::ActiveConnection::State::Deactivated && (uuid.isEmpty() || (!uuid.isEmpty() && uuid == m_activatedWlanUuid))) { @@ -547,7 +546,6 @@ void WlanPage::onWlanSwitchClicked() qDebug() << "On wlan switch button clicked! old state = " << !m_netSwitch->getSwitchStatus() << Q_FUNC_INFO << __LINE__; //应该先检测是否有无线网卡可用,才改变开关状态 m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList); - qDebug()<< "------------应该先检测是否有无线网卡可用,才改变开关状态-------------" <requestWirelessScan(); - getAllWlan(); } void WlanPage::onHiddenWlanClicked() @@ -614,17 +610,16 @@ void WlanPage::getWlanConnectStatus(QString uuid, NetworkManager::ActiveConnecti } if(NetworkManager::ActiveConnection::State::Activated == state){ wlanIsConnected = true; - qDebug() << "111111111111[wlanpage]------------" << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; + qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; } else { wlanIsConnected = false; - qDebug() << "1111111111111[wlanpage]--------------" << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; + qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; } } void WlanPage::onWifinEnabledChanged(bool isWifiOn) { //监听外部命令导致wifi状态变化,更新界面 - qDebug() <<"------------------------------监听外部命令导致wifi状态变化,更新界面-----------------------------------------"; //应该先检测是否有无线网卡可用,才改变开关状态 m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList); if (m_devList.isEmpty()) { @@ -635,7 +630,6 @@ void WlanPage::onWifinEnabledChanged(bool isWifiOn) return; }else{ //m_wirelessConnectOpreation->setWirelessEnabled(isWifiOn); - qDebug() << "have no device to use++++++++++++++++ " << Q_FUNC_INFO << __LINE__; m_netSwitch->setSwitchStatus(isWifiOn); //外部命令导致连接状态发生变化,通知主界面刷新图标 emit this->wlanConnectChanged(); From 7f8b8ad266d3c6de1e83e61a981f91d645db4882 Mon Sep 17 00:00:00 2001 From: jinxujie Date: Thu, 23 Sep 2021 10:31:01 +0800 Subject: [PATCH 4/6] 0923-1-jxj --- src/frontend/tab-pages/lanpage.cpp | 36 ++++++++++++--------------- src/frontend/tab-pages/lanpage.h | 3 --- src/frontend/tab-pages/wlanpage.cpp | 38 ++++++++++++----------------- src/frontend/tab-pages/wlanpage.h | 3 --- 4 files changed, 32 insertions(+), 48 deletions(-) diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 7243e399..816d8ce0 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -450,9 +450,24 @@ void LanPage::initList(QString m_deviceName) //程序拉起,初始化显 void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason) { - qDebug()<<"[LanPage] State change slot:"<getInterfaceByUuid(devName, type, uuid)) { + if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) { + return; + } + } + if (NetworkManager::ActiveConnection::State::Activated == state){ + lanIsConnected = true; + qDebug() << "[lanpage]lanIsConnected status : " << lanIsConnected << Q_FUNC_INFO << __LINE__ ; + } else { + lanIsConnected = false; + qDebug() << "=[lanpage]lanIsConnected status : " << lanIsConnected << Q_FUNC_INFO << __LINE__ ; + } + qDebug()<<"[LanPage] State change slot:"<getInterfaceByUuid(devName, type, uuid)) { if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) { @@ -615,25 +630,6 @@ void LanPage::onLanDataChange(QString uuid) } } -void LanPage::getLanConnectStatus(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason) -{ - //lanpage函数内持续监听连接状态的变化并记录供其他函数调用获取状态 - QString devName; - NetworkManager::ConnectionSettings::ConnectionType type; - if (m_connectResourse->getInterfaceByUuid(devName, type, uuid)) { - if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) { - return; - } - } - if (NetworkManager::ActiveConnection::State::Activated == state){ - lanIsConnected = true; - qDebug() << "[lanpage]lanIsConnected status : " << lanIsConnected << Q_FUNC_INFO << __LINE__ ; - } else { - lanIsConnected = false; - qDebug() << "=[lanpage]lanIsConnected status : " << lanIsConnected << Q_FUNC_INFO << __LINE__ ; - } -} - void LanPage::setWiredDeviceEnable(const QString& devName, bool enable) { saveDeviceEnableState(devName, enable); diff --git a/src/frontend/tab-pages/lanpage.h b/src/frontend/tab-pages/lanpage.h index effe9d84..49030f34 100644 --- a/src/frontend/tab-pages/lanpage.h +++ b/src/frontend/tab-pages/lanpage.h @@ -83,9 +83,6 @@ private slots: void onDeviceNameUpdate(QString oldName, QString newName); void onDeviceComboxIndexChanged(int currentIndex); void onLanDataChange(QString uuid); - void getLanConnectStatus(QString uuid, - NetworkManager::ActiveConnection::State state, - NetworkManager::ActiveConnection::Reason reason); }; #endif // LANPAGE_H diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 40407ffb..e38f03dc 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -37,7 +37,6 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent) connect(this, &WlanPage::hiddenWlanClicked, this, &WlanPage::onHiddenWlanClicked); connect(this, &WlanPage::settingsClicked, this, &WlanPage::showControlCenter); connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::onWlanStatusChange); - connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::getWlanConnectStatus); connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::wifinEnabledChanged, this, &WlanPage::onWifinEnabledChanged); } @@ -597,26 +596,6 @@ void WlanPage::showControlCenter() QProcess process; process.startDetached("ukui-control-center --wlanconnect"); } - -void WlanPage::getWlanConnectStatus(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason) -{ - //wlanpage函数内持续监听连接状态的变化并记录供其他函数调用获取状态 - QString devName; - NetworkManager::ConnectionSettings::ConnectionType type; - if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) { - if (type != NetworkManager::ConnectionSettings::ConnectionType::Wireless) { - return; - } - } - if(NetworkManager::ActiveConnection::State::Activated == state){ - wlanIsConnected = true; - qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; - } else { - wlanIsConnected = false; - qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; - } -} - void WlanPage::onWifinEnabledChanged(bool isWifiOn) { //监听外部命令导致wifi状态变化,更新界面 @@ -808,7 +787,7 @@ void WlanPage::showDetailPage(QString devName, QString ssid) void WlanPage::onWlanStatusChange(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason) { - //弹窗显示wifi连接状况 + //wlanpage函数内持续监听连接状态的变化并记录供其他函数调用获取状态 QString devName; NetworkManager::ConnectionSettings::ConnectionType type; if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) { @@ -816,6 +795,21 @@ void WlanPage::onWlanStatusChange(QString uuid, NetworkManager::ActiveConnection return; } } + if(NetworkManager::ActiveConnection::State::Activated == state){ + wlanIsConnected = true; + qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; + } else { + wlanIsConnected = false; + qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; + } + //弹窗显示wifi连接状况 +// QString devName; +// NetworkManager::ConnectionSettings::ConnectionType type; +// if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) { +// if (type != NetworkManager::ConnectionSettings::ConnectionType::Wireless) { +// return; +// } +// } qDebug() << "[WlanPage] State changed to :" << state << reason << Q_FUNC_INFO <<__LINE__; QString ssid; m_resource->getSsidByUuid(uuid, ssid, m_defaultDevice); diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index efc5df17..a2477721 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -120,9 +120,6 @@ private slots: void requestScan(); void onHiddenWlanClicked(); void showControlCenter(); - void getWlanConnectStatus(QString uuid, - NetworkManager::ActiveConnection::State state, - NetworkManager::ActiveConnection::Reason reason); void onWifinEnabledChanged(bool isWifiOn); }; From 0184986b921ef4e7e94b00a078cf095ea4170922 Mon Sep 17 00:00:00 2001 From: jinxujie Date: Thu, 23 Sep 2021 14:23:43 +0800 Subject: [PATCH 5/6] 0923-jxj-2 --- src/frontend/new-mainwindow.cpp | 16 ++--- src/frontend/new-mainwindow.h | 2 +- src/frontend/tab-pages/tabpage.cpp | 12 ++-- src/frontend/tab-pages/wlanpage.cpp | 95 +++++++++++++---------------- src/frontend/tab-pages/wlanpage.h | 13 ++-- 5 files changed, 63 insertions(+), 75 deletions(-) diff --git a/src/frontend/new-mainwindow.cpp b/src/frontend/new-mainwindow.cpp index fa96a715..3bd2909e 100644 --- a/src/frontend/new-mainwindow.cpp +++ b/src/frontend/new-mainwindow.cpp @@ -170,7 +170,7 @@ void MainWindow::initDbusConnnect() connect(m_lanWidget, &LanPage::lanRemove, this, &MainWindow::lanRemove); connect(m_lanWidget, &LanPage::lanUpdate, this, &MainWindow::lanUpdate); connect(m_lanWidget, &LanPage::lanActiveConnectionStateChanged, this, &MainWindow::lanActiveConnectionStateChanged); - connect(m_lanWidget, &LanPage::lanConnectChanged, this, &MainWindow::onGetConnectChangedIcon); + connect(m_lanWidget, &LanPage::lanConnectChanged, this, &MainWindow::onRefreshTrayIcon); connect(m_wlanWidget, &WlanPage::wlanAdd, this, &MainWindow::wlanAdd); @@ -180,7 +180,7 @@ void MainWindow::initDbusConnnect() connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated); connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange); connect(m_wlanWidget, &WlanPage::signalStrengthChange, this, &MainWindow::signalStrengthChange); - connect(m_wlanWidget, &WlanPage::wlanConnectChanged, this, &MainWindow::onGetConnectChangedIcon); + connect(m_wlanWidget, &WlanPage::wlanConnectChanged, this, &MainWindow::onRefreshTrayIcon); } /** @@ -303,11 +303,10 @@ void MainWindow::resetWindowTheme() void MainWindow::showControlCenter() { QProcess process; - if(m_lanWidget->lanIsConnected == false && m_wlanWidget->wlanIsConnected == true){ - process.startDetached("ukui-control-center --wlanconnect"); - } - else{ - process.startDetached("ukui-control-center --wiredconnect"); + if (m_lanWidget->lanIsConnected == false && m_wlanWidget->wlanIsConnected == true){ + process.startDetached("ukui-control-center --wlanconnect"); + } else { + process.startDetached("ukui-control-center --wiredconnect"); } } @@ -345,8 +344,9 @@ void MainWindow::onThemeChanged(const QString &key) } } -void MainWindow::onGetConnectChangedIcon() +void MainWindow::onRefreshTrayIcon() { + //更新托盘图标显示 if (m_lanWidget->lanIsConnected == true){ m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); } else if (m_wlanWidget->wlanIsConnected == true && m_lanWidget->lanIsConnected == false){ diff --git a/src/frontend/new-mainwindow.h b/src/frontend/new-mainwindow.h index ff195d19..da6185f1 100644 --- a/src/frontend/new-mainwindow.h +++ b/src/frontend/new-mainwindow.h @@ -117,7 +117,7 @@ private slots: void onShowMainwindowActionTriggled(); void onShowSettingsActionTriggled(); void onThemeChanged(const QString &key); - void onGetConnectChangedIcon(); + void onRefreshTrayIcon(); }; #endif // MAINWINDOW_H diff --git a/src/frontend/tab-pages/tabpage.cpp b/src/frontend/tab-pages/tabpage.cpp index bfd38925..5ed68412 100644 --- a/src/frontend/tab-pages/tabpage.cpp +++ b/src/frontend/tab-pages/tabpage.cpp @@ -116,12 +116,12 @@ void TabPage::showDesktopNotify(const QString &message) QList args; args<<(tr("Kylin NM")) <<((unsigned int) 0) - <getSsidByUuid(uuid, ssid, m_defaultDevice); + if (m_activatedWlanSSid == ssid && state == NetworkManager::ActiveConnection::State::Activated) { + if(m_activedssid != m_activatedWlanSSid){ + m_activedssid = m_activatedWlanSSid; + qDebug() << "[WlanPage] State changed to :" << state << ssid << reason << Q_FUNC_INFO <<__LINE__; + this->showDesktopNotify(tr("WLAN Connected Successfully")); + } + } + if (state == NetworkManager::ActiveConnection::State::Deactivating){ + m_disconectuuid = uuid; + m_disconectingflag = true; + } + if (state == NetworkManager::ActiveConnection::State::Deactivated && m_disconectuuid == uuid){ + if(m_disconectingflag){ + m_disconectingflag = false; + this->showDesktopNotify(tr("WLAN Disconnected Successfully")); + qDebug() << "clear the activessid" << Q_FUNC_INFO <<__LINE__; + m_activedssid = ""; + } + } + + //QString ssid,devName; + //NetworkManager::ConnectionSettings::ConnectionType type; if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) { if (type != NetworkManager::ConnectionSettings::ConnectionType::Wireless) { @@ -596,7 +635,7 @@ void WlanPage::showControlCenter() QProcess process; process.startDetached("ukui-control-center --wlanconnect"); } -void WlanPage::onWifinEnabledChanged(bool isWifiOn) +void WlanPage::onWifiEnabledChanged(bool isWifiOn) { //监听外部命令导致wifi状态变化,更新界面 //应该先检测是否有无线网卡可用,才改变开关状态 @@ -785,51 +824,3 @@ void WlanPage::showDetailPage(QString devName, QString ssid) netDetail->show(); } -void WlanPage::onWlanStatusChange(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason) -{ - //wlanpage函数内持续监听连接状态的变化并记录供其他函数调用获取状态 - QString devName; - NetworkManager::ConnectionSettings::ConnectionType type; - if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) { - if (type != NetworkManager::ConnectionSettings::ConnectionType::Wireless) { - return; - } - } - if(NetworkManager::ActiveConnection::State::Activated == state){ - wlanIsConnected = true; - qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; - } else { - wlanIsConnected = false; - qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ; - } - //弹窗显示wifi连接状况 -// QString devName; -// NetworkManager::ConnectionSettings::ConnectionType type; -// if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) { -// if (type != NetworkManager::ConnectionSettings::ConnectionType::Wireless) { -// return; -// } -// } - qDebug() << "[WlanPage] State changed to :" << state << reason << Q_FUNC_INFO <<__LINE__; - QString ssid; - m_resource->getSsidByUuid(uuid, ssid, m_defaultDevice); - if (m_activatedWlanSSid == ssid && state == NetworkManager::ActiveConnection::State::Activated) { - if(activessid != m_activatedWlanSSid){ - activessid = m_activatedWlanSSid; - qDebug() << "[WlanPage] State changed to :" << state << ssid << reason << Q_FUNC_INFO <<__LINE__; - this->showDesktopNotify(tr("WLAN Connected Successfully")); - } - } - if (state == NetworkManager::ActiveConnection::State::Deactivating){ - deactinguuid = uuid; - deactingflag = true; - } - if (state == NetworkManager::ActiveConnection::State::Deactivated && deactinguuid == uuid){ - if(deactingflag){ - deactingflag = false; - this->showDesktopNotify(tr("WLAN Disconnected Successfully")); - qDebug() << "clear the activessid" << Q_FUNC_INFO <<__LINE__; - activessid = ""; - } - } -} diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index a2477721..82763974 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -53,9 +53,6 @@ signals: public slots: void onMainWindowVisibleChanged(const bool &visible); - void onWlanStatusChange(QString uuid, - NetworkManager::ActiveConnection::State state, - NetworkManager::ActiveConnection::Reason reason); protected: bool eventFilter(QObject *watched, QEvent *event); @@ -63,10 +60,10 @@ protected: private: void initWlanUI(); void initConnections(); - QString activessid; - QString deactinguuid; - int deacting; - bool deactingflag = false; + QString m_activedssid; + QString m_disconectuuid; + int m_disconecting; + bool m_disconectingflag = false; //定时触发扫描的定时器 void initTimer(); @@ -120,7 +117,7 @@ private slots: void requestScan(); void onHiddenWlanClicked(); void showControlCenter(); - void onWifinEnabledChanged(bool isWifiOn); + void onWifiEnabledChanged(bool isWifiOn); }; #endif // WLANPAGE_H From ad013540f44b1d17a28a5966a7467aef7677b637 Mon Sep 17 00:00:00 2001 From: jinxujie Date: Thu, 23 Sep 2021 20:19:01 +0800 Subject: [PATCH 6/6] 0923-jxj-3 --- src/frontend/new-mainwindow.cpp | 8 ++++---- src/frontend/tab-pages/lanpage.cpp | 8 ++++---- src/frontend/tab-pages/lanpage.h | 2 +- src/frontend/tab-pages/wlanpage.cpp | 10 +++++----- src/frontend/tab-pages/wlanpage.h | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/frontend/new-mainwindow.cpp b/src/frontend/new-mainwindow.cpp index 3bd2909e..53f0f40c 100644 --- a/src/frontend/new-mainwindow.cpp +++ b/src/frontend/new-mainwindow.cpp @@ -303,7 +303,7 @@ void MainWindow::resetWindowTheme() void MainWindow::showControlCenter() { QProcess process; - if (m_lanWidget->lanIsConnected == false && m_wlanWidget->wlanIsConnected == true){ + if (m_lanWidget->m_isLanConnected == false && m_wlanWidget->wlanIsConnected == true){ process.startDetached("ukui-control-center --wlanconnect"); } else { process.startDetached("ukui-control-center --wiredconnect"); @@ -347,11 +347,11 @@ void MainWindow::onThemeChanged(const QString &key) void MainWindow::onRefreshTrayIcon() { //更新托盘图标显示 - if (m_lanWidget->lanIsConnected == true){ + if (m_lanWidget->m_isLanConnected == true){ m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); - } else if (m_wlanWidget->wlanIsConnected == true && m_lanWidget->lanIsConnected == false){ + } else if (m_wlanWidget->wlanIsConnected == true && m_lanWidget->m_isLanConnected == false){ m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic")); - } else if (m_wlanWidget->wlanIsConnected == false && m_lanWidget->lanIsConnected == false){ + } else if (m_wlanWidget->wlanIsConnected == false && m_lanWidget->m_isLanConnected == false){ m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); } } diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 816d8ce0..24507f38 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -459,11 +459,11 @@ void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::Stat } } if (NetworkManager::ActiveConnection::State::Activated == state){ - lanIsConnected = true; - qDebug() << "[lanpage]lanIsConnected status : " << lanIsConnected << Q_FUNC_INFO << __LINE__ ; + m_isLanConnected = true; + qDebug() << "[lanpage]lanIsConnected status : " << m_isLanConnected << Q_FUNC_INFO << __LINE__ ; } else { - lanIsConnected = false; - qDebug() << "=[lanpage]lanIsConnected status : " << lanIsConnected << Q_FUNC_INFO << __LINE__ ; + m_isLanConnected = false; + qDebug() << "=[lanpage]lanIsConnected status : " << m_isLanConnected << Q_FUNC_INFO << __LINE__ ; } qDebug()<<"[LanPage] State change slot:"< > &map); diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 8abb3bed..96287136 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -463,12 +463,12 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec } } if (state == NetworkManager::ActiveConnection::State::Deactivating){ - m_disconectuuid = uuid; - m_disconectingflag = true; + m_disconnectuuid = uuid; + m_disconnectingflag = true; } - if (state == NetworkManager::ActiveConnection::State::Deactivated && m_disconectuuid == uuid){ - if(m_disconectingflag){ - m_disconectingflag = false; + if (state == NetworkManager::ActiveConnection::State::Deactivated && m_disconnectuuid == uuid){ + if(m_disconnectingflag){ + m_disconnectingflag = false; this->showDesktopNotify(tr("WLAN Disconnected Successfully")); qDebug() << "clear the activessid" << Q_FUNC_INFO <<__LINE__; m_activedssid = ""; diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index 82763974..47cad272 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -61,9 +61,9 @@ private: void initWlanUI(); void initConnections(); QString m_activedssid; - QString m_disconectuuid; - int m_disconecting; - bool m_disconectingflag = false; + QString m_disconnectuuid; + int m_disconnecting; + bool m_disconnectingflag = false; //定时触发扫描的定时器 void initTimer();