kylin-nm 1.0.6

This commit is contained in:
chenlelin 2019-09-25 08:52:10 +08:00
parent 7f5a1a5cff
commit f394204a00
6 changed files with 116 additions and 42 deletions

View File

@ -17,7 +17,9 @@
*/ */
#include "backthread.h" #include "backthread.h"
#include <QFile> #include <QFile>
#include <QRegExp>
BackThread::BackThread(QObject *parent) : QObject(parent){ BackThread::BackThread(QObject *parent) : QObject(parent){
} }
@ -108,12 +110,15 @@ void BackThread::execDisWifi(){
void BackThread::execConnLan(QString connName){ void BackThread::execConnLan(QString connName){
QString net_card = "ifconfig>/tmp/kylin-nm-ifconfig"; QString net_card = "ifconfig>/tmp/kylin-nm-ifconfig";
system(net_card.toUtf8().data()); system(net_card.toUtf8().data());
QFile file("/tmp/kylin-nm-ifconfig"); QFile file("/tmp/kylin-nm-ifconfig");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug()<<"Can't open the file kylin-nm-ifconfig!"<<endl; qDebug()<<"Can't open the file kylin-nm-ifconfig!"<<endl;
} }
QString txt = file.readLine(); QString txt = file.readLine();
QString strType = txt.mid(0, 6); QString strType = txt.mid(0, 6);
QString carrierPath ="/sys/class/net/" + strType + "/carrier"; QString carrierPath ="/sys/class/net/" + strType + "/carrier";
QFile sys_carrier(carrierPath); QFile sys_carrier(carrierPath);
if(!sys_carrier.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!sys_carrier.open(QIODevice::ReadOnly | QIODevice::Text)){

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
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 <jianfengli@ubuntukylin.com> Tue, 24 Sep 2019 12:51:40 +0800
kylin-nm (1.0.5-0ubuntu1) eoan; urgency=medium kylin-nm (1.0.5-0ubuntu1) eoan; urgency=medium
* Change the method to get the path of carrier file * Change the method to get the path of carrier file

View File

@ -1,14 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<<<<<<< HEAD <!-- Written by QtCreator 4.6.2, 2019-09-25T08:50:23. -->
<!-- Written by QtCreator 4.6.2, 2019-09-24T13:06:38. -->
=======
<!-- Written by QtCreator 4.6.2, 2019-09-23T17:00:02. -->
>>>>>>> b43f78de198252c1f54a06af74b0f347f757ec1d
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
<value type="QByteArray">{d24ee5cf-e33b-4ac0-b3ff-aa81cafc226a}</value> <value type="QByteArray">{871a7e44-b0ca-4f6c-adc5-39582f458132}</value>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -65,12 +61,12 @@
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{3b9e90dd-8b5f-4932-ae85-9f4afd675bbc}</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{efe0a144-059c-4715-871b-4801b9a8c8f6}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/chenlelin/kylin-nm/build-kylin-nm-unknown-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/chenlelin/test/build-kylin-nm-unknown-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -130,7 +126,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/chenlelin/kylin-nm/build-kylin-nm-unknown-Release</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/chenlelin/test/build-kylin-nm-unknown-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -190,7 +186,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/chenlelin/kylin-nm/build-kylin-nm-unknown-Profile</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/chenlelin/test/build-kylin-nm-unknown-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -308,13 +304,13 @@
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">kylin-nm</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">kylin-nm</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/chenlelin/kylin-nm/kylin-nm/kylin-nm.pro</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/chenlelin/test/kylin-nm/kylin-nm.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value> <value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">kylin-nm.pro</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">kylin-nm.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/chenlelin/kylin-nm/build-kylin-nm-unknown-Debug</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/chenlelin/test/build-kylin-nm-unknown-Debug</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value> <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>

View File

@ -30,6 +30,8 @@ int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
QIcon::setThemeName("ukui-icon-theme");
// 国际化 // 国际化
QString locale = QLocale::system().name(); QString locale = QLocale::system().name();
QTranslator trans_global; QTranslator trans_global;

View File

@ -180,14 +180,21 @@ void MainWindow::createTrayIcon()
trayIcon->setContextMenu(trayIconMenu); trayIcon->setContextMenu(trayIconMenu);
// 初始化托盘所有Icon // 初始化托盘所有Icon
QString iconDir = "/usr/share/icons/ukui-icon-theme/48x48/status/"; // QString iconDir = "/usr/share/icons/ukui-icon-theme/48x48/status/";
iconLanOnline = QIcon(iconDir + "nm-device-wire.png"); // iconLanOnline = QIcon(iconDir + "nm-device-wire.png");
iconLanOffline = QIcon(iconDir + "nm-no-connection.png"); // iconLanOffline = QIcon(iconDir + "nm-no-connection.png");
iconWifiFull = QIcon(iconDir + "nm-signal-100.png"); // iconWifiFull = QIcon(iconDir + "nm-signal-100.png");
iconWifiHigh = QIcon(iconDir + "nm-signal-75.png"); // iconWifiHigh = QIcon(iconDir + "nm-signal-75.png");
iconWifiMedium = QIcon(iconDir + "nm-signal-50.png"); // iconWifiMedium = QIcon(iconDir + "nm-signal-50.png");
iconWifiLow = QIcon(iconDir + "nm-signal-25.png"); // iconWifiLow = QIcon(iconDir + "nm-signal-25.png");
iconConnecting = QIcon(iconDir + ".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/1.png"));
loadIcons.append(QIcon(":/res/s/conning-s/2.png")); loadIcons.append(QIcon(":/res/s/conning-s/2.png"));
@ -772,30 +779,52 @@ void MainWindow::on_btnNet_clicked()
void MainWindow::on_btnWifi_clicked() void MainWindow::on_btnWifi_clicked()
{ {
// 网络开关关闭时点击Wifi开关无效 QString wlan_card = "iwconfig>/tmp/kylin-nm-iwconfig";
if(checkLanOn()){ system(wlan_card.toUtf8().data());
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();
}else{ QFile file("/tmp/kylin-nm-iwconfig");
QThread *t = new QThread(); if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
BackThread *bt = new BackThread(); qDebug()<<"Can't open the file kylin-nm-iwconfig!"<<endl;
bt->moveToThread(t); }
connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); QString txt = file.readAll();
connect(t, SIGNAL(started()), bt, SLOT(execEnWifi())); file.close();
connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone()));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); //当连接上无线网卡时才能打开wifi开关
t->start(); if(txt.indexOf("IEEE 802.11") != -1){
// 网络开关关闭时点击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();
}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();
} }
} else {
this->startLoading(); 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();
} }
} }
@ -1379,3 +1408,37 @@ void MainWindow::disWifiDone(){
this->stopLoading(); this->stopLoading();
} }
void MainWindow::keepDisWifiState()
{
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
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(false);
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();
on_btnWifiList_clicked();
this->stopLoading();
}

View File

@ -160,6 +160,7 @@ private slots:
void disNetDone(); void disNetDone();
void enWifiDone(); void enWifiDone();
void disWifiDone(); void disWifiDone();
void keepDisWifiState();
void connLanDone(int connFlag); void connLanDone(int connFlag);
void connDone(int connFlag); void connDone(int connFlag);