From 9a7530edb6910d76e45843ea153603720c483018 Mon Sep 17 00:00:00 2001 From: chenlelin Date: Thu, 26 Sep 2019 18:20:54 +0800 Subject: [PATCH] kylin-nm 1.0.8 --- backthread.cpp | 5 ++ debian/changelog | 26 +++++++++ kylin-nm.pro.user | 10 ++-- main.cpp | 2 + mainwindow.cpp | 135 +++++++++++++++++++++++++++++++++++----------- mainwindow.h | 1 + 6 files changed, 140 insertions(+), 39 deletions(-) diff --git a/backthread.cpp b/backthread.cpp index 302c7e8c..31520804 100644 --- a/backthread.cpp +++ b/backthread.cpp @@ -17,7 +17,9 @@ */ #include "backthread.h" + #include +#include BackThread::BackThread(QObject *parent) : QObject(parent){ } @@ -108,12 +110,15 @@ void BackThread::execDisWifi(){ void BackThread::execConnLan(QString connName){ QString net_card = "ifconfig>/tmp/kylin-nm-ifconfig"; system(net_card.toUtf8().data()); + QFile file("/tmp/kylin-nm-ifconfig"); if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug()<<"Can't open the file kylin-nm-ifconfig!"< Thu, 26 Sep 2019 17:31:40 +0800 + +kylin-nm (1.0.8-0ubuntu1) eoan; urgency=medium + + * Change a sentence in backthread.cpp, this sentence is wrong in 1.0.7-0ubuntu1 + + -- handsome_feng Thu, 26 Sep 2019 17:11:40 +0800 + +kylin-nm (1.0.7-0ubuntu1) eoan; urgency=medium + + * Bug-fix: + - Fix the bug which kylin-nm window-state can not update after pluging in or out wireless network adapter + + -- handsome_feng Thu, 26 Sep 2019 16:51:40 +0800 + +kylin-nm (1.0.6-0ubuntu1) eoan; urgency=medium + + * Use ukui-icon-theme to set the tray icon of kylin-nm + * Can not open the function of wifi without wireless network adapter + + -- handsome_feng Tue, 24 Sep 2019 12:51:40 +0800 + kylin-nm (1.0.5-0ubuntu1) eoan; urgency=medium * Change the method to get the path of carrier file diff --git a/kylin-nm.pro.user b/kylin-nm.pro.user index 3ce1de91..008e248a 100644 --- a/kylin-nm.pro.user +++ b/kylin-nm.pro.user @@ -1,14 +1,10 @@ -<<<<<<< HEAD - -======= - ->>>>>>> b43f78de198252c1f54a06af74b0f347f757ec1d + EnvironmentId - {d24ee5cf-e33b-4ac0-b3ff-aa81cafc226a} + {871a7e44-b0ca-4f6c-adc5-39582f458132} ProjectExplorer.Project.ActiveTarget @@ -65,7 +61,7 @@ 桌面 桌面 - {3b9e90dd-8b5f-4932-ae85-9f4afd675bbc} + {efe0a144-059c-4715-871b-4801b9a8c8f6} 0 0 0 diff --git a/main.cpp b/main.cpp index 63210b94..b45682f1 100644 --- a/main.cpp +++ b/main.cpp @@ -30,6 +30,8 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); + QIcon::setThemeName("ukui-icon-theme"); + // 国际化 QString locale = QLocale::system().name(); QTranslator trans_global; diff --git a/mainwindow.cpp b/mainwindow.cpp index 9a094fd6..8fb011f0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -180,14 +180,12 @@ void MainWindow::createTrayIcon() trayIcon->setContextMenu(trayIconMenu); // 初始化托盘所有Icon - QString iconDir = "/usr/share/icons/ukui-icon-theme/48x48/status/"; - iconLanOnline = QIcon(iconDir + "nm-device-wire.png"); - iconLanOffline = QIcon(iconDir + "nm-no-connection.png"); - iconWifiFull = QIcon(iconDir + "nm-signal-100.png"); - iconWifiHigh = QIcon(iconDir + "nm-signal-75.png"); - iconWifiMedium = QIcon(iconDir + "nm-signal-50.png"); - iconWifiLow = QIcon(iconDir + "nm-signal-25.png"); - iconConnecting = QIcon(iconDir + ".png"); + iconLanOnline = QIcon::fromTheme("nm-device-wired"); + iconLanOffline = QIcon::fromTheme("nm-no-connection"); + iconWifiFull = QIcon::fromTheme("nm-signal-100"); + iconWifiHigh = QIcon::fromTheme("nm-signal-75"); + iconWifiMedium = QIcon::fromTheme("nm-signal-50"); + iconWifiLow = QIcon::fromTheme("nm-signal-25"); loadIcons.append(QIcon(":/res/s/conning-s/1.png")); loadIcons.append(QIcon(":/res/s/conning-s/2.png")); @@ -340,7 +338,7 @@ void MainWindow::getIface(){ } else if(iface->lstate == 0) { connLanDone(3); } else if(iface->wstate == 1 && (iface->lstate == 1)) { - qDebug()<<"开机,即将循环检测 Lan或Wifi 是否开启"; + qDebug()<<"启动软件,即将循环检测 Lan或Wifi 是否开启"; check_isNetOn = new QTimer(this); check_isNetOn->setTimerType(Qt::PreciseTimer); QObject::connect(check_isNetOn, SIGNAL(timeout()), this, SLOT(on_isNetOn())); @@ -772,30 +770,52 @@ void MainWindow::on_btnNet_clicked() void MainWindow::on_btnWifi_clicked() { - // 网络开关关闭时,点击Wifi开关无效 - if(checkLanOn()){ - if(checkWlOn()){ - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - bt->moveToThread(t); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), bt, SLOT(execDisWifi())); - connect(bt, SIGNAL(disWifiDone()), this, SLOT(disWifiDone())); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - t->start(); + QString wlan_card = "iwconfig>/tmp/kylin-nm-iwconfig"; + system(wlan_card.toUtf8().data()); - }else{ - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - bt->moveToThread(t); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), bt, SLOT(execEnWifi())); - connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone())); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - t->start(); + QFile file("/tmp/kylin-nm-iwconfig"); + if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug()<<"Can't open the file kylin-nm-iwconfig!"<moveToThread(t); + connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); + connect(t, SIGNAL(started()), bt, SLOT(execDisWifi())); + connect(bt, SIGNAL(disWifiDone()), this, SLOT(disWifiDone())); + connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); + t->start(); + + }else{ + QThread *t = new QThread(); + BackThread *bt = new BackThread(); + bt->moveToThread(t); + connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); + connect(t, SIGNAL(started()), bt, SLOT(execEnWifi())); + connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone())); + connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); + t->start(); + } + + this->startLoading(); } - - this->startLoading(); + } else { + QThread *t = new QThread(); + BackThread *bt = new BackThread(); + bt->moveToThread(t); + connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); + connect(t, SIGNAL(started()), bt, SLOT(execDisWifi())); + connect(bt, SIGNAL(disWifiDone()), this, SLOT(keepDisWifiState())); + connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); + t->start(); } } @@ -933,7 +953,7 @@ void MainWindow::on_isLanConnect() IFace *iface = bt->execGetIface(); if (iface->lstate == 1){ - qDebug()<<"注意:Lan 网络连接已经断开"; + qDebug()<<"注意:有线网络连接已经断开"; if(this->is_btnNetList_clicked == 1) { this->ksnm->execGetLanList(); } @@ -959,6 +979,10 @@ void MainWindow::on_isLanConnect() count_loop = 0; } } + + if (iface->wstate == 2) { + on_btnWifi_clicked(); + } } void MainWindow::on_isNetOn() @@ -1011,6 +1035,10 @@ void MainWindow::on_isNetOn() count_loop = 0; } } + + if (iface->wstate == 2) { + on_btnWifi_clicked(); + } } // Wifi连接结果,0点击连接成功 1失败 2没有配置文件 3开机直连成功 @@ -1067,6 +1095,10 @@ void MainWindow::on_isWifiConnect() count_loop = 0; } } + + if (iface->wstate == 2) { + on_btnWifi_clicked(); + } } void MainWindow::on_btnAdvConf_clicked() @@ -1379,3 +1411,42 @@ void MainWindow::disWifiDone(){ this->stopLoading(); } + +void MainWindow::keepDisWifiState() +{ + if(this->is_btnNetList_clicked == 1) { + ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}"); + ui->lbBtnWifiBG->setStyleSheet(btnOffQss); + ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭" + } + if(this->is_btnWifiList_clicked== 1) { + QList wifiList = wifiListWidget->findChildren(); + for(int i = 0; i < wifiList.size(); i ++){ + OneConnForm *ocf = wifiList.at(i); + if(ocf->isActive == true){ + ocf->setSelected(false); + ocf->setName(tr("Not connected"));//"当前未连接任何 Wifi" + ocf->setSafe("--"); + ocf->setSignal("0"); + ocf->setSafeString("--"); + ocf->setConnedString(tr("Disconnected"));//"未连接" + ocf->setShowPoint(true); + disconnect(ocf, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneWifiFormSelected(QString))); + }else{ + ocf->deleteLater(); + } + } + lbWifiList->move(12, 68); + + ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}"); + ui->lbBtnWifiBG->setStyleSheet(btnOffQss); + ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭" + + this->lanListWidget->hide(); + this->wifiListWidget->show(); + this->scrollAreal->hide(); + this->scrollAreaw->show(); + + this->stopLoading(); + } +} diff --git a/mainwindow.h b/mainwindow.h index 1694c206..c0b4a5c9 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -160,6 +160,7 @@ private slots: void disNetDone(); void enWifiDone(); void disWifiDone(); + void keepDisWifiState(); void connLanDone(int connFlag); void connDone(int connFlag);