无线、有线无设备时,开关状态

This commit is contained in:
jzxc95 2022-12-28 14:39:46 +08:00
parent 745bae5fca
commit 3e18517407
4 changed files with 8 additions and 6 deletions

View File

@ -557,7 +557,7 @@ void WlanConnect::onSwitchBtnChanged(bool state)
if (getSwitchBtnState() == state) {
return;
}
setSwitchBtnEnable(true);
setSwitchBtnState(state);
if (!getSwitchBtnState()) {
hideLayout(ui->availableLayout);
@ -716,6 +716,7 @@ void WlanConnect::initSwtichState()
}
bool state = result.arguments().at(0).toBool();
setSwitchBtnEnable(true);
setSwitchBtnState(state);
}

View File

@ -127,12 +127,12 @@ private:
void initSwtichState();
inline void setSwitchBtnEnable(bool state) {
if (m_wifiSwitch != nullptr) {
m_wifiSwitch->setCheckable(state);
m_wifiSwitch->setEnabled(state);
}
}
inline bool getSwitchBtnEnable() {
if (m_wifiSwitch != nullptr) {
return m_wifiSwitch->isCheckable();
return m_wifiSwitch->isEnabled();
}
}

View File

@ -78,7 +78,7 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
connect(m_connectResource, &KyConnectResourse::connectivityChanged, this, &WlanPage::connectivityChanged);
connect(m_netSwitch, &KSwitchButton::clicked, this, [=](bool checked) {
//解决switchBtn不支持点击的情况下点击按钮有无线网卡后不自动开启的问题
//解决 switchBtn不支持点击的情况下点击按钮有无线网卡后不自动开启的问题
if (getSwitchBtnEnable()) {
setSwitchBtnState(!checked);
setWirelessEnable(checked);
@ -803,6 +803,7 @@ void WlanPage::onWlanStateChanged(NetworkManager::Device::State newstate, Networ
if (getSwitchBtnState() == getWirelessDevieceUseable()) {
return ;
}
setSwitchBtnEnable(true);
setSwitchBtnState(getWirelessDevieceUseable());
initDeviceCombox();
initWlanArea();

View File

@ -196,12 +196,12 @@ private:
}
inline void setSwitchBtnEnable(bool state) {
if (m_netSwitch != nullptr) {
m_netSwitch->setCheckable(state);
m_netSwitch->setEnabled(state);
}
}
inline bool getSwitchBtnEnable() {
if (m_netSwitch != nullptr) {
return m_netSwitch->isCheckable();
return m_netSwitch->isEnabled();
}
}