From 0cae47b1aec52ce524c2f890b951eca2c775dac9 Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Wed, 22 Jun 2022 09:43:36 +0800 Subject: [PATCH] init wlanSwitchEnable status --- src/frontend/tab-pages/wlanpage.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 8c8b6889..feaff4a5 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -58,12 +58,14 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent) bool WlanPage::eventFilter(QObject *w, QEvent *e) { - if (e->type() == QEvent::MouseButtonRelease) { - if (w == m_settingsBtn) { + if (w == m_settingsBtn) { + if (e->type() == QEvent::MouseButtonRelease) { //ZJP_TODO 打开控制面板 qDebug() << LOG_FLAG <<"recive event show control center"; showControlCenter(); - } else if (w == m_netSwitch) { + } + } else if (w == m_netSwitch) { + if (e->type() == QEvent::MouseButtonRelease) { if (m_devList.isEmpty()) { showDesktopNotify(tr("No wireless network card detected"), "networkwrong"); //检测不到无线网卡不再触发click信号 @@ -133,6 +135,7 @@ void WlanPage::onWlanSwithGsettingsChanged(const QString &key) void WlanPage::initWlanSwitchState() { + bool wirelessGsetting = true; if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) { m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA); if (m_switchGsettings->keys().contains(WIRELESS_SWITCH)) { @@ -140,17 +143,19 @@ void WlanPage::initWlanSwitchState() m_netSwitch->setCheckable(false); m_netSwitch->setChecked(false); } else { - bool wiredGsetting = m_switchGsettings->get(WIRELESS_SWITCH).toBool(); + wirelessGsetting = m_switchGsettings->get(WIRELESS_SWITCH).toBool(); if (m_wirelessConnectOpreation->getWirelessEnabled() - != wiredGsetting) { + != wirelessGsetting) { //以gsetting为准 - m_wirelessConnectOpreation->setWirelessEnabled(wiredGsetting); + m_wirelessConnectOpreation->setWirelessEnabled(wirelessGsetting); } - m_netSwitch->setChecked(wiredGsetting); + m_netSwitch->setChecked(wirelessGsetting); } connect(m_switchGsettings, &QGSettings::changed, this, &WlanPage::onWlanSwithGsettingsChanged); } } + m_netSwitch->setChecked(wirelessGsetting); + m_wlanSwitchEnable = wirelessGsetting; } void WlanPage::initTimer()