bug#100825

This commit is contained in:
kangshuning 2022-01-05 16:32:55 +08:00
parent 6cc2e731eb
commit 452e6da8de
3 changed files with 12 additions and 12 deletions

View File

@ -125,8 +125,9 @@ void WlanPage::onWlanSwitchClicked()
{ {
if (m_devList.isEmpty()) { if (m_devList.isEmpty()) {
showDesktopNotify(tr("No wireless network card detected")); showDesktopNotify(tr("No wireless network card detected"));
//检测不到无线网卡不再触发click信号 //检测不到无线网卡不再触发click信号
m_netSwitch->setSwitchStatus(false); m_netSwitch->setSwitchStatus(false);
m_netSwitch->setEnabled(false);
} else { } else {
bool switchEnable = m_netSwitch->getSwitchStatus(); bool switchEnable = m_netSwitch->getSwitchStatus();
if (m_wlanSwitchEnable != switchEnable) { if (m_wlanSwitchEnable != switchEnable) {
@ -154,15 +155,16 @@ void WlanPage::initWlanSwitchState()
if (m_switchGsettings->keys().contains(WIRELESS_SWITCH)) { if (m_switchGsettings->keys().contains(WIRELESS_SWITCH)) {
if (m_devList.isEmpty()) { if (m_devList.isEmpty()) {
m_wlanSwitchEnable = false; m_wlanSwitchEnable = false;
m_netSwitch->setSwitchStatus(m_wlanSwitchEnable);
m_netSwitch->setEnabled(false);
} else { } else {
m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool(); m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
} }
connect(m_switchGsettings, &QGSettings::changed, this, &WlanPage::onWlanSwithGsettingsChanged); connect(m_switchGsettings, &QGSettings::changed, this, &WlanPage::onWlanSwithGsettingsChanged);
} }
} }
m_netSwitch->setSwitchStatus(m_wlanSwitchEnable); m_netSwitch->setSwitchStatus(m_wlanSwitchEnable);
//m_netSwitch->setEnabled(m_wlanSwitchEnable);
connect(m_netSwitch, &SwitchButton::clicked, this, &WlanPage::onWlanSwitchClicked); 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_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList);
m_currentDevice = getDefaultDeviceName(WIRELESS); m_currentDevice = getDefaultDeviceName(WIRELESS);
return; return;
} }
@ -229,8 +230,8 @@ void WlanPage::initDeviceCombox()
} }
} else { } else {
m_deviceFrame->hide(); m_deviceFrame->hide();
//m_currentDevice = ""; m_currentDevice = "";
//setDefaultDevice(WIRELESS, m_currentDevice); setDefaultDevice(WIRELESS, m_currentDevice);
} }
connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
@ -655,7 +656,7 @@ void WlanPage::addDeviceToCombox(QString deviceName)
void WlanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType) 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) { if (deviceType != NetworkManager::Device::Type::Wifi) {
return; return;
} }
@ -666,7 +667,7 @@ void WlanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type devi
if (m_devList.isEmpty()) { if (m_devList.isEmpty()) {
m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool(); m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
//m_netSwitch->setEnabled(m_wlanSwitchEnable); m_netSwitch->setEnabled(true);
m_netSwitch->setSwitchStatus(m_wlanSwitchEnable); m_netSwitch->setSwitchStatus(m_wlanSwitchEnable);
} }
@ -728,8 +729,8 @@ void WlanPage::onDeviceRemove(QString deviceName)
if (m_devList.isEmpty()) { if (m_devList.isEmpty()) {
m_wlanSwitchEnable = false; m_wlanSwitchEnable = false;
//m_netSwitch->setEnabled(m_wlanSwitchEnable);
m_netSwitch->setSwitchStatus(m_wlanSwitchEnable); m_netSwitch->setSwitchStatus(m_wlanSwitchEnable);
m_netSwitch->setEnabled(false);
} }
if (originalDeviceName == deviceName) { if (originalDeviceName == deviceName) {

View File

@ -106,9 +106,8 @@ void SwitchButton::mousePressEvent(QMouseEvent *event) {
if (m_enabled) { if (m_enabled) {
m_bIsOn = !m_bIsOn; m_bIsOn = !m_bIsOn;
Q_EMIT clicked(m_bIsOn);
} }
Q_EMIT clicked();
return QWidget::mousePressEvent(event); return QWidget::mousePressEvent(event);
} }

View File

@ -48,7 +48,7 @@ private:
bool m_enabled = true; bool m_enabled = true;
Q_SIGNALS: Q_SIGNALS:
void clicked(int check); void clicked();
void switchStatusChanged(); void switchStatusChanged();
private Q_SLOTS: private Q_SLOTS: