Delete code do not need anymore, add more comments

This commit is contained in:
chenlelin 2020-05-28 14:44:04 +08:00
parent d594ca4d85
commit 18f6c73c5c
18 changed files with 591 additions and 1073 deletions

View File

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

View File

@ -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);
@ -56,8 +59,9 @@ IFace* BackThread::execGetIface(){
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");
@ -77,29 +81,31 @@ IFace* BackThread::execGetIface(){
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,7 +114,9 @@ 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);
@ -125,7 +133,9 @@ void BackThread::execEnNet(){
} }
} }
void BackThread::execDisNet(){ //turn off the switch of wireless network first, then turn off the switch of network
void BackThread::execDisNet()
{
if (execGetIface()->wstate != 2) { if (execGetIface()->wstate != 2) {
char *chr = "nmcli radio wifi off"; char *chr = "nmcli radio wifi off";
Utils::m_system(chr); Utils::m_system(chr);
@ -156,7 +166,9 @@ void BackThread::execDisNet(){
} }
} }
void BackThread::execEnWifi(){ //turn on the switch of wireless network
void BackThread::execEnWifi()
{
//if (execGetIface()->lstate == 2){ //if (execGetIface()->lstate == 2){
// char *chr = "nmcli networking on"; // char *chr = "nmcli networking on";
// Utils::m_system(chr); // Utils::m_system(chr);
@ -180,6 +192,7 @@ void BackThread::execEnWifi(){
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,7 +205,9 @@ 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");
@ -207,11 +222,14 @@ 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());
@ -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);
@ -256,7 +276,9 @@ void BackThread::execConnWifiPWD(QString connName, QString password){
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";
@ -269,7 +291,7 @@ void BackThread::on_readoutput()
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) {
@ -288,15 +310,17 @@ void BackThread::on_readerror()
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";
@ -353,32 +377,9 @@ 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";
@ -388,8 +389,7 @@ QString BackThread::execChkLanWidth(QString ethName){
// 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;
} }
@ -405,6 +405,7 @@ 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);
@ -414,11 +415,11 @@ void BackThread::disConnSparedNetSlot(QString type)
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;

View File

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

View File

@ -141,7 +141,8 @@ 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();
@ -149,17 +150,21 @@ void ConfForm::mousePressEvent(QMouseEvent *event){
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);
@ -199,6 +204,7 @@ void ConfForm::setProp(QString connName, QString v4method, QString addr, QString
} }
} }
//点击了创建新的网络的按钮
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";
@ -219,6 +225,7 @@ void ConfForm::on_btnCreate_clicked()
this->hide(); this->hide();
} }
//点击了保存更改网络设置的按钮
void ConfForm::on_btnOk_clicked() void ConfForm::on_btnOk_clicked()
{ {
QString mask = ""; QString mask = "";
@ -271,12 +278,15 @@ 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){ //根据需要设置的种类(自动或手动等)显示界面内容
void ConfForm::cbTypeChanged(int index)
{
if (isShowSaveBtn) { if (isShowSaveBtn) {
ui->leName->setEnabled(false); ui->leName->setEnabled(false);
ui->btnOk->show(); ui->btnOk->show();
@ -328,31 +338,37 @@ 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 ) {
@ -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);

View File

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

View File

@ -33,7 +33,9 @@ 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(){ //获取有线网络列表数据
void KSimpleNM::execGetLanList()
{
if (isExecutingGetWifiList) { 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";
@ -45,19 +47,25 @@ 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);

View File

@ -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",

View File

@ -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');}");
@ -56,14 +57,16 @@ void LoadingDiv::switchAnimStep(){
} }
} }
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();
} }

View File

@ -102,7 +102,6 @@ MainWindow::MainWindow(QWidget *parent) :
getInitLanSlist(); //初始化有线网列表 getInitLanSlist(); //初始化有线网列表
initNetwork(); //初始化网络 initNetwork(); //初始化网络
initTimer(); //初始化定时器 initTimer(); //初始化定时器
//changeTimerState();//停止所有定时器
connect(ui->btnNetList, &QPushButton::clicked, this, &MainWindow::onBtnNetListClicked); connect(ui->btnNetList, &QPushButton::clicked, this, &MainWindow::onBtnNetListClicked);
connect(ui->btnWifi, &QPushButton::clicked, this, &MainWindow::onBtnWifiClicked); connect(ui->btnWifi, &QPushButton::clicked, this, &MainWindow::onBtnWifiClicked);
@ -120,6 +119,7 @@ MainWindow::MainWindow(QWidget *parent) :
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
trayIconMenu->deleteLater();
delete ui; delete ui;
} }
@ -433,7 +433,7 @@ void MainWindow::initNetwork()
qDebug()<<"state of network: '0' is connected, '1' is disconnected, '2' is net device switch off"; qDebug()<<"state of network: '0' is connected, '1' is disconnected, '2' is net device switch off";
syslog(LOG_DEBUG, "state of network: '0' is connected, '1' is disconnected, '2' is net device switch off"); syslog(LOG_DEBUG, "state of network: '0' is connected, '1' is disconnected, '2' is net device switch off");
qDebug()<<"current network state: lan state ="<<iface->lstate<<", wifi state ="<<iface->wstate ; qDebug()<<"current network state: lan state ="<<iface->lstate<<", wifi state ="<<iface->wstate ;
syslog(LOG_DEBUG, "current network state: lan state =%d, wifi state =%d", iface->lstate, iface->wstate); syslog(LOG_DEBUG, "current network state: wired state =%d, wifi state =%d", iface->lstate, iface->wstate);
qDebug()<<"==="; qDebug()<<"===";
ui->lbBtnNetBG->setStyleSheet(btnOnQss); ui->lbBtnNetBG->setStyleSheet(btnOnQss);
@ -452,11 +452,6 @@ void MainWindow::initNetwork()
} else { } else {
if (iface->lstate == 0) { if (iface->lstate == 0) {
connLanDone(3); connLanDone(3);
}else{
//syslog(LOG_DEBUG, "Launch kylin-nm, will check if Lan or Wifi connected circularly");
//qDebug()<<"连接状态启动kylin-nm, 即将循环检测 Lan或Wifi 是否连接";
//changeTimerState();
//checkIfNetworkOn->start(8000);
} }
} }
on_btnWifiList_clicked(); on_btnWifiList_clicked();
@ -468,13 +463,7 @@ void MainWindow::initNetwork()
if (iface->lstate != 2) { if (iface->lstate != 2) {
if (iface->lstate == 0) { if (iface->lstate == 0) {
connLanDone(3); connLanDone(3);
} else{
//syslog(LOG_DEBUG, "Launch kylin-nm, will check if Lan or Wifi connected circularly");
//qDebug()<<"连接状态启动kylin-nm, 即将循环检测 Lan或Wifi 是否连接";
//changeTimerState();
//checkIfNetworkOn->start(8000);
} }
onBtnNetListClicked(); onBtnNetListClicked();
ui->btnNetList->setStyleSheet("QPushButton{border:0px solid rgba(255,255,255,0);background-color:rgba(255,255,255,0);}"); ui->btnNetList->setStyleSheet("QPushButton{border:0px solid rgba(255,255,255,0);background-color:rgba(255,255,255,0);}");
@ -510,38 +499,27 @@ void MainWindow::initNetwork()
// 初始化定时器 // 初始化定时器
void MainWindow::initTimer() void MainWindow::initTimer()
{ {
// checkIfLanConnect = new QTimer(this);
// checkIfLanConnect->setTimerType(Qt::PreciseTimer);
// QObject::connect(checkIfLanConnect, SIGNAL(timeout()), this, SLOT(on_isLanConnect()));
// checkIfLanConnect->start(2000);
// checkIfWifiConnect = new QTimer(this);
// checkIfWifiConnect->setTimerType(Qt::PreciseTimer);
// QObject::connect(checkIfWifiConnect, SIGNAL(timeout()), this, SLOT(on_isWifiConnect()));
// checkIfWifiConnect->start(2000);
// checkIfNetworkOn = new QTimer(this);
// checkIfNetworkOn->setTimerType(Qt::PreciseTimer);
// QObject::connect(checkIfNetworkOn, SIGNAL(timeout()), this, SLOT(on_isNetOn()));
// checkIfNetworkOn->start(2000);
//循环检测wifi列表的变化可用于更新wifi列表 //循环检测wifi列表的变化可用于更新wifi列表
checkWifiListChanged = new QTimer(this); checkWifiListChanged = new QTimer(this);
checkWifiListChanged->setTimerType(Qt::PreciseTimer); checkWifiListChanged->setTimerType(Qt::PreciseTimer);
QObject::connect(checkWifiListChanged, SIGNAL(timeout()), this, SLOT(on_checkWifiListChanged())); QObject::connect(checkWifiListChanged, SIGNAL(timeout()), this, SLOT(on_checkWifiListChanged()));
checkWifiListChanged->start(7000); checkWifiListChanged->start(7000);
//网线插入时定时执行 //网线插入时定时执行
wiredCableUpTimer = new QTimer(this); wiredCableUpTimer = new QTimer(this);
wiredCableUpTimer->setTimerType(Qt::PreciseTimer); wiredCableUpTimer->setTimerType(Qt::PreciseTimer);
QObject::connect(wiredCableUpTimer, SIGNAL(timeout()), this, SLOT(onCarrierUpHandle())); QObject::connect(wiredCableUpTimer, SIGNAL(timeout()), this, SLOT(onCarrierUpHandle()));
//网线拔出时定时执行 //网线拔出时定时执行
wiredCableDownTimer = new QTimer(this); wiredCableDownTimer = new QTimer(this);
wiredCableDownTimer->setTimerType(Qt::PreciseTimer); wiredCableDownTimer->setTimerType(Qt::PreciseTimer);
QObject::connect(wiredCableDownTimer, SIGNAL(timeout()), this, SLOT(onCarrierDownHandle())); QObject::connect(wiredCableDownTimer, SIGNAL(timeout()), this, SLOT(onCarrierDownHandle()));
//定时处理异常网络即当点击Lan列表按钮时若lstate=2但任然有有线网连接的情况 //定时处理异常网络即当点击Lan列表按钮时若lstate=2但任然有有线网连接的情况
deleteLanTimer = new QTimer(this); deleteLanTimer = new QTimer(this);
deleteLanTimer->setTimerType(Qt::PreciseTimer); deleteLanTimer->setTimerType(Qt::PreciseTimer);
QObject::connect(deleteLanTimer, SIGNAL(timeout()), this, SLOT(onDeleteLan())); QObject::connect(deleteLanTimer, SIGNAL(timeout()), this, SLOT(onDeleteLan()));
//定时获取网速 //定时获取网速
setNetSpeed = new QTimer(this); setNetSpeed = new QTimer(this);
setNetSpeed->setTimerType(Qt::PreciseTimer); setNetSpeed->setTimerType(Qt::PreciseTimer);
@ -549,21 +527,6 @@ void MainWindow::initTimer()
setNetSpeed->start(3000); setNetSpeed->start(3000);
} }
void MainWindow::changeTimerState()
{
if (checkIfLanConnect->isActive()){
checkIfLanConnect->stop();
}
if (checkIfNetworkOn->isActive()){
checkIfNetworkOn->stop();
}
if (checkIfWifiConnect->isActive()){
checkIfWifiConnect->stop();
}
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// 任务栏托盘管理、托盘图标处理 // 任务栏托盘管理、托盘图标处理
@ -573,17 +536,17 @@ void MainWindow::createTrayIcon()
trayIcon = new QSystemTrayIcon(this); trayIcon = new QSystemTrayIcon(this);
trayIcon->setToolTip(QString(tr("kylin-nm"))); trayIcon->setToolTip(QString(tr("kylin-nm")));
trayIconMenu = new QMenu(this); trayIconMenu = new QMenu();
//trayIconMenu->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
mShowWindow = new QAction(tr("Show MainWindow"),this); mShowWindow = new QAction(tr("Show MainWindow"),this);
mAdvConf = new QAction(tr("Advanced"),this); mAdvConf = new QAction(tr("Advanced"),this);
//mAdvConf->setIcon(QIcon(":/res/x/setup.png"));
mAdvConf->setIcon(QIcon::fromTheme("document-page-setup", QIcon(":/res/x/setup.png")) ); mAdvConf->setIcon(QIcon::fromTheme("document-page-setup", QIcon(":/res/x/setup.png")) );
trayIconMenu->addAction(mShowWindow); trayIconMenu->addAction(mShowWindow);
//trayIconMenu->addSeparator(); //trayIconMenu->addSeparator();
trayIconMenu->addAction(mAdvConf); trayIconMenu->addAction(mAdvConf);
//trayIconMenu->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
//trayIconMenu->setWindowOpacity(0.8);
trayIcon->setContextMenu(trayIconMenu); trayIcon->setContextMenu(trayIconMenu);
// 初始化托盘所有Icon // 初始化托盘所有Icon
@ -594,18 +557,18 @@ void MainWindow::createTrayIcon()
iconWifiMedium = QIcon::fromTheme("network-wireless-signal-ok"); iconWifiMedium = QIcon::fromTheme("network-wireless-signal-ok");
iconWifiLow = QIcon::fromTheme("network-wireless-signal-low"); iconWifiLow = QIcon::fromTheme("network-wireless-signal-low");
loadIcons.append(QIcon::fromTheme("network-1")); loadIcons.append(QIcon::fromTheme("kylin-network-1"));
loadIcons.append(QIcon::fromTheme("network-2")); loadIcons.append(QIcon::fromTheme("kylin-network-2"));
loadIcons.append(QIcon::fromTheme("network-3")); loadIcons.append(QIcon::fromTheme("kylin-network-3"));
loadIcons.append(QIcon::fromTheme("network-4")); loadIcons.append(QIcon::fromTheme("kylin-network-4"));
loadIcons.append(QIcon::fromTheme("network-5")); loadIcons.append(QIcon::fromTheme("kylin-network-5"));
loadIcons.append(QIcon::fromTheme("network-6")); loadIcons.append(QIcon::fromTheme("kylin-network-6"));
loadIcons.append(QIcon::fromTheme("network-7")); loadIcons.append(QIcon::fromTheme("kylin-network-7"));
loadIcons.append(QIcon::fromTheme("network-8")); loadIcons.append(QIcon::fromTheme("kylin-network-8"));
loadIcons.append(QIcon::fromTheme("network-9")); loadIcons.append(QIcon::fromTheme("kylin-network-9"));
loadIcons.append(QIcon::fromTheme("network-10")); loadIcons.append(QIcon::fromTheme("kylin-network-10"));
loadIcons.append(QIcon::fromTheme("network-11")); loadIcons.append(QIcon::fromTheme("kylin-network-11"));
loadIcons.append(QIcon::fromTheme("network-12")); loadIcons.append(QIcon::fromTheme("kylin-network-12"));
iconTimer = new QTimer(this); iconTimer = new QTimer(this);
connect(iconTimer, SIGNAL(timeout()), this, SLOT(iconStep())); connect(iconTimer, SIGNAL(timeout()), this, SLOT(iconStep()));
@ -679,16 +642,6 @@ void MainWindow::handleIconClicked()
QRect deskDupRect = desktopWidget->availableGeometry(1);//获取可用桌面大小 QRect deskDupRect = desktopWidget->availableGeometry(1);//获取可用桌面大小
QRect screenDupRect = desktopWidget->screenGeometry(1);//获取设备屏幕大小 QRect screenDupRect = desktopWidget->screenGeometry(1);//获取设备屏幕大小
// qDebug()<<" ";
// qDebug()<<"trayIcon:"<<trayIcon->geometry();
// qDebug()<<"screenGeometry: "<<screenGeometry;
// qDebug()<<"availableGeometry: "<<availableGeometry;
// qDebug()<<"deskMainRect: "<<deskMainRect;
// qDebug()<<"screenMainRect: "<<screenMainRect;
// qDebug()<<"deskDupRect: "<<deskDupRect;
// qDebug()<<"screenDupRect: "<<screenDupRect;
int n = objKyDBus->getTaskBarPos("position"); int n = objKyDBus->getTaskBarPos("position");
int m = objKyDBus->getTaskBarHeight("height"); int m = objKyDBus->getTaskBarHeight("height");
int d = 2; //窗口边沿到任务栏距离 int d = 2; //窗口边沿到任务栏距离
@ -751,7 +704,7 @@ void MainWindow::showTrayIconMenu()
int n = objKyDBus->getTaskBarPos("position"); int n = objKyDBus->getTaskBarPos("position");
int m = objKyDBus->getTaskBarHeight("height"); int m = objKyDBus->getTaskBarHeight("height");
int d = 4; //窗口边沿到任务栏距离 int d = 0; //窗口边沿到任务栏距离
int s = 80; //窗口边沿到屏幕边沿距离 int s = 80; //窗口边沿到屏幕边沿距离
if (screenGeometry.width() == availableGeometry.width() && screenGeometry.height() == availableGeometry.height()) { if (screenGeometry.width() == availableGeometry.width() && screenGeometry.height() == availableGeometry.height()) {
@ -795,61 +748,6 @@ void MainWindow::on_showWindowAction()
this->showNormal(); this->showNormal();
} }
void MainWindow::init_widget_action(QWidget *wid, QString iconstr, QString textstr)
{
QString style="QWidget{background:transparent;border:0px;border-radius: 4px;}\
QWidget:hover{background-color:#34bed8ef;}\
QWidget:pressed{background-color:#3abed8ef;}";
QHBoxLayout* layout=new QHBoxLayout(wid);
wid->setLayout(layout);
wid->setFixedSize(248, 36);
wid->setStyleSheet(style);
wid->setFocusPolicy(Qt::NoFocus);
if(!iconstr.isEmpty()) {
QLabel* labelicon=new QLabel(wid);
labelicon->setFixedSize(16, 16);
labelicon->move(10, 12);
QPixmap *pixmap = new QPixmap(":/res/x/setup.png");
pixmap->scaled(labelicon->size(), Qt::KeepAspectRatio);
labelicon->setScaledContents(true);
labelicon->setPixmap(*pixmap);
// QLabel* labelicon=new QLabel(wid);
// QSvgRenderer* svg=new QSvgRenderer(wid); //#include <QSvgRenderer>
// svg->load(iconstr);
// QPixmap* pixmap=new QPixmap(22, 22);
// pixmap->fill(Qt::transparent);
// QPainter p(pixmap);
// svg->render(&p);
// labelicon->setPixmap(*pixmap);
// labelicon->setFixedSize(pixmap->size());
// labelicon->move(10, 14);
// labelicon->setAlignment(Qt::AlignCenter);
// labelicon->setStyleSheet("QLabel{background:transparent;border:0px;}");
// labelicon->setStyleSheet("QLabel{background-image:url(:/res/x/setup.png);}");
// layout->addWidget(labelicon);
}
QLabel* labeltext=new QLabel(wid);
labeltext->setStyleSheet("background:transparent;border:0px;color:rgba(255,255,255,0.91);font-size:14px;");
QByteArray textbyte=textstr.toLocal8Bit();
char* text=textbyte.data();
labeltext->setText(tr(text));
labeltext->adjustSize();
layout->addWidget(labeltext);
iconstr = ""; //用QSvgRenderer的话这句要注释掉
if(!iconstr.isEmpty()) {
layout->setContentsMargins(10,0,wid->width()-16-labeltext->width()-20,0);
layout->setSpacing(5);
}
else {
layout->setContentsMargins(36,0,0,0);
}
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
//加载动画,获取当前连接的网络和状态并设置图标 //加载动画,获取当前连接的网络和状态并设置图标
@ -1211,7 +1109,6 @@ void MainWindow::onBtnWifiClicked(int flag)
} }
QString txt(tr("please insert the wireless network adapter")); QString txt(tr("please insert the wireless network adapter"));
//m_notify->execNotifySend(txt); //显示本应用自带的桌面通知
objKyDBus->showDesktopNotify(txt); objKyDBus->showDesktopNotify(txt);
//QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
//int status = system(cmd.toUtf8().data()); //int status = system(cmd.toUtf8().data());
@ -1267,62 +1164,8 @@ void MainWindow::onBtnNetListClicked(int flag)
this->startLoading(); this->startLoading();
this->ksnm->execGetLanList(); this->ksnm->execGetLanList();
} else { } else {
// const int BUF_SIZE = 1024;
// char buf[BUF_SIZE];
// FILE * p_file = NULL;
// p_file = popen("nmcli connection show -active", "r");
// if (!p_file) {
// syslog(LOG_ERR, "Error occurred when popen cmd 'nmcli connection show'");
// qDebug()<<"Error occurred when popen cmd 'nmcli connection show";
// }
// while (fgets(buf, BUF_SIZE, p_file) != NULL) {
// QString line(buf);
// if(line.indexOf("ethernet") != -1){
// QString txt(tr("Abnormal connection exist, program will delete it"));//仍然有连接异常的有线网络,断开异常连接的网络
// //m_notify->execNotifySend(txt);//显示本应用自带的桌面通知
// //objKyDBus->showDesktopNotify(txt);
// //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800";
// //int status = system(cmd.toUtf8().data());
// //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'onBtnNetListClicked' failed");}
// is_stop_check_net_state = 1;
// this->startLoading();
// deleteLanTimer->start(1000);
// pclose(p_file);
// return;
// }
// }
// pclose(p_file);
this->startLoading(); this->startLoading();
this->ksnm->execGetLanList(); this->ksnm->execGetLanList();
// delete topLanListWidget; // 清空top列表
// createTopLanUI(); //创建顶部有线网item
// lbTopLanList->hide();
// btnCreateNet->hide();
// // 清空lan列表
// lanListWidget = new QWidget(scrollAreal);
// lanListWidget->resize(W_LIST_WIDGET, H_NORMAL_ITEM + H_LAN_ITEM_EXTEND);
// scrollAreal->setWidget(lanListWidget);
// scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA);
// // 当前连接的lan
// OneLancForm *ccf = new OneLancForm(topLanListWidget, this, confForm, ksnm);
// ccf->setName(tr("Not connected"));//"当前未连接任何 以太网"
// ccf->setIcon(false);
// ccf->setConnedString(1, tr("Disconnected"));//"未连接"
// ccf->setAct(true);
// ccf->move(L_VERTICAL_LINE_TO_ITEM, 0);
// ccf->setTopItem(false);
// ccf->show();
// this->lanListWidget->show();
// this->wifiListWidget->hide();
} }
this->scrollAreal->show(); this->scrollAreal->show();
@ -1790,7 +1633,8 @@ void MainWindow::updateWifiListDone(QStringList slist)
OneConnForm *ocf = wifiList.at(pos); OneConnForm *ocf = wifiList.at(pos);
if (ocf->getName() == lastWname) { if (ocf->getName() == lastWname) {
if (ocf->isActive == true){break; if (ocf->isActive == true){break;
} else { delete ocf; } else {
delete ocf;
//删除元素下面的的所有元素上移 //删除元素下面的的所有元素上移
for (int after_pos = pos+1; after_pos < wifiList.size(); after_pos ++) { for (int after_pos = pos+1; after_pos < wifiList.size(); after_pos ++) {
OneConnForm *after_ocf = wifiList.at(after_pos); OneConnForm *after_ocf = wifiList.at(after_pos);
@ -2230,7 +2074,6 @@ void MainWindow::activeLanDisconn()
syslog(LOG_DEBUG, "Wired net is disconnected"); syslog(LOG_DEBUG, "Wired net is disconnected");
QString txt(tr("Wired net is disconnected")); QString txt(tr("Wired net is disconnected"));
//m_notify->execNotifySend(txt);
objKyDBus->showDesktopNotify(txt); objKyDBus->showDesktopNotify(txt);
//QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800"; //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800";
//int status1 = system(cmd.toUtf8().data()); //int status1 = system(cmd.toUtf8().data());
@ -2259,7 +2102,6 @@ void MainWindow::activeStartLoading()
syslog(LOG_DEBUG, "Wi-Fi is disconnected"); syslog(LOG_DEBUG, "Wi-Fi is disconnected");
QString txt(tr("Wi-Fi is disconnected")); QString txt(tr("Wi-Fi is disconnected"));
//m_notify->execNotifySend(txt);
objKyDBus->showDesktopNotify(txt); objKyDBus->showDesktopNotify(txt);
//QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800"; //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800";
//int status1 = system(cmd.toUtf8().data()); //int status1 = system(cmd.toUtf8().data());
@ -2560,21 +2402,15 @@ void MainWindow::connLanDone(int connFlag)
// Lan连接结果0点击连接成功 1失败 3开机启动网络工具时已经连接 // Lan连接结果0点击连接成功 1失败 3开机启动网络工具时已经连接
if (connFlag == 0) { if (connFlag == 0) {
syslog(LOG_DEBUG, "Wired net already connected by clicking button"); syslog(LOG_DEBUG, "Wired net already connected by clicking button");
//syslog(LOG_DEBUG, "Wired net already connected by clicking button, will check if Lan disconnected again circularly");
//qDebug()<<"连接状态:有线网络已经点击连接,即将重新检测 Lan 是否断开";
this->is_wired_line_ready = 1; this->is_wired_line_ready = 1;
this->is_by_click_connect = 1; this->is_by_click_connect = 1;
this->ksnm->execGetLanList(); this->ksnm->execGetLanList();
QString txt(tr("Conn Ethernet Success")); QString txt(tr("Conn Ethernet Success"));
//m_notify->execNotifySend(txt);
objKyDBus->showDesktopNotify(txt); objKyDBus->showDesktopNotify(txt);
//QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
//int status = system(cmd.toUtf8().data()); //int status = system(cmd.toUtf8().data());
//if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connLanDone' failed");} //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connLanDone' failed");}
//changeTimerState();
//checkIfLanConnect->start(8000);
} }
if (connFlag == 1) { if (connFlag == 1) {
@ -2583,7 +2419,6 @@ void MainWindow::connLanDone(int connFlag)
is_stop_check_net_state = 0; is_stop_check_net_state = 0;
QString txt(tr("Conn Ethernet Fail")); QString txt(tr("Conn Ethernet Fail"));
//m_notify->execNotifySend(txt);
objKyDBus->showDesktopNotify(txt); objKyDBus->showDesktopNotify(txt);
//QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
//int status = system(cmd.toUtf8().data()); //int status = system(cmd.toUtf8().data());
@ -2592,183 +2427,34 @@ void MainWindow::connLanDone(int connFlag)
if (connFlag == 3) { if (connFlag == 3) {
syslog(LOG_DEBUG, "Launch kylin-nm, Lan already connected"); syslog(LOG_DEBUG, "Launch kylin-nm, Lan already connected");
//syslog(LOG_DEBUG, "Launch kylin-nm, Lan already connected, will check if Lan disconnected circularly");
//qDebug()<<"连接状态启动kylin-nm,Lan已经开启即将循环检测是否断开";
this->is_wired_line_ready = 1; this->is_wired_line_ready = 1;
//changeTimerState();
//checkIfLanConnect->start(8000);
} }
this->stopLoading(); this->stopLoading();
} }
void MainWindow::on_isLanConnect()
{
BackThread *loop_bt = new BackThread();
IFace *loop_iface = loop_bt->execGetIface();
if (is_stop_check_net_state == 0){
if (loop_iface->lstate == 1){
syslog(LOG_DEBUG, "Wired net is disconnected");
qDebug()<<"连接状态:有线网络连接已经断开";
if(this->is_btnNetList_clicked == 1) {
this->ksnm->execGetLanList();
}
if(this->is_btnWifiList_clicked== 1) {
this->ksnm->execGetWifiList();
}
this->is_by_click_connect = 0;
checkIfLanConnect->stop();
if (loop_iface->wstate != 0){
syslog(LOG_DEBUG, "Will check if LAN or Wi-Fi connected again circularly");
qDebug()<<"连接状态:即将循环检测是否重新连接 Lan或Wifi";
//changeTimerState();
//checkIfNetworkOn->start(8000);
}
} else if (loop_iface->wstate != 2) {
count_loop = 1;
if (count_loop==1 && this->is_btnWifiList_clicked == 1){
if (this->isVisible() ){
is_update_wifi_list = 1;
this->ksnm->execGetWifiList(); //更新wifi列表
}
}
if (count_loop >= 2){ count_loop = 1;}
}
}
delete loop_iface;
delete loop_bt;
}
void MainWindow::on_isNetOn()
{
BackThread *loop_bt = new BackThread();
IFace *loop_iface = loop_bt->execGetIface();
if (is_stop_check_net_state == 0){
if (loop_iface->lstate == 0 && this->is_by_click_connect == 0 && this->is_wired_line_ready == 1){
syslog(LOG_DEBUG, "Lan already connected again, will check if Wi-Fi disconnected circularly");
qDebug()<<"连接状态:有线网络已经重新连接,即将循环检测 Lan 是否断开";
if(this->is_btnNetList_clicked == 1) {
this->ksnm->execGetLanList();
}
if(this->is_btnWifiList_clicked== 1) {
this->ksnm->execGetWifiList();
}
checkIfNetworkOn->stop();
//changeTimerState();
//checkIfLanConnect->start(8000);
} else if (loop_iface->lstate == 0 && this->is_by_click_connect == 1){
qDebug()<<"连接状态:有线网络已经点击连接,即将重新循环检测 Lan 是否断开";
checkIfNetworkOn->stop();
} else if (loop_iface->wstate == 0 && this->is_by_click_connect == 0){
syslog(LOG_DEBUG, "Wi-Fi already connected again, will check if Wi-Fi disconnected circularly");
qDebug()<<"连接状态Wifi网络已经重新连接即将循环检测 Wifi 是否断开";
if(this->is_btnNetList_clicked == 1) {
this->ksnm->execGetLanList();
}
if(this->is_btnWifiList_clicked== 1) {
this->ksnm->execGetWifiList();
}
checkIfNetworkOn->stop();
//changeTimerState();
//checkIfWifiConnect->start(8000);
} else if (loop_iface->wstate == 0 && this->is_by_click_connect == 1){
qDebug()<<"连接状态Wifi网络已经点击连接即将重新循环检测 Wifi 是否断开";
checkIfNetworkOn->stop();
} else if (loop_iface->wstate != 2) {
count_loop = 1;
if (count_loop==1 && this->is_btnWifiList_clicked == 1){
if (this->isVisible() ){
is_update_wifi_list = 1;
this->ksnm->execGetWifiList(); //更新wifi列表
}
}
if (count_loop >= 2){ count_loop = 1;}
}
}
delete loop_iface;
delete loop_bt;
}
void MainWindow::connWifiDone(int connFlag) void MainWindow::connWifiDone(int connFlag)
{ {
// Wifi连接结果0点击连接成功 1失败 2没有配置文件 3开机启动网络工具时已经连接 // Wifi连接结果0点击连接成功 1失败 2没有配置文件 3开机启动网络工具时已经连接
if (connFlag == 0) { if (connFlag == 0) {
syslog(LOG_DEBUG, "Wi-Fi already connected by clicking button"); syslog(LOG_DEBUG, "Wi-Fi already connected by clicking button");
//syslog(LOG_DEBUG, "Wi-Fi already connected by clicking button, will check if Wi-Fi disconnected again circularly");
//qDebug()<<"连接状态Wifi网络已经点击连接即将重新循环检测 Wifi 是否断开";
this->is_by_click_connect = 1; this->is_by_click_connect = 1;
this->ksnm->execGetWifiList(); this->ksnm->execGetWifiList();
QString txt(tr("Conn Wifi Success")); QString txt(tr("Conn Wifi Success"));
//m_notify->execNotifySend(txt);
objKyDBus->showDesktopNotify(txt); objKyDBus->showDesktopNotify(txt);
//QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
//int status = system(cmd.toUtf8().data()); //int status = system(cmd.toUtf8().data());
//if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connWifiDone' failed");} //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connWifiDone' failed");}
//changeTimerState();
//checkIfWifiConnect->start(8000);
} else if (connFlag == 1) { } else if (connFlag == 1) {
is_stop_check_net_state = 0; is_stop_check_net_state = 0;
QString txt(tr("Confirm your Wi-Fi password or usable of wireless card")); QString txt(tr("Confirm your Wi-Fi password or usable of wireless card"));
//m_notify->execNotifySend(txt);
objKyDBus->showDesktopNotify(txt); objKyDBus->showDesktopNotify(txt);
//QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800"; //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800";
//int status1 = system(cmd.toUtf8().data()); //int status1 = system(cmd.toUtf8().data());
//if (status1 != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'execConnWifiPWD' failed");} //if (status1 != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'execConnWifiPWD' failed");}
} else if (connFlag == 3) { } else if (connFlag == 3) {
syslog(LOG_DEBUG, "Launch kylin-nm, Wi-Fi already connected"); syslog(LOG_DEBUG, "Launch kylin-nm, Wi-Fi already connected");
//syslog(LOG_DEBUG, "Launch kylin-nm, Wi-Fi already connected, will check if Wi-Fi disconnected circularly");
//qDebug()<<"连接状态启动kylin-nm, Wifi已经连接即将循环检测是否断开";
//changeTimerState();
//checkIfWifiConnect->start(8000);
} }
} }
void MainWindow::on_isWifiConnect()
{
BackThread *loop_bt = new BackThread();
IFace *loop_iface = loop_bt->execGetIface();
if (is_stop_check_net_state == 0){
if (loop_iface->wstate == 1){
syslog(LOG_DEBUG, "Wi-Fi is disconnected");
qDebug()<<"连接状态Wifi 网络连接已经断开";
if(this->is_btnNetList_clicked == 1) {
this->ksnm->execGetLanList();
}
if(this->is_btnWifiList_clicked== 1) {
this->ksnm->execGetWifiList();
}
this->is_by_click_connect = 0;
checkIfWifiConnect->stop();
if (loop_iface->lstate != 0){
syslog(LOG_DEBUG, "Will check if LAN or Wi-Fi connected again circularly");
qDebug()<<"连接状态:即将循环检测是否重新开启 Lan或Wifi";
//changeTimerState();
//checkIfNetworkOn->start(8000);
}
} else if (loop_iface->wstate != 2){
count_loop = 1;
if (count_loop==1 && this->is_btnWifiList_clicked == 1){
if (this->isVisible() ){
is_update_wifi_list = 1;
this->ksnm->execGetWifiList(); //更新wifi列表
}
}
if (count_loop >= 2){ count_loop = 1;}
}
}
delete loop_iface;
delete loop_bt;
}

View File

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

View File

@ -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();
}

View File

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

View File

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

View File

@ -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,7 +197,8 @@ 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();
@ -218,7 +219,8 @@ 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();
@ -263,7 +265,8 @@ void OneConnForm::setTopItem(bool isSelected){
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);
@ -314,7 +317,8 @@ 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();
@ -332,7 +336,8 @@ void OneConnForm::setHideItem(bool isHideItem, bool isShowHideBtn){
} }
} }
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();
@ -342,7 +347,8 @@ void OneConnForm::setConnedString(bool showLable, QString str, QString str1){
} }
} }
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;\">&nbsp; " + txt + ": " + rate + " &nbsp;</span>"); this->setToolTip("<span style=\"font-size:14px;border:none;background-color:#3593b5;color:white;\">&nbsp; " + txt + ": " + rate + " &nbsp;</span>");
this->setToolTip(txt + ":" + rate); this->setToolTip(txt + ":" + rate);
@ -372,7 +379,8 @@ void OneConnForm::setLine(bool isShow)
} }
} }
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;
@ -441,7 +449,8 @@ void OneConnForm::slotConnWifi()
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());
@ -666,7 +675,8 @@ 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) {
@ -698,7 +708,6 @@ void OneConnForm::slotConnWifiResult(int connFlag){
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";
@ -718,7 +727,8 @@ void OneConnForm::slotConnWifiResult(int connFlag){
//} //}
} }
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');}");
@ -735,7 +745,8 @@ void OneConnForm::waitAnimStep(){
} }
} }
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);}");
@ -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();

View File

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

View File

@ -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);//避免重名情况
} }
@ -143,7 +144,8 @@ 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();
@ -214,13 +216,15 @@ 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);
@ -250,7 +254,8 @@ 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 {
@ -267,7 +272,8 @@ void OneLancForm::setLine(bool isShow)
} }
} }
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());
@ -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');}");
@ -385,7 +392,8 @@ void OneLancForm::waitAnimStep(){
} }
} }
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 {
@ -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();

View File

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