diff --git a/src/backend/dbusadaptor.cpp b/src/backend/dbusadaptor.cpp index 05762e36..b5684d1a 100644 --- a/src/backend/dbusadaptor.cpp +++ b/src/backend/dbusadaptor.cpp @@ -78,16 +78,17 @@ void DbusAdaptor::setWiredSwitchEnable(bool enable) void DbusAdaptor::setWirelessSwitchEnable(bool enable) { //todo mainwindow调用backend 对开关 打开/关闭 - if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) { - QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM); - if (gsetting->get(KEY_WIRELESS_SWITCH).toBool() != enable) { - gsetting->set(KEY_WIRELESS_SWITCH, enable); - } - delete gsetting; - gsetting = nullptr; - } else { - qDebug()<<"isSchemaInstalled false"; - } +// if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) { +// QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM); +// if (gsetting->get(KEY_WIRELESS_SWITCH).toBool() != enable) { +// gsetting->set(KEY_WIRELESS_SWITCH, enable); +// } +// delete gsetting; +// gsetting = nullptr; +// } else { +// qDebug()<<"isSchemaInstalled false"; +// } + parent()->setWirelessSwitchEnable(enable); } //启用/禁用网卡 diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp index c88ad2c4..73fcf2e4 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -448,6 +448,12 @@ void MainWindow::getStoredApInfo(QStringList &list) m_wlanWidget->getStoredApInfo(list); } +//无线开关 +void MainWindow::setWirelessSwitchEnable(bool enable) +{ + m_wlanWidget->setWirelessSwitchEnable(enable); +} + void MainWindow::setWiredDeviceEnable(const QString& devName, bool enable) { m_lanWidget->setWiredDeviceEnable(devName, enable); diff --git a/src/frontend/mainwindow.h b/src/frontend/mainwindow.h index f67611b9..da632ee5 100644 --- a/src/frontend/mainwindow.h +++ b/src/frontend/mainwindow.h @@ -42,6 +42,8 @@ public: //无线连接断开 void activateWireless(const QString& devName, const QString& ssid); void deactivateWireless(const QString& devName, const QString& ssid); + //无线总开关 + void setWirelessSwitchEnable(bool enable); void setWiredDeviceEnable(const QString& devName, bool enable); diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index 8f85ed15..6091af7d 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -831,17 +831,24 @@ bool NetDetail::updateConnect() m_wiredConnOperation->updateWiredConnect(m_uuid, connetSetting); } - if (isWlan && securityPage->checkIsChanged(m_info)) { - KySecuType secuType; - KyEapMethodType enterpriseType; - securityPage->getSecuType(secuType, enterpriseType); - if (secuType == WPA_AND_WPA2_ENTERPRISE) { - updateWirelessEnterPriseConnect(enterpriseType); - } else { - updateWirelessPersonalConnect(); + bool securityChange = false; + if (isWlan) { + securityChange = securityPage->checkIsChanged(m_info); + if (securityChange) { + KySecuType secuType; + KyEapMethodType enterpriseType; + securityPage->getSecuType(secuType, enterpriseType); + if (secuType == WPA_AND_WPA2_ENTERPRISE) { + updateWirelessEnterPriseConnect(enterpriseType); + } else { + updateWirelessPersonalConnect(); + } } + } + + if (ipv4Change || ipv6Change || securityChange) { if (isActive) { - //安全性变化 断开-重连 + //信息变化 断开-重连 m_wirelessConnOpration->activateConnection(m_uuid, m_deviceName); } } diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 1db5d3ee..f7af2fbe 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -970,6 +970,21 @@ void WlanPage::showDetailPage(QString devName, QString ssid) netDetail->show(); } +void WlanPage::setWirelessSwitchEnable(bool enable) +{ + qDebug() << "dbus setWirelessSwitchEnable = " << enable << __LINE__; + //应该先检测是否有无线网卡可用,才改变开关状态 + m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList); + if (m_devList.isEmpty()) { + qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__; + //检测不到无线网卡不再触发click信号 + m_netSwitch->setSwitchStatus(false); + m_netSwitch->setEnabled(false); + }else{ + m_wirelessConnectOpreation->setWirelessEnabled(enable); + } +} + void WlanPage::getWirelessDeviceCap(QMap &map) { for (int i = 0; i < m_devList.size(); ++i) { diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index ebebb1f2..10c8a824 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -39,6 +39,8 @@ public: void getApInfoBySsid(QString devName, QString ssid, QStringList &list); void activateWireless(const QString& devName, const QString& ssid); void deactivateWireless(const QString& devName, const QString& ssid); + //无线总开关 + void setWirelessSwitchEnable(bool enable); void showDetailPage(QString devName, QString uuid);