Delete code do not need anymore, add more comments
This commit is contained in:
parent
d594ca4d85
commit
18f6c73c5c
|
@ -55,7 +55,6 @@ SOURCES += \
|
||||||
src/loadingdiv.cpp \
|
src/loadingdiv.cpp \
|
||||||
src/main.cpp \
|
src/main.cpp \
|
||||||
src/mainwindow.cpp \
|
src/mainwindow.cpp \
|
||||||
src/notifysend.cpp \
|
|
||||||
src/oneconnform.cpp \
|
src/oneconnform.cpp \
|
||||||
src/onelancform.cpp \
|
src/onelancform.cpp \
|
||||||
src/utils.cpp \
|
src/utils.cpp \
|
||||||
|
@ -81,7 +80,6 @@ HEADERS += \
|
||||||
src/kylin-network-interface.h \
|
src/kylin-network-interface.h \
|
||||||
src/loadingdiv.h \
|
src/loadingdiv.h \
|
||||||
src/mainwindow.h \
|
src/mainwindow.h \
|
||||||
src/notifysend.h \
|
|
||||||
src/oneconnform.h \
|
src/oneconnform.h \
|
||||||
src/onelancform.h \
|
src/onelancform.h \
|
||||||
src/utils.h \
|
src/utils.h \
|
||||||
|
@ -101,7 +99,6 @@ HEADERS += \
|
||||||
FORMS += \
|
FORMS += \
|
||||||
src/confform.ui \
|
src/confform.ui \
|
||||||
src/mainwindow.ui \
|
src/mainwindow.ui \
|
||||||
src/notifysend.ui \
|
|
||||||
src/oneconnform.ui \
|
src/oneconnform.ui \
|
||||||
src/onelancform.ui \
|
src/onelancform.ui \
|
||||||
wireless-security/dlgconnhidwifi.ui \
|
wireless-security/dlgconnhidwifi.ui \
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
BackThread::BackThread(QObject *parent) : QObject(parent){
|
BackThread::BackThread(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
cmdConnWifi = new QProcess(this);
|
cmdConnWifi = new QProcess(this);
|
||||||
connect(cmdConnWifi , SIGNAL(readyReadStandardOutput()) , this , SLOT(on_readoutput()));
|
connect(cmdConnWifi , SIGNAL(readyReadStandardOutput()) , this , SLOT(on_readoutput()));
|
||||||
connect(cmdConnWifi , SIGNAL(readyReadStandardError()) , this , SLOT(on_readerror()));
|
connect(cmdConnWifi , SIGNAL(readyReadStandardError()) , this , SLOT(on_readerror()));
|
||||||
|
@ -41,8 +42,10 @@ BackThread::~BackThread()
|
||||||
{
|
{
|
||||||
cmdConnWifi->close();
|
cmdConnWifi->close();
|
||||||
}
|
}
|
||||||
|
\
|
||||||
IFace* BackThread::execGetIface(){
|
//get the connection state of wired and wireles network
|
||||||
|
IFace* BackThread::execGetIface()
|
||||||
|
{
|
||||||
IFace *iface = new IFace();
|
IFace *iface = new IFace();
|
||||||
|
|
||||||
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
||||||
|
@ -51,13 +54,14 @@ IFace* BackThread::execGetIface(){
|
||||||
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f TYPE,DEVICE,STATE device > " + localPath;
|
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f TYPE,DEVICE,STATE device > " + localPath;
|
||||||
Utils::m_system(cmd.toUtf8().data());
|
Utils::m_system(cmd.toUtf8().data());
|
||||||
|
|
||||||
// int status = system(cmd.toUtf8().data());
|
// int status = system(cmd.toUtf8().data());
|
||||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device' in function 'execGetIface' failed");}
|
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device' in function 'execGetIface' failed");}
|
||||||
|
|
||||||
QFile file(localPath);
|
QFile file(localPath);
|
||||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-iface!");
|
// print information if can not open file ~/.config/kylin-nm-iface
|
||||||
qDebug()<<"Can't open the file /tmp/kylin-nm-iface!"<<endl;
|
syslog(LOG_ERR, "Can't open the file ~/.config/kylin-nm-iface!");
|
||||||
|
qDebug()<<"Can't open the file ~/.config/kylin-nm-iface!";
|
||||||
}
|
}
|
||||||
QString txt = file.readAll();
|
QString txt = file.readAll();
|
||||||
QStringList txtList = txt.split("\n");
|
QStringList txtList = txt.split("\n");
|
||||||
|
@ -66,9 +70,9 @@ IFace* BackThread::execGetIface(){
|
||||||
iface->lstate = 2;
|
iface->lstate = 2;
|
||||||
iface->wstate = 2;
|
iface->wstate = 2;
|
||||||
|
|
||||||
for(int i = 1; i < txtList.size(); i ++){
|
for (int i = 1; i < txtList.size(); i ++) {
|
||||||
QString line = txtList.at(i);
|
QString line = txtList.at(i);
|
||||||
if(line != ""){
|
if (line != "") {
|
||||||
int index1 = line.indexOf(" ");
|
int index1 = line.indexOf(" ");
|
||||||
QString type = line.left(index1);
|
QString type = line.left(index1);
|
||||||
QString lastStr = line.mid(index1).trimmed();
|
QString lastStr = line.mid(index1).trimmed();
|
||||||
|
@ -76,30 +80,32 @@ IFace* BackThread::execGetIface(){
|
||||||
QString iname = lastStr.left(index2);
|
QString iname = lastStr.left(index2);
|
||||||
QString istateStr = lastStr.mid(index2).trimmed();
|
QString istateStr = lastStr.mid(index2).trimmed();
|
||||||
|
|
||||||
if(type == "ethernet"){
|
if (type == "ethernet") {
|
||||||
|
// if type is wired network
|
||||||
iface->lname = iname;
|
iface->lname = iname;
|
||||||
|
|
||||||
if(istateStr == "unmanaged"){
|
if (istateStr == "unmanaged") {
|
||||||
iface->lstate = 2;
|
iface->lstate = 2; //switch of wired device is off
|
||||||
}
|
}
|
||||||
if(istateStr == "disconnected" || istateStr == "unavailable"){
|
if (istateStr == "disconnected" || istateStr == "unavailable") {
|
||||||
iface->lstate = 1;
|
iface->lstate = 1; //wired network is disconnected
|
||||||
}
|
}
|
||||||
if(istateStr == "connected"){
|
if (istateStr == "connected") {
|
||||||
iface->lstate = 0;
|
iface->lstate = 0; //wired network is connected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(type == "wifi"){
|
if (type == "wifi") {
|
||||||
|
// if type is wireless network
|
||||||
iface->wname = iname;
|
iface->wname = iname;
|
||||||
|
|
||||||
if(istateStr == "unmanaged" || istateStr == "unavailable"){
|
if (istateStr == "unmanaged" || istateStr == "unavailable") {
|
||||||
iface->wstate = 2;
|
iface->wstate = 2; //switch of wireless device is off
|
||||||
}
|
}
|
||||||
if(istateStr == "disconnected"){
|
if (istateStr == "disconnected") {
|
||||||
iface->wstate = 1;
|
iface->wstate = 1; //wireless network is disconnected
|
||||||
}
|
}
|
||||||
if(istateStr == "connected"){
|
if (istateStr == "connected") {
|
||||||
iface->wstate = 0;
|
iface->wstate = 0; //wireless network is connected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,14 +114,16 @@ IFace* BackThread::execGetIface(){
|
||||||
return iface;
|
return iface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackThread::execEnNet(){
|
//turn on the switch of network
|
||||||
|
void BackThread::execEnNet()
|
||||||
|
{
|
||||||
char *chr = "nmcli networking on";
|
char *chr = "nmcli networking on";
|
||||||
Utils::m_system(chr);
|
Utils::m_system(chr);
|
||||||
|
|
||||||
// int status = system("nmcli networking on");
|
// int status = system("nmcli networking on");
|
||||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking on' in function 'execEnNet' failed");}
|
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking on' in function 'execEnNet' failed");}
|
||||||
while(1){
|
while (1) {
|
||||||
if (execGetIface()->lstate != 2){
|
if (execGetIface()->lstate != 2) {
|
||||||
sleep(3);
|
sleep(3);
|
||||||
emit enNetDone();
|
emit enNetDone();
|
||||||
emit btFinish();
|
emit btFinish();
|
||||||
|
@ -125,15 +133,17 @@ void BackThread::execEnNet(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackThread::execDisNet(){
|
//turn off the switch of wireless network first, then turn off the switch of network
|
||||||
if (execGetIface()->wstate != 2){
|
void BackThread::execDisNet()
|
||||||
|
{
|
||||||
|
if (execGetIface()->wstate != 2) {
|
||||||
char *chr = "nmcli radio wifi off";
|
char *chr = "nmcli radio wifi off";
|
||||||
Utils::m_system(chr);
|
Utils::m_system(chr);
|
||||||
|
|
||||||
// int status = system("nmcli radio wifi off");
|
// int status = system("nmcli radio wifi off");
|
||||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi off' in function 'execDisNet' failed");}
|
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi off' in function 'execDisNet' failed");}
|
||||||
while(1){
|
while (1) {
|
||||||
if (execGetIface()->wstate == 2){
|
if (execGetIface()->wstate == 2) {
|
||||||
emit disWifiDone();
|
emit disWifiDone();
|
||||||
emit btFinish();
|
emit btFinish();
|
||||||
break;
|
break;
|
||||||
|
@ -144,10 +154,10 @@ void BackThread::execDisNet(){
|
||||||
|
|
||||||
char *chr1 = "nmcli networking off";
|
char *chr1 = "nmcli networking off";
|
||||||
Utils::m_system(chr1);
|
Utils::m_system(chr1);
|
||||||
// int status1 = system("nmcli networking off");
|
// int status1 = system("nmcli networking off");
|
||||||
// if (status1 != 0){ syslog(LOG_ERR, "execute 'nmcli networking off' in function 'execDisNet' failed");}
|
// if (status1 != 0){ syslog(LOG_ERR, "execute 'nmcli networking off' in function 'execDisNet' failed");}
|
||||||
while(1){
|
while (1) {
|
||||||
if (execGetIface()->lstate == 2){
|
if (execGetIface()->lstate == 2) {
|
||||||
emit disNetDone();
|
emit disNetDone();
|
||||||
emit btFinish();
|
emit btFinish();
|
||||||
break;
|
break;
|
||||||
|
@ -156,30 +166,33 @@ void BackThread::execDisNet(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackThread::execEnWifi(){
|
//turn on the switch of wireless network
|
||||||
// if (execGetIface()->lstate == 2){
|
void BackThread::execEnWifi()
|
||||||
// char *chr = "nmcli networking on";
|
{
|
||||||
// Utils::m_system(chr);
|
//if (execGetIface()->lstate == 2){
|
||||||
// //int status = system("nmcli networking on");
|
// char *chr = "nmcli networking on";
|
||||||
// //if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking on' in function 'execEnWifi' failed");}
|
// Utils::m_system(chr);
|
||||||
// while(1){
|
// //int status = system("nmcli networking on");
|
||||||
// if (execGetIface()->lstate != 2){
|
// //if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking on' in function 'execEnWifi' failed");}
|
||||||
// emit launchLanDone();
|
// while(1){
|
||||||
// break;
|
// if (execGetIface()->lstate != 2){
|
||||||
// }
|
// emit launchLanDone();
|
||||||
// sleep(1);
|
// break;
|
||||||
// }
|
// }
|
||||||
// }
|
// sleep(1);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
char *chr1 = "nmcli radio wifi on";
|
char *chr1 = "nmcli radio wifi on";
|
||||||
Utils::m_system(chr1);
|
Utils::m_system(chr1);
|
||||||
//int status1 = system("nmcli radio wifi on");
|
//int status1 = system("nmcli radio wifi on");
|
||||||
//if (status1 != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi on' in function 'execEnWifi' failed");}
|
//if (status1 != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi on' in function 'execEnWifi' failed");}
|
||||||
while(1){
|
while (1) {
|
||||||
if (execGetIface()->wstate != 2){
|
if (execGetIface()->wstate != 2) {
|
||||||
KylinDBus objKyDbus;
|
KylinDBus objKyDbus;
|
||||||
while(1){
|
while (1) {
|
||||||
if (objKyDbus.getAccessPointsNumber() > 0){
|
if (objKyDbus.getAccessPointsNumber() > 0) {
|
||||||
|
// objKyDbus.getAccessPointsNumber()>0 standard can get wireless accesspoints now
|
||||||
emit enWifiDone();
|
emit enWifiDone();
|
||||||
emit btFinish();
|
emit btFinish();
|
||||||
break;
|
break;
|
||||||
|
@ -192,13 +205,15 @@ void BackThread::execEnWifi(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackThread::execDisWifi(){
|
//turn off the switch of wireless network
|
||||||
|
void BackThread::execDisWifi()
|
||||||
|
{
|
||||||
char *chr = "nmcli radio wifi off";
|
char *chr = "nmcli radio wifi off";
|
||||||
Utils::m_system(chr);
|
Utils::m_system(chr);
|
||||||
// int status = system("nmcli radio wifi off");
|
// int status = system("nmcli radio wifi off");
|
||||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi off' in function 'execDisWifi' failed");}
|
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi off' in function 'execDisWifi' failed");}
|
||||||
while(1){
|
while (1) {
|
||||||
if (execGetIface()->wstate == 2){
|
if (execGetIface()->wstate == 2) {
|
||||||
emit disWifiDone();
|
emit disWifiDone();
|
||||||
emit btFinish();
|
emit btFinish();
|
||||||
break;
|
break;
|
||||||
|
@ -207,15 +222,18 @@ void BackThread::execDisWifi(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackThread::execConnLan(QString connName){
|
//to connect wired network
|
||||||
|
void BackThread::execConnLan(QString connName)
|
||||||
|
{
|
||||||
disConnLanOrWifi("ethernet");
|
disConnLanOrWifi("ethernet");
|
||||||
|
|
||||||
KylinDBus objKyDbus;
|
KylinDBus objKyDbus;
|
||||||
if(objKyDbus.isWiredCableOn){
|
if (objKyDbus.isWiredCableOn) {
|
||||||
|
// only if wired cable is plug in, can connect wired network
|
||||||
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'";
|
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'";
|
||||||
Utils::m_system(cmd.toUtf8().data());
|
Utils::m_system(cmd.toUtf8().data());
|
||||||
// int status = system(cmd.toUtf8().data());
|
// int status = system(cmd.toUtf8().data());
|
||||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection up' in function 'execConnLan' failed");}
|
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection up' in function 'execConnLan' failed");}
|
||||||
qDebug()<<"debug: in function execConnLan, wired net state is: "<<QString::number(execGetIface()->lstate);
|
qDebug()<<"debug: in function execConnLan, wired net state is: "<<QString::number(execGetIface()->lstate);
|
||||||
syslog(LOG_DEBUG, "In function execConnLan, wired net state is: %d", execGetIface()->lstate);
|
syslog(LOG_DEBUG, "In function execConnLan, wired net state is: %d", execGetIface()->lstate);
|
||||||
emit connDone(0);
|
emit connDone(0);
|
||||||
|
@ -226,7 +244,9 @@ void BackThread::execConnLan(QString connName){
|
||||||
emit btFinish();
|
emit btFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackThread::execConnWifiPWD(QString connName, QString password){
|
//to connected wireless network need a password
|
||||||
|
void BackThread::execConnWifiPWD(QString connName, QString password)
|
||||||
|
{
|
||||||
//disConnLanOrWifi("wifi");
|
//disConnLanOrWifi("wifi");
|
||||||
|
|
||||||
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
||||||
|
@ -234,29 +254,31 @@ void BackThread::execConnWifiPWD(QString connName, QString password){
|
||||||
|
|
||||||
QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli device wifi connect '" + connName + "' password '" + password + "' > " + localPath;
|
QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli device wifi connect '" + connName + "' password '" + password + "' > " + localPath;
|
||||||
Utils::m_system(cmdStr.toUtf8().data());
|
Utils::m_system(cmdStr.toUtf8().data());
|
||||||
// int status = system(cmdStr.toUtf8().data());
|
// int status = system(cmdStr.toUtf8().data());
|
||||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'execConnWifiPWD' failed");}
|
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'execConnWifiPWD' failed");}
|
||||||
|
|
||||||
QFile file(localPath);
|
QFile file(localPath);
|
||||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
syslog(LOG_DEBUG, "Can't open the file /tmp/kylin-nm-btoutput !");
|
syslog(LOG_DEBUG, "Can't open the file /tmp/kylin-nm-btoutput !");
|
||||||
qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput !"<<endl;
|
qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput !"<<endl;
|
||||||
}
|
}
|
||||||
QString line = file.readLine();
|
QString line = file.readLine();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
if(line.indexOf("successfully") != -1){
|
if (line.indexOf("successfully") != -1) {
|
||||||
emit connDone(0);
|
emit connDone(0);
|
||||||
qDebug()<<"debug: in function execConnWifiPWD, wireless net state is: "<<QString::number(execGetIface()->wstate);
|
qDebug()<<"debug: in function execConnWifiPWD, wireless net state is: "<<QString::number(execGetIface()->wstate);
|
||||||
syslog(LOG_DEBUG, "In function execConnWifiPWD, wireless net state is: %d", execGetIface()->wstate);
|
syslog(LOG_DEBUG, "In function execConnWifiPWD, wireless net state is: %d", execGetIface()->wstate);
|
||||||
}else{
|
} else {
|
||||||
emit connDone(1);
|
emit connDone(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit btFinish();
|
emit btFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackThread::execConnWifi(QString connName){
|
//to connected wireless network driectly do not need a password
|
||||||
|
void BackThread::execConnWifi(QString connName)
|
||||||
|
{
|
||||||
//disConnLanOrWifi("wifi");
|
//disConnLanOrWifi("wifi");
|
||||||
|
|
||||||
QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'\n";
|
QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'\n";
|
||||||
|
@ -268,13 +290,13 @@ void BackThread::on_readoutput()
|
||||||
QString str = cmdConnWifi->readAllStandardOutput();
|
QString str = cmdConnWifi->readAllStandardOutput();
|
||||||
cmdConnWifi->close();
|
cmdConnWifi->close();
|
||||||
qDebug()<<"on_readoutput: "<< str;
|
qDebug()<<"on_readoutput: "<< str;
|
||||||
if(str.indexOf("successfully") != -1){
|
if (str.indexOf("successfully") != -1) {
|
||||||
emit connDone(0);
|
emit connDone(0); //send this signal if connect net successfully
|
||||||
qDebug()<<"debug: in function on_readoutput, wireless net state is: "<<QString::number(execGetIface()->wstate);
|
qDebug()<<"debug: in function on_readoutput, wireless net state is: "<<QString::number(execGetIface()->wstate);
|
||||||
syslog(LOG_DEBUG, "In function on_readoutput, wireless net state is: %d", execGetIface()->wstate);
|
syslog(LOG_DEBUG, "In function on_readoutput, wireless net state is: %d", execGetIface()->wstate);
|
||||||
}else if(str.indexOf("unknown") != -1){
|
} else if(str.indexOf("unknown") != -1) {
|
||||||
emit connDone(2);
|
emit connDone(2);
|
||||||
}else{
|
} else {
|
||||||
emit connDone(1);
|
emit connDone(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,28 +307,30 @@ void BackThread::on_readerror()
|
||||||
QString str = cmdConnWifi->readAllStandardError();
|
QString str = cmdConnWifi->readAllStandardError();
|
||||||
cmdConnWifi->close();
|
cmdConnWifi->close();
|
||||||
qDebug()<<"on_readerror: "<< str;
|
qDebug()<<"on_readerror: "<< str;
|
||||||
if(str.indexOf("successfully") != -1){
|
if (str.indexOf("successfully") != -1) {
|
||||||
emit connDone(0);
|
emit connDone(0);
|
||||||
}else if(str.indexOf("unknown") != -1 || str.indexOf("not exist") != -1){
|
} else if(str.indexOf("unknown") != -1 || str.indexOf("not exist") != -1) {
|
||||||
emit connDone(2);
|
emit connDone(2); //send this signal if the network we want to connect has not a configuration file
|
||||||
}else{
|
} else {
|
||||||
emit connDone(1);
|
emit connDone(1); //send this signal if connect net failed
|
||||||
}
|
}
|
||||||
|
|
||||||
emit btFinish();
|
emit btFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BackThread::getConnProp(QString connName){
|
//get property of connected network
|
||||||
|
QString BackThread::getConnProp(QString connName)
|
||||||
|
{
|
||||||
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
||||||
QString localPath = homePath.at(0) + "/.config/kylin-nm-connprop";
|
QString localPath = homePath.at(0) + "/.config/kylin-nm-connprop";
|
||||||
|
|
||||||
QString cmd = "nmcli connection show '" + connName + "' > " + localPath;
|
QString cmd = "nmcli connection show '" + connName + "' > " + localPath;
|
||||||
Utils::m_system(cmd.toUtf8().data());
|
Utils::m_system(cmd.toUtf8().data());
|
||||||
// int status = system(cmd.toUtf8().data());
|
// int status = system(cmd.toUtf8().data());
|
||||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'getConnProp' failed");}
|
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'getConnProp' failed");}
|
||||||
|
|
||||||
QFile file(localPath);
|
QFile file(localPath);
|
||||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-connprop!");
|
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-connprop!");
|
||||||
qDebug()<<"Can't open the file /tmp/kylin-nm-connprop!"<<endl;
|
qDebug()<<"Can't open the file /tmp/kylin-nm-connprop!"<<endl;
|
||||||
}
|
}
|
||||||
|
@ -317,34 +341,34 @@ QString BackThread::getConnProp(QString connName){
|
||||||
|
|
||||||
QString rtn = "";
|
QString rtn = "";
|
||||||
foreach (QString line, txtLine) {
|
foreach (QString line, txtLine) {
|
||||||
if(line.startsWith("ipv4.method:")){
|
if (line.startsWith("ipv4.method:")) {
|
||||||
QString v4method = line.mid(12).trimmed();
|
QString v4method = line.mid(12).trimmed();
|
||||||
rtn += "method:" + v4method + "|";
|
rtn += "method:" + v4method + "|";
|
||||||
}
|
}
|
||||||
if(line.startsWith("ipv4.addresses:")){
|
if (line.startsWith("ipv4.addresses:")) {
|
||||||
QString value = line.mid(15).trimmed();
|
QString value = line.mid(15).trimmed();
|
||||||
if(value == "--"){
|
if (value == "--") {
|
||||||
rtn += "addr:|mask:|";
|
rtn += "addr:|mask:|";
|
||||||
}else{
|
} else {
|
||||||
QString addr = value.split("/").at(0);
|
QString addr = value.split("/").at(0);
|
||||||
QString mask = value.trimmed().split("/").at(1);
|
QString mask = value.trimmed().split("/").at(1);
|
||||||
rtn += "addr:" + addr + "|";
|
rtn += "addr:" + addr + "|";
|
||||||
rtn += "mask:" + mask + "|";
|
rtn += "mask:" + mask + "|";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(line.startsWith("ipv4.gateway:")){
|
if (line.startsWith("ipv4.gateway:")) {
|
||||||
QString value = line.mid(13).trimmed();
|
QString value = line.mid(13).trimmed();
|
||||||
if(value == "--"){
|
if (value == "--") {
|
||||||
rtn += "gateway:|";
|
rtn += "gateway:|";
|
||||||
}else{
|
} else {
|
||||||
rtn += "gateway:" + value + "|";
|
rtn += "gateway:" + value + "|";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(line.startsWith("ipv4.dns:")){
|
if (line.startsWith("ipv4.dns:")) {
|
||||||
QString value = line.mid(9).trimmed();
|
QString value = line.mid(9).trimmed();
|
||||||
if(value == "--"){
|
if (value == "--") {
|
||||||
rtn += "dns:|";
|
rtn += "dns:|";
|
||||||
}else{
|
} else {
|
||||||
rtn += "dns:" + value + "|";
|
rtn += "dns:" + value + "|";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,43 +377,19 @@ QString BackThread::getConnProp(QString connName){
|
||||||
return rtn.left(rtn.length() - 1);
|
return rtn.left(rtn.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BackThread::execChkWifiExist(QString connName){
|
//get band width of wired network
|
||||||
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
QString BackThread::execChkLanWidth(QString ethName)
|
||||||
QString localPath = homePath.at(0) + "/.config/kylin-nm-chkwifiexist";
|
{
|
||||||
|
|
||||||
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection show '" + connName + "' > " + localPath;
|
|
||||||
Utils::m_system(cmd.toUtf8().data());
|
|
||||||
// int status = system(cmd.toUtf8().data());
|
|
||||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'execChkWifiExist' failed");}
|
|
||||||
|
|
||||||
QFile file(localPath);
|
|
||||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
|
||||||
{
|
|
||||||
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-chkwifiexist!");
|
|
||||||
qDebug()<<"Can't open the file /tmp/kylin-nm-chkwifiexist!"<<endl;
|
|
||||||
}
|
|
||||||
QString line = file.readLine();
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
if(line.length() < 2 || line.indexOf("Error:") != -1){
|
|
||||||
return false;
|
|
||||||
}else{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString BackThread::execChkLanWidth(QString ethName){
|
|
||||||
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
||||||
QString localPath = homePath.at(0) + "/.config/kylin-nm-bandwidth";
|
QString localPath = homePath.at(0) + "/.config/kylin-nm-bandwidth";
|
||||||
|
|
||||||
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';ethtool '" + ethName + "' | grep Speed > " + localPath;
|
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';ethtool '" + ethName + "' | grep Speed > " + localPath;
|
||||||
Utils::m_system(cmd.toUtf8().data());
|
Utils::m_system(cmd.toUtf8().data());
|
||||||
// int status = system(cmd.toUtf8().data());
|
// int status = system(cmd.toUtf8().data());
|
||||||
// if (status != 0){ syslog(LOG_ERR, "execute 'ethtool' in function 'execChkLanWidth' failed");}
|
// if (status != 0){ syslog(LOG_ERR, "execute 'ethtool' in function 'execChkLanWidth' failed");}
|
||||||
|
|
||||||
QFile file(localPath);
|
QFile file(localPath);
|
||||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
{
|
|
||||||
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-bandwidth!");
|
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-bandwidth!");
|
||||||
qDebug()<<"Can't open the file /tmp/kylin-nm-bandwidth!"<<endl;
|
qDebug()<<"Can't open the file /tmp/kylin-nm-bandwidth!"<<endl;
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ QString BackThread::execChkLanWidth(QString ethName){
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
QStringList params = line.split(":");
|
QStringList params = line.split(":");
|
||||||
if(params.size() < 2){
|
if (params.size() < 2) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,20 +405,21 @@ QString BackThread::execChkLanWidth(QString ethName){
|
||||||
return rtn.trimmed();
|
return rtn.trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//disconnected spare ethernet or wifi
|
||||||
void BackThread::disConnSparedNetSlot(QString type)
|
void BackThread::disConnSparedNetSlot(QString type)
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
if (type == "wifi"){
|
if (type == "wifi") {
|
||||||
disConnLanOrWifi("wifi");
|
disConnLanOrWifi("wifi");
|
||||||
} else if(type == "ethernet") {
|
} else if(type == "ethernet") {
|
||||||
disConnLanOrWifi("ethernet");
|
disConnLanOrWifi("ethernet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
emit disFinish();
|
emit disFinish();
|
||||||
emit ttFinish();
|
emit ttFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//disconnected ethernet or wifi according to network type
|
||||||
void BackThread::disConnLanOrWifi(QString type)
|
void BackThread::disConnLanOrWifi(QString type)
|
||||||
{
|
{
|
||||||
QString strSlist;
|
QString strSlist;
|
||||||
|
|
|
@ -47,7 +47,6 @@ public:
|
||||||
|
|
||||||
IFace* execGetIface();
|
IFace* execGetIface();
|
||||||
QString getConnProp(QString connName);
|
QString getConnProp(QString connName);
|
||||||
bool execChkWifiExist(QString connName);
|
|
||||||
QString execChkLanWidth(QString ethName);
|
QString execChkLanWidth(QString ethName);
|
||||||
QProcess *cmdConnWifi = nullptr;
|
QProcess *cmdConnWifi = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -141,32 +141,37 @@ ConfForm::~ConfForm()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfForm::mousePressEvent(QMouseEvent *event){
|
void ConfForm::mousePressEvent(QMouseEvent *event)
|
||||||
if(event->button() == Qt::LeftButton){
|
{
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
this->isPress = true;
|
this->isPress = true;
|
||||||
this->winPos = this->pos();
|
this->winPos = this->pos();
|
||||||
this->dragPos = event->globalPos();
|
this->dragPos = event->globalPos();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ConfForm::mouseReleaseEvent(QMouseEvent *event){
|
void ConfForm::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
this->isPress = false;
|
this->isPress = false;
|
||||||
}
|
}
|
||||||
void ConfForm::mouseMoveEvent(QMouseEvent *event){
|
void ConfForm::mouseMoveEvent(QMouseEvent *event)
|
||||||
if(this->isPress){
|
{
|
||||||
|
if (this->isPress) {
|
||||||
this->move(this->winPos - (this->dragPos - event->globalPos()));
|
this->move(this->winPos - (this->dragPos - event->globalPos()));
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfForm::setProp(QString connName, QString v4method, QString addr, QString mask, QString gateway, QString dns, bool isActConf){
|
//网络配置参数设置界面的显示内容
|
||||||
|
void ConfForm::setProp(QString connName, QString v4method, QString addr, QString mask, QString gateway, QString dns, bool isActConf)
|
||||||
|
{
|
||||||
this->isActConf = isActConf;
|
this->isActConf = isActConf;
|
||||||
ui->leName->setText(connName);
|
ui->leName->setText(connName);
|
||||||
|
|
||||||
if(v4method == "auto" || v4method == ""){
|
if (v4method == "auto" || v4method == "") {
|
||||||
ui->cbType->setCurrentIndex(0);
|
ui->cbType->setCurrentIndex(0);
|
||||||
cbTypeChanged(0);
|
cbTypeChanged(0);
|
||||||
}else{
|
} else {
|
||||||
ui->cbType->setCurrentIndex(1);
|
ui->cbType->setCurrentIndex(1);
|
||||||
cbTypeChanged(1);
|
cbTypeChanged(1);
|
||||||
}
|
}
|
||||||
|
@ -175,30 +180,31 @@ void ConfForm::setProp(QString connName, QString v4method, QString addr, QString
|
||||||
ui->leGateway->setText(gateway);
|
ui->leGateway->setText(gateway);
|
||||||
|
|
||||||
// 配置中有多个DNS,只处理前两个
|
// 配置中有多个DNS,只处理前两个
|
||||||
if(dns.indexOf(",") != -1){
|
if (dns.indexOf(",") != -1) {
|
||||||
QStringList dnss = dns.split(",");
|
QStringList dnss = dns.split(",");
|
||||||
ui->leDns->setText(dnss.at(0));
|
ui->leDns->setText(dnss.at(0));
|
||||||
ui->leDns2->setText(dnss.at(1));
|
ui->leDns2->setText(dnss.at(1));
|
||||||
}else{
|
} else {
|
||||||
ui->leDns->setText(dns);
|
ui->leDns->setText(dns);
|
||||||
ui->leDns2->setText("");
|
ui->leDns2->setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mask == "24"){
|
if (mask == "24") {
|
||||||
ui->cbMask->setCurrentIndex(0);
|
ui->cbMask->setCurrentIndex(0);
|
||||||
}else if(mask == "23"){
|
} else if(mask == "23") {
|
||||||
ui->cbMask->setCurrentIndex(1);
|
ui->cbMask->setCurrentIndex(1);
|
||||||
}else if(mask == "22"){
|
} else if(mask == "22") {
|
||||||
ui->cbMask->setCurrentIndex(2);
|
ui->cbMask->setCurrentIndex(2);
|
||||||
}else if(mask == "16"){
|
} else if(mask == "16") {
|
||||||
ui->cbMask->setCurrentIndex(3);
|
ui->cbMask->setCurrentIndex(3);
|
||||||
}else if(mask == "8"){
|
} else if(mask == "8") {
|
||||||
ui->cbMask->setCurrentIndex(4);
|
ui->cbMask->setCurrentIndex(4);
|
||||||
}else{
|
} else {
|
||||||
ui->cbMask->setCurrentIndex(0);
|
ui->cbMask->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//点击了创建新的网络的按钮
|
||||||
void ConfForm::on_btnCreate_clicked()
|
void ConfForm::on_btnCreate_clicked()
|
||||||
{
|
{
|
||||||
QString cmdStr = "nmcli connection add con-name '" + ui->leName->text() + "' type ethernet";
|
QString cmdStr = "nmcli connection add con-name '" + ui->leName->text() + "' type ethernet";
|
||||||
|
@ -206,7 +212,7 @@ void ConfForm::on_btnCreate_clicked()
|
||||||
//int status = system(cmdStr.toUtf8().data());
|
//int status = system(cmdStr.toUtf8().data());
|
||||||
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection add con-name' in function 'on_btnCreate_clicked' failed");}
|
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection add con-name' in function 'on_btnCreate_clicked' failed");}
|
||||||
|
|
||||||
if(ui->cbType->currentIndex() == 1){
|
if (ui->cbType->currentIndex() == 1) {
|
||||||
//config the ipv4 and netmask and gateway if select Manual
|
//config the ipv4 and netmask and gateway if select Manual
|
||||||
this->isCreateNewNet = true;
|
this->isCreateNewNet = true;
|
||||||
this->on_btnOk_clicked();
|
this->on_btnOk_clicked();
|
||||||
|
@ -219,28 +225,29 @@ void ConfForm::on_btnCreate_clicked()
|
||||||
this->hide();
|
this->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//点击了保存更改网络设置的按钮
|
||||||
void ConfForm::on_btnOk_clicked()
|
void ConfForm::on_btnOk_clicked()
|
||||||
{
|
{
|
||||||
QString mask = "";
|
QString mask = "";
|
||||||
if(ui->cbMask->currentIndex() == 0){
|
if (ui->cbMask->currentIndex() == 0) {
|
||||||
mask = "24";
|
mask = "24";
|
||||||
}else if(ui->cbMask->currentIndex() == 1){
|
} else if(ui->cbMask->currentIndex() == 1) {
|
||||||
mask = "23";
|
mask = "23";
|
||||||
}else if(ui->cbMask->currentIndex() == 2){
|
} else if(ui->cbMask->currentIndex() == 2) {
|
||||||
mask = "22";
|
mask = "22";
|
||||||
}else if(ui->cbMask->currentIndex() == 3){
|
} else if(ui->cbMask->currentIndex() == 3) {
|
||||||
mask = "16";
|
mask = "16";
|
||||||
}else if(ui->cbMask->currentIndex() == 4){
|
} else if(ui->cbMask->currentIndex() == 4) {
|
||||||
mask = "8";
|
mask = "8";
|
||||||
}else{
|
} else {
|
||||||
mask = "24";
|
mask = "24";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ui->cbType->currentIndex() == 0){
|
if (ui->cbType->currentIndex() == 0) {
|
||||||
kylin_network_set_automethod(ui->leName->text().toUtf8().data());
|
kylin_network_set_automethod(ui->leName->text().toUtf8().data());
|
||||||
}else{
|
} else {
|
||||||
QString dnss = ui->leDns->text();
|
QString dnss = ui->leDns->text();
|
||||||
if(ui->leDns2->text() != ""){
|
if (ui->leDns2->text() != "") {
|
||||||
dnss.append(",");
|
dnss.append(",");
|
||||||
dnss.append(ui->leDns2->text());
|
dnss.append(ui->leDns2->text());
|
||||||
}
|
}
|
||||||
|
@ -255,7 +262,7 @@ void ConfForm::on_btnOk_clicked()
|
||||||
kylindbus.showDesktopNotify(txt);
|
kylindbus.showDesktopNotify(txt);
|
||||||
|
|
||||||
if (!this->isCreateNewNet) {
|
if (!this->isCreateNewNet) {
|
||||||
if(this->isActConf == true){
|
if (this->isActConf == true) {
|
||||||
// 如果是修改当前连接的网络,则修改设置后简略重连网络
|
// 如果是修改当前连接的网络,则修改设置后简略重连网络
|
||||||
//QString cmd = "/usr/share/kylin-nm/shell/connup.sh '" + ui->leName->text() + "'";
|
//QString cmd = "/usr/share/kylin-nm/shell/connup.sh '" + ui->leName->text() + "'";
|
||||||
kylindbus.connectWiredNet(ui->leName->text()); //reconnect this wired network
|
kylindbus.connectWiredNet(ui->leName->text()); //reconnect this wired network
|
||||||
|
@ -271,20 +278,23 @@ void ConfForm::on_btnOk_clicked()
|
||||||
this->isCreateNewNet = false;
|
this->isCreateNewNet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//点击取消按钮
|
||||||
void ConfForm::on_btnCancel_clicked()
|
void ConfForm::on_btnCancel_clicked()
|
||||||
{
|
{
|
||||||
this->hide();
|
this->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfForm::cbTypeChanged(int index){
|
//根据需要设置的种类(自动或手动等)显示界面内容
|
||||||
if (isShowSaveBtn){
|
void ConfForm::cbTypeChanged(int index)
|
||||||
|
{
|
||||||
|
if (isShowSaveBtn) {
|
||||||
ui->leName->setEnabled(false);
|
ui->leName->setEnabled(false);
|
||||||
ui->btnOk->show();
|
ui->btnOk->show();
|
||||||
ui->btnCreate->hide();
|
ui->btnCreate->hide();
|
||||||
ui->lbLeftupTitle->setText(tr("Edit Network"));
|
ui->lbLeftupTitle->setText(tr("Edit Network"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(index == 0){
|
if (index == 0) {
|
||||||
ui->lineUp->hide();
|
ui->lineUp->hide();
|
||||||
ui->lineDown->hide();
|
ui->lineDown->hide();
|
||||||
ui->wgManual->hide();
|
ui->wgManual->hide();
|
||||||
|
@ -295,7 +305,7 @@ void ConfForm::cbTypeChanged(int index){
|
||||||
|
|
||||||
this->resize(432, 230);
|
this->resize(432, 230);
|
||||||
}
|
}
|
||||||
if(index == 1){
|
if (index == 1) {
|
||||||
ui->lineUp->show();
|
ui->lineUp->show();
|
||||||
ui->lineDown->show();
|
ui->lineDown->show();
|
||||||
ui->wgManual->show();
|
ui->wgManual->show();
|
||||||
|
@ -306,7 +316,7 @@ void ConfForm::cbTypeChanged(int index){
|
||||||
|
|
||||||
this->resize(432, 510);
|
this->resize(432, 510);
|
||||||
}
|
}
|
||||||
if(index == 3){
|
if (index == 3) {
|
||||||
ui->btnOk->setStyleSheet(btnOffQss);
|
ui->btnOk->setStyleSheet(btnOffQss);
|
||||||
ui->btnOk->setEnabled(false);
|
ui->btnOk->setEnabled(false);
|
||||||
|
|
||||||
|
@ -328,50 +338,56 @@ void ConfForm::cbTypeChanged(int index){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//编辑网络名称
|
||||||
void ConfForm::on_leName_textEdited(const QString &arg1)
|
void ConfForm::on_leName_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
this->setEnableOfBtn();
|
this->setEnableOfBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//编辑网络ip
|
||||||
void ConfForm::on_leAddr_textEdited(const QString &arg1)
|
void ConfForm::on_leAddr_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
this->setEnableOfBtn();
|
this->setEnableOfBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//编辑网络网关
|
||||||
void ConfForm::on_leGateway_textEdited(const QString &arg1)
|
void ConfForm::on_leGateway_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
this->setEnableOfBtn();
|
this->setEnableOfBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//编辑网络DNS
|
||||||
void ConfForm::on_leDns_textEdited(const QString &arg1)
|
void ConfForm::on_leDns_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
this->setEnableOfBtn();
|
this->setEnableOfBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//编辑网络备用DNS
|
||||||
void ConfForm::on_leDns2_textEdited(const QString &arg1)
|
void ConfForm::on_leDns2_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
// this->setEnableOfBtn();
|
// this->setEnableOfBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//设置界面按钮是否可点击
|
||||||
void ConfForm::setEnableOfBtn()
|
void ConfForm::setEnableOfBtn()
|
||||||
{
|
{
|
||||||
if (ui->leName->text().size() == 0 ){
|
if (ui->leName->text().size() == 0 ) {
|
||||||
this->setBtnEnableFalse();
|
this->setBtnEnableFalse();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui->cbType->currentIndex() == 1){
|
if (ui->cbType->currentIndex() == 1) {
|
||||||
if (!this->getTextEditState(ui->leAddr->text()) ){
|
if (!this->getTextEditState(ui->leAddr->text()) ) {
|
||||||
this->setBtnEnableFalse();
|
this->setBtnEnableFalse();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->getTextEditState(ui->leGateway->text()) ){
|
if (!this->getTextEditState(ui->leGateway->text()) ) {
|
||||||
this->setBtnEnableFalse();
|
this->setBtnEnableFalse();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->getTextEditState(ui->leDns->text()) ){
|
if (!this->getTextEditState(ui->leDns->text()) ) {
|
||||||
this->setBtnEnableFalse();
|
this->setBtnEnableFalse();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -384,6 +400,7 @@ void ConfForm::setEnableOfBtn()
|
||||||
ui->btnCreate->setEnabled(true);
|
ui->btnCreate->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//文本的输入要符合ip的格式要求
|
||||||
bool ConfForm::getTextEditState(QString text)
|
bool ConfForm::getTextEditState(QString text)
|
||||||
{
|
{
|
||||||
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
|
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
|
||||||
|
@ -395,6 +412,7 @@ bool ConfForm::getTextEditState(QString text)
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//设置创建或保存按钮不可点击
|
||||||
void ConfForm::setBtnEnableFalse()
|
void ConfForm::setBtnEnableFalse()
|
||||||
{
|
{
|
||||||
ui->btnOk->setStyleSheet(btnOffQss);
|
ui->btnOk->setStyleSheet(btnOffQss);
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
#ifndef CONFFORM_H
|
#ifndef CONFFORM_H
|
||||||
#define CONFFORM_H
|
#define CONFFORM_H
|
||||||
|
|
||||||
#include "notifysend.h"
|
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
|
@ -33,8 +33,10 @@ KSimpleNM::KSimpleNM(QObject *parent) : QObject(parent)
|
||||||
connect(runShellProcess, SIGNAL(finished(int)), this, SLOT(finishedProcess(int)));
|
connect(runShellProcess, SIGNAL(finished(int)), this, SLOT(finishedProcess(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void KSimpleNM::execGetLanList(){
|
//获取有线网络列表数据
|
||||||
if (isExecutingGetWifiList){
|
void KSimpleNM::execGetLanList()
|
||||||
|
{
|
||||||
|
if (isExecutingGetWifiList) {
|
||||||
syslog(LOG_DEBUG, "It is running getting wifi list when getting lan list");
|
syslog(LOG_DEBUG, "It is running getting wifi list when getting lan list");
|
||||||
qDebug()<<"debug: it is running getting wifi list when getting lan list";
|
qDebug()<<"debug: it is running getting wifi list when getting lan list";
|
||||||
isUseOldLanSlist = true;
|
isUseOldLanSlist = true;
|
||||||
|
@ -45,24 +47,30 @@ void KSimpleNM::execGetLanList(){
|
||||||
runShellProcess->start("nmcli -f type,device,name connection show");
|
runShellProcess->start("nmcli -f type,device,name connection show");
|
||||||
}
|
}
|
||||||
|
|
||||||
void KSimpleNM::execGetWifiList(){
|
//获取无线网络列表数据
|
||||||
|
void KSimpleNM::execGetWifiList()
|
||||||
|
{
|
||||||
isExecutingGetWifiList = true;
|
isExecutingGetWifiList = true;
|
||||||
shellOutput = "";
|
shellOutput = "";
|
||||||
type = 1;
|
type = 1;
|
||||||
runShellProcess->start("nmcli -f signal,security,ssid device wifi");
|
runShellProcess->start("nmcli -f signal,security,ssid device wifi");
|
||||||
}
|
}
|
||||||
|
|
||||||
void KSimpleNM::readProcess(){
|
//读取获取到的结果
|
||||||
|
void KSimpleNM::readProcess()
|
||||||
|
{
|
||||||
QString output = runShellProcess->readAll();
|
QString output = runShellProcess->readAll();
|
||||||
shellOutput += output;
|
shellOutput += output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KSimpleNM::finishedProcess(int msg){
|
//读取完所有列表数据后发信号,将数据发往mainwindow用于显示网络列表
|
||||||
|
void KSimpleNM::finishedProcess(int msg)
|
||||||
|
{
|
||||||
QStringList slist = shellOutput.split("\n");
|
QStringList slist = shellOutput.split("\n");
|
||||||
if(type == 0){
|
if (type == 0) {
|
||||||
emit getLanListFinished(slist);
|
emit getLanListFinished(slist);
|
||||||
isExecutingGetLanList = false;
|
isExecutingGetLanList = false;
|
||||||
}else{
|
} else {
|
||||||
emit getWifiListFinished(slist);
|
emit getWifiListFinished(slist);
|
||||||
isExecutingGetWifiList = false;
|
isExecutingGetWifiList = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent)
|
||||||
qDebug()<<"Can not find wired device object path when using dbus.";
|
qDebug()<<"Can not find wired device object path when using dbus.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wirelessPath.path() != ""){
|
if (wirelessPath.path() != "") {
|
||||||
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
|
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
|
||||||
QString(wirelessPath.path()),
|
QString(wirelessPath.path()),
|
||||||
QString("org.freedesktop.NetworkManager.Device.Wireless"),
|
QString("org.freedesktop.NetworkManager.Device.Wireless"),
|
||||||
|
@ -110,7 +110,7 @@ void KylinDBus::getObjectPath()
|
||||||
|
|
||||||
QList<QDBusObjectPath> obj_paths = obj_reply.value();
|
QList<QDBusObjectPath> obj_paths = obj_reply.value();
|
||||||
|
|
||||||
foreach (QDBusObjectPath obj_path, obj_paths){
|
foreach (QDBusObjectPath obj_path, obj_paths) {
|
||||||
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
||||||
obj_path.path(),
|
obj_path.path(),
|
||||||
"org.freedesktop.DBus.Introspectable",
|
"org.freedesktop.DBus.Introspectable",
|
||||||
|
@ -121,9 +121,9 @@ void KylinDBus::getObjectPath()
|
||||||
qDebug()<<"execute dbus method 'Introspect' is invalid in func getObjectPath()";
|
qDebug()<<"execute dbus method 'Introspect' is invalid in func getObjectPath()";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wired") != -1){
|
if(reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wired") != -1) {
|
||||||
wiredPath = obj_path;
|
wiredPath = obj_path;
|
||||||
} else if (reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wireless") != -1){
|
} else if (reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wireless") != -1) {
|
||||||
wirelessPath = obj_path;
|
wirelessPath = obj_path;
|
||||||
isWirelessCardOn = true;
|
isWirelessCardOn = true;
|
||||||
}
|
}
|
||||||
|
@ -139,17 +139,17 @@ void KylinDBus::getPhysicalCarrierState(int n)
|
||||||
|
|
||||||
QDBusReply<QVariant> reply = interface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "Carrier");
|
QDBusReply<QVariant> reply = interface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "Carrier");
|
||||||
|
|
||||||
try{
|
try {
|
||||||
if (reply.value().toString() == "true"){
|
if (reply.value().toString() == "true") {
|
||||||
isWiredCableOn = true;
|
isWiredCableOn = true;
|
||||||
if (n == 1){ this->mw->onPhysicalCarrierChanged(isWiredCableOn);}
|
if (n == 1){ this->mw->onPhysicalCarrierChanged(isWiredCableOn);}
|
||||||
} else if (reply.value().toString() == "false"){
|
} else if (reply.value().toString() == "false") {
|
||||||
isWiredCableOn = false;
|
isWiredCableOn = false;
|
||||||
if (n == 1){ this->mw->onPhysicalCarrierChanged(isWiredCableOn);}
|
if (n == 1){ this->mw->onPhysicalCarrierChanged(isWiredCableOn);}
|
||||||
} else {
|
} else {
|
||||||
throw -1;
|
throw -1;
|
||||||
}
|
}
|
||||||
}catch(...){
|
} catch(...) {
|
||||||
syslog(LOG_ERR, "Error occurred when get the property 'Carrier' of Wired");
|
syslog(LOG_ERR, "Error occurred when get the property 'Carrier' of Wired");
|
||||||
qDebug()<<"Error occurred when get the property 'Carrier' of Wired";
|
qDebug()<<"Error occurred when get the property 'Carrier' of Wired";
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ void KylinDBus::getLanIp(QString netName)
|
||||||
QDBusReply<QList<QDBusObjectPath>> m_reply = m_interface.call("ListConnections");
|
QDBusReply<QList<QDBusObjectPath>> m_reply = m_interface.call("ListConnections");
|
||||||
|
|
||||||
QList<QDBusObjectPath> m_objNets = m_reply.value();
|
QList<QDBusObjectPath> m_objNets = m_reply.value();
|
||||||
foreach (QDBusObjectPath objNet, m_objNets){
|
foreach (QDBusObjectPath objNet, m_objNets) {
|
||||||
QDBusInterface m_interface("org.freedesktop.NetworkManager",
|
QDBusInterface m_interface("org.freedesktop.NetworkManager",
|
||||||
objNet.path(),
|
objNet.path(),
|
||||||
"org.freedesktop.NetworkManager.Settings.Connection",
|
"org.freedesktop.NetworkManager.Settings.Connection",
|
||||||
|
@ -221,26 +221,26 @@ void KylinDBus::getLanIp(QString netName)
|
||||||
QMap<QString,QMap<QString,QVariant>> map;
|
QMap<QString,QMap<QString,QVariant>> map;
|
||||||
dbusArg1st >> map;
|
dbusArg1st >> map;
|
||||||
|
|
||||||
for(QString outside_key : map.keys() ){
|
for (QString outside_key : map.keys() ) {
|
||||||
QMap<QString,QVariant> outsideMap = map.value(outside_key);
|
QMap<QString,QVariant> outsideMap = map.value(outside_key);
|
||||||
if (outside_key == "connection") {
|
if (outside_key == "connection") {
|
||||||
for (QString search_key : outsideMap.keys()){
|
for (QString search_key : outsideMap.keys()) {
|
||||||
if (search_key == "id"){
|
if (search_key == "id") {
|
||||||
//const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value<QDBusArgument>();
|
//const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value<QDBusArgument>();
|
||||||
if (netName == outsideMap.value(search_key).toString()){
|
if (netName == outsideMap.value(search_key).toString()) {
|
||||||
// qDebug()<<"aaaaaa"<<outsideMap.value(search_key).toString();
|
// qDebug()<<"aaaaaa"<<outsideMap.value(search_key).toString();
|
||||||
|
|
||||||
for(QString key : map.keys() ){
|
for (QString key : map.keys() ) {
|
||||||
QMap<QString,QVariant> innerMap = map.value(key);
|
QMap<QString,QVariant> innerMap = map.value(key);
|
||||||
//qDebug() << "Key: " << key;
|
//qDebug() << "Key: " << key;
|
||||||
if (key == "ipv4") {
|
if (key == "ipv4") {
|
||||||
for (QString inner_key : innerMap.keys()){
|
for (QString inner_key : innerMap.keys()) {
|
||||||
if (inner_key == "address-data"){
|
if (inner_key == "address-data") {
|
||||||
const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value<QDBusArgument>();
|
const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value<QDBusArgument>();
|
||||||
QMap<QString,QVariant> m_map;
|
QMap<QString,QVariant> m_map;
|
||||||
|
|
||||||
dbusArg2nd.beginArray();
|
dbusArg2nd.beginArray();
|
||||||
while (!dbusArg2nd.atEnd()){
|
while (!dbusArg2nd.atEnd()) {
|
||||||
dbusArg2nd >> m_map;// append map to a vector here if you want to keep it
|
dbusArg2nd >> m_map;// append map to a vector here if you want to keep it
|
||||||
}
|
}
|
||||||
dbusArg2nd.endArray();
|
dbusArg2nd.endArray();
|
||||||
|
@ -252,13 +252,13 @@ void KylinDBus::getLanIp(QString netName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == "ipv6") {
|
if (key == "ipv6") {
|
||||||
for (QString inner_key : innerMap.keys()){
|
for (QString inner_key : innerMap.keys()) {
|
||||||
if (inner_key == "address-data"){
|
if (inner_key == "address-data"){
|
||||||
const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value<QDBusArgument>();
|
const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value<QDBusArgument>();
|
||||||
QMap<QString,QVariant> m_map;
|
QMap<QString,QVariant> m_map;
|
||||||
|
|
||||||
dbusArg2nd.beginArray();
|
dbusArg2nd.beginArray();
|
||||||
while (!dbusArg2nd.atEnd()){
|
while (!dbusArg2nd.atEnd()) {
|
||||||
dbusArg2nd >> m_map;// append map to a vector here if you want to keep it
|
dbusArg2nd >> m_map;// append map to a vector here if you want to keep it
|
||||||
}
|
}
|
||||||
dbusArg2nd.endArray();
|
dbusArg2nd.endArray();
|
||||||
|
@ -283,39 +283,6 @@ void KylinDBus::getWifiMac(QString netName)
|
||||||
{
|
{
|
||||||
dbusWifiMac = "";
|
dbusWifiMac = "";
|
||||||
|
|
||||||
// //将wifi名转为utf-8 十进制形式
|
|
||||||
// std::vector<int> vec;
|
|
||||||
// int len_encoded;
|
|
||||||
// int len_netName = netName.size();
|
|
||||||
// for (int i=0;i<len_netName;i++){
|
|
||||||
// QTextCodec *utf8 = QTextCodec::codecForName("utf-8");
|
|
||||||
// QByteArray encoded = utf8->fromUnicode(netName.at(i)).toHex();
|
|
||||||
// len_encoded = encoded.size();
|
|
||||||
// qDebug()<<"debug: 11"<<QString::number(len_encoded);
|
|
||||||
|
|
||||||
// if (len_encoded == 2){
|
|
||||||
// QString str;
|
|
||||||
// str.append(encoded.at(0));
|
|
||||||
// str.append(encoded.at(1));
|
|
||||||
// bool ok;
|
|
||||||
// QString hex = str;
|
|
||||||
// int dec = hex.toInt(&ok, 16);
|
|
||||||
// vec.push_back(dec);
|
|
||||||
// } else if (len_encoded == 6){
|
|
||||||
// for (int j=0;j<3;j++){
|
|
||||||
// QString str = "";
|
|
||||||
// str.append(encoded.at(j*2));
|
|
||||||
// str.append(encoded.at(j*2 + 1));
|
|
||||||
// bool ok;
|
|
||||||
// QString hex = str;
|
|
||||||
// int dec = hex.toInt(&ok, 16);
|
|
||||||
// vec.push_back(dec);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
// len_encoded = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
||||||
wirelessPath.path(),
|
wirelessPath.path(),
|
||||||
"org.freedesktop.NetworkManager.Device.Wireless",
|
"org.freedesktop.NetworkManager.Device.Wireless",
|
||||||
|
@ -324,7 +291,7 @@ void KylinDBus::getWifiMac(QString netName)
|
||||||
QDBusReply<QList<QDBusObjectPath>> reply = interface.call("GetAllAccessPoints");
|
QDBusReply<QList<QDBusObjectPath>> reply = interface.call("GetAllAccessPoints");
|
||||||
QList<QDBusObjectPath> objPaths = reply.value();
|
QList<QDBusObjectPath> objPaths = reply.value();
|
||||||
|
|
||||||
foreach (QDBusObjectPath objPath, objPaths){
|
foreach (QDBusObjectPath objPath, objPaths) {
|
||||||
QDBusInterface ssid_interface( "org.freedesktop.NetworkManager",
|
QDBusInterface ssid_interface( "org.freedesktop.NetworkManager",
|
||||||
objPath.path(),
|
objPath.path(),
|
||||||
"org.freedesktop.DBus.Properties",
|
"org.freedesktop.DBus.Properties",
|
||||||
|
@ -333,7 +300,7 @@ void KylinDBus::getWifiMac(QString netName)
|
||||||
QDBusReply<QVariant> ssid_replys = ssid_interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "Ssid");
|
QDBusReply<QVariant> ssid_replys = ssid_interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "Ssid");
|
||||||
QString str_name = ssid_replys.value().toString();
|
QString str_name = ssid_replys.value().toString();
|
||||||
|
|
||||||
if (str_name == netName){
|
if (str_name == netName) {
|
||||||
QDBusInterface path_interface( "org.freedesktop.NetworkManager",
|
QDBusInterface path_interface( "org.freedesktop.NetworkManager",
|
||||||
objPath.path(),
|
objPath.path(),
|
||||||
"org.freedesktop.DBus.Properties",
|
"org.freedesktop.DBus.Properties",
|
||||||
|
@ -382,7 +349,7 @@ void KylinDBus::onNewConnection(QDBusObjectPath objPath)
|
||||||
QMap<QString,QMap<QString,QVariant>> map;
|
QMap<QString,QMap<QString,QVariant>> map;
|
||||||
dbusArg1st >> map;
|
dbusArg1st >> map;
|
||||||
|
|
||||||
for(QString key : map.keys() ){
|
for(QString key : map.keys() ) {
|
||||||
if (key == "802-3-ethernet") {
|
if (key == "802-3-ethernet") {
|
||||||
emit this->updateWiredList(0);
|
emit this->updateWiredList(0);
|
||||||
syslog(LOG_DEBUG, "A new wired network was created.");
|
syslog(LOG_DEBUG, "A new wired network was created.");
|
||||||
|
@ -396,7 +363,7 @@ void KylinDBus::onConnectionRemoved(QDBusObjectPath objPath)
|
||||||
syslog(LOG_DEBUG, "An old network was removed from configure directory.");
|
syslog(LOG_DEBUG, "An old network was removed from configure directory.");
|
||||||
qDebug()<<"An old network was removed from configure directory.";
|
qDebug()<<"An old network was removed from configure directory.";
|
||||||
|
|
||||||
if (mw->is_btnNetList_clicked == 1){
|
if (mw->is_btnNetList_clicked == 1) {
|
||||||
emit this->updateWiredList(0);
|
emit this->updateWiredList(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -709,7 +676,7 @@ bool KylinDBus::getSwitchStatus(QString key) {
|
||||||
|
|
||||||
void KylinDBus::setWifiSwitchState(bool signal)
|
void KylinDBus::setWifiSwitchState(bool signal)
|
||||||
{
|
{
|
||||||
if(!m_gsettings) {
|
if (!m_gsettings) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,7 +690,7 @@ void KylinDBus::setWifiSwitchState(bool signal)
|
||||||
|
|
||||||
void KylinDBus::setWifiCardState(bool signal)
|
void KylinDBus::setWifiCardState(bool signal)
|
||||||
{
|
{
|
||||||
if(!m_gsettings) {
|
if (!m_gsettings) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,8 @@ LoadingDiv::LoadingDiv(QWidget *parent) : QWidget(parent)
|
||||||
this->hide();
|
this->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadingDiv::switchAnimStep(){
|
void LoadingDiv::switchAnimStep()
|
||||||
|
{
|
||||||
QString qpmQss = "QLabel{background-image:url(':/res/s/conning-b/";
|
QString qpmQss = "QLabel{background-image:url(':/res/s/conning-b/";
|
||||||
qpmQss.append(QString::number(this->currentPage));
|
qpmQss.append(QString::number(this->currentPage));
|
||||||
qpmQss.append(".png');}");
|
qpmQss.append(".png');}");
|
||||||
|
@ -46,24 +47,26 @@ void LoadingDiv::switchAnimStep(){
|
||||||
|
|
||||||
this->currentPage --;
|
this->currentPage --;
|
||||||
|
|
||||||
if(this->currentPage < 1){
|
if (this->currentPage < 1) {
|
||||||
this->currentPage = 12;
|
this->currentPage = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->countCurrentTime += FRAMESPEED;
|
this->countCurrentTime += FRAMESPEED;
|
||||||
if (this->countCurrentTime >= ALLTIME){
|
if (this->countCurrentTime >= ALLTIME) {
|
||||||
emit this->toStopLoading();
|
emit this->toStopLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadingDiv::startLoading(){
|
void LoadingDiv::startLoading()
|
||||||
|
{
|
||||||
this->currentPage = 12;
|
this->currentPage = 12;
|
||||||
this->countCurrentTime = 0;
|
this->countCurrentTime = 0;
|
||||||
this->switchTimer->start(FRAMESPEED);
|
this->switchTimer->start(FRAMESPEED);
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadingDiv::stopLoading(){
|
void LoadingDiv::stopLoading()
|
||||||
|
{
|
||||||
this->switchTimer->stop();
|
this->switchTimer->stop();
|
||||||
this->hide();
|
this->hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ int main(int argc, char *argv[])
|
||||||
// 国际化
|
// 国际化
|
||||||
QString locale = QLocale::system().name();
|
QString locale = QLocale::system().name();
|
||||||
QTranslator trans_global;
|
QTranslator trans_global;
|
||||||
if(locale == "zh_CN"){
|
if (locale == "zh_CN") {
|
||||||
trans_global.load(":/translations/kylin-nm_zh_CN.qm");
|
trans_global.load(":/translations/kylin-nm_zh_CN.qm");
|
||||||
//trans_global.load(":/translations/kylin-nm_bo.qm");
|
//trans_global.load(":/translations/kylin-nm_bo.qm");
|
||||||
a.installTranslator(&trans_global);
|
a.installTranslator(&trans_global);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,7 +25,6 @@
|
||||||
#include "kylin-dbus-interface.h"
|
#include "kylin-dbus-interface.h"
|
||||||
#include "kylin-network-interface.h"
|
#include "kylin-network-interface.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "notifysend.h"
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -130,11 +129,8 @@ public:
|
||||||
void getActiveInfo();
|
void getActiveInfo();
|
||||||
|
|
||||||
void initTimer();
|
void initTimer();
|
||||||
void changeTimerState();
|
|
||||||
void checkIsWirelessDeviceOn();
|
void checkIsWirelessDeviceOn();
|
||||||
|
|
||||||
void init_widget_action(QWidget *wid, QString iconstr, QString textstr);
|
|
||||||
|
|
||||||
QIcon iconLanOnline, iconLanOffline;
|
QIcon iconLanOnline, iconLanOffline;
|
||||||
QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow;
|
QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow;
|
||||||
QIcon iconConnecting;
|
QIcon iconConnecting;
|
||||||
|
@ -142,7 +138,6 @@ public:
|
||||||
QString mwBandWidth;
|
QString mwBandWidth;
|
||||||
KylinDBus *objKyDBus = nullptr;
|
KylinDBus *objKyDBus = nullptr;
|
||||||
NetworkSpeed *objNetSpeed = nullptr;
|
NetworkSpeed *objNetSpeed = nullptr;
|
||||||
NotifySend *m_notify = nullptr;
|
|
||||||
|
|
||||||
//状态设置,0为假,1为真
|
//状态设置,0为假,1为真
|
||||||
int is_update_wifi_list = 0; //是否是update wifi列表,而不是load wifi列表
|
int is_update_wifi_list = 0; //是否是update wifi列表,而不是load wifi列表
|
||||||
|
@ -292,9 +287,6 @@ private slots:
|
||||||
void on_checkWifiListChanged();
|
void on_checkWifiListChanged();
|
||||||
void on_setNetSpeed();
|
void on_setNetSpeed();
|
||||||
void on_checkOverTime();
|
void on_checkOverTime();
|
||||||
void on_isLanConnect();
|
|
||||||
void on_isWifiConnect();
|
|
||||||
void on_isNetOn();
|
|
||||||
|
|
||||||
// 后台回调
|
// 后台回调
|
||||||
void enNetDone();
|
void enNetDone();
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
#include "notifysend.h"
|
|
||||||
#include "ui_notifysend.h"
|
|
||||||
|
|
||||||
NotifySend::NotifySend(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::NotifySend)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
|
||||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
|
|
||||||
QPainterPath path;
|
|
||||||
auto rect = this->rect();
|
|
||||||
rect.adjust(1, 1, -1, -1);
|
|
||||||
path.addRoundedRect(rect, 4, 4);
|
|
||||||
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
|
|
||||||
|
|
||||||
this->setStyleSheet("QWidget{border:none;border-radius:4px;}");
|
|
||||||
ui->backwidget->setStyleSheet("QWidget{border:1px solid rgba(255, 255, 255, 0.05);border-radius:4px;background:rgba(19,19,20,0.7);}");
|
|
||||||
ui->lbColor->setStyleSheet("QLabel{border:none;background:rgba(61,107,229,1);}");
|
|
||||||
ui->leText->setStyleSheet("QLineEdit{border:none;background:transparent;font-size:14px;color:white;font-size:14px;}");
|
|
||||||
ui->btnClose->setStyleSheet("QPushButton{background-image:url(:/res/g/close_white.png);background-color:transparent;border:none;}");
|
|
||||||
ui->btnClose->setFocusPolicy(Qt::NoFocus);
|
|
||||||
|
|
||||||
QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
|
|
||||||
int d = 10; //窗口上边沿到屏幕边沿距离
|
|
||||||
int s = 10; //窗口右边沿到屏幕边沿距离
|
|
||||||
|
|
||||||
this->move(availableGeometry.x() + availableGeometry.width() - this->width() - s, availableGeometry.y() + d);
|
|
||||||
}
|
|
||||||
|
|
||||||
NotifySend::~NotifySend()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifySend::execNotifySend(QString text)
|
|
||||||
{
|
|
||||||
ui->leText->setText(text);
|
|
||||||
this->show();
|
|
||||||
|
|
||||||
QTimer::singleShot(4000, this, SLOT(closeNotifyDialog() ));
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifySend::closeNotifyDialog(){
|
|
||||||
ui->leText->setText("");
|
|
||||||
this->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifySend::on_btnClose_clicked()
|
|
||||||
{
|
|
||||||
this->hide();
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
#ifndef NOTIFYSEND_H
|
|
||||||
#define NOTIFYSEND_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QScreen>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class NotifySend;
|
|
||||||
}
|
|
||||||
|
|
||||||
class NotifySend : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit NotifySend(QWidget *parent = nullptr);
|
|
||||||
~NotifySend();
|
|
||||||
|
|
||||||
void execNotifySend(QString text);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::NotifySend *ui;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void closeNotifyDialog();
|
|
||||||
|
|
||||||
void on_btnClose_clicked();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void timeout();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // NOTIFYSEND_H
|
|
|
@ -1,69 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>NotifySend</class>
|
|
||||||
<widget class="QWidget" name="NotifySend">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>70</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QLabel" name="lbColor">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>60</width>
|
|
||||||
<height>70</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton" name="btnClose">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>360</x>
|
|
||||||
<y>20</y>
|
|
||||||
<width>30</width>
|
|
||||||
<height>30</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLineEdit" name="leText">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>80</x>
|
|
||||||
<y>20</y>
|
|
||||||
<width>260</width>
|
|
||||||
<height>27</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="backwidget" native="true">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>70</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<zorder>backwidget</zorder>
|
|
||||||
<zorder>lbColor</zorder>
|
|
||||||
<zorder>btnClose</zorder>
|
|
||||||
<zorder>leText</zorder>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -144,11 +144,11 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
|
||||||
|
|
||||||
OneConnForm::~OneConnForm()
|
OneConnForm::~OneConnForm()
|
||||||
{
|
{
|
||||||
m_notify->deleteLater();
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneConnForm::mousePressEvent(QMouseEvent *){
|
void OneConnForm::mousePressEvent(QMouseEvent *)
|
||||||
|
{
|
||||||
emit selectedOneWifiForm(wifiName, H_WIFI_ITEM_BIG_EXTEND);
|
emit selectedOneWifiForm(wifiName, H_WIFI_ITEM_BIG_EXTEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,11 +197,12 @@ bool OneConnForm::eventFilter(QObject *obj, QEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否当前连接的网络,字体设置不同
|
// 是否当前连接的网络,字体设置不同
|
||||||
void OneConnForm::setAct(bool isAct){
|
void OneConnForm::setAct(bool isAct)
|
||||||
if(isAct){
|
{
|
||||||
|
if (isAct) {
|
||||||
ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}");
|
ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}");
|
||||||
ui->lbConned->show();
|
ui->lbConned->show();
|
||||||
}else{
|
} else {
|
||||||
ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}");
|
ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}");
|
||||||
ui->lbConned->hide();
|
ui->lbConned->hide();
|
||||||
}
|
}
|
||||||
|
@ -210,7 +211,7 @@ void OneConnForm::setAct(bool isAct){
|
||||||
|
|
||||||
void OneConnForm::setLePassword()
|
void OneConnForm::setLePassword()
|
||||||
{
|
{
|
||||||
if(ui->lePassword->text() == "Input Password..." || ui->lePassword->text() == "输入密码..."){
|
if (ui->lePassword->text() == "Input Password..." || ui->lePassword->text() == "输入密码...") {
|
||||||
ui->lePassword->setText(tr(""));
|
ui->lePassword->setText(tr(""));
|
||||||
ui->lePassword->setEchoMode(QLineEdit::Password);
|
ui->lePassword->setEchoMode(QLineEdit::Password);
|
||||||
ui->checkBoxPwd->setChecked(false);
|
ui->checkBoxPwd->setChecked(false);
|
||||||
|
@ -218,8 +219,9 @@ void OneConnForm::setLePassword()
|
||||||
}
|
}
|
||||||
|
|
||||||
//点击窗口最上面的item时
|
//点击窗口最上面的item时
|
||||||
void OneConnForm::setTopItem(bool isSelected){
|
void OneConnForm::setTopItem(bool isSelected)
|
||||||
if(isSelected){
|
{
|
||||||
|
if (isSelected) {
|
||||||
resize(W_ITEM, H_ITEM_BIG);
|
resize(W_ITEM, H_ITEM_BIG);
|
||||||
ui->wbg_3->show();
|
ui->wbg_3->show();
|
||||||
ui->leInfo_1->show();
|
ui->leInfo_1->show();
|
||||||
|
@ -227,7 +229,7 @@ void OneConnForm::setTopItem(bool isSelected){
|
||||||
ui->leInfo_3->show();
|
ui->leInfo_3->show();
|
||||||
|
|
||||||
this->isSelected = true;
|
this->isSelected = true;
|
||||||
}else{
|
} else {
|
||||||
resize(W_ITEM, H_ITEM);
|
resize(W_ITEM, H_ITEM);
|
||||||
ui->lePassword->setText("");
|
ui->lePassword->setText("");
|
||||||
ui->wbg_3->hide();
|
ui->wbg_3->hide();
|
||||||
|
@ -250,21 +252,22 @@ void OneConnForm::setTopItem(bool isSelected){
|
||||||
ui->btnHideConn->hide();
|
ui->btnHideConn->hide();
|
||||||
ui->btnInfo->show();
|
ui->btnInfo->show();
|
||||||
|
|
||||||
if (isConnected){
|
if (isConnected) {
|
||||||
if (this->isWaiting){
|
if (this->isWaiting) {
|
||||||
ui->btnDisConn->hide();
|
ui->btnDisConn->hide();
|
||||||
}else{
|
} else {
|
||||||
ui->btnDisConn->show();
|
ui->btnDisConn->show();
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
ui->btnDisConn->hide();
|
ui->btnDisConn->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->isTopItem = true;
|
this->isTopItem = true;
|
||||||
}
|
}
|
||||||
// 点击窗口下面的item时
|
// 点击窗口下面的item时
|
||||||
void OneConnForm::setSelected(bool isSelected, bool isCurrName){
|
void OneConnForm::setSelected(bool isSelected, bool isCurrName)
|
||||||
if(isSelected){
|
{
|
||||||
|
if (isSelected) {
|
||||||
resize(W_ITEM, H_ITEM_BIG);
|
resize(W_ITEM, H_ITEM_BIG);
|
||||||
ui->line->move(X_LINE_BIG_EXTEND, Y_LINE_BIG_EXTEND);
|
ui->line->move(X_LINE_BIG_EXTEND, Y_LINE_BIG_EXTEND);
|
||||||
ui->wbg->hide();
|
ui->wbg->hide();
|
||||||
|
@ -277,7 +280,7 @@ void OneConnForm::setSelected(bool isSelected, bool isCurrName){
|
||||||
ui->btnConnSub->show();
|
ui->btnConnSub->show();
|
||||||
|
|
||||||
this->isSelected = true;
|
this->isSelected = true;
|
||||||
}else{
|
} else {
|
||||||
resize(W_ITEM, H_ITEM);
|
resize(W_ITEM, H_ITEM);
|
||||||
ui->lePassword->setText(tr("Input Password..."));//"输入密码..."
|
ui->lePassword->setText(tr("Input Password..."));//"输入密码..."
|
||||||
ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;"
|
ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;"
|
||||||
|
@ -293,9 +296,9 @@ void OneConnForm::setSelected(bool isSelected, bool isCurrName){
|
||||||
ui->leInfo_2->hide();
|
ui->leInfo_2->hide();
|
||||||
ui->leInfo_3->hide();
|
ui->leInfo_3->hide();
|
||||||
|
|
||||||
if (isCurrName){
|
if (isCurrName) {
|
||||||
ui->btnConn->show();
|
ui->btnConn->show();
|
||||||
}else{
|
} else {
|
||||||
ui->btnConn->hide();
|
ui->btnConn->hide();
|
||||||
}
|
}
|
||||||
ui->btnConnSub->hide();
|
ui->btnConnSub->hide();
|
||||||
|
@ -314,8 +317,9 @@ void OneConnForm::setSelected(bool isSelected, bool isCurrName){
|
||||||
this->isTopItem = false;
|
this->isTopItem = false;
|
||||||
}
|
}
|
||||||
// 点击连接隐藏wifi的item时
|
// 点击连接隐藏wifi的item时
|
||||||
void OneConnForm::setHideItem(bool isHideItem, bool isShowHideBtn){
|
void OneConnForm::setHideItem(bool isHideItem, bool isShowHideBtn)
|
||||||
if (isHideItem){
|
{
|
||||||
|
if (isHideItem) {
|
||||||
ui->lbName->move(14, 20);
|
ui->lbName->move(14, 20);
|
||||||
ui->wbg->hide();
|
ui->wbg->hide();
|
||||||
ui->btnConn->hide();
|
ui->btnConn->hide();
|
||||||
|
@ -325,24 +329,26 @@ void OneConnForm::setHideItem(bool isHideItem, bool isShowHideBtn){
|
||||||
ui->btnConn->show();
|
ui->btnConn->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isShowHideBtn){
|
if (isShowHideBtn) {
|
||||||
ui->btnHideConn->show();
|
ui->btnHideConn->show();
|
||||||
} else{
|
} else{
|
||||||
ui->btnHideConn->hide();
|
ui->btnHideConn->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneConnForm::setConnedString(bool showLable, QString str, QString str1){
|
void OneConnForm::setConnedString(bool showLable, QString str, QString str1)
|
||||||
if (!showLable){
|
{
|
||||||
|
if (!showLable) {
|
||||||
ui->lbConned->setText(str1);
|
ui->lbConned->setText(str1);
|
||||||
ui->lbConned->hide();
|
ui->lbConned->hide();
|
||||||
ui->lbName->move(63, 18);
|
ui->lbName->move(63, 18);
|
||||||
}else{
|
} else {
|
||||||
ui->lbConned->setText(str);
|
ui->lbConned->setText(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneConnForm::setName(QString name){
|
void OneConnForm::setName(QString name)
|
||||||
|
{
|
||||||
ui->lbName->setText(name);
|
ui->lbName->setText(name);
|
||||||
wifiName = name;
|
wifiName = name;
|
||||||
}
|
}
|
||||||
|
@ -357,7 +363,8 @@ QString OneConnForm::getName()
|
||||||
return ui->lbName->text();
|
return ui->lbName->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneConnForm::setRate(QString rate){
|
void OneConnForm::setRate(QString rate)
|
||||||
|
{
|
||||||
QString txt(tr("Rate"));//"速率"
|
QString txt(tr("Rate"));//"速率"
|
||||||
this->setToolTip("<span style=\"font-size:14px;border:none;background-color:#3593b5;color:white;\"> " + txt + ": " + rate + " </span>");
|
this->setToolTip("<span style=\"font-size:14px;border:none;background-color:#3593b5;color:white;\"> " + txt + ": " + rate + " </span>");
|
||||||
this->setToolTip(txt + ":" + rate);
|
this->setToolTip(txt + ":" + rate);
|
||||||
|
@ -365,57 +372,58 @@ void OneConnForm::setRate(QString rate){
|
||||||
|
|
||||||
void OneConnForm::setLine(bool isShow)
|
void OneConnForm::setLine(bool isShow)
|
||||||
{
|
{
|
||||||
if(isShow){
|
if (isShow) {
|
||||||
ui->line->show();
|
ui->line->show();
|
||||||
}else{
|
} else {
|
||||||
ui->line->hide();
|
ui->line->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneConnForm::setSignal(QString lv, QString secu){
|
void OneConnForm::setSignal(QString lv, QString secu)
|
||||||
|
{
|
||||||
int signal = lv.toInt();
|
int signal = lv.toInt();
|
||||||
if (secu == "--" || secu == ""){
|
if (secu == "--" || secu == "") {
|
||||||
hasPwd = false;
|
hasPwd = false;
|
||||||
}else{
|
} else {
|
||||||
hasPwd = true;
|
hasPwd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(signal > 75){
|
if (signal > 75) {
|
||||||
if(hasPwd){
|
if (hasPwd) {
|
||||||
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-full-pwd.png);}");
|
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-full-pwd.png);}");
|
||||||
}else{
|
} else {
|
||||||
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-full.png);}");
|
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-full.png);}");
|
||||||
}
|
}
|
||||||
signalLv = 1;
|
signalLv = 1;
|
||||||
}
|
}
|
||||||
if(signal > 55 && signal <= 75){
|
if (signal > 55 && signal <= 75) {
|
||||||
if(hasPwd){
|
if (hasPwd) {
|
||||||
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-high-pwd.png);}");
|
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-high-pwd.png);}");
|
||||||
}else{
|
} else {
|
||||||
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-high.png);}");
|
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-high.png);}");
|
||||||
}
|
}
|
||||||
signalLv = 2;
|
signalLv = 2;
|
||||||
}
|
}
|
||||||
if(signal > 35 && signal <= 55){
|
if (signal > 35 && signal <= 55) {
|
||||||
if(hasPwd){
|
if (hasPwd) {
|
||||||
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-medium-pwd.png);}");
|
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-medium-pwd.png);}");
|
||||||
}else{
|
} else {
|
||||||
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-medium.png);}");
|
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-medium.png);}");
|
||||||
}
|
}
|
||||||
signalLv = 3;
|
signalLv = 3;
|
||||||
}
|
}
|
||||||
if(signal > 15 && signal <= 35){
|
if (signal > 15 && signal <= 35) {
|
||||||
if(hasPwd){
|
if (hasPwd) {
|
||||||
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-low-pwd.png);}");
|
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-low-pwd.png);}");
|
||||||
}else{
|
} else {
|
||||||
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-low.png);}");
|
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-low.png);}");
|
||||||
}
|
}
|
||||||
signalLv = 4;
|
signalLv = 4;
|
||||||
}
|
}
|
||||||
if(signal <= 15){
|
if (signal <= 15) {
|
||||||
if(hasPwd){
|
if (hasPwd) {
|
||||||
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-none-pwd.png);}");
|
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-none-pwd.png);}");
|
||||||
}else{
|
} else {
|
||||||
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-none.png);}");
|
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-none.png);}");
|
||||||
}
|
}
|
||||||
signalLv = 4;
|
signalLv = 4;
|
||||||
|
@ -437,12 +445,13 @@ void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3)
|
||||||
|
|
||||||
void OneConnForm::slotConnWifi()
|
void OneConnForm::slotConnWifi()
|
||||||
{
|
{
|
||||||
// mw->startLoading();
|
//mw->startLoading();
|
||||||
this->startWaiting(true);
|
this->startWaiting(true);
|
||||||
emit sigConnWifi(ui->lbName->text());
|
emit sigConnWifi(ui->lbName->text());
|
||||||
}
|
}
|
||||||
void OneConnForm::slotConnWifiPWD(){
|
void OneConnForm::slotConnWifiPWD()
|
||||||
// mw->startLoading();
|
{
|
||||||
|
//mw->startLoading();
|
||||||
this->startWaiting(true);
|
this->startWaiting(true);
|
||||||
emit sigConnWifiPWD(ui->lbName->text(), ui->lePassword->text());
|
emit sigConnWifiPWD(ui->lbName->text(), ui->lePassword->text());
|
||||||
}
|
}
|
||||||
|
@ -640,19 +649,19 @@ void OneConnForm::on_btnInfo_clicked()
|
||||||
QStringList propList = connProp.split("|");
|
QStringList propList = connProp.split("|");
|
||||||
QString v4method, addr, mask, gateway, dns;
|
QString v4method, addr, mask, gateway, dns;
|
||||||
foreach (QString line, propList) {
|
foreach (QString line, propList) {
|
||||||
if(line.startsWith("method:")){
|
if (line.startsWith("method:")) {
|
||||||
v4method = line.split(":").at(1);
|
v4method = line.split(":").at(1);
|
||||||
}
|
}
|
||||||
if(line.startsWith("addr:")){
|
if (line.startsWith("addr:")) {
|
||||||
addr = line.split(":").at(1);
|
addr = line.split(":").at(1);
|
||||||
}
|
}
|
||||||
if(line.startsWith("mask:")){
|
if (line.startsWith("mask:")) {
|
||||||
mask = line.split(":").at(1);
|
mask = line.split(":").at(1);
|
||||||
}
|
}
|
||||||
if(line.startsWith("gateway:")){
|
if (line.startsWith("gateway:")) {
|
||||||
gateway= line.split(":").at(1);
|
gateway= line.split(":").at(1);
|
||||||
}
|
}
|
||||||
if(line.startsWith("dns:")){
|
if (line.startsWith("dns:")) {
|
||||||
dns = line.split(":").at(1);
|
dns = line.split(":").at(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,10 +675,11 @@ void OneConnForm::on_btnInfo_clicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wifi连接结果,0成功 1失败 2没有配置文件
|
// Wifi连接结果,0成功 1失败 2没有配置文件
|
||||||
void OneConnForm::slotConnWifiResult(int connFlag){
|
void OneConnForm::slotConnWifiResult(int connFlag)
|
||||||
|
{
|
||||||
qDebug()<<"Function slotConnWifiResult receives a number: "<<connFlag;
|
qDebug()<<"Function slotConnWifiResult receives a number: "<<connFlag;
|
||||||
|
|
||||||
if(connFlag == 2){
|
if (connFlag == 2) {
|
||||||
mw->currSelNetName = "";
|
mw->currSelNetName = "";
|
||||||
emit selectedOneWifiForm(ui->lbName->text(), H_WIFI_ITEM_SMALL_EXTEND);
|
emit selectedOneWifiForm(ui->lbName->text(), H_WIFI_ITEM_SMALL_EXTEND);
|
||||||
|
|
||||||
|
@ -693,12 +703,11 @@ void OneConnForm::slotConnWifiResult(int connFlag){
|
||||||
this->isSelected = true;
|
this->isSelected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(connFlag == 1){
|
if (connFlag == 1) {
|
||||||
// 使用配置文件连接失败,需要删除该配置文件
|
// 使用配置文件连接失败,需要删除该配置文件
|
||||||
QString txt(tr("Conn Wifi Failed"));//"连接 Wifi 失败"
|
QString txt(tr("Conn Wifi Failed"));//"连接 Wifi 失败"
|
||||||
syslog(LOG_DEBUG, "Try to connect wifi named %s, but failed, will delete it's configuration file", ui->lbName->text().toUtf8().data());
|
syslog(LOG_DEBUG, "Try to connect wifi named %s, but failed, will delete it's configuration file", ui->lbName->text().toUtf8().data());
|
||||||
|
|
||||||
//m_notify->execNotifySend(txt);
|
|
||||||
KylinDBus kylindbus;
|
KylinDBus kylindbus;
|
||||||
kylindbus.showDesktopNotify(txt);
|
kylindbus.showDesktopNotify(txt);
|
||||||
//QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + ui->lbName->text() + "';notify-send '" + txt + "...' -t 3800";
|
//QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + ui->lbName->text() + "';notify-send '" + txt + "...' -t 3800";
|
||||||
|
@ -713,12 +722,13 @@ void OneConnForm::slotConnWifiResult(int connFlag){
|
||||||
currentActWifiSignalLv = signalLv;
|
currentActWifiSignalLv = signalLv;
|
||||||
|
|
||||||
this->stopWaiting();
|
this->stopWaiting();
|
||||||
// if (connFlag != 0){
|
//if (connFlag != 0){
|
||||||
// mw->stopLoading();
|
// mw->stopLoading();
|
||||||
// }
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneConnForm::waitAnimStep(){
|
void OneConnForm::waitAnimStep()
|
||||||
|
{
|
||||||
QString qpmQss = "QLabel{background-image:url(':/res/s/conning-a/";
|
QString qpmQss = "QLabel{background-image:url(':/res/s/conning-a/";
|
||||||
qpmQss.append(QString::number(this->waitPage));
|
qpmQss.append(QString::number(this->waitPage));
|
||||||
qpmQss.append(".png');}");
|
qpmQss.append(".png');}");
|
||||||
|
@ -726,20 +736,21 @@ void OneConnForm::waitAnimStep(){
|
||||||
|
|
||||||
this->waitPage --;
|
this->waitPage --;
|
||||||
|
|
||||||
if(this->waitPage < 1){
|
if (this->waitPage < 1) {
|
||||||
this->waitPage = TOTAL_PAGE;
|
this->waitPage = TOTAL_PAGE;
|
||||||
}
|
}
|
||||||
this->countCurrentTime += FRAME_SPEED;
|
this->countCurrentTime += FRAME_SPEED;
|
||||||
if (this->countCurrentTime >= LIMIT_TIME){
|
if (this->countCurrentTime >= LIMIT_TIME) {
|
||||||
this->stopWaiting();
|
this->stopWaiting();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneConnForm::startWaiting(bool isConn){
|
void OneConnForm::startWaiting(bool isConn)
|
||||||
|
{
|
||||||
this->isWaiting = true;
|
this->isWaiting = true;
|
||||||
if (isConn){
|
if (isConn) {
|
||||||
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}");
|
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}");
|
||||||
}else{
|
} else {
|
||||||
ui->btnDisConn->hide();
|
ui->btnDisConn->hide();
|
||||||
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);}");
|
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);}");
|
||||||
}
|
}
|
||||||
|
@ -752,7 +763,8 @@ void OneConnForm::startWaiting(bool isConn){
|
||||||
mw->setTrayLoading(true);
|
mw->setTrayLoading(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneConnForm::stopWaiting(){
|
void OneConnForm::stopWaiting()
|
||||||
|
{
|
||||||
this->isWaiting = false;
|
this->isWaiting = false;
|
||||||
this->waitTimer->stop();
|
this->waitTimer->stop();
|
||||||
ui->lbWaiting->hide();
|
ui->lbWaiting->hide();
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include "confform.h"
|
#include "confform.h"
|
||||||
#include "backthread.h"
|
#include "backthread.h"
|
||||||
#include "ksimplenm.h"
|
#include "ksimplenm.h"
|
||||||
#include "notifysend.h"
|
|
||||||
|
|
||||||
#define FRAME_SPEED 150
|
#define FRAME_SPEED 150
|
||||||
#define LIMIT_TIME 20*1000
|
#define LIMIT_TIME 20*1000
|
||||||
|
@ -82,7 +81,6 @@ public:
|
||||||
|
|
||||||
bool isWifiConfExist(QString netName);
|
bool isWifiConfExist(QString netName);
|
||||||
|
|
||||||
NotifySend *m_notify = nullptr;
|
|
||||||
QString wifiName;
|
QString wifiName;
|
||||||
bool isSelected;
|
bool isSelected;
|
||||||
bool isActive;
|
bool isActive;
|
||||||
|
|
|
@ -99,7 +99,8 @@ OneLancForm::~OneLancForm()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneLancForm::mousePressEvent(QMouseEvent *){
|
void OneLancForm::mousePressEvent(QMouseEvent *)
|
||||||
|
{
|
||||||
//emit selectedOneLanForm(lanName);
|
//emit selectedOneLanForm(lanName);
|
||||||
emit selectedOneLanForm(lanName, uniqueName);//避免重名情况
|
emit selectedOneLanForm(lanName, uniqueName);//避免重名情况
|
||||||
}
|
}
|
||||||
|
@ -107,31 +108,31 @@ void OneLancForm::mousePressEvent(QMouseEvent *){
|
||||||
//事件过滤器
|
//事件过滤器
|
||||||
bool OneLancForm::eventFilter(QObject *obj, QEvent *event)
|
bool OneLancForm::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
if (obj == ui->btnInfo){
|
if (obj == ui->btnInfo) {
|
||||||
if(event->type() == QEvent::HoverEnter) {
|
if(event->type() == QEvent::HoverEnter) {
|
||||||
ui->leInfo_1->setStyleSheet(leQssHigh);
|
ui->leInfo_1->setStyleSheet(leQssHigh);
|
||||||
ui->leInfo_2->setStyleSheet(leQssHigh);
|
ui->leInfo_2->setStyleSheet(leQssHigh);
|
||||||
ui->leInfo_3->setStyleSheet(leQssHigh);
|
ui->leInfo_3->setStyleSheet(leQssHigh);
|
||||||
ui->leInfo_4->setStyleSheet(leQssHigh);
|
ui->leInfo_4->setStyleSheet(leQssHigh);
|
||||||
return true;
|
return true;
|
||||||
} else if(event->type() == QEvent::HoverLeave){
|
} else if(event->type() == QEvent::HoverLeave) {
|
||||||
ui->leInfo_1->setStyleSheet(leQssLow);
|
ui->leInfo_1->setStyleSheet(leQssLow);
|
||||||
ui->leInfo_2->setStyleSheet(leQssLow);
|
ui->leInfo_2->setStyleSheet(leQssLow);
|
||||||
ui->leInfo_3->setStyleSheet(leQssLow);
|
ui->leInfo_3->setStyleSheet(leQssLow);
|
||||||
ui->leInfo_4->setStyleSheet(leQssLow);
|
ui->leInfo_4->setStyleSheet(leQssLow);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else if (obj == this){
|
} else if (obj == this) {
|
||||||
if(event->type() == QEvent::HoverEnter) {
|
if (event->type() == QEvent::HoverEnter) {
|
||||||
if (!this->isTopItem){
|
if (!this->isTopItem) {
|
||||||
if (!this->isSelected){
|
if (!this->isSelected) {
|
||||||
ui->btnConn->show();
|
ui->btnConn->show();
|
||||||
ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0.1);}");
|
ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0.1);}");
|
||||||
ui->wbg_2->show();
|
ui->wbg_2->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if(event->type() == QEvent::HoverLeave){
|
} else if(event->type() == QEvent::HoverLeave) {
|
||||||
ui->btnConn->hide();
|
ui->btnConn->hide();
|
||||||
ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0);}");
|
ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0);}");
|
||||||
ui->wbg_2->hide();
|
ui->wbg_2->hide();
|
||||||
|
@ -143,12 +144,13 @@ bool OneLancForm::eventFilter(QObject *obj, QEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否当前连接的网络,字体设置不同
|
// 是否当前连接的网络,字体设置不同
|
||||||
void OneLancForm::setAct(bool isAct){
|
void OneLancForm::setAct(bool isAct)
|
||||||
if(isAct){
|
{
|
||||||
|
if (isAct) {
|
||||||
ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}");
|
ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}");
|
||||||
ui->lbConned->show();
|
ui->lbConned->show();
|
||||||
ui->btnConnSub->hide();
|
ui->btnConnSub->hide();
|
||||||
}else{
|
} else {
|
||||||
ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}");
|
ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}");
|
||||||
ui->lbConned->hide();
|
ui->lbConned->hide();
|
||||||
ui->btnConnSub->hide();
|
ui->btnConnSub->hide();
|
||||||
|
@ -159,7 +161,7 @@ void OneLancForm::setAct(bool isAct){
|
||||||
// 是否选中
|
// 是否选中
|
||||||
void OneLancForm::setSelected(bool isSelected, bool isCurrName)
|
void OneLancForm::setSelected(bool isSelected, bool isCurrName)
|
||||||
{
|
{
|
||||||
if(isSelected){
|
if (isSelected) {
|
||||||
resize(W_ITEM, H_ITEM_EXTEND);
|
resize(W_ITEM, H_ITEM_EXTEND);
|
||||||
ui->wbg->show();
|
ui->wbg->show();
|
||||||
ui->wbg_2->hide();
|
ui->wbg_2->hide();
|
||||||
|
@ -168,7 +170,7 @@ void OneLancForm::setSelected(bool isSelected, bool isCurrName)
|
||||||
ui->btnConnSub->show();
|
ui->btnConnSub->show();
|
||||||
|
|
||||||
this->isSelected = true;
|
this->isSelected = true;
|
||||||
}else{
|
} else {
|
||||||
resize(W_ITEM, H_ITEM);
|
resize(W_ITEM, H_ITEM);
|
||||||
ui->wbg->hide();
|
ui->wbg->hide();
|
||||||
ui->wbg_2->show();
|
ui->wbg_2->show();
|
||||||
|
@ -190,18 +192,18 @@ void OneLancForm::setSelected(bool isSelected, bool isCurrName)
|
||||||
|
|
||||||
void OneLancForm::setTopItem(bool isSelected)
|
void OneLancForm::setTopItem(bool isSelected)
|
||||||
{
|
{
|
||||||
if(isSelected){
|
if (isSelected) {
|
||||||
resize(W_ITEM, H_ITEM_EXTEND);
|
resize(W_ITEM, H_ITEM_EXTEND);
|
||||||
ui->wbg->show();
|
ui->wbg->show();
|
||||||
ui->btnConnSub->hide();
|
ui->btnConnSub->hide();
|
||||||
this->isSelected = true;
|
this->isSelected = true;
|
||||||
}else{
|
} else {
|
||||||
resize(W_ITEM, H_ITEM);
|
resize(W_ITEM, H_ITEM);
|
||||||
ui->wbg->hide();
|
ui->wbg->hide();
|
||||||
ui->btnConnSub->hide();
|
ui->btnConnSub->hide();
|
||||||
this->isSelected = false;
|
this->isSelected = false;
|
||||||
}
|
}
|
||||||
if (isConnected){
|
if (isConnected) {
|
||||||
ui->btnDisConn->show();
|
ui->btnDisConn->show();
|
||||||
} else {
|
} else {
|
||||||
ui->btnDisConn->hide();
|
ui->btnDisConn->hide();
|
||||||
|
@ -214,28 +216,30 @@ void OneLancForm::setTopItem(bool isSelected)
|
||||||
this->isTopItem = true;
|
this->isTopItem = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneLancForm::setName(QString name, QString uniName){
|
void OneLancForm::setName(QString name, QString uniName)
|
||||||
|
{
|
||||||
ui->lbName->setText(name);
|
ui->lbName->setText(name);
|
||||||
lanName = name;
|
lanName = name;
|
||||||
uniqueName = uniName;
|
uniqueName = uniName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneLancForm::setConnedString(bool showLable, QString str){
|
void OneLancForm::setConnedString(bool showLable, QString str)
|
||||||
if (!showLable){
|
{
|
||||||
|
if (!showLable) {
|
||||||
ui->lbConned->hide();
|
ui->lbConned->hide();
|
||||||
ui->lbName->move(63, 18);
|
ui->lbName->move(63, 18);
|
||||||
}else{
|
} else {
|
||||||
ui->lbConned->setText(str);
|
ui->lbConned->setText(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneLancForm::setLanInfo(QString str1, QString str2, QString str3, QString str4)
|
void OneLancForm::setLanInfo(QString str1, QString str2, QString str3, QString str4)
|
||||||
{
|
{
|
||||||
if (str1 == "" || str1 == "auto"){
|
if (str1 == "" || str1 == "auto") {
|
||||||
str1 = tr("No Configuration");
|
str1 = tr("No Configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str2 == "" || str2 == "auto"){
|
if (str2 == "" || str2 == "auto") {
|
||||||
str2 = tr("No Configuration");
|
str2 = tr("No Configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,24 +254,26 @@ void OneLancForm::setLanInfo(QString str1, QString str2, QString str3, QString s
|
||||||
ui->leInfo_4->setText(strMAC + str4);
|
ui->leInfo_4->setText(strMAC + str4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneLancForm::setIcon(bool isOn){
|
void OneLancForm::setIcon(bool isOn)
|
||||||
if(isOn){
|
{
|
||||||
|
if (isOn) {
|
||||||
ui->lbIcon->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/l/network-online.png);}");
|
ui->lbIcon->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/l/network-online.png);}");
|
||||||
}else{
|
} else {
|
||||||
ui->lbIcon->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/l/network-offline.png);}");
|
ui->lbIcon->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/l/network-offline.png);}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneLancForm::setLine(bool isShow)
|
void OneLancForm::setLine(bool isShow)
|
||||||
{
|
{
|
||||||
if(isShow){
|
if (isShow) {
|
||||||
ui->line->show();
|
ui->line->show();
|
||||||
}else{
|
} else {
|
||||||
ui->line->hide();
|
ui->line->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneLancForm::slotConnLan(){
|
void OneLancForm::slotConnLan()
|
||||||
|
{
|
||||||
//mw->startLoading();
|
//mw->startLoading();
|
||||||
this->startWaiting(true);
|
this->startWaiting(true);
|
||||||
emit sigConnLan(ui->lbName->text());
|
emit sigConnLan(ui->lbName->text());
|
||||||
|
@ -341,19 +347,19 @@ void OneLancForm::on_btnInfo_clicked()
|
||||||
QStringList propList = connProp.split("|");
|
QStringList propList = connProp.split("|");
|
||||||
QString v4method, addr, mask, gateway, dns;
|
QString v4method, addr, mask, gateway, dns;
|
||||||
foreach (QString line, propList) {
|
foreach (QString line, propList) {
|
||||||
if(line.startsWith("method:")){
|
if (line.startsWith("method:")) {
|
||||||
v4method = line.split(":").at(1);
|
v4method = line.split(":").at(1);
|
||||||
}
|
}
|
||||||
if(line.startsWith("addr:")){
|
if (line.startsWith("addr:")) {
|
||||||
addr = line.split(":").at(1);
|
addr = line.split(":").at(1);
|
||||||
}
|
}
|
||||||
if(line.startsWith("mask:")){
|
if (line.startsWith("mask:")) {
|
||||||
mask = line.split(":").at(1);
|
mask = line.split(":").at(1);
|
||||||
}
|
}
|
||||||
if(line.startsWith("gateway:")){
|
if (line.startsWith("gateway:")) {
|
||||||
gateway= line.split(":").at(1);
|
gateway= line.split(":").at(1);
|
||||||
}
|
}
|
||||||
if(line.startsWith("dns:")){
|
if (line.startsWith("dns:")) {
|
||||||
dns = line.split(":").at(1);
|
dns = line.split(":").at(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,7 +373,8 @@ void OneLancForm::on_btnInfo_clicked()
|
||||||
cf->raise();
|
cf->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneLancForm::waitAnimStep(){
|
void OneLancForm::waitAnimStep()
|
||||||
|
{
|
||||||
QString qpmQss = "QLabel{background-image:url(':/res/s/conning-a/";
|
QString qpmQss = "QLabel{background-image:url(':/res/s/conning-a/";
|
||||||
qpmQss.append(QString::number(this->waitPage));
|
qpmQss.append(QString::number(this->waitPage));
|
||||||
qpmQss.append(".png');}");
|
qpmQss.append(".png');}");
|
||||||
|
@ -375,20 +382,21 @@ void OneLancForm::waitAnimStep(){
|
||||||
|
|
||||||
this->waitPage --;
|
this->waitPage --;
|
||||||
|
|
||||||
if(this->waitPage < 1){
|
if (this->waitPage < 1) {
|
||||||
this->waitPage = TOTAL_PAGE;
|
this->waitPage = TOTAL_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->countCurrentTime += FRAME_SPEED;
|
this->countCurrentTime += FRAME_SPEED;
|
||||||
if (this->countCurrentTime >= LIMIT_TIME){
|
if (this->countCurrentTime >= LIMIT_TIME) {
|
||||||
this->stopWaiting();
|
this->stopWaiting();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneLancForm::startWaiting(bool isConn){
|
void OneLancForm::startWaiting(bool isConn)
|
||||||
if (isConn){
|
{
|
||||||
|
if (isConn) {
|
||||||
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}");
|
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}");
|
||||||
}else{
|
} else {
|
||||||
ui->btnDisConn->hide();
|
ui->btnDisConn->hide();
|
||||||
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);}");
|
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);}");
|
||||||
}
|
}
|
||||||
|
@ -401,7 +409,8 @@ void OneLancForm::startWaiting(bool isConn){
|
||||||
mw->setTrayLoading(true);
|
mw->setTrayLoading(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneLancForm::stopWaiting(){
|
void OneLancForm::stopWaiting()
|
||||||
|
{
|
||||||
this->waitTimer->stop();
|
this->waitTimer->stop();
|
||||||
ui->lbWaiting->hide();
|
ui->lbWaiting->hide();
|
||||||
ui->lbWaitingIcon->hide();
|
ui->lbWaitingIcon->hide();
|
||||||
|
|
|
@ -33,7 +33,7 @@ int Utils::m_system(char *cmd)
|
||||||
int status = 0;
|
int status = 0;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
if ((pid = vfork()) <0){
|
if ((pid = vfork()) <0) {
|
||||||
qDebug()<<"failed to create a subprocess by using vfork";
|
qDebug()<<"failed to create a subprocess by using vfork";
|
||||||
syslog(LOG_ERR, "failed to create a subprocess by using vfork");
|
syslog(LOG_ERR, "failed to create a subprocess by using vfork");
|
||||||
status = -1;
|
status = -1;
|
||||||
|
@ -84,36 +84,36 @@ int NetworkSpeed::getCurrentDownloadRates(char *netname, long *save_rate, long *
|
||||||
//int i = 0;
|
//int i = 0;
|
||||||
char tmp_value[128];
|
char tmp_value[128];
|
||||||
|
|
||||||
if((NULL == netname)||(NULL == save_rate)||(NULL == tx_rate)){
|
if((NULL == netname)||(NULL == save_rate)||(NULL == tx_rate)) {
|
||||||
qDebug()<<"parameter pass to function getCurrentDownloadRates() error";
|
qDebug()<<"parameter pass to function getCurrentDownloadRates() error";
|
||||||
syslog(LOG_ERR, "parameter pass to function getCurrentDownloadRates() error");
|
syslog(LOG_ERR, "parameter pass to function getCurrentDownloadRates() error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (net_dev_file=fopen("/proc/net/dev", "r")) == NULL ){ //打开文件/pro/net/dev/,从中读取流量数据
|
if ( (net_dev_file=fopen("/proc/net/dev", "r")) == NULL ) { //打开文件/pro/net/dev/,从中读取流量数据
|
||||||
qDebug()<<"error occurred when try to open file /proc/net/dev/";
|
qDebug()<<"error occurred when try to open file /proc/net/dev/";
|
||||||
syslog(LOG_ERR, "error occurred when try to open file /proc/net/dev/");
|
syslog(LOG_ERR, "error occurred when try to open file /proc/net/dev/");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memset(buffer,0,sizeof(buffer));
|
memset(buffer,0,sizeof(buffer));
|
||||||
|
|
||||||
while(fgets(buffer,sizeof(buffer),net_dev_file) != NULL){
|
while (fgets(buffer,sizeof(buffer),net_dev_file) != NULL) {
|
||||||
match = strstr(buffer,netname);
|
match = strstr(buffer,netname);
|
||||||
|
|
||||||
if(NULL == match){
|
if (NULL == match) {
|
||||||
// qDebug()<<"No eth0 keyword to find!";
|
// qDebug()<<"No eth0 keyword to find!";
|
||||||
continue;
|
continue;
|
||||||
}else{
|
} else {
|
||||||
match = match + strlen(netname) + strlen(":"); //地址偏移到冒号
|
match = match + strlen(netname) + strlen(":"); //地址偏移到冒号
|
||||||
sscanf(match,"%ld ",save_rate);
|
sscanf(match,"%ld ",save_rate);
|
||||||
memset(tmp_value,0,sizeof(tmp_value));
|
memset(tmp_value,0,sizeof(tmp_value));
|
||||||
sscanf(match,"%s ",tmp_value);
|
sscanf(match,"%s ",tmp_value);
|
||||||
match = match + strlen(tmp_value);
|
match = match + strlen(tmp_value);
|
||||||
for(size_t i=0;i<strlen(buffer);i++){
|
for (size_t i=0;i<strlen(buffer);i++) {
|
||||||
if(0x20 == *match){
|
if (0x20 == *match) {
|
||||||
match ++;
|
match ++;
|
||||||
} else{
|
} else {
|
||||||
if(8 == counter){
|
if (8 == counter) {
|
||||||
sscanf(match,"%ld ",tx_rate);
|
sscanf(match,"%ld ",tx_rate);
|
||||||
}
|
}
|
||||||
memset(tmp_value,0,sizeof(tmp_value));
|
memset(tmp_value,0,sizeof(tmp_value));
|
||||||
|
@ -189,19 +189,6 @@ int CustomStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *opt
|
||||||
|
|
||||||
void CustomStyle::polish(QWidget *widget)
|
void CustomStyle::polish(QWidget *widget)
|
||||||
{
|
{
|
||||||
// if (widget) {
|
|
||||||
// if (widget->inherits("QTipLabel")){
|
|
||||||
// widget->setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
|
|
||||||
// QPainterPath path;
|
|
||||||
// auto rect = widget->rect();
|
|
||||||
// rect.adjust(0, 0, -0, -0);
|
|
||||||
// path.addRoundedRect(rect, 3, 3);
|
|
||||||
|
|
||||||
// widget->setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return QProxyStyle::polish(widget);
|
return QProxyStyle::polish(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue