diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index 829fc2cb..61dbe675 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -51,7 +51,6 @@ WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, Q connect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked); connect(m_menu, &QMenu::triggered, this, &WlanListItem::onMenuTriggered); - connect(qApp, &QApplication::paletteChanged, this, &WlanListItem::setConnectButtonState); m_wirelessConnectOperation = new KyWirelessConnectOperation(this); m_deviceResource = new KyNetworkDeviceResourse(this); @@ -242,6 +241,16 @@ void WlanListItem::keyPressEvent(QKeyEvent *event) return QFrame::keyPressEvent(event); } +void WlanListItem::paintEvent(QPaintEvent *event) +{ + QPalette pal = qApp->palette(); + if (m_pwdLineEdit != nullptr) { + m_pwdLineEdit->setPalette(pal); + } + + return QWidget::paintEvent(event); +} + void WlanListItem::initWlanUI() { m_hasPwd = (m_wirelessNetItem.m_secuType.isEmpty() || m_wirelessNetItem.m_secuType == "") ? false : true; @@ -268,6 +277,8 @@ void WlanListItem::initWlanUI() m_pwdLineEdit = new KPasswordEdit(m_pwdFrame); m_pwdLineEdit->setFixedWidth(LINEEDIT_WIDTH); + m_pwdLineEdit->setProperty("needTranslucent", true); + m_pwdLineEdit->setUseCustomPalette(true); m_pwdLineEdit->setClearButtonEnabled(false); //禁用ClearBtn按钮 m_pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, true); //打开输入法 // m_pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false); @@ -283,6 +294,7 @@ void WlanListItem::initWlanUI() m_pwdFrameLyt->addWidget(m_pwdLineEdit); m_connectButton = new QPushButton(m_pwdFrame); + m_connectButton->setProperty("isImportant", true); m_connectButton->setProperty("needTranslucent", true); m_connectButton->setFixedSize(CONNECT_BUTTON_WIDTH, PWD_AREA_HEIGHT); m_connectButton->setText(tr("Connect")); @@ -555,7 +567,6 @@ void WlanListItem::onPwdEditorTextChanged() } else { m_connectButton->setEnabled(true); } - setConnectButtonState(); return; } @@ -653,16 +664,3 @@ void WlanListItem::forgetPwd() return; } } - -void WlanListItem::setConnectButtonState() -{ - QPalette btnPal; - if (m_connectButton->isEnabled()) { - btnPal.setColor(QPalette::Button, ENABLE_BUTTON_COLOR); - btnPal.setColor(QPalette::ButtonText, Qt::white); - m_connectButton->setPalette(btnPal); - } else { - btnPal.setColor(QPalette::Button, UNABLE_BUTTON_COLOR); - m_connectButton->setPalette(btnPal); - } -} diff --git a/src/frontend/list-items/wlanlistitem.h b/src/frontend/list-items/wlanlistitem.h index 43ef24a0..4427ad24 100644 --- a/src/frontend/list-items/wlanlistitem.h +++ b/src/frontend/list-items/wlanlistitem.h @@ -86,6 +86,7 @@ protected: void leaveEvent(QEvent *event); bool eventFilter(QObject *watched, QEvent *event); void keyPressEvent(QKeyEvent *event); + void paintEvent(QPaintEvent *event); Q_SIGNALS: void itemHeightChanged(const bool isExpanded, const QString &ssid); @@ -132,7 +133,6 @@ private Q_SLOTS: void onConnectButtonClicked(); void onMenuTriggered(QAction *action); void onEnterpriseWlanDialogClose(bool isShow); - void setConnectButtonState(); }; #endif // WLANLISTITEM_H diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 3c9bca01..507145e6 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -73,6 +73,10 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent) connect(m_wiredConnectOperation, &KyWiredConnectOperation::activateConnectionError, this, &LanPage::activateFailed); connect(m_wiredConnectOperation, &KyWiredConnectOperation::deactivateConnectionError, this, &LanPage::deactivateFailed); connect(m_wiredConnectOperation, &KyWiredConnectOperation::wiredEnabledChanged, this, &LanPage::onWiredEnabledChanged); + connect(m_netSwitch, &KSwitchButton::clicked, this, [=](bool checked) { + m_netSwitch->setChecked(!checked); + m_wiredConnectOperation->setWiredEnabled(checked); + }); } LanPage::~LanPage() @@ -1188,16 +1192,7 @@ bool LanPage::eventFilter(QObject *watched, QEvent *event) this->showDesktopNotify(tr("No ethernet device avaliable"), "networkwrong"); m_netSwitch->setChecked(false); m_netSwitch->setCheckable(false); - } else { - m_netSwitch->setCheckable(true); -// if (m_netSwitch->isChecked()) { -// m_switchGsettings->set(WIRED_SWITCH, false); -// } else { -// m_switchGsettings->set(WIRED_SWITCH,true); -// } - m_wiredConnectOperation->setWiredEnabled(!m_netSwitch->isChecked()); } - return true; } } diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 93089e6f..c55f7ba2 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -78,6 +78,10 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent) connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::wifiEnabledChanged, this, &WlanPage::onWifiEnabledChanged); connect(m_connectResource, &KyConnectResourse::connectivityChanged, this, &WlanPage::connectivityChanged); + connect(m_netSwitch, &KSwitchButton::clicked, this, [=](bool checked) { + m_netSwitch->setChecked(!checked); + setWirelessEnable(checked); + }); } bool WlanPage::eventFilter(QObject *w, QEvent *e) @@ -93,10 +97,7 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e) if (!getSwitchBtnEnable()) { showDesktopNotify(tr("No wireless network card detected"), "networkwrong"); //检测不到无线网卡不再触发click信号 - } else { - setWirelessEnable(!getSwitchBtnState()); } - return true; } } return QWidget::eventFilter(w,e);