From 452e6da8de306edf5063996b5e51f04b84df779c Mon Sep 17 00:00:00 2001 From: kangshuning Date: Wed, 5 Jan 2022 16:32:55 +0800 Subject: [PATCH] bug#100825 --- src/frontend/tab-pages/wlanpage.cpp | 19 ++++++++++--------- src/frontend/tools/switchbutton.cpp | 3 +-- src/frontend/tools/switchbutton.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index e9be8ef1..0ebe0840 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -125,8 +125,9 @@ void WlanPage::onWlanSwitchClicked() { if (m_devList.isEmpty()) { showDesktopNotify(tr("No wireless network card detected")); - //检测不到无线网卡不再触发click信号 + //检测不到无线网卡不再触发click信号 m_netSwitch->setSwitchStatus(false); + m_netSwitch->setEnabled(false); } else { bool switchEnable = m_netSwitch->getSwitchStatus(); if (m_wlanSwitchEnable != switchEnable) { @@ -154,15 +155,16 @@ void WlanPage::initWlanSwitchState() if (m_switchGsettings->keys().contains(WIRELESS_SWITCH)) { if (m_devList.isEmpty()) { m_wlanSwitchEnable = false; + m_netSwitch->setSwitchStatus(m_wlanSwitchEnable); + m_netSwitch->setEnabled(false); } else { m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool(); } connect(m_switchGsettings, &QGSettings::changed, this, &WlanPage::onWlanSwithGsettingsChanged); } } - m_netSwitch->setSwitchStatus(m_wlanSwitchEnable); - //m_netSwitch->setEnabled(m_wlanSwitchEnable); + connect(m_netSwitch, &SwitchButton::clicked, this, &WlanPage::onWlanSwitchClicked); @@ -188,7 +190,6 @@ void WlanPage::initDevice() m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList); m_currentDevice = getDefaultDeviceName(WIRELESS); - return; } @@ -229,8 +230,8 @@ void WlanPage::initDeviceCombox() } } else { m_deviceFrame->hide(); - //m_currentDevice = ""; - //setDefaultDevice(WIRELESS, m_currentDevice); + m_currentDevice = ""; + setDefaultDevice(WIRELESS, m_currentDevice); } connect(m_deviceComboBox, QOverload::of(&QComboBox::currentIndexChanged), @@ -655,7 +656,7 @@ void WlanPage::addDeviceToCombox(QString deviceName) void WlanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType) { - qDebug() << LOG_FLAG << "deviceAdd" << deviceName; + qDebug() << LOG_FLAG << "currentDevice" << m_currentDevice << "deviceAdd" << deviceName; if (deviceType != NetworkManager::Device::Type::Wifi) { return; } @@ -666,7 +667,7 @@ void WlanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type devi if (m_devList.isEmpty()) { m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool(); - //m_netSwitch->setEnabled(m_wlanSwitchEnable); + m_netSwitch->setEnabled(true); m_netSwitch->setSwitchStatus(m_wlanSwitchEnable); } @@ -728,8 +729,8 @@ void WlanPage::onDeviceRemove(QString deviceName) if (m_devList.isEmpty()) { m_wlanSwitchEnable = false; - //m_netSwitch->setEnabled(m_wlanSwitchEnable); m_netSwitch->setSwitchStatus(m_wlanSwitchEnable); + m_netSwitch->setEnabled(false); } if (originalDeviceName == deviceName) { diff --git a/src/frontend/tools/switchbutton.cpp b/src/frontend/tools/switchbutton.cpp index 430443c6..806ca05e 100644 --- a/src/frontend/tools/switchbutton.cpp +++ b/src/frontend/tools/switchbutton.cpp @@ -106,9 +106,8 @@ void SwitchButton::mousePressEvent(QMouseEvent *event) { if (m_enabled) { m_bIsOn = !m_bIsOn; - Q_EMIT clicked(m_bIsOn); } - + Q_EMIT clicked(); return QWidget::mousePressEvent(event); } diff --git a/src/frontend/tools/switchbutton.h b/src/frontend/tools/switchbutton.h index 55d985c8..fea1e480 100644 --- a/src/frontend/tools/switchbutton.h +++ b/src/frontend/tools/switchbutton.h @@ -48,7 +48,7 @@ private: bool m_enabled = true; Q_SIGNALS: - void clicked(int check); + void clicked(); void switchStatusChanged(); private Q_SLOTS: