From 62497b138a46b9a29f132f32929df16ffd537f43 Mon Sep 17 00:00:00 2001 From: crrs666 Date: Mon, 29 Mar 2021 21:11:27 +0800 Subject: [PATCH] fix press kbd wifi button to en/disable wifi and include kds as depend --- debian/control | 1 + src/mainwindow.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++-- src/mainwindow.h | 3 +++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index a4d9f33b..30468ebe 100644 --- a/debian/control +++ b/debian/control @@ -27,6 +27,7 @@ Depends: network-manager (>=1.2.6), network-manager-config-connectivity-ubuntu, gir1.2-javascriptcoregtk-4.0, gir1.2-webkit2-4.0, + kylin-display-switch, ${shlibs:Depends}, ${misc:Depends} Description: Gui Applet tool for display and edit network simply diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 274f5faa..d027cd33 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -58,7 +58,7 @@ MainWindow::MainWindow(QWidget *parent) : "/", \ "org.ukui.kds.interface", \ QDBusConnection::systemBus()); - QDBusConnection::systemBus().connect(kdsDbus->service(), kdsDbus->path(), kdsDbus->interface(), "signalRfkillStatusChanged", this, SLOT(onRfkillStatusChanged)); + QDBusConnection::systemBus().connect(kdsDbus->service(), kdsDbus->path(), kdsDbus->interface(), "signalRfkillStatusChanged", this, SLOT(onRfkillStatusChanged())); UseQssFile::setStyle("style.qss"); @@ -1166,6 +1166,7 @@ void MainWindow::onBtnWifiClicked(int flag) syslog(LOG_DEBUG, "Value of flag passed into function 'onBtnWifiClicked' is: %d", flag); if (is_wireless_adapter_ready == 1) { + // flag: 0->UI点击关闭 1->UI点击打开 2->gsetting打开 3->gsetting关闭 4->网卡热插 5->网卡热拔 // 当连接上无线网卡时才能打开wifi开关 // 网络开关关闭时,点击Wifi开关时,程序先打开有线开关 if (flag == 0 || flag == 1 || flag == 4 || flag == 5) { @@ -3677,7 +3678,66 @@ void MainWindow::onRfkillStatusChanged() qWarning("Error Occur When Get Current WlanMode"); return; } - onExternalWifiSwitchChange(bool(current)); + if (!current) { + is_stop_check_net_state = 1; + lbTopWifiList->hide(); + btnAddNet->hide(); + objKyDBus->setWifiSwitchState(false); + + QThread *t = new QThread(); + BackThread *bt = new BackThread(); + bt->moveToThread(t); + btnWireless->setSwitchStatus(true); + connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); + connect(t, SIGNAL(started()), bt, SLOT(execDisWifi())); + connect(bt, SIGNAL(disWifiDone()), this, SLOT(rfkillDisableWifiDone())); + connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); + t->start(); + this->startLoading(); + } else { + if (is_fly_mode_on == 0) { + on_btnWifiList_clicked(); + is_stop_check_net_state = 1; + objKyDBus->setWifiCardState(true); + objKyDBus->setWifiSwitchState(true); + + QThread *t = new QThread(); + BackThread *bt = new BackThread(); + bt->moveToThread(t); + btnWireless->setSwitchStatus(true); + connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); + connect(t, SIGNAL(started()), bt, SLOT(execEnWifi())); + connect(bt, SIGNAL(enWifiDone()), this, SLOT(rfkillEnableWifiDone())); + connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); + t->start(); + this->startLoading(); + } + } + } +} + +void MainWindow::rfkillDisableWifiDone() +{ + if (is_btnWifiList_clicked) + disWifiDoneChangeUI(); + + qDebug()<<"debug: already turn off the switch of wifi network by keyboard button"; + syslog(LOG_DEBUG, "Already turn off the switch of wifi network by keyboard button"); + + this->stopLoading(); + is_stop_check_net_state = 0; +} + +void MainWindow::rfkillEnableWifiDone() +{ + current_wifi_list_state = LOAD_WIFI_LIST; + if (is_btnWifiList_clicked) { + this->ksnm->execGetWifiList(this->wcardname); + } else { +// on_btnWifiList_clicked(); } + objKyDBus->getWirelessCardName(); + qDebug()<<"debug: already turn on the switch of wifi network"; + syslog(LOG_DEBUG, "Already turn on the switch of wifi network"); } diff --git a/src/mainwindow.h b/src/mainwindow.h index a9ab10f8..0274101e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -232,6 +232,9 @@ public slots: void toReconnectWifi(); + void rfkillDisableWifiDone(); + void rfkillEnableWifiDone(); + protected: bool eventFilter(QObject *obj, QEvent *event); void paintEvent(QPaintEvent *event);