kylin-nm 1.0.8

This commit is contained in:
chenlelin 2019-09-26 18:20:54 +08:00
parent 7f5a1a5cff
commit 9a7530edb6
6 changed files with 140 additions and 39 deletions

View File

@ -17,7 +17,9 @@
*/
#include "backthread.h"
#include <QFile>
#include <QRegExp>
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!"<<endl;
}
QString txt = file.readLine();
QString strType = txt.mid(0, 6);
QString carrierPath ="/sys/class/net/" + strType + "/carrier";
QFile sys_carrier(carrierPath);
if(!sys_carrier.open(QIODevice::ReadOnly | QIODevice::Text)){

26
debian/changelog vendored
View File

@ -1,3 +1,29 @@
kylin-nm (1.0.9-0ubuntu1) eoan; urgency=medium
* reUpload
-- handsome_feng <jianfengli@ubuntukylin.com> 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 <jianfengli@ubuntukylin.com> 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 <jianfengli@ubuntukylin.com> 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 <jianfengli@ubuntukylin.com> 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

View File

@ -1,14 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<<<<<<< HEAD
<!-- Written by QtCreator 4.6.2, 2019-09-24T13:06:38. -->
=======
<!-- Written by QtCreator 4.6.2, 2019-09-23T17:00:02. -->
>>>>>>> b43f78de198252c1f54a06af74b0f347f757ec1d
<!-- Written by QtCreator 4.6.2, 2019-09-26T18:17:25. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{d24ee5cf-e33b-4ac0-b3ff-aa81cafc226a}</value>
<value type="QByteArray">{871a7e44-b0ca-4f6c-adc5-39582f458132}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -65,7 +61,7 @@
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</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.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>

View File

@ -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;

View File

@ -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!"<<endl;
}
QString txt = file.readAll();
file.close();
//当连接上无线网卡时才能打开wifi开关
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();
}
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<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(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();
}
}

View File

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