diff --git a/plugins/netconnect/netconnect.cpp b/plugins/netconnect/netconnect.cpp index 2341ccb7..2dbe580c 100644 --- a/plugins/netconnect/netconnect.cpp +++ b/plugins/netconnect/netconnect.cpp @@ -207,8 +207,8 @@ void NetConnect::initComponent() { getDeviceStatusMap(deviceStatusMap); if (deviceStatusMap.isEmpty()) { qDebug() << "[Netconnect] no device exist when init, set switch disable"; - wiredSwitch->setCheckable(false); wiredSwitch->setChecked(false); + wiredSwitch->setCheckable(false); } initNet(); @@ -593,8 +593,8 @@ void NetConnect::onDeviceStatusChanged() } deviceStatusMap = map; if (deviceStatusMap.isEmpty()) { - wiredSwitch->setCheckable(false); wiredSwitch->setChecked(false); + wiredSwitch->setCheckable(false); } else { wiredSwitch->setCheckable(true); setSwitchStatus(); diff --git a/plugins/wlanconnect/wlanconnect.cpp b/plugins/wlanconnect/wlanconnect.cpp index 67cc3a88..7ce6b6e9 100644 --- a/plugins/wlanconnect/wlanconnect.cpp +++ b/plugins/wlanconnect/wlanconnect.cpp @@ -267,8 +267,10 @@ void WlanConnect::initComponent() { getDeviceList(deviceList); if (deviceList.isEmpty()) { qDebug() << "[WlanConnect]no device exist when init, set switch disable"; - m_wifiSwitch->setCheckable(false); m_wifiSwitch->setChecked(false); + m_wifiSwitch->setCheckable(false); + qDebug() << "KSwitchButton-----WlanConnect::initComponent" <isCheckable() + << "checked"<isChecked(); } initNet(); @@ -525,8 +527,10 @@ void WlanConnect::onDeviceStatusChanged() } deviceList = list; if (deviceList.isEmpty()) { - m_wifiSwitch->setCheckable(false); m_wifiSwitch->setChecked(false); + m_wifiSwitch->setCheckable(false); + qDebug() << "KSwitchButton-----WlanConnect::onDeviceStatusChanged" <isCheckable() + << "checked"<isChecked(); } else { m_wifiSwitch->setCheckable(true); setSwitchStatus(); diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 830b9668..7792f642 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -629,8 +629,8 @@ void LanPage::onDeviceRemove(QString deviceName) m_devList.removeOne(deviceName); if (m_devList.count() == 0) { - m_netSwitch->setCheckable(false); m_netSwitch->setChecked(false); + m_netSwitch->setCheckable(false); qDebug() << "[wiredSwitch]set not enable after device remove"; } @@ -1183,8 +1183,8 @@ bool LanPage::eventFilter(QObject *watched, QEvent *event) if (m_devList.count() == 0) { this->showDesktopNotify(tr("No ethernet device avaliable"), "networkwrong"); - m_netSwitch->setCheckable(false); m_netSwitch->setChecked(false); + m_netSwitch->setCheckable(false); } else { m_netSwitch->setCheckable(true); if (m_netSwitch->isChecked()) { diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 82ff0500..4593615c 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -54,6 +54,19 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent) connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::wifiEnabledChanged, this, &WlanPage::onWifiEnabledChanged); connect(m_connectResource, &KyConnectResourse::connectivityChanged, this, &WlanPage::connectivityChanged); + + +// QTimer::singleShot(10000, this, [=](){ +// qDebug() << "KSwitchButton-----WlanPage::onDeviceRemove-before" <isCheckable() +// << "checked"<isChecked(); + +// onDeviceRemove("wlp3s0"); + +// qDebug() << "KSwitchButton-----WlanPage::onDeviceRemove-after" <isCheckable() +// << "checked"<isChecked(); + +// }); + } bool WlanPage::eventFilter(QObject *w, QEvent *e) @@ -69,8 +82,10 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e) if (m_devList.isEmpty()) { showDesktopNotify(tr("No wireless network card detected"), "networkwrong"); //检测不到无线网卡不再触发click信号 - m_netSwitch->setCheckable(false); m_netSwitch->setChecked(false); + m_netSwitch->setCheckable(false); + qDebug() << "KSwitchButton-----WlanPage::eventFilter" <isCheckable() + << "checked"<isChecked(); } else { m_wirelessConnectOpreation->setWirelessEnabled(!m_netSwitch->isChecked()); } @@ -123,13 +138,15 @@ void WlanPage::onWlanSwithGsettingsChanged(const QString &key) m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool(); qDebug() << LOG_FLAG << "wlan switch state" << m_wlanSwitchEnable; - m_netSwitch->setChecked(m_wlanSwitchEnable); + if (m_wirelessConnectOpreation->getWirelessEnabled() != m_wlanSwitchEnable) { + m_wirelessConnectOpreation->setWirelessEnabled(m_wlanSwitchEnable); + qDebug() <<"wlan switch state!="; + } + m_netSwitch->setChecked(m_wlanSwitchEnable); initDeviceCombox(); initWlanArea(); } - - return; } void WlanPage::initWlanSwitchState() @@ -139,8 +156,10 @@ void WlanPage::initWlanSwitchState() m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA); if (m_switchGsettings->keys().contains(WIRELESS_SWITCH)) { if (m_devList.isEmpty()) { - m_netSwitch->setCheckable(false); m_netSwitch->setChecked(false); + m_netSwitch->setCheckable(false); + qDebug() << "KSwitchButton-----WlanPage::initWlanSwitchState" <isCheckable() + << "checked"<isChecked(); } else { wirelessGsetting = m_switchGsettings->get(WIRELESS_SWITCH).toBool(); if (m_wirelessConnectOpreation->getWirelessEnabled() @@ -716,8 +735,10 @@ void WlanPage::onDeviceRemove(QString deviceName) deleteDeviceFromCombox(deviceName); if (m_devList.isEmpty()) { - m_netSwitch->setCheckable(false); m_netSwitch->setChecked(false); + m_netSwitch->setCheckable(false); + qDebug() << "KSwitchButton-----WlanPage::onDeviceRemove-after" <isCheckable() + << "checked"<isChecked(); } if (originalDeviceName == deviceName) { @@ -1019,6 +1040,7 @@ void WlanPage::onWifiEnabledChanged(bool isWifiOn) { //监听外部命令导致wifi状态变化,更新界面 qDebug() << "[WlanPage] onWifiEnabledChanged wifi state" << isWifiOn; + isWifiOn = m_wirelessConnectOpreation->getWirelessEnabled(); //应该先检测是否有无线网卡可用,才改变开关状态 if (m_devList.isEmpty()) { @@ -1029,9 +1051,9 @@ void WlanPage::onWifiEnabledChanged(bool isWifiOn) if (m_wlanSwitchEnable == isWifiOn) { return; } else { - if (!m_netSwitch->isChecked()) { - m_netSwitch->setChecked(true); - } +// if (!m_netSwitch->isChecked()) { +// m_netSwitch->setChecked(true); +// } m_switchGsettings->set(WIRELESS_SWITCH, isWifiOn); } @@ -1391,12 +1413,18 @@ void WlanPage::setWirelessSwitchEnable(bool enable) qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__; //检测不到无线网卡不再触发click信号 // m_netSwitch->setSwitchStatus(false); - m_netSwitch->setEnabled(false); + m_netSwitch->setChecked(false); + m_netSwitch->setCheckable(false); + qDebug() << "KSwitchButton-----WlanPage::setWirelessSwitchEnable checkable" <isCheckable() + << "checked"<isChecked(); }else{ m_wirelessConnectOpreation->setWirelessEnabled(enable); if (!enable) { // m_netSwitch->setEnabled(false); m_netSwitch->setChecked(false); + m_netSwitch->setCheckable(false); + qDebug() << "KSwitchButton-----WlanPage::setWirelessSwitchEnable2" <isCheckable() + << "checked"<isChecked();; m_activatedNetFrame->hide(); m_activatedNetDivider->hide(); m_inactivatedNetFrame->hide(); diff --git a/src/main.cpp b/src/main.cpp index 0bfe5126..5669c6d7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) // window_hints.decorations = MWM_DECOR_BORDER; // XAtomHelper::getInstance()->setWindowMotifHint(w.winId(), window_hints); - w.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint /*| Qt::X11BypassWindowManagerHint*/); +// w.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint /*| Qt::X11BypassWindowManagerHint*/); DbusAdaptor adaptor(&w);