Merge branch '0930-new' into 'dbus-interface'

Delete useless files.

See merge request kylin-desktop/kylin-nm!298
This commit is contained in:
ren peijia 2021-10-11 02:11:41 +00:00
commit 0e19d97a88
65 changed files with 538 additions and 24765 deletions

View File

@ -3,11 +3,7 @@ include(hotspot/hotspot.pri)
include(dbus-interface/dbus-interface.pri)
HEADERS += \
$$PWD/backthread.h \
$$PWD/dbusadaptor.h \
$$PWD/ksimplenm.h \
$$PWD/kylin-dbus-interface.h \
$$PWD/kylin-network-interface.h \
$$PWD/kylinarping.h \
$$PWD/kylinipv4arping.h \
$$PWD/kylinipv6arping.h \
@ -16,11 +12,7 @@ HEADERS += \
$$PWD/wifi-auth-thread.h
SOURCES += \
$$PWD/backthread.cpp \
$$PWD/dbusadaptor.cpp \
$$PWD/ksimplenm.cpp \
$$PWD/kylin-dbus-interface.cpp \
$$PWD/kylin-network-interface.c \
$$PWD/kylinipv4arping.cpp \
$$PWD/kylinipv6arping.cpp \
$$PWD/sysdbusregister.cpp \

View File

@ -1,673 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "backthread.h"
#include "utils.h"
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <QFile>
#include <QRegExp>
#include <QDir>
BackThread::BackThread(QObject *parent) : QObject(parent)
{
cmdProcessWifi = new QProcess(this);
connect(cmdProcessWifi , SIGNAL(readyReadStandardOutput()) , this , SLOT(onReadOutputWifi()));
connect(cmdProcessWifi , SIGNAL(readyReadStandardError()) , this , SLOT(onReadErrorWifi()));
cmdProcessLan = new QProcess(this);
connect(cmdProcessLan , SIGNAL(readyReadStandardOutput()) , this , SLOT(onReadOutputLan()));
connect(cmdProcessLan , SIGNAL(readyReadStandardError()) , this , SLOT(onReadErrorLan()));
}
BackThread::~BackThread()
{
cmdProcessWifi->close();
cmdProcessLan->close();
}
//get the connection state of wired and wireles network
IFace* BackThread::execGetIface()
{
IFace *iface = new IFace();
QString tmpPath = "/tmp/kylin-nm-iface-" + QDir::home().dirName();
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f TYPE,DEVICE,STATE device > " + tmpPath;
Utils::m_system(cmd.toUtf8().data());
QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug()<<"Can't open the file ~/.config/kylin-nm-iface!";
}
QString txt = file.readAll();
QStringList txtList = txt.split("\n");
file.close();
iface->lstate = 2;
iface->wstate = 2;
for (int i = 1; i < txtList.size(); i ++) {
QString line = txtList.at(i);
if (line != "") {
int index1 = line.indexOf(" ");
QString type = line.left(index1);
QString lastStr = line.mid(index1).trimmed();
int index2 = lastStr.indexOf(" ");
QString iname = lastStr.left(index2);
QString istateStr = lastStr.mid(index2).trimmed();
//只要存在一个有线设备已连接,就不再扫描其他有线设备状态,避免有线被误断开
if (type == "ethernet" && iface->lstate != 0) {
// if type is wired network
iface->lname = iname;
if (istateStr == "unmanaged") {
iface->lstate = 2; //switch of wired device is off
} else if (istateStr == "unavailable") {
iface->lstate = 4;
} else if (istateStr == "disconnected") {
iface->lstate = 1; //wired network is disconnected
} else if (istateStr == "connected" || istateStr == "connecting (getting IP configuration)") {
iface->lstate = 0; //wired network is connected
} else {
//连接中,正在配置
iface->lstate = 3;
}
}
if (type == "wifi" && iface->wname.isEmpty()) { //仅统计第一个无线网卡,后续无线网卡状态必然等于或差与第一个获取到的无线网卡
// if type is wireless network
iface->wname = iname;
if (istateStr == "unmanaged" || istateStr == "unavailable") {
iface->wstate = 2; //switch of wireless device is off
} else if (istateStr == "disconnected") {
iface->wstate = 1; //wireless network is disconnected
} else if (istateStr == "connected") {
iface->wstate = 0; //wireless network is connected
} else {
//连接中,正在配置
iface->wstate = 3;
}
}
}
}
return iface;
}
void BackThread::saveSwitchButtonState(const QString &key, const QVariant &value)
{
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
m_settings->setValue(key, value);
m_settings->sync();
delete m_settings;
return;
}
QVariant BackThread::getSwitchState(const QString &key)
{
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
QVariant value = m_settings->value(key);
delete m_settings;
if (!value.isValid())
return QVariant();
return value;
}
//turn on the switch of network
void BackThread::execEnNet()
{
char *chr = "nmcli networking on";
Utils::m_system(chr);
while (1) {
if (execGetIface()->lstate != 2) {
sleep(3);
emit enNetDone();
emit btFinish();
break;
}
sleep(1);
}
}
//turn off the switch of wireless network first, then turn off the switch of network
void BackThread::execDisNet()
{
if (execGetIface()->wstate != 2) {
char *chr = "nmcli radio wifi off";
Utils::m_system(chr);
while (1) {
if (execGetIface()->wstate == 2) {
emit disWifiDone();
emit btFinish();
break;
}
sleep(1);
}
}
char *chr1 = "nmcli networking off";
Utils::m_system(chr1);
while (1) {
if (execGetIface()->lstate == 2) {
emit disNetDone();
emit btFinish();
break;
}
sleep(1);
}
}
//turn on the switch of wireless network
void BackThread::execEnWifi()
{
char *chr1 = "nmcli radio wifi on";
Utils::m_system(chr1);
emit btFinish();
KylinDBus objBackThreadDBus;
while (1) {
if (execGetIface()->wstate != 2) {
while (1) {
if (objBackThreadDBus.getAccessPointsNumber() > 0) {
// objBackThreadDBus.getAccessPointsNumber()>0 standard can get wireless accesspoints now
emit enWifiDone();
emit btFinish();
break;
}
sleep(2);
}
break;
}
sleep(1);
}
}
void BackThread::rfKillexecEnWifi()
{
char *chr1 = "nmcli radio wifi on";
Utils::m_system(chr1);
if (execGetIface()->wstate != 2) {
emit enWifiDoneByRfkill();
emit btFinishByRfkill();
} else {
usleep(500*1000);
emit enWifiDoneByRfkill();
emit btFinishByRfkill();
}
}
//turn off the switch of wireless network
void BackThread::execDisWifi()
{
char *chr = "nmcli radio wifi off";
Utils::m_system(chr);
while (1) {
if (execGetIface()->wstate == 2) {
emit disWifiDone();
emit btFinish();
break;
}
sleep(1);
}
}
void BackThread::rfkillExecDisWifi()
{
char *chr = "nmcli radio wifi off";
Utils::m_system(chr);
while (1) {
if (execGetIface()->wstate == 2) {
emit disWifiDoneByRfkill();
emit btFinishByRfkill();
break;
}
sleep(1);
}
}
//to connect wired network
void BackThread::execConnLan(QString connName, QString ifname, QString connectType)
{
currConnLanUuid = connName;
currConnLanType = connectType;
QString mycmd; //连接命令
KylinDBus objBackThreadDBus;
bool isWiredCableAlready = objBackThreadDBus.getWiredCableStateByIfname(ifname);
if (connectType == "bluetooth" || connectType == "vpn"|| ifname == "") {
isWiredCableAlready = true; //对于蓝牙类型的网络不需要接入网线就可以连接
mycmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'";
} else {
mycmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname '" + ifname + "'";
}
qDebug()<<"Trying to connect wifi. ssid="<<connName;
if (isWiredCableAlready) {
QStringList options;
options << "-c" << mycmd;
cmdProcessLan->start("/bin/bash",options);
cmdProcessLan->waitForStarted();
cmdProcessLan->waitForFinished();
} else {
qDebug()<<"connect wired network failed for without wired cable plug in.";
emit connDone(1);
}
emit btFinish();
}
void BackThread::onReadOutputLan()
{
QByteArray cmdout = cmdProcessLan->readAllStandardOutput();
QString strResult = QString::fromLocal8Bit(cmdout);
qDebug()<<"on_readoutput_lan: "<< strResult;
dellConnectLanResult(strResult);
}
void BackThread::onReadErrorLan()
{
QByteArray cmdout = cmdProcessLan->readAllStandardError();
QString strResult = QString::fromLocal8Bit(cmdout);
qDebug()<<"on_readerror_lan: "<< strResult;
dellConnectLanResult(strResult);
}
void BackThread::dellConnectLanResult(QString info)
{
if (info.indexOf("successfully") != -1) {
qDebug()<<"debug: in function execConnLan, wired net state is: "<<QString::number(execGetIface()->lstate);
if (currConnLanType == "bluetooth") {
emit connDone(2);
} else {
emit connDone(0);
}
} else {
QString cmd = "nmcli connection down '" + currConnLanUuid + "'";
Utils::m_system(cmd.toUtf8().data());
if (info.indexOf("IP configuration could not be reserved") != -1) {
emit connDone(4);
} else if(info.indexOf("MACs") != -1 || info.indexOf("Mac") != -1 || info.indexOf("MAC") != -1) {
emit connDone(5);
} else if(info.indexOf("Killed") != -1 || info.indexOf("killed") != -1) {
emit connDone(6);
} else if(info.indexOf("The Bluetooth connection failed") != -1) {
emit connDone(7);
} else if(info.indexOf("Carrier/link changed") != -1) {
emit connDone(8);
} else {
if (currConnLanType == "vpn"){
emit connDone(10);
}
else{
emit connDone(9);
}
}
}
}
//to connected wireless network need a password
void BackThread::execConnWifiPWD(QString connName, QString password, QString connType, QString security, QString ifname)
{
//disConnLanOrWifi("wifi");
if (!connType.isEmpty()) {
QString strConntype = "nmcli connection modify '" + connName + "' wifi-sec.psk-flags 0";
Utils::m_system(strConntype.toUtf8().data());
}
QString tmpPath = "/tmp/kylin-nm-btoutput-" + QDir::home().dirName();
if (security.contains("WPA3")) {
QString create_cmd = QString("nmcli connection add con-name %1 type wifi 802-11-wireless-security.key-mgmt sae ssid %2 802-11-wireless-security.psk %3").arg(connName).arg(connName).arg(password);
Utils::m_system(create_cmd.toUtf8().data());
QString connect_cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname " + ifname +" > " + tmpPath;
Utils::m_system(connect_cmdStr.toUtf8().data());
} else {
QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli device wifi connect '" + connName + "' password '" + password + "' > " + tmpPath;
Utils::m_system(cmdStr.toUtf8().data());
}
QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput !"<<endl;
}
QString line = file.readLine();
file.close();
qDebug()<<"connect_wifi_result: "<< line;
if (line.indexOf("successfully") != -1) {
emit connDone(0);
qDebug()<<"debug: in function execConnWifiPWD, wireless net state is: "<<QString::number(execGetIface()->wstate);
} else if(line.indexOf("Secrets were required") != -1){
//emit connDone(4);//发出信号4是之前添加每次连接输入密码的功能时需要的
emit connDone(1);
} else {
emit connDone(1);
}
emit btFinish();
}
void BackThread::execConnHiddenWifiWPA(QString wifiName, QString wifiPassword)
{
int x(1), n(0);
do {
n += 1;
if (n >= 4) {
qDebug()<<"connection attempt of hidden wifi"<<wifiName<<" failed for 3 times, no more attempt";
x = 0;
emit connDone(1);
emit btFinish();
return ;
}
QString tmpPath = "/tmp/kylin-nm-btoutput-" + QDir::home().dirName();
QString cmd = "nmcli device wifi connect '" + wifiName + "' password '" + wifiPassword + "' hidden yes > " + tmpPath + " 2>&1";
int status = Utils::m_system(cmd.toUtf8().data());
qDebug() << Q_FUNC_INFO << cmd << tmpPath << "res=" << status;
QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug()<<"Can't open the file!"<<endl;
}
QString text = file.readAll();
file.close();
if(text.indexOf("Scanning not allowed") != -1
|| text.isEmpty()
|| text.indexOf("No network with SSID") != -1){
x = 1;
sleep(10);//nm扫描冷却为10s
} else {
emit connDone(6);
x = 0;
}
} while (x == 1);
emit btFinish();
}
void BackThread::execConnRememberedHiddenWifi(QString wifiName)
{
QProcess shellProcess;
shellProcess.start("nmcli -f ssid device wifi");
shellProcess.waitForFinished(3000); // 等待最多3s
if (shellProcess.exitCode() == 0) {
QString shellOutput = shellProcess.readAllStandardOutput();
QStringList wlist = shellOutput.split("\n");
bool is_hidden = true;
foreach (QString wifi, wlist) {
if (wifi.trimmed() == wifiName) {
is_hidden = false;
}
}
if (! is_hidden) {
QString cmd = "nmcli connection up '" + wifiName + "'";
qDebug()<<"Trying to connect wifi. ssid="<<wifiName;
int res = Utils::m_system(cmd.toUtf8().data());
if (res == 0) {
emit connDone(6);
} else {
emit connDone(res);
}
} else {
//已保存的wifi没有在wifi列表找到隐藏wifi保存后也会出现在wifi列表则当前区域无法连接此wifi
qDebug() << "Choosen wifi can not be sacnned, wifiName=" << wifiName;
emit connDone(5);
}
}
emit btFinish();
}
void BackThread::execConnWifiPsk(QString cmd)
{
int res = Utils::m_system(cmd.toUtf8().data());
emit connDone(res);
}
//to connected wireless network driectly do not need a password
void BackThread::execConnWifi(QString connName, QString connIfName)
{
qDebug() << "Will to connect wifi " << connName << " with wifi card named " << connIfName;
QString cmdStr;
KylinDBus objBackThreadDBus;
QString wifiUuid = objBackThreadDBus.checkHasWifiConfigFile(connName);
if (!wifiUuid.isEmpty()) {
//有配置文件
cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + wifiUuid + "' ifname '" + connIfName + "'\n";
} else {
//没有配置文件
cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname '" + connIfName + "'\n";
}
qDebug() << "Trying to connect wifi. cmd=" << cmdStr;
QStringList options;
options << "-c" << cmdStr;
cmdProcessWifi->start("/bin/bash",options);
cmdProcessWifi->waitForStarted();
cmdProcessWifi->waitForFinished();
}
void BackThread::execReconnWIfi(QString uuid)
{
QString cmd = "nmcli connection down " + uuid;
Utils::m_system(cmd.toUtf8().data());
cmd = "nmcli connection up " + uuid;
Utils::m_system(cmd.toUtf8().data());
qDebug()<<"Trying to connect wifi. uuid="<<uuid;
}
void BackThread::onReadOutputWifi()
{
QString str = cmdProcessWifi->readAllStandardOutput();
qDebug()<<"on_readoutput_wifi: "<< str;
dellConnectWifiResult(str);
}
void BackThread::onReadErrorWifi()
{
QString str = cmdProcessWifi->readAllStandardError();
qDebug()<<"on_readerror_wifi: "<< str;
dellConnectWifiResult(str);
}
void BackThread::dellConnectWifiResult(QString info)
{
if (info.indexOf("successfully") != -1) {
emit connDone(0);
} else if(info.indexOf("unknown") != -1 || info.indexOf("not exist") != -1) {
//qDebug() << "send this signal if the network we want to connect has not a configuration file";
emit connDone(2);
} else if (info.indexOf("The connection was not a Wi-Fi connection..") != -1) {
emit connDone(2);
} else if(info.indexOf("not given") != -1 || info.indexOf("Secrets were required") != -1) {
//nothing need to do
} else if(info.indexOf("Passwords or encryption keys are required") != -1){
//qDebug() << "password for '802-11-wireless-security.psk' not given in 'passwd-file'";
emit connDone(4);
} else {
//qDebug() << "send this signal if connect net failed";
emit connDone(1);
}
emit btFinish();
}
//get property of connected network
QString BackThread::getConnProp(QString connName)
{
QString tmpPath = "/tmp/kylin-nm-connprop-" + QDir::home().dirName();
QString cmd = "nmcli connection show '" + connName + "' > " + tmpPath;
Utils::m_system(cmd.toUtf8().data());
QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "Can't open the file /tmp/kylin-nm-connprop!";
}
QString txt = file.readAll();
QStringList txtLine = txt.split("\n");
file.close();
QString rtn = "";
foreach (QString line, txtLine) {
if (line.startsWith("ipv4.method:")) {
QString v4method = line.mid(12).trimmed();
rtn += "method:" + v4method + "|";
}
if (line.startsWith("ipv4.addresses:")) {
QString value = line.mid(15).trimmed();
if (value == "--" || value == "") {
rtn += "v4addr:|mask:|";
} else {
QString addr = value.split("/").at(0);
QString mask = value.trimmed().split("/").at(1);
rtn += "v4addr:" + addr + "|";
rtn += "mask:" + mask + "|";
}
}
if (line.startsWith("ipv6.method:")) {
QString value = line.mid(12).trimmed();
if (value == "auto") {
rtn += "v6method:auto|v6addr:|";
} else {
rtn += "v6method:manual|";
}
}
if (line.startsWith("ipv6.addresses:")) {
QString value = line.mid(15).trimmed();
if (value == "--" || value == "") {
rtn += "v6addr:|";
} else {
QString addr = value.split("/").at(0);
rtn += "v6addr:" + addr + "|";
}
}
if (line.startsWith("ipv4.gateway:")) {
QString value = line.mid(13).trimmed();
if (value == "--" || value == "") {
rtn += "gateway:|";
} else {
rtn += "gateway:" + value + "|";
}
}
if (line.startsWith("ipv4.dns:")) {
QString value = line.mid(9).trimmed();
if (value == "--" || value == "") {
rtn += "dns:|";
} else {
rtn += "dns:" + value + "|";
}
}
}
return rtn.left(rtn.length() - 1);
}
//get band width of wired network
QString BackThread::execChkLanWidth(QString ethName)
{
QString tmpPath = "/tmp/kylin-nm-bandwidth-" + QDir::home().dirName();
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';ethtool '" + ethName + "' | grep Speed > " + tmpPath;
int res = Utils::m_system(cmd.toUtf8().data());
qDebug() << "executed cmd=" << cmd << ".res="<<res;
QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "Can't open the file /tmp/kylin-nm-bandwidth!";
}
QString line = file.readLine();
file.close();
QStringList params = line.split(":");
if (params.size() < 2) {
return "";
}
QString rtn = params.at(1);
return rtn.trimmed();
}
//disconnected spare ethernet or wifi
void BackThread::disConnSparedNetSlot(QString type)
{
if (type == "wifi") {
//disConnLanOrWifi("wifi");
} else if(type == "ethernet") {
sleep(1);
disConnLanOrWifi("ethernet");
}
}
//disconnected ethernet or wifi according to network type
void BackThread::disConnLanOrWifi(QString type)
{
QString strSlist;
const int BUF_SIZE = 1024;
char buf[BUF_SIZE];
FILE * p_file = NULL;
p_file = popen("nmcli connection show -active", "r");
if (!p_file) {
qDebug() << "Error occurred when popen cmd 'nmcli connection show";
}
while (fgets(buf, BUF_SIZE, p_file) != NULL) {
QString line(buf);
if (line.indexOf("802-11-wireless") != -1) {
if (type == "wifi") {
type = "802-11-wireless";
}
}
if (line.indexOf("802-3-ethernet") != -1) {
if (type == "ethernet") {
type = "802-3-ethernet";
}
}
if (line.indexOf(type) != -1) {
QStringList subLine = line.split(" ");
if (subLine[1].size() == 1) {
strSlist = subLine[0]+ " " + subLine[1];
} else {
strSlist = subLine[0];
}
kylin_network_set_con_down(strSlist.toUtf8().data());
}
}
emit btFinish();
pclose(p_file);
}

View File

@ -1,105 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef BACKTHREAD_H
#define BACKTHREAD_H
#include "kylin-dbus-interface.h"
#include "kylin-network-interface.h"
#include <QObject>
#include <QDebug>
#include <QDir>
#include <QTimer>
#include <QProcess>
#include <QDBusInterface>
#include <QDBusMessage>
#include <QDBusArgument>
#include <QSettings>
#include "tab-pages/tabpage.h"
//#define CONFIG_FILE_PATH QDir::homePath() + "/.config/ukui/kylin-nm.conf"
#define WIFI_SWITCH_OPENED "wifi_switch_opened"
#define LAN_SWITCH_OPENED "lan_switch_opened"
class IFace{
public:
QString lname;
QString wname;
int lstate; // 0已连接 1未连接 2已关闭
int wstate; // 0已连接 1未连接 2已关闭
};
class BackThread : public QObject
{
Q_OBJECT
public:
explicit BackThread(QObject *parent = nullptr);
~BackThread();
static IFace* execGetIface();
static void saveSwitchButtonState(const QString &key, const QVariant &value);
static QVariant getSwitchState(const QString &key);
QString getConnProp(QString connName);
QString execChkLanWidth(QString ethName);
QProcess *cmdProcessWifi = nullptr;
QProcess *cmdProcessLan;
QString currConnLanUuid;
QString currConnLanType;
public slots:
void execEnNet();
void execDisNet();
void execEnWifi();
void rfKillexecEnWifi();
void execDisWifi();
void rfkillExecDisWifi();
void execConnLan(QString connName, QString ifname, QString connectType);
void execConnWifi(QString connName, QString connIfName);
void execReconnWIfi(QString uuid);
void execConnWifiPWD(QString connName, QString password, QString connType, QString security, QString ifname);
void execConnWifiPsk(QString cmd);
void execConnHiddenWifiWPA(QString connName, QString password);
void execConnRememberedHiddenWifi(QString connName);
void disConnSparedNetSlot(QString type);
void disConnLanOrWifi(QString type);
void onReadOutputWifi();
void onReadErrorWifi();
void dellConnectWifiResult(QString info);
void onReadOutputLan();
void onReadErrorLan();
void dellConnectLanResult(QString info);
signals:
void enNetDone();
void disNetDone();
void enWifiDone();
void enWifiDoneByRfkill();
void disWifiDone();
void disWifiDoneByRfkill();
void connDone(int connFlag);
void btFinish();
void btFinishByRfkill();
};
#endif // BACKTHREAD_H

View File

@ -32,7 +32,7 @@ QT_END_NAMESPACE
* Adaptor class for interface com.kylin.weather
*/
#include "new-mainwindow.h"
#include "mainwindow.h"
class DbusAdaptor: public QDBusAbstractAdaptor
{

View File

@ -1,142 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "ksimplenm.h"
#include <stdio.h>
#include <unistd.h>
#include <QThread>
#define MAX_LEN 2048
#define MAX_PATH 1024
KSimpleNM::KSimpleNM(QObject *parent) : QObject(parent)
{
runProcessLan = new QProcess(this);
connect(runProcessLan, &QProcess::readyRead, this, &KSimpleNM::readProcessLan);
connect(runProcessLan, SIGNAL(finished(int)), this, SLOT(finishedProcessLan(int)));
runProcessWifi = new QProcess(this);
connect(runProcessWifi, &QProcess::readyRead, this, &KSimpleNM::readProcessWifi);
connect(runProcessWifi, SIGNAL(finished(int)), this, SLOT(finishedProcessWifi(int)));
runProcessConn = new QProcess(this);
connect(runProcessConn, &QProcess::readyRead, this, &KSimpleNM::readProcessConn);
connect(runProcessConn, SIGNAL(finished(int)), this, SLOT(finishedProcessConn(int)));
}
KSimpleNM::~KSimpleNM()
{
delete runProcessLan;
delete runProcessWifi;
}
//获取有线网络列表数据
void KSimpleNM::execGetLanList()
{
if (isExecutingGetLanList) {
qDebug()<<"debug: it is running getting lan list when getting lan list";
isUseOldLanSlist = true;
QStringList slistmEmpty;
slistmEmpty.append("Empty");
emit getLanListFinished(slistmEmpty);
return;
}
isExecutingGetLanList = true;
shellOutputLan = "";
QString getCmd = "export LANG='zh_CN.UTF-8';export LANGUAGE='zh_CN:zh';nmcli -f type,uuid,name connection show";
QStringList options;
options << "-c" << getCmd;
runProcessLan->start("/bin/bash",options);
//runProcessLan->start("nmcli -f type,uuid,name connection show");
}
//获取无线网络列表数据
void KSimpleNM::execGetWifiList(const QString& wname, const bool &isHuaweiPc)
{
if (isExecutingGetWifiList) {
qDebug() << "It is running getting wifi list when getting wifi list";
isUseOldWifiSlist = true;
QStringList slistmEmpty;
slistmEmpty.append("Empty");
emit requestRevalueUpdateWifi();
emit getWifiListFinished(slistmEmpty);
return;
}
isExecutingGetWifiList = true;
shellOutputWifi = "";
QString cmd;
//将ssid放置在最后一列以防ssid存在中文或特殊字符导致其后面的列不对齐
if (wname.isEmpty() || wname == "") {
if (isHuaweiPc)
cmd = "nmcli -f in-use,signal,security,freq,bssid,dbus-path,category,ssid device wifi";
else
cmd = "nmcli -f in-use,signal,security,freq,bssid,dbus-path,ssid device wifi";
} else {
if (isHuaweiPc)
cmd = "nmcli -f in-use,signal,security,freq,bssid,dbus-path,category,ssid device wifi list ifname " + wname;
else
cmd = "nmcli -f in-use,signal,security,freq,bssid,dbus-path,ssid device wifi list ifname " + wname;
}
runProcessWifi->start(cmd);
}
//获取保存的网络列表数据
void KSimpleNM::execGetConnList()
{
shellOutputConn = "";
runProcessConn->start("nmcli -f name connection show");
}
//读取获取到的结果
void KSimpleNM::readProcessLan()
{
QString output = runProcessLan->readAll();
shellOutputLan += output;
}
void KSimpleNM::readProcessWifi()
{
QString output = runProcessWifi->readAll();
shellOutputWifi += output;
}
void KSimpleNM::readProcessConn()
{
QString output = runProcessConn->readAll();
shellOutputConn += output;
}
//读取完所有列表数据后发信号将数据发往mainwindow用于显示网络列表
void KSimpleNM::finishedProcessLan(int msg)
{
QStringList slist = shellOutputLan.split("\n");
emit getLanListFinished(slist);
isExecutingGetLanList = false;
}
void KSimpleNM::finishedProcessWifi(int msg)
{
QStringList slist = shellOutputWifi.split("\n");
emit getWifiListFinished(slist);
isExecutingGetWifiList = false;
}
void KSimpleNM::finishedProcessConn(int msg)
{
QStringList slist = shellOutputConn.split("\n");
emit getConnListFinished(slist);
}

View File

@ -1,64 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef KSIMPLENM_H
#define KSIMPLENM_H
#include <QObject>
#include <QProcess>
#include <QDebug>
class KSimpleNM : public QObject
{
Q_OBJECT
public:
explicit KSimpleNM(QObject *parent = nullptr);
~KSimpleNM();
QProcess *runProcessLan;
QProcess *runProcessWifi;
QProcess *runProcessConn;
QString shellOutputLan;
QString shellOutputWifi;
QString shellOutputConn;
bool isExecutingGetLanList = false; //是否正在执行获取有线网列表
bool isExecutingGetWifiList = false; //是否正在执行获取无线网列表
bool isUseOldLanSlist = false; //是否应该要用上一次获取的有线列表
bool isUseOldWifiSlist = false; //是否应该要用上一次获取的有线列表
void execGetLanList();
void execGetWifiList(const QString& wname, const bool& isHuaweiPc = false);
void execGetConnList();
signals:
void getLanListFinished(QStringList slist);
void getWifiListFinished(QStringList slist);
void getConnListFinished(QStringList slist);
void requestRevalueUpdateWifi();
public slots:
void readProcessLan();
void readProcessWifi();
void readProcessConn();
void finishedProcessLan(int msg);
void finishedProcessWifi(int msg);
void finishedProcessConn(int msg);
};
#endif // KSIMPLENM_H

File diff suppressed because it is too large Load Diff

View File

@ -1,162 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef KYLINDBUSINTERFACE_H
#define KYLINDBUSINTERFACE_H
#include <QObject>
#include <QDebug>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusObjectPath>
#include <QDBusReply>
#include <QDBusObjectPath>
#include <QVariant>
#include <QVariantMap>
#include <QGSettings/QGSettings>
#include <QTimer>
#include <QThread>
#define WIFI_CONNECTING 1
#define WIFI_CONNECTED 2
#define WIFI_DISCONNECTED 3
class OldMainWindow;
class Utils;
class KylinDBus : public QObject
{
Q_OBJECT
public:
explicit KylinDBus(OldMainWindow *mw = 0, QObject *parent = nullptr);
~KylinDBus();
void getObjectPath();
int getAccessPointsNumber();
int getWiredNetworkNumber();
QStringList getWifiSsidList();
QString checkHasWifiConfigFile(QString wifiName);
void showDesktopNotify(QString message);
void initConnectionInfo();
QList<QString> getAtiveLanSsidUuidState();
QString getActiveWifiUuid();
QList<QString> getAtiveWifiBSsidUuid(QStringList wifilist);
void reConnectWiredNet(QString netUuid);
bool toConnectWiredNet(QString netUuid, QString netIfName);
void getConnectNetIp(QString netUuid);
void getLanIpChanged();
void onWiredSettingNumChanged();
int getTaskBarPos(QString str);
int getTaskBarHeight(QString str);
void initTaskbarGsetting();
int getTaskbarHeight();
int getTaskbarPos();
void getWifiSwitchState();
bool getSwitchStatus(QString key);
void setWifiSwitchState(bool signal);
void setWifiCardState(bool signal);
void initTransparentState();
double getTransparentData();
int checkWifiConnectivity();
bool checkNetworkConnectivity();
int getActiveWifiSignal();
QString getWifiSsid(QString accessPointPath);
void toGetWifiList();
QDBusObjectPath wirelessPath; //无线设备的路径
QList<QDBusObjectPath> multiWirelessPaths; //Wireless Device的对象路径列表
QList<QDBusObjectPath> multiWiredPaths; //Wired Device的对象路径列表
QList<QString> multiWiredCableState;//多有线网卡的情况,判断有线网卡对应网线是否插入
QList<QString> multiWiredMac; //对应有线网卡的Mac地址
QList<QString> multiWiredIfName; //对应有线网的接口
bool isWiredCableOn = false; //是否插入了网线
bool isWirelessCardOn = false; //是否插入了无线网卡
QString dbusLanIpv4 = "";
QString dbusLanIpv6 = "";
QString dbusLanIpv6Method = "";
QString dbusWifiIpv4Method = "";
QString dbusWifiIpv6Method = "";
QString dbusActiveLanIpv4 = "";
QString dbusActiveLanIpv6 = "";
QString dbusActiveWifiIpv4 = "";
QString dbusActiveWifiIpv6 = "";
QString dbusWifiIpv4 = "";
QString dbusWifiIpv6 = "";
QString dbusLanGateway = "";
QString dbusWiFiCardName = "";
QString dbusWifiMac = "";
QString dbusIfName;
QString dbusMacDefault;
int dbusActLanDNS;
public slots:
void onNewConnection(QDBusObjectPath objPath);
void onConnectionRemoved(QDBusObjectPath objPath);
void toCreateNewLan();
bool getWiredCableStateByIfname(QString ifname);
QString getConnLanNameByIfname(QString ifname);
void onPropertiesChanged(QVariantMap qvm);
void onAutoConnect();
void onLanPropertyChanged(QVariantMap qvm);
void onLanIpPropertiesChanged();
void onWifiIpPropertiesChanged();
void getPhysicalCarrierState(int n);
void getLanHwAddressState();
void getWiredCardName();
void getWirelessCardName();
void getLanIpDNS(QString uuidName, bool isActNet);
void getWifiIp(QString uuid);
QString getLanMAC(QString ifname);
void getWifiMac(QString netName);
void slot_timeout();
void requestScanWifi();
private:
OldMainWindow *mw;
Utils *mUtils;
QThread *mUtilsThread;
int a = 0;
bool isRunningFunction = false;
QTimer *time = nullptr;
QList<QDBusObjectPath> oldPaths; //已连接网络的对象路径列表
QList<QDBusObjectPath> oldSettingPaths; //保存之前的路径
QStringList oldPathInfo; //某个已连接网络对象路径对应的网络类型(ethernet or wifi)
bool oldWifiSwitchState; //上一次获取到的wifi开关状态
QGSettings *m_tastbar_gsettings = nullptr;
QGSettings *m_gsettings = nullptr;
QGSettings *m_transparency_gsettings = nullptr;
QStringList m_lanPathList;//有线网dbuspath列表
signals:
void updateWiredList(int n);
void updateWirelessList();
void requestSendDesktopNotify(QString message);
void newConnAdded(int type);
void toGetWifiListFinished(QStringList slist);
};
#endif // KYLINDBUSINTERFACE_H

File diff suppressed because it is too large Load Diff

View File

@ -1,270 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef __KYLINNETWORKINTERFACE_H__
#define __KYLINNETWORKINTERFACE_H__
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <string.h>
#ifdef __cplusplus
extern "C"{
#endif
typedef struct
{
char *if_name;
}ifname;
typedef struct
{
char *ssid;//wifi名称
int signal;//信号强度
char *safety;//安全性
}wifilist;//存放wifi信息的结构体
typedef struct
{
char *con_name;//网络连接名称
char *type;//网络连接类型
}conlist;//存放所有网络连接
typedef struct
{
char *con_name;//活动网络连接名称
char *type;//活动网络连接类型
char *dev;//活动网络所属设备
}activecon;//存放当前活动网络连接
/*
* Get the network interface name.
* return the struct pointer.
*/
ifname *kylin_network_get_ifacename();
/*
* Get the all network connection.
* return the struct pointer.
*/
conlist *kylin_network_get_conlist_info();
/*
* Get the active network connection.
* return the struct pointer.
*/
activecon *kylin_network_get_activecon_info();
/*
* Create a new Ethernet connection.
* @con_name is the connection name.
* @if_name is the interface name.
*/
void kylin_network_create_new_ethernet(char *con_name,char *if_name);
/*
* Create a new Wifi connection.
* @con_name is the connection name.
* @if_name is the interface name.
*/
void kylin_network_create_new_wifi(char *con_name, char *if_name);
/*
* Delete ethernet connection.
* @con_name is the connection name.
*/
void kylin_network_del_ethernet_con(char *con_name);
/*
* Set up dynamic IP allocation.
* @con_name is the connection name.
*/
void kylin_network_set_automethod(char *con_name);
void kylin_network_set_ipv6_automethod(char *con_name);
/*
* Set up manual IP assignment.
* @con_name is the connection name.
* @ip is the ip address(for example,"192.168.68.160/16")
*/
void kylin_network_set_manualmethod(char *con_name,char *ip);
void kylin_network_set_ipv6_manualmethod(char *con_name,char *ip);
/*
* Set up manual all prop.
*/
void kylin_network_set_manualall(char *con_name, char *addr, char *mask, char *gateway, char *dns);
/*
* Sets whether the connection is automatic.
* @con_name is the connection name.
* @autocon is the automatic connection option.
*/
void kylin_network_set_autoconnect(char *con_name,bool autocon);
/*
* Modify the ip address.
* @con_name is the connection name.
* @ip is the ip address(for example,"192.168.68.160/16")
*/
void kylin_network_mod_ip(char *con_name,char *ip);
/*
* Modify the gateway.
* @con_name is the connection name.
* @gw is the gateway address.
*/
void kylin_network_mod_gateway(char *con_name,char *gw);
/*
* Modify the dns address.
* @con_name is the connection name.
* @dns is the dns address.
*/
void kylin_network_mod_dns(char *con_name,char *dns);
/*
* Connect the ethernet.
* @con_name is the connection name.
*/
void kylin_network_set_con_up(char *con_name);
/*
* Disconnect the ethernet.
* @con_name is the connection name.
*/
void kylin_network_set_con_down(char *con_name);
/*
* Connect the wifi.
* @con_name is the wifi name.
* @passwd is the wifi password.
*/
void kylin_network_set_wifi_up(char *con_name,char *passwd);
/*
* Disconnect the wifi.
* @if_name is the network interface name.
*/
void kylin_network_set_wifi_down(char *if_name);
/*
* Get wifi list information.
* Return the struct pointer.
*/
wifilist *kylin_network_get_wifilist_info();
/*
* Enable networking.
*/
void kylin_network_enable_networking();
/*
* Disable networking.
*/
void kylin_network_disable_networking();
/*
* Enable wifi.
*/
void kylin_network_enable_wifi();
/*
* Disable wifi.
*/
void kylin_network_disable_wifi();
/* Get the ip address.
* @if_name is the interface name.
* @ipaddr is used to save the ip address.
*/
int kylin_network_get_ipaddr(char *if_name,char *ipaddr);
/*
* Get the broadcast address.
* @if_name is the interface name.
* @brdaddr is used to save the broadcast address.
*/
int kylin_network_get_brdaddr(char *if_name,char *brdaddr);
/*
* Get the subnet mask.
* @if_name is the interface name.
* @netmask is used to save the subnet mask.
*/
int kylin_network_get_netmask(char *if_name,char *netmask);
/*
* Get MAC address.
* @if_name is the interface name.
* @macaddr is used to save the MAC address.
*/
int kylin_network_get_mac(char *if_name,char *macaddr);
/* Get the MTU.
* @if_name is the interface name.
* return the MTU value.
*/
int kylin_network_get_mtu(char *if_name);
/*
* Total upload and download data volume.
* @if_name is the network interface name.
* return the address of the first element of a one-dimensional long integer array.
*/
long *kylin_network_get_bytes(char *if_name);
/*
* Total upload and download data packets.
* @if_name is the network interface name.
* return the address of the first element of a one-dimensional long integer array.
*/
long *kylin_network_get_packets(char *if_name);
/*
* Total wrong data packets number of uploading and downloading.
* @if_name is the network interface name.
* return the address of the first element of a one-dimensional long integer array.
*/
long *kylin_network_get_errs(char *if_name);
/*
* Total discarded data packets number of uploading and downloading.
* @if_name is the network interface name.
* return the address of the first element of a one-dimensional long integer array.
*/
long *kylin_network_get_drop(char *if_name);
/*
* Total overloaded data packets number of uploading and downloading.
* @if_name is the network interface name.
* return the address of the first element of a one-dimensional long integer array.
*/
long *kylin_network_get_fifo(char *if_name);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,765 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "confform.h"
#include "ui_confform.h"
#include "kylin-network-interface.h"
#include "backthread.h"
#include "utils.h"
#include "wireless-security/kylinheadfile.h"
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <KWindowEffects>
extern QString llname, lwname;
ConfForm::ConfForm(QWidget *parent) :
QDialog(parent),
ui(new Ui::ConfForm)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //Qt::WindowStaysOnTopHint
this->setWindowTitle(tr("edit network"));//"网络设置"
this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
//需要添加 void paintEvent(QPaintEvent *event) 函数
//this->setWindowIcon(QIcon::fromTheme("indicator-china-weather", QIcon(":/res/x/setup.png")) );
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
//use uniform ui style instead
// labelQss = "QLabel{border:0px;color:rgba(255,255,255,0.97);background-color:transparent;}";
// cbxQss = "QComboBox{padding-left:20px;font-size:13px;color:rgba(255,255,255,0.91);"
// "border:1px solid rgba(255, 255, 255, 0.05);border-radius:4px;background:rgba(255,255,255,0.08);}"
// "QComboBox::drop-down{border:0px;width:30px;}"
// "QComboBox::down-arrow{image:url(:/res/g/down_arrow.png);}"
// "QComboBox QAbstractItemView {margin:0px 0px 0px 0px;padding: 0px 0px;border-radius:0px;background-color:#48484C;outline:0px;}"
// "QComboBox QAbstractItemView::item{padding-left:17px;border-radius:0px;font-size:13px;color:rgba(255,255,255,0.91);height: 32px;background-color:#48484C;outline:0px;}"
// "QComboBox QAbstractItemView::item:hover{padding-left:17px;border-radius:0px;font-size:13px;color:rgba(255,255,255,0.91);background-color:#3D6BE5;outline:0px;}";
// leQss = "QLineEdit{padding-left:20px;color:rgba(255,255,255,0.97);background:rgba(255,255,255,0.08);}";
// btnOffQss = "QPushButton[on=false]{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.08);color:white;font-size:14px;}"
// "QPushButton[on=false]:Hover{border:0px solid rgba(255,255,255,0.1);border-radius:4px;background-color:rgba(255,255,255,0.1);}"
// "QPushButton[on=false]:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"
// "QPushButton[on=true]{border:0px;border-radius:4px;background-color:rgba(244,244,244,0.12);color:white;font-size:14px;}"
// "QPushButton[on=true]:Hover{border:0px solid rgba(244,244,244,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}"
// "QPushButton[on=true]:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}";
// btnOnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}"
// "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}"
// "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);";
// lineQss = "background:rgba(156,156,156,0.1);";
ui->wdHead->setStyleSheet("#wdHead{border:none}");
ui->wgManual->setStyleSheet("#wgManual{border:none}");
ui->wdBottom->setStyleSheet("#wdBottom{border:none}");
ui->lbLeftupTitle->setStyleSheet("QLabel{font-size:20px;}");
ui->leAddr->setContextMenuPolicy(Qt::NoContextMenu);
ui->leName->setContextMenuPolicy(Qt::NoContextMenu);
ui->leDns->setContextMenuPolicy(Qt::NoContextMenu);
ui->leDns2->setContextMenuPolicy(Qt::NoContextMenu);
ui->leGateway->setContextMenuPolicy(Qt::NoContextMenu);
ui->leAddr_ipv6->setContextMenuPolicy(Qt::NoContextMenu);
//设置网络名称的正则表达式
// ui->leName->setValidator(new QRegExpValidator(QRegExp("[^ \s]*"), ui->leName));
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->lineUp->hide();
ui->lineDown->hide();
ui->lbName->setText(tr("LAN name: "));//"网络名称:"
ui->lbTxt1->setText(tr("Method: "));//"编辑IP设置"
ui->lbTxt2->setText(tr("Address: "));//"IP地址"
ui->lbTxt3->setText(tr("Netmask: "));//"子网掩码:"
ui->lbTxt4->setText(tr("Gateway: "));//"默认网关:"
ui->lbTxt5->setText(tr("DNS 1: "));//"首选DNS"
ui->lbTxt6->setText(tr("DNS 2: "));//"备选DNS"
ui->lbTxt_ipv6->setText(tr("Ipv6 Address: "));
ui->lbLeftupTitle->setText(tr("Edit Conn"));//"网络设置"
ui->cbType->addItem(tr("Auto(DHCP)"));//"自动(DHCP)"
ui->cbType->addItem(tr("Manual"));//"手动"
connect(ui->cbType, SIGNAL(currentIndexChanged(int)), this, SLOT(cbTypeChanged(int)));
ui->cbMask->addItem("255.255.255.0"); //24
ui->cbMask->addItem("255.255.254.0"); //23
ui->cbMask->addItem("255.255.252.0"); //22
ui->cbMask->addItem("255.255.0.0"); //16
ui->cbMask->addItem("255.0.0.0"); //8
connect(ui->cbMask, SIGNAL(currentIndexChanged(int)), this, SLOT(cbMaskChanged(int)));
ui->btnCancel->setText(tr("Cancel"));//"取消"
ui->btnSave->setText(tr("Save"));//"保存"
ui->btnCreate->setText(tr("Ok"));//"确定"
ui->btnCancel->setProperty("on",true);
ui->btnSave->setProperty("on",false);
ui->btnCreate->setProperty("on",false);
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnSave->setStyleSheet(objQss.btnOffQss);
ui->btnCreate->setStyleSheet(objQss.btnOffQss);
ui->btnCancel->setFocusPolicy(Qt::NoFocus);
ui->btnSave->setFocusPolicy(Qt::NoFocus);
ui->btnCreate->setFocusPolicy(Qt::NoFocus);
// IP的正则格式限制
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 ipv6_rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$");
ui->leAddr->setValidator(new QRegExpValidator(rx, this));
ui->leGateway->setValidator(new QRegExpValidator(rx, this));
ui->leDns->setValidator(new QRegExpValidator(rx, this));
ui->leDns2->setValidator(new QRegExpValidator(rx, this));
ui->leAddr_ipv6->setValidator(new QRegExpValidator(ipv6_rx, this));
setModal(false);
setEnableOfBtn();
}
ConfForm::~ConfForm()
{
delete ui;
}
void ConfForm::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
return QDialog::mousePressEvent(event);
}
void ConfForm::mouseReleaseEvent(QMouseEvent *event)
{
this->isPress = false;
}
void ConfForm::mouseMoveEvent(QMouseEvent *event)
{
if (this->isPress) {
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
return QDialog::mouseMoveEvent(event);
}
//网络配置参数设置界面的显示内容
void ConfForm::setProp(QString connName, QString uuidName, QString v4method, QString v4addr, QString v6method, QString v6addr, QString mask, QString gateway, QString dns, bool isActConf, bool isWiFi)
{
this->isActConf = isActConf;
ui->leName->setText(connName);
lastConnName = connName;
lastIpv4 = v4addr;
lastIpv6 = v6addr;
lastTypeIndex = ui->cbType->currentIndex();
netUuid = uuidName;
qDebug() << Q_FUNC_INFO << connName << uuidName;
isActWifi = false;
if (isWiFi) {
ui->leName->setEnabled(false);
isActWifi = isWiFi;
}
if ((v4method == "auto" || v4method == "") && (v6method == "auto" || v6method == "")) {
ui->cbType->setCurrentIndex(0);
cbTypeChanged(0);
} else {
ui->cbType->setCurrentIndex(1);
cbTypeChanged(1);
}
if (v6method == "manual") {
ui->leAddr_ipv6->setText(v6addr);
}
ui->leAddr->setText(v4addr);
ui->leGateway->setText(gateway);
// 配置中有多个DNS只处理前两个
if (dns.indexOf(",") != -1) {
QStringList dnss = dns.split(",");
ui->leDns->setText(dnss.at(0));
ui->leDns2->setText(dnss.at(1));
} else {
ui->leDns->setText(dns);
ui->leDns2->setText("");
}
if (mask == "24") {
ui->cbMask->setCurrentIndex(0);
} else if(mask == "23") {
ui->cbMask->setCurrentIndex(1);
} else if(mask == "22") {
ui->cbMask->setCurrentIndex(2);
} else if(mask == "16") {
ui->cbMask->setCurrentIndex(3);
} else if(mask == "8") {
ui->cbMask->setCurrentIndex(4);
} else {
ui->cbMask->setCurrentIndex(0);
}
ui->btnSave->setEnabled(false);
}
void ConfForm::connectInfoConstruct(KyConnectSetting &connectInfo)
{
QString connectName = ui->leName->text();
connectInfo.setConnectName(connectName);
connectInfo.setIfaceName(m_ifaceName);
if (MANUAL_IP == ui->cbType->currentIndex()) {
if (!ui->leAddr->text().isEmpty()) {
QString ipv4Address = ui->leAddr->text();
QString ipv4NetMask = ui->cbMask->currentText();
QString ipv4GateWay = ui->leGateway->text();
QStringList ipv4DnsList;
ipv4DnsList.clear();
ipv4DnsList<<ui->leDns->text();
if (ui->leDns2->text() != "") {
ipv4DnsList << ui->leDns2->text();
}
connectInfo.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
connectInfo.ipv4AddressConstruct(ipv4Address, ipv4NetMask,
ipv4GateWay, ipv4DnsList);
}
if (!ui->leAddr_ipv6->text().isEmpty()) {
qWarning()<<"ipv6 function need todo";
}
}
return;
}
//点击了创建新的网络的按钮
void ConfForm::on_btnCreate_clicked()
{
KylinDBus kylindbus;
kylindbus.getWiredCardName();
if (kylindbus.multiWiredIfName.size() == 0) {
QString tip(tr("Can not create new wired network for without wired card"));
kylindbus.showDesktopNotify(tip);
onConfformHide();
return;
} else {
m_ifaceName = kylindbus.multiWiredIfName.at(0);
}
if (ui->cbType->currentIndex() == MANUAL_IP) {
//在手动配置网络的情况下以及当前的IP参数有更改的情况下检测IP冲突
if (!ui->leAddr->text().isEmpty()|| !ui->leAddr_ipv6->text().isEmpty()) {
if (check_ip_conflict(m_ifaceName)) {
return;
}
}
}
KyConnectSetting newConnectInfo;
connectInfoConstruct(newConnectInfo);
m_networkConnect.createWiredConnect(newConnectInfo);
if (DHCP_IP == ui->cbType->currentIndex()) {
//选择自动,则配置完成并发出桌面通知
QString txt(tr("New network already created"));
kylindbus.showDesktopNotify(txt);
}
onConfformHide();
}
//点击了保存更改网络设置的按钮
void ConfForm::on_btnSave_clicked()
{
KylinDBus kylindbus;
if (isActWifi) {
kylindbus.getWirelessCardName();
m_ifaceName = kylindbus.dbusWiFiCardName;
this->isCreateNewNet = false;
if (m_ifaceName.isEmpty()) {
QString notifyTxt(tr("Wireless card not exist"));
kylindbus.showDesktopNotify(notifyTxt);
return;
}
if (ui->cbType->currentIndex() == 1) {
//在手动配置网络的情况下以及当前的IP参数有更改的情况下检测IP冲突
if ((!ui->leAddr->text().isEmpty() && (ui->leAddr->text() != lastIpv4)) || (!ui->leAddr_ipv6->text().isEmpty() && (ui->leAddr_ipv6->text() != lastIpv6))) {
if (check_ip_conflict(m_ifaceName)) {
return;
}
}
}
this->saveNetworkConfiguration();
} else {
kylindbus.getWiredCardName();
if (kylindbus.multiWiredIfName.size() == 0) {
QString tip(tr("Can not save wired network for without wired card"));
kylindbus.showDesktopNotify(tip);
//this->close();
onConfformHide();
return;
} else {
m_ifaceName = kylindbus.multiWiredIfName.at(0);
}
this->isCreateNewNet = false;
if (ui->cbType->currentIndex() == 1) {
//在手动配置网络的情况下以及当前的IP参数有更改的情况下检测IP冲突
if ((!ui->leAddr->text().isEmpty() && (ui->leAddr->text() != lastIpv4)) || (!ui->leAddr_ipv6->text().isEmpty() && (ui->leAddr_ipv6->text() != lastIpv6))) {
if (check_ip_conflict(m_ifaceName)) {
return;
}
}
}
this->saveNetworkConfiguration();
}
QString txt(tr("New network settings already finished"));
kylindbus.showDesktopNotify(txt);
}
void ConfForm::saveNetworkConfiguration()
{
KylinDBus kylindbus;
KyConnectSetting newConnectInfo;
connectInfoConstruct(newConnectInfo);
m_networkConnect.updateWiredConnect(netUuid, newConnectInfo);
//是选择的自动还是手动配置网络
if (ui->cbType->currentIndex() == DHCP_IP) {
if (this->isActConf && lastTypeIndex == 1 && ui->cbType->currentIndex() == 0) {
//对于已经连接的网络,若由手动改为自动,则进行重连以保证配置生效
kylindbus.reConnectWiredNet(netUuid.toUtf8().data());
}
}
onConfformHide();
}
void ConfForm::showNotify(QString message)
{
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
args<<(tr("kylin-nm"))
<<((unsigned int) 0)
<<QString("/usr/share/icons/ukui-icon-theme-default/24x24/devices/gnome-dev-ethernet.png")
<<tr("kylin network applet desktop message") //显示的是什么类型的信息
<<message //显示的具体信息
<<QStringList()
<<QVariantMap()
<<(int)-1;
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
}
bool ConfForm::check_ip_conflict(QString ifname)
{
if (canCheckIpConflict) {
canCheckIpConflict = false;
QTimer::singleShot(2*1000, this, SLOT(changeEnableCheckIp() ));
} else {
return true;
}
//即将检测Ip地址冲突
QString strIpCheck = tr("Will check the IP address conflict");
QString bufferIpCheck = "notify-send -i network-offline " + strIpCheck;
showNotify(strIpCheck);
FILE *fp;
char ret[10], arp_all[1024];
// if (!ui->leAddr_ipv6->text().isEmpty() && ui->leAddr_ipv6->text() != "") {
if (!ui->leAddr->text().isEmpty() && ui->leAddr->text() != "") {
//ipv4地址不为空需要验证是否冲突
QString arp_all_cmd = "arping -c 3 -f -I " + ifname + " -D " + ui->leAddr->text();
fp = popen(arp_all_cmd.toUtf8().data(),"r");
if(!fp)
return false;
fread(arp_all, 1, sizeof(arp_all), fp);
pclose(fp);
if (strstr(arp_all, "Received") && strstr(arp_all, " response(s)")) {
QString arp_result = "arping -c 1 -f -I " + ifname + " -D " + ui->leAddr->text() + " | awk '{print $2}' | sed -n '3p'";
fp = popen(arp_result.toUtf8().data(),"r");
if(!fp)
return false;
fgets(ret,sizeof(ret),fp);
pclose(fp);
ret[strlen(ret)-1]=0;
if ( ret != NULL ) {
// if (!strcmp(ret,"0")) {
// //printf("正常连接");
// return false;
// } else {
if (strcmp(ret,"0")) {
//printf("ipv4地址冲突");
QString strInfo = tr("IPV4 address conflict, Please change IP");
// QString buffer = "notify-send -i network-offline " + strInfo;
showNotify(strInfo);
return true;
}
}
}
}
if (ui->leAddr_ipv6->text().isEmpty() || ui->leAddr_ipv6->text() == "") {
//未配置ipv6地址跳过ipv6地址冲突检测
return false;
}
isIpv6Conflict = false;
QProcess * process = new QProcess;
if (this->isActWifi) {
//指定无线网卡检测
process->start(QString("ping6 %1%%2").arg(ui->leAddr_ipv6->text()).arg(wcard));
} else {
//指定有线网卡检测
process->start(QString("ping6 %1%%2").arg(ui->leAddr_ipv6->text()).arg(lcard));
}
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});
connect(process, &QProcess::readyReadStandardOutput, this, [ = ]() {
QString str = process->readAllStandardOutput();
if (!str.contains("PING")) {
if (str.contains("unreachable")) {
isIpv6Conflict = false;
} else {
//如果能ping通需要看是不是当前本机连接的ipv6地址如果是本机连接的也不算冲突
if (this->isActWifi) {
if (ui->leAddr_ipv6->text() == actWifiIpv6Addr) {
//新地址与当前本机连接的wifi的ipv6地址一直不算冲突
isIpv6Conflict = false;
} else {
isIpv6Conflict = true;
}
} else {
if (ui->leAddr_ipv6->text() == actLanIpv6Addr) {
//新地址与当前本机连接的有线的ipv6地址一直不算冲突
isIpv6Conflict = false;
} else {
isIpv6Conflict = true;
}
}
}
process->close();
}
});
connect(process, &QProcess::readyReadStandardError, this, [ = ]() {
isIpv6Conflict = false;
process->close();
});
process->waitForFinished();
if (isIpv6Conflict) {
//printf("ipv6地址冲突");
QString strInfo = tr("IPV6 address conflict, Please change IP");
showNotify(strInfo);
return true;
}
//printf("正常连接");
return false;
}
void ConfForm::changeEnableCheckIp()
{
canCheckIpConflict = true;
}
//点击取消按钮
void ConfForm::on_btnCancel_clicked()
{
onConfformHide();
}
//根据需要设置的种类(自动或手动等)显示界面内容
void ConfForm::cbTypeChanged(int index)
{
if (isShowSaveBtn) {
if (!isActWifi) {
ui->leName->setEnabled(true);
}
ui->btnSave->show(); //显示保存按钮
ui->btnCreate->hide(); //隐藏创建按钮
ui->lbLeftupTitle->setText(tr("Edit Network"));
}
if (index == 0) {
ui->lineUp->hide();
ui->lineDown->hide();
ui->wgManual->hide();
//ui->centralWidget->resize(432, 230);
ui->centralWidget->setFixedSize(432, 230);
ui->wdBottom->move(1, 170);
this->setEnableOfBtn();
//this->resize(432, 230);
this->setFixedSize(432, 230);
}
if (index == 1) {
ui->lineUp->show();
ui->lineDown->show();
ui->wgManual->show();
//ui->centralWidget->resize(432, 510);
ui->centralWidget->setFixedSize(432, 510);
ui->wdBottom->move(1, 440);
this->setEnableOfBtn();
//this->resize(432, 510);
this->setFixedSize(432, 510);
}
if (index == 3) {
setBtnEnableFalse();
if (!isActWifi) {
ui->leName->setEnabled(true);
}
ui->btnSave->hide();
ui->btnCreate->show();
ui->lbLeftupTitle->setText(tr("Add Wired Network"));
isShowSaveBtn = false;
ui->lineUp->hide();
ui->lineDown->hide();
ui->wgManual->hide();
//ui->centralWidget->resize(432, 230);
ui->centralWidget->setFixedSize(432, 230);
ui->wdBottom->move(1, 170);
//this->resize(432, 230);
this->setFixedSize(432, 230);
}
}
void ConfForm::cbMaskChanged(int index)
{
this->setEnableOfBtn();
}
//编辑网络名称
void ConfForm::on_leName_textEdited(const QString &arg1)
{
this->setEnableOfBtn();
}
//编辑网络ip
void ConfForm::on_leAddr_textEdited(const QString &arg1)
{
this->setEnableOfBtn();
}
//编辑ipv6地址
void ConfForm::on_leAddr_ipv6_textChanged(const QString &arg1)
{
this->setEnableOfBtn();
}
//编辑网络网关
void ConfForm::on_leGateway_textEdited(const QString &arg1)
{
this->setEnableOfBtn();
}
//编辑网络DNS
void ConfForm::on_leDns_textEdited(const QString &arg1)
{
this->setEnableOfBtn();
}
//编辑网络备用DNS
void ConfForm::on_leDns2_textEdited(const QString &arg1)
{
this->setEnableOfBtn();
}
//设置界面按钮是否可点击
void ConfForm::setEnableOfBtn()
{
// if(!isEditingAlready()){
// this->setBtnEnableFalse();
// return;
// }
if (ui->leName->text().size() == 0 ) {
this->setBtnEnableFalse();
return;
}
if (ui->cbType->currentIndex() == 1) {
if (ui->leAddr->text().isEmpty() && ui->leAddr_ipv6->text().isEmpty()) {
//当ipv4和ipv6地址均未设置时禁止保存
this->setBtnEnableFalse();
return;
}
if (!ui->leAddr->text().isEmpty() && !this->getTextEditState(ui->leAddr->text()) ) {
this->setBtnEnableFalse();
return;
}
if (!ui->leGateway->text().isEmpty() && !this->getTextEditState(ui->leGateway->text()) ) {
this->setBtnEnableFalse();
return;
}
if (!ui->leDns->text().isEmpty() && !this->getTextEditState(ui->leDns->text()) ) {
this->setBtnEnableFalse();
return;
}
if (!ui->leAddr_ipv6->text().isEmpty() && ! this->getIpv6EditState(ui->leAddr_ipv6->text())) {
this->setBtnEnableFalse();
return;
}
if(ui->leDns2->text().isEmpty()){
}else{
if(!this->getTextEditState(ui->leDns2->text())){
this->setBtnEnableFalse();
return ;
}
}
}
ui->btnSave->setEnabled(true);
ui->btnCreate->setEnabled(true);
ui->btnSave->setProperty("on",true);
ui->btnSave->style()->unpolish(ui->btnSave);
ui->btnSave->style()->polish(ui->btnSave);
ui->btnCreate->setProperty("on",true);
ui->btnCreate->style()->unpolish(ui->btnCreate);
ui->btnCreate->style()->polish(ui->btnCreate);
}
bool ConfForm::isEditingAlready(){
if (ui->leName->text().size() == 0) return false;
if(ui->cbType->currentIndex() == 1){ //手动新建网络
//仅填写连接名和ipv4地址时可被按下
if(getTextEditState(ui->leAddr->text()) && ui->leAddr_ipv6->text().isEmpty()
&& ui->leGateway->text().isEmpty() && ui->leDns->text().isEmpty() && ui->leDns2->text().isEmpty()){
return true;
}
//全部填写完成时可被按下
if(getTextEditState(ui->leAddr->text()) && ui->leAddr_ipv6->text().isEmpty()
&& getTextEditState(ui->leGateway->text()) && getTextEditState(ui->leDns->text())){
if(getTextEditState(ui->leDns2->text()) || ui->leDns2->text().isEmpty()){
return true;
}
}
}
return false;
}
//文本的输入要符合ip的格式要求
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");
bool match = false;
match = rx.exactMatch(text);
return match;
}
bool ConfForm::getIpv6EditState(QString text)
{
QRegExp rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$");
bool match = false;
match = rx.exactMatch(text);
return match;
}
void ConfForm::onConfformHide()
{
clearFocus();
ui->leAddr->clearFocus();
ui->leAddr_ipv6->clearFocus();
ui->leGateway->clearFocus();
ui->leDns->clearFocus();
ui->leDns2->clearFocus();
this->hide();
}
//设置创建或保存按钮不可点击
void ConfForm::setBtnEnableFalse()
{
ui->btnSave->setEnabled(false);
ui->btnCreate->setEnabled(false);
ui->btnSave->setProperty("on",false);
ui->btnSave->style()->unpolish(ui->btnSave);
ui->btnSave->style()->polish(ui->btnSave);
ui->btnCreate->setProperty("on",false);
ui->btnCreate->style()->unpolish(ui->btnCreate);
ui->btnCreate->style()->polish(ui->btnCreate);
}
void ConfForm::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QString name = tr("Method: ");
ui->lbTxt1->setText(ui->lbTxt1->fontMetrics().elidedText(name, Qt::ElideRight, 95));
if (name != ui->lbTxt1->text()) {
ui->lbTxt1->setToolTip(tr("Method: "));
} else {
ui->lbTxt1->setToolTip("");
}
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,123 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CONFFORM_H
#define CONFFORM_H
#include <QWidget>
#include <QMouseEvent>
#include <QDebug>
#include <QPoint>
#include <QPainter>
#include <QPainterPath>
#include <QDialog>
#include <QListView>
#include "kylin-dbus-interface.h"
#include "backend/dbus-interface/kylinwiredconnectoperation.h"
#include "backend/dbus-interface/kylinconnectsetting.h"
namespace Ui {
class ConfForm;
}
enum{
DHCP_IP = 0,
MANUAL_IP = 1,
};
class ConfForm : public QDialog
{
Q_OBJECT
public:
explicit ConfForm(QWidget *parent = 0);
~ConfForm();
void setProp(QString connName, QString uuidName, QString v4method, QString v4addr, QString v6method, QString v6addr, QString mask, QString gateway, QString dns, bool isActConf, bool isWiFi);
QString actLanIpv6Addr;
QString actWifiIpv6Addr;
QString lcard, wcard;
public slots:
void cbTypeChanged(int index);
void cbMaskChanged(int index);
void changeEnableCheckIp();
protected:
void paintEvent(QPaintEvent *event);
private slots:
void on_btnSave_clicked();
void on_btnCancel_clicked();
void on_btnCreate_clicked();
void on_leName_textEdited(const QString &arg1);
void on_leAddr_textEdited(const QString &arg1);
void on_leGateway_textEdited(const QString &arg1);
void on_leDns_textEdited(const QString &arg1);
void on_leDns2_textEdited(const QString &arg1);
void setEnableOfBtn();
bool getTextEditState(QString text);
bool getIpv6EditState(QString text);
void setBtnEnableFalse();
void saveNetworkConfiguration();
void on_leAddr_ipv6_textChanged(const QString &arg1);
private:
Ui::ConfForm *ui;
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void showNotify(QString message);
bool check_ip_conflict(QString ifname);
void onConfformHide();
bool isEditingAlready(); //连接按钮是否可被按
void connectInfoConstruct(KyConnectSetting &connectInfo);
bool isPress;
QPoint winPos;
QPoint dragPos;
bool isActConf; //是否对已经连接的网络进行的更改
bool isCreateNewNet = false; //是否是创建的新网络
bool isShowSaveBtn = true; //是否显示保存按钮,即是否是编辑网络界面
QString lastConnName, lastIpv4, netUuid, newUuid, lastIpv6;
int lastTypeIndex;
bool isActWifi; //是否是wifi网络
bool canCheckIpConflict = true; //当前是否可以执行IP冲突的检测
bool isIpv6Conflict = false; //ipv6地址是否冲突
QString labelQss, cbxQss, leQss, lineQss, btnOnQss, btnOffQss;
KyWiredConnectOperation m_networkConnect;
QString m_ifaceName;
signals:
void requestRefreshLanList(int updateType);
};
#endif // CONFFORM_H

View File

@ -1,425 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConfForm</class>
<widget class="QWidget" name="ConfForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>510</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<property name="toolTip">
<string/>
</property>
<widget class="QWidget" name="centralWidget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>510</height>
</rect>
</property>
<widget class="QWidget" name="wgManual" native="true">
<property name="geometry">
<rect>
<x>1</x>
<y>169</y>
<width>430</width>
<height>271</height>
</rect>
</property>
<widget class="QLineEdit" name="leAddr">
<property name="geometry">
<rect>
<x>175</x>
<y>10</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QComboBox" name="cbMask">
<property name="geometry">
<rect>
<x>175</x>
<y>95</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLineEdit" name="leGateway">
<property name="geometry">
<rect>
<x>175</x>
<y>140</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLineEdit" name="leDns">
<property name="geometry">
<rect>
<x>175</x>
<y>185</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbTxt2">
<property name="geometry">
<rect>
<x>76</x>
<y>13</y>
<width>95</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<family>Noto Sans CJK SC</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbTxt3">
<property name="geometry">
<rect>
<x>76</x>
<y>98</y>
<width>95</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<family>Noto Sans CJK SC</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbTxt4">
<property name="geometry">
<rect>
<x>76</x>
<y>143</y>
<width>95</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<family>Noto Sans CJK SC</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbTxt5">
<property name="geometry">
<rect>
<x>76</x>
<y>188</y>
<width>95</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<family>Noto Sans CJK SC</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leDns2">
<property name="geometry">
<rect>
<x>175</x>
<y>230</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbTxt6">
<property name="geometry">
<rect>
<x>76</x>
<y>233</y>
<width>95</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<family>Noto Sans CJK SC</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbTxt_ipv6">
<property name="geometry">
<rect>
<x>76</x>
<y>55</y>
<width>95</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<family>Noto Sans CJK SC</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leAddr_ipv6">
<property name="geometry">
<rect>
<x>175</x>
<y>52</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
</widget>
<widget class="QWidget" name="wdHead" native="true">
<property name="geometry">
<rect>
<x>1</x>
<y>1</y>
<width>430</width>
<height>180</height>
</rect>
</property>
<widget class="QComboBox" name="cbType">
<property name="geometry">
<rect>
<x>175</x>
<y>120</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbTxt1">
<property name="geometry">
<rect>
<x>76</x>
<y>123</y>
<width>95</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<family>Noto Sans CJK SC</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbName">
<property name="geometry">
<rect>
<x>76</x>
<y>78</y>
<width>95</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<family>Noto Sans CJK SC</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leName">
<property name="geometry">
<rect>
<x>175</x>
<y>75</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="maxLength">
<number>20</number>
</property>
</widget>
</widget>
<widget class="QWidget" name="wdBottom" native="true">
<property name="geometry">
<rect>
<x>1</x>
<y>440</y>
<width>430</width>
<height>70</height>
</rect>
</property>
<widget class="QPushButton" name="btnSave">
<property name="geometry">
<rect>
<x>315</x>
<y>20</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>20</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnCreate">
<property name="geometry">
<rect>
<x>315</x>
<y>20</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>240</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>170</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>440</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,6 +1,5 @@
INCLUDEPATH += $$PWD
include(tools/tools.pri)
include(wireless-security/wireless-security.pri)
include(xatom/xatom.pri)
include(tab-pages/tab-pages.pri)
include(list-items/list-items.pri)
@ -8,27 +7,18 @@ include(netdetails/netdetails.pri)
include(enterprise-wlan/enterprise-wlan.pri)
FORMS += \
$$PWD/confform.ui \
$$PWD/mainwindow.ui \
$$PWD/wificonfigdialog.ui \
$$PWD/wpawifidialog.ui
$$PWD/wificonfigdialog.ui
HEADERS += \
$$PWD/confform.h \
$$PWD/customstyle.h \
$$PWD/kylinwiredwidget.h \
$$PWD/mainwindow.h \
$$PWD/nmdemo.h \
$$PWD/wificonfigdialog.h \
$$PWD/wpawifidialog.h \
$$PWD/new-mainwindow.h
$$PWD/wificonfigdialog.h
SOURCES += \
$$PWD/confform.cpp \
$$PWD/customstyle.cpp \
$$PWD/kylinwiredwidget.cpp \
$$PWD/mainwindow.cpp \
$$PWD/nmdemo.cpp \
$$PWD/wificonfigdialog.cpp \
$$PWD/wpawifidialog.cpp \
$$PWD/new-mainwindow.cpp
$$PWD/wificonfigdialog.cpp

View File

@ -34,18 +34,18 @@ void KyWiredWidget::constructWiredActiveConnectList()
m_activeConnectResource->getActiveConnectionList("enp2s0",
NetworkManager::ConnectionSettings::ConnectionType::Wired,
wiredActiveConnect);
if (wiredActiveConnect.isEmpty()) {
OneLancForm *activeWiredForm = new OneLancForm(this, nullptr);
activeWiredForm->constructActiveConnectionEmptyItem();
m_wiredActiveFormlist<<activeWiredForm;
} else {
for (int index = 0; index < wiredActiveConnect.size(); ++index) {
resize(width(), height() + H_NORMAL_ITEM * index);
OneLancForm *activeWiredForm = new OneLancForm(this, wiredActiveConnect.at(index));
activeWiredForm->constructActiveConnectionItem(index);
m_wiredActiveFormlist<<activeWiredForm;
}
}
// if (wiredActiveConnect.isEmpty()) {
// LanListItem *activeWiredForm = new LanListItem(this, nullptr);
// activeWiredForm->constructActiveConnectionEmptyItem();
// m_wiredActiveFormlist<<activeWiredForm;
// } else {
// for (int index = 0; index < wiredActiveConnect.size(); ++index) {
// resize(width(), height() + H_NORMAL_ITEM * index);
// LanListItem *activeWiredForm = new LanListItem(this, wiredActiveConnect.at(index));
// activeWiredForm->constructActiveConnectionItem(index);
// m_wiredActiveFormlist<<activeWiredForm;
// }
// }
return;
}
@ -62,14 +62,14 @@ void KyWiredWidget::constructWiredConnectList()
m_connectResource->getConnectionList("enp2s0",
NetworkManager::ConnectionSettings::ConnectionType::Wired,
wiredConnections);
if (!wiredConnections.isEmpty()) {
for (int index = 0; index < wiredConnections.size(); ++index) {
resize(W_LIST_WIDGET, height() + H_NORMAL_ITEM);
OneLancForm *wiredForm = new OneLancForm(this, wiredConnections.at(index));
wiredForm->constructConnectionItem(index);
m_wiredFormlist<<wiredForm;
}
}
// if (!wiredConnections.isEmpty()) {
// for (int index = 0; index < wiredConnections.size(); ++index) {
// resize(W_LIST_WIDGET, height() + H_NORMAL_ITEM);
// OneLancForm *wiredForm = new OneLancForm(this, wiredConnections.at(index));
// wiredForm->constructConnectionItem(index);
// m_wiredFormlist<<wiredForm;
// }
// }
return;
}
@ -78,7 +78,7 @@ void KyWiredWidget::updateWiredActiveConnection()
{
qDebug()<<"updateWiredActiveConnection......";
while (!m_wiredActiveFormlist.empty()) {
OneLancForm *wiredActiveForm = m_wiredActiveFormlist.at(0);
LanListItem *wiredActiveForm = m_wiredActiveFormlist.at(0);
m_wiredActiveFormlist.removeAt(0);
delete wiredActiveForm;
wiredActiveForm = nullptr;
@ -91,9 +91,8 @@ void KyWiredWidget::updateWiredConnection()
{
qDebug()<<"updateWiredConnection........";
while (!m_wiredFormlist.empty()) {
OneLancForm *wiredForm = m_wiredFormlist.at(0);
LanListItem *wiredForm = m_wiredFormlist.at(0);
m_wiredFormlist.removeAt(0);
qDebug()<<"delete item"<< wiredForm->uuidName;
delete wiredForm;
wiredForm = nullptr;
}

View File

@ -6,9 +6,11 @@
#include "backend/dbus-interface/kylinconnectresource.h"
#include "backend/dbus-interface/kylinnetworkdeviceresource.h"
#include "backend/dbus-interface/kylinconnectitem.h"
#include "onelancform.h"
#include "lanlistitem.h"
#include "mainwindow.h"
class LanListItem;
typedef enum{
ACTIVECONNECTION,
CONNECTION,
@ -56,8 +58,8 @@ private:
KyConnectResourse *m_connectResource = nullptr;
KyNetworkDeviceResourse *m_deviceResource = nullptr;
QList<OneLancForm*> m_wiredActiveFormlist;
QList<OneLancForm*> m_wiredFormlist;
QList<LanListItem*> m_wiredActiveFormlist;
QList<LanListItem*> m_wiredFormlist;
};
#endif // KYLINWIREDWIDGET_H

View File

@ -7,14 +7,10 @@ FORMS += \
HEADERS += \
$$PWD/lanlistitem.h \
$$PWD/listitem.h \
$$PWD/oneconnform.h \
$$PWD/onelancform.h \
$$PWD/wlanlistitem.h
SOURCES += \
$$PWD/lanlistitem.cpp \
$$PWD/listitem.cpp \
$$PWD/oneconnform.cpp \
$$PWD/onelancform.cpp \
$$PWD/wlanlistitem.cpp

File diff suppressed because it is too large Load Diff

View File

@ -1,187 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef ONECONNFORM_H
#define ONECONNFORM_H
#include <QWidget>
#include <QScreen>
#include <QThread>
#include <QDialog>
#include <QLineEdit>
#include <QShortcut>
#include <QKeyEvent>
#include <QLabel>
#include <QHBoxLayout>
#include "confform.h"
#include "backthread.h"
#include "ksimplenm.h"
#include "wpawifidialog.h"
//#include "kylinnetworkconnect.h"
#define FRAME_SPEED 150
#define LIMIT_TIME 90*1000
#define TOTAL_PAGE 8
#define W_ITEM 424
#define H_ITEM 60
#define H_ITEM_BIG 138
#define H_ITEM_MIDDLE 106
#define H_WIFI_ITEM_BIG_EXTEND 78 //138 - 60
#define H_WIFI_ITEM_SMALL_EXTEND 46 //106 - 60
#define Y_LINE 59
#define X_LINE 2
#define Y_LINE_SMALL_EXTEND 105
#define X_LINE_SMALL_EXTEND 2
#define Y_LINE_BIG_EXTEND 137
#define X_LINE_BIG_EXTEND 2
class OldMainWindow;
namespace Ui {
class OneConnForm;
}
class OneConnForm : public QWidget
{
Q_OBJECT
public:
explicit OneConnForm(QWidget *parent = 0, OldMainWindow *mw = 0, ConfForm *confForm = 0, KSimpleNM *ksnm = 0);
~OneConnForm();
// category:1->normal protocol 1->wifi 6 2->wifi 6+
void setSignal(QString lv, QString secu, QString category = "0", bool hasSignalStrength = true);
int getSignal();
void setWifiName(QString name, QString bssid, QString uuid, QString isname, bool isHW, bool is9006C);
QString getName();
void setRate(QString rate);
void setLine(bool isShow);
void setWifiInfo(QString str1, QString str2, QString str3, int freq);
void setSelected(bool isSelected, bool isCurrName);
void setHideItem(bool isHideItem, bool isShowHideBtn);
void setTopItem(bool isSelected);
void setAct(bool isAct);
void setConnedString(bool showLable, QString str, QString str1);
void setLePassword();
bool isWifiConfExist(QString netName);
void setlbPwdTipVisble(const bool&);
QString getUuidByWifiName(const QString &wifiname);
QString wifiName;
QString wifiBSsid;
QString wifiUuid;
QString wifiIfName;
QString connType;
QString wifiSecu;
QLabel * lbFreq = nullptr;
QLabel * lbPwdTip = nullptr;
bool isHuaweiPC;
bool isHuaWei9006C;
bool isSelected;
bool isActive;
bool isConnected;
bool isTopItem;
int signalLv;
int m_signal;
public slots:
void waitAnimStep();
void startWifiWaiting(bool isToConnect);
void stopWifiWaiting(bool isUpdateTrayIcon);
void onBtnPropertyClicked();
void onNoConnetion();
void onNotSavedConnection();
protected:
void mousePressEvent(QMouseEvent *event);
bool eventFilter(QObject *obj, QEvent *event);
private:
bool getWifiConfig(WifiConfig &wc, QString netName);
bool checkIsSaved();
void showLePassword();
private slots:
void on_btnConn_clicked();
void on_btnConnSub_clicked();
void on_btnDisConn_clicked();
void toConnectWirelessNetwork();
void slotConnWifi();
void slotConnWifiPWD();
void slotConnWifiResult(int connFlag);
void on_btnConnPWD_clicked();
void on_btnHideConn_clicked();
void on_lePassword_textEdited(const QString &arg1);
void on_btnInfo_clicked();
void on_btnCancel_clicked();
void on_checkBoxPwd_clicked();
bool onMenuTriggered(QAction *);
private:
QTimer *waitTimer = nullptr;
int waitPage;
int countCurrentTime;
bool isWaiting = false;
int psk_flag = 0; //密码存储策略
int getPskFlag();
bool m_connWithPwd = true; //是否使用密码连接
Ui::OneConnForm *ui = nullptr;
OldMainWindow *mw = nullptr;
ConfForm *cf = nullptr;
KSimpleNM *ks = nullptr;
bool hasPwd;
QString leQssLow, leQssHigh;
QLabel * lbNameText = nullptr;
QHBoxLayout * lbNameLyt = nullptr;
QString key_mgmt, funcBtnQss;
QPushButton *btnProperty = nullptr;
QMenu * m_menu = nullptr;
KyWiredConnectOperation *m_networkConnect = nullptr;
signals:
void selectedOneWifiForm(QString wifiName, int extendLength);
void connDone(int connFlag);
void requestHandleWifiDisconn();
void requestRefreshWifiList();
void sigConnWifi(QString, QString);
void sigConnWifiPWD(QString, QString, QString, QString, QString);
void sigConnWifiPsk(QString);
void activateWirelessConnection(const QString &connectSsid, const QString &connectUuid);
void activateWirelessConnectionWithPWD(const QString &connectSsid, const QString &psk, bool isNotSaved, const QString &connectUuid);
};
#endif // ONECONNFORM_H

View File

@ -1,632 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "onelancform.h"
#include "ui_onelancform.h"
#include "mainwindow.h"
#include "kylinwiredwidget.h"
#include <time.h>
OneLancForm::OneLancForm(QWidget *parent, KyConnectItem *wiredConnectItem) :
QWidget(parent),
ui(new Ui::OneLancForm)
{
ui->setupUi(this);
ui->btnConnSub->setText(tr("Connect"));//"连接"
ui->btnConn->setText(tr("Connect"));//"连接"
ui->btnDisConn->setText(tr("Disconnect"));//"断开连接"
ui->btnCancel->setText(tr("Cancel"));//取消连接
ui->lbConned->setAlignment(Qt::AlignLeft);
leQssLow = "QLineEdit{border:none;background:transparent;font-size:14px;}";
leQssHigh = "QLineEdit{border:none;background:transparent;font-size:14px;}";
ui->leInfo_1->setStyleSheet(leQssLow);
ui->leInfo_2->setStyleSheet(leQssLow);
ui->leInfo_3->setStyleSheet(leQssLow);
ui->leInfo_4->setStyleSheet(leQssLow);
ui->btnInfo->setStyleSheet("QPushButton{border:none;background:transparent;}");
ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(156,156,156,0.1);}");
ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(156,156,156,0);}");
ui->lbName->setStyleSheet("QLabel{font-size:14px;}");
ui->lbConned->setStyleSheet("QLabel{font-size:14px;}");
ui->btnConnSub->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}"
"QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}"
"QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}");
ui->btnDisConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}"
"QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}"
"QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}");
ui->btnConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}"
"QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}"
"QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}");
ui->btnCancel->setStyleSheet("QPushButton{border:none;background:transparent;color:white;font-size:14px;}");
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}");
ui->lbWaitingIcon->setStyleSheet("QLabel{border:0px;background-color:transparent;}");
ui->btnInfo->setCursor(QCursor(Qt::PointingHandCursor));
ui->btnInfo->setFocusPolicy(Qt::NoFocus);
ui->btnConnSub->setFocusPolicy(Qt::NoFocus);
ui->btnConn->setFocusPolicy(Qt::NoFocus);
ui->btnDisConn->setFocusPolicy(Qt::NoFocus);
ui->btnCancel->setFocusPolicy(Qt::NoFocus);
ui->wbg->hide();
ui->wbg_2->show();
ui->lbName->show();
ui->btnConnSub->hide();
ui->btnConn->hide();
ui->btnDisConn->hide();
ui->btnCancel->hide();
ui->line->show();
ui->lbWaiting->hide();
ui->lbWaitingIcon->hide();
m_wiredConnectItem = wiredConnectItem;
this->isSelected = false;
this->isActive = false;
this->setAttribute(Qt::WA_Hover,true);
this->installEventFilter(this);
ui->btnInfo->setAttribute(Qt::WA_Hover,true);
ui->btnInfo->installEventFilter(this);
this->waitTimer = new QTimer(this);
#if 0
connect(waitTimer, SIGNAL(timeout()), this, SLOT(waitAnimStep()));
connect(mw, SIGNAL(waitLanStop()), this, SLOT(stopWaiting()));
connect(mw, &MainWindow::lanClicked, this, [ = ](QString name) {
if (QString::compare(name, this->ssidName) == 0 && !this->isActive) {
on_btnConn_clicked();
}
});
#endif
m_updateSpeedTimer = new QTimer(this);
connect(m_updateSpeedTimer, &QTimer::timeout, this, &OneLancForm::updateNetworkSpeed);
if (nullptr != m_wiredConnectItem
&& NetworkManager::ActiveConnection::State::Activated == m_wiredConnectItem->m_connectState) {
m_updateSpeedTimer->start(1000);
}
ui->btnConn->setShortcut(Qt::Key_Return);//将字母区回车键与连接按钮绑定在一起
ui->btnConnSub->setShortcut(Qt::Key_Return);//点击连接按钮触发回车键
m_wiredConnectOperation = new KyWiredConnectOperation();
srand((unsigned)time(NULL));
}
OneLancForm::~OneLancForm()
{
delete m_wiredConnectItem;
delete m_wiredConnectOperation;
delete ui;
}
void OneLancForm::constructActiveConnectionEmptyItem()
{
setLanName(tr("Not connected"), tr("Not connected"), "--", "--");//"当前未连接任何 以太网"
setIcon(false);
setConnedString(1, tr("Disconnected"), "");//"未连接"
isConnected = false;
setTopItem(false);//"当前未连接任何 以太网"
setAct(true);
move(L_VERTICAL_LINE_TO_ITEM, 0);
show();
setLine(false);
}
void OneLancForm::constructActiveConnectionItem(int index)
{
setLanName(m_wiredConnectItem->m_connectName,
tr("Ethernet"), m_wiredConnectItem->m_connectUuid,
m_wiredConnectItem->m_ifaceName);//第二个参数本来是strLanName但目前不需要翻译
setIcon(true);
//setLanInfo(m_wiredConnectItem->m_ipv4, m_wiredConnectItem->m_ipv6,
// m_wiredConnectItem->m_bandWith, m_wiredConnectItem->m_hardAddress);
//setConnedString(true, tr("NetOn,IfName:"), m_wiredConnectItem->m_ifaceName);
setConnedString(1, tr("NetOn,"), "");
isConnected = true;
setTopItem(false);
setLine(true);
setAct(true);
move(L_VERTICAL_LINE_TO_ITEM, index*H_NORMAL_ITEM);
show();
}
void OneLancForm::constructConnectionItem(int index)
{
setLanName(m_wiredConnectItem->m_connectName,
tr("Ethernet"), m_wiredConnectItem->m_connectUuid,
m_wiredConnectItem->m_ifaceName);
setIcon(true);
setLine(true);
//setLanInfo(m_wiredConnectItem->m_ipv4, m_wiredConnectItem->m_ipv6,
// tr("Disconnected"), m_wiredConnectItem->m_hardAddress);
setConnedString(0, tr("Disconnected"), "");//"未连接"
move(L_VERTICAL_LINE_TO_ITEM, index * H_NORMAL_ITEM);
setSelected(false, false);
show();
}
void OneLancForm::mousePressEvent(QMouseEvent *)
{
emit selectedOneLanForm(ssidName, uuidName);//避免重名情况
}
//事件过滤器
bool OneLancForm::eventFilter(QObject *obj, QEvent *event)
{
if (obj == ui->btnInfo) {
if(event->type() == QEvent::HoverEnter) {
ui->leInfo_1->setStyleSheet(leQssHigh);
ui->leInfo_2->setStyleSheet(leQssHigh);
ui->leInfo_3->setStyleSheet(leQssHigh);
ui->leInfo_4->setStyleSheet(leQssHigh);
return true;
} else if(event->type() == QEvent::HoverLeave) {
ui->leInfo_1->setStyleSheet(leQssLow);
ui->leInfo_2->setStyleSheet(leQssLow);
ui->leInfo_3->setStyleSheet(leQssLow);
ui->leInfo_4->setStyleSheet(leQssLow);
return true;
}
} else if (obj == this) {
if (event->type() == QEvent::HoverEnter) {
if (!this->isTopItem) {
if (!this->isSelected) {
ui->btnConn->show();
ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(156,156,156,0.1);}");
ui->wbg_2->show();
}
}
return true;
} else if(event->type() == QEvent::HoverLeave) {
ui->btnConn->hide();
ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(156,156,156,0);}");
ui->wbg_2->hide();
return true;
}
}
return QWidget::eventFilter(obj,event);
}
// 是否当前连接的网络,字体设置不同
void OneLancForm::setAct(bool isAct)
{
if (isAct) {
ui->lbConned->show();
ui->btnConnSub->hide();
} else {
ui->lbConned->hide();
ui->btnConnSub->hide();
}
isActive = isAct;
}
// 是否选中
void OneLancForm::setSelected(bool isSelected, bool isCurrName)
{
if (isSelected) {
resize(W_ITEM, H_ITEM_EXTEND);
ui->wbg->show();
ui->wbg_2->hide();
ui->line->move(X_LINE_EXTEND, Y_LINE_EXTEND);
ui->btnConn->hide();
ui->btnConnSub->show();
this->isSelected = true;
} else {
resize(W_ITEM, H_ITEM);
ui->wbg->hide();
ui->wbg_2->show();
ui->line->move(X_LINE, Y_LINE);
if(isCurrName){
ui->btnConn->show();
}else{
ui->btnConn->hide();
}
ui->btnConnSub->hide();
this->isSelected = false;
}
ui->btnDisConn->hide();
this->isTopItem = false;
}
//设置顶部这个item的显示
void OneLancForm::setTopItem(bool isSelected)
{
if (isSelected) {
resize(W_ITEM, H_ITEM_EXTEND);
ui->wbg->show();
ui->btnConnSub->hide();
this->isSelected = true;
ui->line->move(X_LINE_EXTEND, Y_LINE_EXTEND);
} else {
resize(W_ITEM, H_ITEM);
ui->wbg->hide();
ui->btnConnSub->hide();
this->isSelected = false;
ui->line->move(X_LINE, Y_LINE);
}
if (isConnected) {
ui->btnDisConn->show();
} else {
ui->btnDisConn->hide();
}
ui->btnConn->hide();
ui->wbg_2->hide();
this->isTopItem = true;
}
//设置网络名称
void OneLancForm::setLanName(QString ssid, QString transSsid, QString uuid, QString interface)
{
//处理过长SSID
QString displayName;
if(ssid.length() > 23){
displayName = ssid.mid(0, 20) + "...";
}else{
displayName = ssid;
}
ui->lbName->setText(displayName);
ssidName = ssid;
m_sConnectType = transSsid;
uuidName = uuid;
ifName = interface;
}
//根据有线网络连接与否,设置显示'已连接'文字的控件的可见与否
void OneLancForm::setConnedString(bool showLable, QString str, QString ifname)
{
if (!showLable) {
ui->lbConned->hide();
ui->lbName->move(63, 18);
} else {
ui->lbConned->setText(str+ifname);
}
}
//设置item被扩展后出现的网络信息
void OneLancForm::setLanInfo(QString str1, QString str2, QString str3, QString str4)
{
if (str2 == "" || str2 == "auto") {
str2 = tr("No Configuration");
}
if (str1 == "" || str1 == "auto") {
str1 = tr("No Configuration");
// str2 = tr("No Configuration");
}
if (str4 == "--" || str4 == "") {
str1 = tr("No Configuration");
str4 = tr("No IfName");
}
QString strIPv4 = QString(tr("IPv4"));
QString strIPv6 = QString(tr("IPv6"));
QString strBW = QString(tr("BandWidth"));
QString strMAC = QString(tr("MAC"));
ui->leInfo_1->setText(strIPv4 + str1);
ui->leInfo_2->setText(strIPv6 + str2);
ui->leInfo_3->setText(strBW + str3);
ui->leInfo_4->setText(strMAC + str4);
}
//根据网络是否连接,设置网络状态图标
void OneLancForm::setIcon(bool isOn)
{
if (isOn) {
if (!QIcon::fromTheme("network-wired-connected-symbolic").isNull()) {
ui->lbIcon->setPixmap(QIcon::fromTheme("network-wired-connected-symbolic").pixmap(32,32));
ui->lbIcon->setProperty("useIconHighlightEffect", 0x10);
} else {
ui->lbIcon->setPixmap(QIcon(":/res/l/network-online.png").pixmap(32,32));
}
} else {
if (!QIcon::fromTheme("network-wired-disconnected-symbolic").isNull()) {
ui->lbIcon->setPixmap(QIcon::fromTheme("network-wired-disconnected-symbolic").pixmap(32,32));
ui->lbIcon->setProperty("useIconHighlightEffect", 0x10);
} else {
ui->lbIcon->setPixmap(QIcon(":/res/l/network-offline.png").pixmap(32,32));
}
}
}
//设置item下方横线的可见与否
void OneLancForm::setLine(bool isShow)
{
if (isShow) {
ui->line->show();
} else {
ui->line->hide();
}
}
void OneLancForm::slotConnLan()
{
//mw->startLoading();
this->startWaiting(true);
//emit sigConnLan(ui->lbName->text(), ifName);
emit sigConnLan(uuidName, ifName, m_sConnectType);
}
//点击网络断开按钮,执行该函数
void OneLancForm::on_btnDisConn_clicked()
{
qDebug()<<"DisConnect button about lan net is clicked, current wired net name is "<<ui->lbName->text();
m_wiredConnectOperation->deactivateWiredConnection(ssidName, uuidName);
#if 0
this->startWaiting(false);
mw->is_stop_check_net_state = 1;
//使用有线网ssid断开网络
//kylin_network_set_con_down(ssidName.toUtf8().data());
//使用有线网uuid断开网络
//kylin_network_set_con_down(uuidName.toUtf8().data());
m_networkConnect->deactivateConnection(ui->lbName->text(), uuidName);
//使用dbus接口断开网络
//toDisConnWiredNetwork(uuidName);
disconnect(this, SIGNAL(selectedOneLanForm(QString, QString)), mw, SLOT(oneTopLanFormSelected(QString, QString)));
emit requestHandleLanDisconn();
#endif
}
void OneLancForm::toDisConnWiredNetwork(QString netUuid)
{
QDBusInterface interface( "org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",
"org.freedesktop.DBus.Properties",
QDBusConnection::systemBus() );
//获取已经连接了那些网络,及这些网络对应的网络类型(ethernet or wifi)
QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager", "ActiveConnections");
QList<QVariant> outArgs = result.arguments();
QVariant first = outArgs.at(0);
QDBusVariant dbvFirst = first.value<QDBusVariant>();
QVariant vFirst = dbvFirst.variant();
QDBusArgument dbusArgs = vFirst.value<QDBusArgument>();
QDBusObjectPath activeConnPath;
dbusArgs.beginArray();
while (!dbusArgs.atEnd()) {
dbusArgs >> activeConnPath;
QDBusInterface interfacePro( "org.freedesktop.NetworkManager",
activeConnPath.path(),
"org.freedesktop.DBus.Properties",
QDBusConnection::systemBus() );
QDBusReply<QVariant> replyUuid = interfacePro.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Uuid");
if (replyUuid.value().toString() == netUuid) {
//断开当前连接网络
QDBusInterface disConnIf("org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",
"org.freedesktop.NetworkManager",
QDBusConnection::systemBus() );
QDBusReply<QDBusObjectPath> disReply = disConnIf.call("DeactivateConnection", QVariant::fromValue(activeConnPath));
}
}
dbusArgs.endArray();
}
//点击了连接网络按钮,执行该函数
void OneLancForm::on_btnConn_clicked()
{
qDebug()<<"A button named btnConn about lan net is clicked.";
toConnectWiredNetwork();
}
//点击了item被扩展中的连接网络按钮执行该函数
void OneLancForm::on_btnConnSub_clicked()
{
qDebug()<<"A button named btnConnSub about lan net is clicked.";
toConnectWiredNetwork();
}
void OneLancForm::toConnectWiredNetwork()
{
/*
if (mw->is_stop_check_net_state == 1) {
return;
}
mw->is_stop_check_net_state = 1;
QThread *t = new QThread();
BackThread *bt = new BackThread();
bt->moveToThread(t);
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
connect(t, SIGNAL(started()), this, SLOT(slotConnLan()));
connect(this, SIGNAL(sigConnLan(QString, QString, QString)), bt, SLOT(execConnLan(QString, QString, QString)));
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connLanDone(int)));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
t->start();
*/
QString devName = "enp2s0";
m_wiredConnectOperation->activateWiredConnection(uuidName, devName);
}
//点击列表中item扩展后显示信息的位置时执行该函数用于显示网络配置界面
void OneLancForm::on_btnInfo_clicked()
{
QPoint pos = QCursor::pos();
QRect primaryGeometry;
for (QScreen *screen : qApp->screens()) {
if (screen->geometry().contains(pos)) {
primaryGeometry = screen->geometry();
}
}
if (primaryGeometry.isEmpty()) {
primaryGeometry = qApp->primaryScreen()->geometry();
}
BackThread *bt = new BackThread();
QString connProp = bt->getConnProp(uuidName);
QStringList propList = connProp.split("|");
QString v4method, addr, mask, gateway, dns, v6method, v6addr;
foreach (QString line, propList) {
if (line.startsWith("method:")) {
v4method = line.split(":").at(1);
}
if (line.startsWith("v4addr:")) {
addr = line.split(":").at(1);
}
if (line.startsWith("mask:")) {
mask = line.split(":").at(1);
}
if (line.startsWith("v6method:")) {
v6method = line.split(":").at(1);
}
if (line.startsWith("v6addr:")) {
v6addr = line.right(line.length() - line.indexOf(":") - 1);
}
if (line.startsWith("gateway:")) {
gateway= line.split(":").at(1);
}
if (line.startsWith("dns:")) {
dns = line.split(":").at(1);
}
}
// qDebug()<<v4method<<addr<<mask<<gateway<<dns;
connect(cf, SIGNAL(requestRefreshLanList(int)), mw, SLOT(onBtnNetListClicked(int)));
cf->setProp(ui->lbName->text(), uuidName, v4method, addr, v6method, v6addr, mask, gateway, dns, this->isActive, false);
qDebug() << Q_FUNC_INFO << __LINE__ << ui->lbName->text() << uuidName;
cf->move(primaryGeometry.width() / 2 - cf->width() / 2, primaryGeometry.height() / 2 - cf->height() / 2);
cf->show();
cf->raise();
cf->activateWindow();
bt->deleteLater();
}
void OneLancForm::waitAnimStep()
{
QString qpmQss = "QLabel{background-image:url(':/res/s/conning-a/";
qpmQss.append(QString::number(this->waitPage));
qpmQss.append(".png');}");
ui->lbWaitingIcon->setStyleSheet(qpmQss);
this->waitPage ++;
if (this->waitPage > TOTAL_PAGE) {
this->waitPage = 1; //循环播放8张图片
}
this->countCurrentTime += FRAME_SPEED;
if (this->countCurrentTime >= LIMIT_TIME) {
QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程
int status = system(cmd.toUtf8().data());
if (status != 0) {
qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed";
}
this->stopWaiting(); //动画超出时间限制,强制停止动画
mw->is_stop_check_net_state = 0;
}
}
void OneLancForm::startWaiting(bool isToConnect)
{
if (isToConnect) {
ui->btnCancel->show();
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}");
} else {
ui->lbWaitingIcon->move(ui->lbWaitingIcon->x() - 24, ui->lbWaitingIcon->y());
ui->btnDisConn->hide();
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);}");
}
this->countCurrentTime = 0;
this->waitPage = 1; //总共有8张图片
this->waitTimer->start(FRAME_SPEED);
ui->lbWaiting->show();
ui->lbWaitingIcon->show();
mw->setTrayLoading(true);
}
void OneLancForm::stopWaiting()
{
ui->lbWaitingIcon->move(380, 20);
ui->btnCancel->hide();
this->waitTimer->stop();
ui->lbWaiting->hide();
ui->lbWaitingIcon->hide();
KylinDBus myKylinDbus;
QList<QString> actLanSsidUuidState = myKylinDbus.getAtiveLanSsidUuidState();
if (actLanSsidUuidState.size() >= 3) {
for (int i=0; i<actLanSsidUuidState.size()-1; i++) {
if (actLanSsidUuidState.at(i) == uuidName && actLanSsidUuidState.at(i+1) == "connecting") {
kylin_network_set_con_down(uuidName.toUtf8().data());
}
}
}
mw->setTrayLoading(false);
mw->getActiveInfoAndSetTrayIcon();
}
void OneLancForm::updateNetworkSpeed()
{
KyWiredWidget *wiredWidget = (KyWiredWidget *)parentWidget();
// wiredWidget->updateDeviceRefreshRate(m_wiredConnectItem->m_ifaceName, 1000);
// wiredWidget->updateNetworkSpeed(m_wiredConnectItem);
return;
}
void OneLancForm::on_btnCancel_clicked()
{
QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程
int status = system(cmd.toUtf8().data());
if (status != 0) {
qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'on_btnCancel_clicked' failed";
}
KylinDBus myKylinDbus;
QList<QString> lanSsidAndUuid = myKylinDbus.getAtiveLanSsidUuidState();
if (lanSsidAndUuid.contains(uuidName)) {
kylin_network_set_con_down(uuidName.toUtf8().data());
}
this->stopWaiting();
mw->is_stop_check_net_state = 0;
}

View File

@ -1,140 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef ONELANCFORM_H
#define ONELANCFORM_H
#include <QWidget>
#include <QScreen>
#include <QThread>
#include <QEvent>
#include "confform.h"
#include "kylin-network-interface.h"
#include "backend/dbus-interface/kylinwiredconnectoperation.h"
#include "backthread.h"
#include "ksimplenm.h"
#include "backend/dbus-interface/kylinconnectitem.h"
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusObjectPath>
#include <QDBusReply>
#include <QDBusObjectPath>
#include <QVariant>
#include <QVariantMap>
#define FRAME_SPEED 150
#define LIMIT_TIME 60*1000
#define TOTAL_PAGE 8
#define W_ITEM 424
#define H_ITEM 60
#define H_ITEM_EXTEND 162
#define Y_LINE 59
#define X_LINE 2
#define Y_LINE_EXTEND 161
#define X_LINE_EXTEND 2
class OldMainWindow;
namespace Ui {
class OneLancForm;
}
class OneLancForm : public QWidget
{
Q_OBJECT
public:
explicit OneLancForm(QWidget *parent = 0, KyConnectItem *wiredConnectItem = 0);
~OneLancForm();
public:
void constructConnectionItem(int index);
void constructActiveConnectionItem(int index);
void constructActiveConnectionEmptyItem();
void setLanName(QString ssid, QString transSsid, QString uuid, QString interface);
void setIcon(bool isOn);
void setLine(bool isShow);
void setLanInfo(QString str1, QString str2, QString str3, QString str4);
void setSelected(bool isSelected, bool isCurrName);
void setTopItem(bool isSelected);
void setAct(bool isAct);
void setConnedString(bool showLable, QString str, QString ifname);
bool isSelected;
bool isTopItem;
bool isActive;
bool isConnected;
QString ssidName;
QString m_sConnectType;
QString uuidName;
QString ifName;
public slots:
void waitAnimStep();
void startWaiting(bool isToConnect);
void stopWaiting();
void updateNetworkSpeed();
protected:
void mousePressEvent(QMouseEvent *event);
bool eventFilter(QObject *obj, QEvent *event);
private slots:
void on_btnConn_clicked();
void on_btnConnSub_clicked();
void on_btnDisConn_clicked();
void toConnectWiredNetwork();
void toDisConnWiredNetwork(QString netUuid);
void slotConnLan();
void on_btnInfo_clicked();
void on_btnCancel_clicked();
private:
QTimer *waitTimer = nullptr;
QTimer *m_updateSpeedTimer = nullptr;
int waitPage;
int countCurrentTime;
Ui::OneLancForm *ui = nullptr;
OldMainWindow *mw = nullptr;
ConfForm *cf = nullptr;
KSimpleNM *ks = nullptr;
KyWiredConnectOperation *m_wiredConnectOperation = nullptr;
QString leQssLow, leQssHigh;
KyConnectItem *m_wiredConnectItem = nullptr;
signals:
void selectedOneLanForm(QString lanName, QString uniqueName);
void connDone(int connFlag);
void requestHandleLanDisconn();
void sigConnLan(QString, QString, QString);
};
#endif // ONELANCFORM_H

File diff suppressed because it is too large Load Diff

View File

@ -1,458 +1,125 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "ksimplenm.h"
#include "loadingdiv.h"
#include "confform.h"
#include "kylin-dbus-interface.h"
#include "kylin-network-interface.h"
#include "utils.h"
#include "switchbutton.h"
#include "backend/dbus-interface/kylinnetworkresourcemanager.h"
#include "kylinwiredwidget.h"
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <unistd.h>
#include <xcb/xcb.h>
#include <QMainWindow>
#include <QWidget>
#include <QLabel>
#include <QTableWidget>
#include <QGSettings/QGSettings>
#include <QTimer>
#include <QSystemTrayIcon>
#include <QDesktopWidget>
#include <QScrollBar>
#include <QScrollArea>
#include <QPushButton>
#include <QScreen>
#include <QMenu>
#include <QAction>
#include <QAction>
#include <QHBoxLayout>
#include <QPainter>
#include <QPainterPath>
#include <QDebug>
#include <QString>
#include <QTimer>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusObjectPath>
#include <QDBusObjectPath>
#include <QVariant>
#include <QStandardPaths>
#include <QStringList>
#include <QToolTip>
#include <QSvgRenderer>
//#include <kysec/libkysec.h>
//#include <kysec/status.h>
//#include <QMessageBox>
#include <QDBusInterface>
#include "lanpage.h"
#include "wlanpage.h"
#include "netdetails/netdetail.h"
#define W_LEFT_AREA 41
#define W_VERTICAL_LINE 1 //左边竖线宽度
#define W_RIGHT_AREA 438 //41 + 1 + 438 = 480
#define L_VERTICAL_LINE_TO_ITEM 4 //竖线到item左侧的距离
class LanPage;
#define X_LEFT_WIFI_BALL 416 //白色小球在左边
#define X_RIGHT_WIFI_BALL 440 //白色小球在右边
#define Y_WIFI_BALL 23 //白色小球y坐标
#define X_ITEM 46 //item到窗口左侧的距离 41 + 1 + 4 = 46
#define W_ITEM 424
#define Y_TOP_ITEM 57 //顶部item、topLanListWidget、topWifiListWidget的y坐标
#define H_NORMAL_ITEM 60 //一个没有扩展的普通item的高度
#define H_GAP_UP 10 //H_NORMAL_ITEM 与 H_MIDDLE_WORD之间的间距
#define H_MIDDLE_WORD 46 //"显示可用网络列表的label"
#define H_GAP_DOWN 5 //57 + 60 + 10 + 46 + 5 = 178
#define X_MIDDLE_WORD 19
#define W_MIDDLE_WORD 260
#define H_LAN_ITEM_EXTEND 102 //162 - 60
#define H_WIFI_ITEM_BIG_EXTEND 78 //138 - 60
#define H_WIFI_ITEM_SMALL_EXTEND 46 //106 - 60
#define Y_SCROLL_AREA 178
#define W_SCROLL_AREA 450
#define H_SCROLL_AREA 360
#define W_TOP_LIST_WIDGET 435
#define W_LIST_WIDGET 440
#define W_BTN_FUN 59
#define H_BTN_FUN 14
#define X_BTN_FUN 360
#define Y_BTN_FUN 87 //新建网络加入网络按钮的宽高、x坐标、y坐标
#define W_NO_ITEM_TIP 240
#define H_NO_ITEM_TIP 24
#define DBUS_NAME "org.ukui.SettingsDaemon"
#define DBUS_PATH "/org/ukui/SettingsDaemon/wayland"
#define DBUS_INTERFACE "org.ukui.SettingsDaemon.wayland"
#define LOAD_WIFI_LIST 0
#define UPDATE_WIFI_LIST 1
#define RECONNECT_WIFI 2
#define REFRESH_WIFI 3
class OneConnForm;
class ConfForm;
class KyWiredWidget;
namespace Ui {
class MainWindow;
}
class OldMainWindow : public QMainWindow
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit OldMainWindow(QWidget *parent = 0);
~OldMainWindow();
explicit MainWindow(QWidget *parent = nullptr);
void showMainwindow();
void hideMainwindow();
void justShowTrayIcon();
void setWiredDefaultDevice(QString deviceName);
void setWirelessDefaultDevice(QString deviceName);
void editQssString();
void createTopLanUI();
void createTopWifiUI();
void createOtherUI();
void createListAreaUI();
void createLeftAreaUI();
//for dbus
void getWirelessList(QMap<QString, QVector<QStringList> > &map);
void getWiredList(QMap<QString, QVector<QStringList>> &map);
//开启热点
void activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
//断开热点
void deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
//获取热点
void getStoredApInfo(QStringList &list);
//有线连接断开
void activateWired(const QString& devName, const QString& connUuid);
void deactivateWired(const QString& devName, const QString& connUuid);
//无线连接断开
void activateWireless(const QString& devName, const QString& ssid);
void deactivateWireless(const QString& devName, const QString& ssid);
void startLoading();
void stopLoading();
void setTrayIcon(QIcon icon);
void setTrayIconOfWifi(int);
void setTrayLoading(bool isLoading);
void getActiveInfoAndSetTrayIcon();
void initTimer();
void checkIsWirelessDevicePluggedIn();
void initActNetDNS();
void PrimaryManager();
void toStart();
int getScreenGeometry(QString methodName);
void showPb(QString type, QString name);
QIcon iconLanOnline, iconLanOffline;
QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow;
QIcon iconConnecting;
QList<QIcon> loadIcons;
QString mwBandWidth;
KylinDBus *objKyDBus = nullptr;
NetworkSpeed *objNetSpeed = nullptr;
SwitchButton *btnWireless = nullptr;
SwitchButton *btnWired = nullptr;
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
//状态设置,0为假1为真
int current_wifi_list_state = LOAD_WIFI_LIST;
int is_init_wifi_list = 0; //是否在启动软件时正在获取wifi的列表
int is_btnLanList_clicked = 1; //是否处于有线网界面
int is_btnWifiList_clicked = 0; //是否处于无线网界面
int is_wireless_adapter_ready = 1; //主机是否插入无线网卡
int is_keep_wifi_turn_on_state = 1; //是否要执行wifi开关变为打开样式
int is_stop_check_net_state = 0; //是否要在进行其他操作时停止检查网络状态
int is_connect_net_failed = 0; //刚才是否连接网络失败
int is_wifi_reconnected = 0;//刚才是否主动重连wifi导致wifi断开
int is_fly_mode_on = 0; //是否已经打开飞行模式
int is_hot_sopt_on = 0; //是否已经打开热点
int is_connect_hide_wifi = 0; //是否正在连接隐藏wifi
int currSelNetNum = 0; //当前选中的item序号
bool isLanBeConnUp = false; //lan是否连接上
bool isWifiBeConnUp = false; //wifi是否是连接上
bool isToSetLanValue = true; //本次执行是否进行赋值
bool isToSetWifiValue = true; //本次执行是否进行赋值
bool isReconnectingWifi = false; //是否正在执行wifi的回连
bool isReconnectingLan = false; //是否正在执行lan的回连
bool m_is_inputting_wifi_password = false; //是否正在输入密码
int addNumberForWifi = 0; //短时间内收到关于wifi连接信号的次数
bool isHuaWeiPC;
bool isHuaWei9006C;
bool isHandlingWiredCableOn = false;
bool ifCanReconnectWifiNow = true;
bool isReConnAfterTurnOnWifi = false;//是否是在打开wifi的开关后回连wifi
bool isRadioWifiTurningOn = false; //是否正在打开wifi开关
bool bShowPb = false; //是否可以showPb
bool canExecHandleWifiSwitchChange = true;
QVector<QStringList> dbus_wifiList; //其他组件通过dbus接口获取到的wifi列表,第一个元素一定为已连接wifi若没有已连接wifi则显示为--
void requestRefreshWifiList(); //申请刷新wifi列表
QString currSelNetName = ""; //当前ScrollArea中选中的网络名称
QStringList canReconnectWifiList; //当前可以回连的wifi列表
QString currConnIfname = ""; //当前连接的有线网对应网卡名称,只有一个有线网连接的情况
QString oldWifiIpv4Method = ""; //原来的wifi的ipv4地址获取方式,自动还是手动
int numberForWifiScan; //该值控制wifi的扫描
int m_priX;
int m_priY;
int m_priWid;
int m_priHei;
QStringList m_wifi_list_pwd_changed; //WiFi密码以改变的WiFi列表990/9a0自动回连失败
KyNetworkDeviceResourse m_networkDevice;
void setWiredDeviceEnable(const QString& devName, bool enable);
//唤起属性页 根据网卡类型 参数2 为ssid/uuid
void showPropertyWidget(QString devName, QString ssid);
//唤起新建有线连接界面
void showCreateWiredConnectWidget(const QString devName);
signals:
//设备插拔
void deviceStatusChanged();
//设备名称变化
void deviceNameChanged(QString oldName, QString newName);
//有线无线列表更新(有线增删、无线增加减少)
void lanAdd(QString devName, QStringList info);
void lanRemove(QString dbusPath);
void lanUpdate(QString devName, QStringList info);
void wlanAdd(QString devName, QStringList info);
void wlanRemove(QString devName,QString ssid);
void wlanactiveConnectionStateChanged(QString devName, QString ssid, int status);
void lanActiveConnectionStateChanged(QString devName, QString uuid, int status);
void activateFailed(QString errorMessage);
void deactivateFailed(QString errorMessage);
//热点断开
void hotspotDeactivated(QString devName, QString ssid);
void hotspotActivated(QString devName, QString ssid);
//信号强度变化
void signalStrengthChange(QString devName, QString ssid, int strength);
//安全性变化
void secuTypeChange(QString devName, QString ssid, QString secuType);
void mainWindowVisibleChanged(const bool &visible);
public slots:
void onPhysicalCarrierChanged(bool flag);
void onCarrierUpHandle();
void onCarrierDownHandle();
void onDeleteLan();
void onNetworkDeviceAdded(QDBusObjectPath objPath);
void onNetworkDeviceRemoved(QDBusObjectPath objPath);
void getLanBandWidth();
void checkIfWiredNetExist();
void onExternalConnectionChange(QString type, bool isConnUp);
void onExternalLanChange();
void onExternalWifiChange();
void onToSetTrayIcon();
void onToResetValue();
void onWifiSwitchChange();
void onExternalWifiSwitchChange(bool wifiEnabled);
void oneLanFormSelected(QString lanName, QString uniqueName);
void oneTopLanFormSelected(QString lanName, QString uniqueName);
void oneWifiFormSelected(QString wifibssid, int extendLength);
void oneTopWifiFormSelected(QString wifibssid, int extendLength);
void on_btnHotspot_clicked();
void on_btnHotspotState();
void on_btnWifiList_clicked();
void on_wifi_changed();
void connWifiDone(int connFlag);
void onRequestRefreshWifiList();
void onRefreshWifiListAfterScan();
void onLoadWifiListAfterScan();
void onRequestReconnecWifi();
//flag =0或1为普通点击、2为收到打开信息、3为收到关闭信息、4为无线网卡插入、5为无线网卡拔出
void onBtnWifiClicked(int flag = 0);
//falg=0 UI点击1收到打开信息2收到关闭信息3有线设备插入4有线设备拔出
void onBtnLanClicked(int flag = 0);
void setLanSwitchStatus(bool is_opened);
void on_showWindowAction();
void checkIfConnectedWifiExist();
void toReconnectWifi();
void rfkillDisableWifiDone();
void rfkillEnableWifiDone();
protected:
bool eventFilter(QObject *obj, QEvent *event);
void paintEvent(QPaintEvent *event);
bool event(QEvent *event);
void keyPressEvent(QKeyEvent *event);
bool eventFilter(QObject *watched, QEvent *event) override;
private:
void firstlyStart(); //一级启动
void secondaryStart(); //二级启动
bool m_load_finished = false; //是否二级启动已执行完
QTimer * m_secondary_start_timer = nullptr; //执行二级启动的倒计时
void checkSingleAndShowTrayicon();
void initNetwork();
void createTrayIcon();
void handleIconClicked();
void showTrayIconMenu();
bool checkLanOn();
bool checkWlOn();
void getLanList();
void getWifiList();
void initLanSlistAndGetReconnectNetList();
QPixmap drawSymbolicColoredPixmap(const QPixmap &source);
QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source);
const QPixmap loadSvg(const QString &fileName, const int size);
void getSystemFontFamily();
bool m_loadFinished = false; //是否二级启动已执行完
QTimer * m_secondaryStartTimer = nullptr; //执行二级启动的倒计时
void initWindowProperties();
void initUI();
void initDbusConnnect();
void initTrayIcon();
void resetTrayIconTool();
void initWindowTheme();
void resetWindowTheme();
void showControlCenter();
Ui::MainWindow *ui;
//主窗口的主要构成控件
QTabWidget * m_centralWidget = nullptr;
QHBoxLayout * m_tabBarLayout = nullptr;
QLabel * m_lanLabel = nullptr;
QLabel * m_wlanLabel = nullptr;
LoadingDiv *loading = nullptr;
LanPage * m_lanWidget = nullptr;
WlanPage * m_wlanWidget = nullptr;
QDesktopWidget desktop;
KSimpleNM *ksnm = nullptr;
ConfForm *confForm = nullptr;
KyWiredWidget *topLanListWidget = nullptr;
QWidget *topWifiListWidget = nullptr;
KyWiredWidget *lanListWidget = nullptr;
QWidget *wifiListWidget = nullptr;
QWidget *optWifiWidget = nullptr;
//监听主题的Gsettings
QGSettings * m_styleGsettings = nullptr;
QLabel *lbLoadDown = nullptr;
QLabel *lbLoadDownImg = nullptr;
QLabel *lbLoadUp = nullptr;
QLabel *lbLoadUpImg = nullptr;
//获取和重置窗口位置
void resetWindowPosition();
QDBusInterface * m_positionInterface = nullptr;
QLabel *lbNoItemTip = nullptr;
bool ifLanConnected;
bool ifWLanConnected;
QScrollArea *scrollAreal = nullptr;
QScrollArea *scrollAreaw = nullptr;
QLabel *lbTopLanList = nullptr;
QLabel *lbTopWifiList = nullptr;
QLabel *lbLanList = nullptr;
QLabel *lbWifiList = nullptr;
QPushButton *btnAddNet = nullptr;
QPushButton *btnCreateNet = nullptr;
QSystemTrayIcon *trayIcon = nullptr;
QMenu *trayIconMenu = nullptr;
QAction *mShowWindow = nullptr;
QAction *mAdvConf = nullptr;
QWidget *widShowWindow = nullptr;
QWidget *widAdvConf = nullptr;
QString lcardname, wcardname; // 以太网卡和无线网卡名称
QString btnOffQss, btnOnQss, btnBgOffQss, btnBgOnQss, btnBgHoverQss, btnBgLeaveQss; // 主界面按钮底色
QString scrollBarQss, leftBtnQss, funcBtnQss;
QStringList oldLanSlist; //上一次获取Lan列表
QStringList oldWifiSlist; //上一次获取wifi列表
QStringList oldConnSlist; //上一次获取的以保存网络列表
bool isInitConnList = true;
bool isAddedWifi = false;
bool m_isWifiConnected = false; //专用于处理dbus获取的WiFi状态用于对比每次刷新后的WiFi连接状态变化
QString lastAddedConn = "";
QString oldActLanName = ""; //上一次获取的已连接有线网名称
QString actLanUuid = ""; //当前连接的有线网uuid
QString actLanIpv4Method = ""; //当前连接的有线网的ip获取方式
int oldDbusActLanDNS = 0; //上一次获取的已连接有线网的DNS代号
void wifiListOptimize(QStringList& slist); //只保留同名同频信号最优AP
QVector<QStringList> repetitionFilter(QVector<QStringList>);
QStringList priorityList(QStringList);
QStringList sortApByCategory(QStringList,int);
QStringList sortApByFreq(QStringList,int, int);
void getFinalWifiList(QStringList& slist); //获取应该显示在wifi列表中的最优列表参数
QVector<structWifiProperty> connectableWifiPriorityList(const QStringList slist); //可连接wifi优先级列表
void devListSort(QVector<structWifiProperty> *list);
static bool subDevListSort(const structWifiProperty&info1,const structWifiProperty&info2);
//循环检测网络连接状态
QTimer *iconTimer = nullptr;
QTimer *wiredCableUpTimer = nullptr;
QTimer *wiredCableDownTimer = nullptr;
QTimer *deleteLanTimer = nullptr;
QTimer *checkWifiListChanged = nullptr;
QTimer *checkIfLanConnect = nullptr;
QTimer *checkIfWifiConnect = nullptr;
QTimer *checkIfNetworkOn = nullptr;
QTimer *setNetSpeed = nullptr;
int currentIconIndex;
int activeWifiSignalLv;
int disconnect_time = 0;
int currTopLanItem = 1; //当前连接的有线网个数
long int start_rcv_rates = 0; //保存开始时的流量计数
long int end_rcv_rates = 0; //保存结束时的流量计数
long int start_tx_rates = 0; //保存开始时的流量计数
long int end_tx_rates = 0; //保存结束时的流量计数
QString actWifiSsid = "--"; //当前连接wifi的ssid
QStringList actWifiBssidList; //当前连接wifi的bssid
QString actWifiUuid = "--"; //当前连接wifi的uuid
// QString hasStarWifiInfo; //nmcli命令获取的wifi列表中已经连接的wifi in-use熟悉会有一个*
// QString hasStarWifiName;
bool hasWifiConnected;//当前是否有wifi连接
bool m_connected_by_self = false; //是否在本进程执行的连接操作
QDBusInterface *mDbusXrandInter;
QDBusInterface *kdsDbus;
//托盘图标,托盘图标右键菜单
QSystemTrayIcon * m_trayIcon = nullptr;
QMenu * m_trayIconMenu = nullptr;
QAction * m_showMainwindowAction = nullptr;
QAction * m_showSettingsAction = nullptr;
private slots:
void iconActivated(QSystemTrayIcon::ActivationReason reason);
void onBtnNetClicked();
// void on_btnWifiList_clicked();
void onBtnNetListClicked(int flag=0);
void onBtnNetListClickeds(int flag=0);
void onNewConnAdded(int type);
void onRequestRevalueUpdateWifi();
void getLanListDone(QStringList slist);
void getWifiListDone(QStringList slist);
void getConnListDone(QStringList slist);
void loadWifiListDone(QStringList slist);
void updateWifiListDone(QStringList slist);
QString TranslateLanName(QString lanName);
QString getMacByUuid(QString uuidName);
void on_btnAdvConf_clicked();
void handleLanDisconn();
void handleWifiDisconn();
void handleWifiDisconnLoading();
void onRequestScanAccesspoint();
void toScanWifi(bool isShow);
void on_setNetSpeeds(qulonglong rx, qulonglong tx);
void on_setNetSpeed();
void on_checkOverTime();
// 后台回调
void enNetDone();
void disNetDone();
void enWifiDone();
void disWifiDone();
void disWifiStateKeep();
void disWifiDoneChangeUI();
void connLanDone(int connFlag);
// void connWifiDone(int connFlag);
void iconStep();
void on_btnFlyMode_clicked();
void onBtnAddNetClicked();
void onBtnCreateNetClicked();
void actionTriggerSlots();
void priScreenChanged(int x, int y, int width, int height);
void onRfkillStatusChanged();
signals:
void showPbSignal(QSystemTrayIcon::ActivationReason act);
void disConnSparedNet(QString type);
void refreshWifiListAfterScan();
void loadWifiListAfterScan();
void carrierDownHandle();
void waitLanStop();
void configurationChanged(); //通知控制面板更新IP的信号
void reConnectWifi(const QString& uuid);
void actWifiSignalLvChanaged(const int& currentLevel);
void getWifiListFinished();
void startReconnectWifi(const QString& ssid);
void stopReconnectWifi(const QString& ssid, const int& result);
void wiredConnectionAdded();
void wiredConnectionRemoved();
void actWiredConnectionChanged();
void requestReconnecWifi();
void wifiClicked(QString);
void lanClicked(QString);
void onWiredDeviceChanged(const bool&);
void onTrayIconActivated();
void onShowMainwindowActionTriggled();
void onShowSettingsActionTriggled();
void onThemeChanged(const QString &key);
void onRefreshTrayIcon();
};
#endif // MAINWINDOW_H

View File

@ -1,316 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>490</width>
<height>538</height>
</rect>
</property>
<property name="windowTitle">
<string>kylin-nm</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QLabel" name="lbBtnNetBG">
<property name="geometry">
<rect>
<x>1</x>
<y>200</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnNet">
<property name="geometry">
<rect>
<x>2</x>
<y>200</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbBtnWifiBG">
<property name="geometry">
<rect>
<x>412</x>
<y>20</y>
<width>50</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnAdvConf">
<property name="geometry">
<rect>
<x>2</x>
<y>490</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnHotspot">
<property name="geometry">
<rect>
<x>2</x>
<y>348</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnFlyMode">
<property name="geometry">
<rect>
<x>2</x>
<y>395</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbNetwork">
<property name="geometry">
<rect>
<x>61</x>
<y>22</y>
<width>80</width>
<height>20</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbBtnWifiBall">
<property name="geometry">
<rect>
<x>440</x>
<y>22</y>
<width>20</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbHotImg">
<property name="geometry">
<rect>
<x>11</x>
<y>359</y>
<width>19</width>
<height>19</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbFlyImg">
<property name="geometry">
<rect>
<x>11</x>
<y>405</y>
<width>19</width>
<height>19</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbNetListBG">
<property name="geometry">
<rect>
<x>2</x>
<y>10</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbWifiListBG">
<property name="geometry">
<rect>
<x>2</x>
<y>57</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbHotBG">
<property name="geometry">
<rect>
<x>2</x>
<y>348</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbFlyBG">
<property name="geometry">
<rect>
<x>2</x>
<y>395</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnNetList">
<property name="geometry">
<rect>
<x>2</x>
<y>10</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnWifiList">
<property name="geometry">
<rect>
<x>2</x>
<y>57</y>
<width>37</width>
<height>37</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="vLine">
<property name="geometry">
<rect>
<x>41</x>
<y>0</y>
<width>1</width>
<height>538</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(156, 156, 156,0.1);</string>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QPushButton" name="btnNetListImg">
<property name="geometry">
<rect>
<x>8</x>
<y>18</y>
<width>24</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnWifiListImg">
<property name="geometry">
<rect>
<x>8</x>
<y>65</y>
<width>24</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnConfImg">
<property name="geometry">
<rect>
<x>8</x>
<y>497</y>
<width>24</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<zorder>lbFlyBG</zorder>
<zorder>lbHotBG</zorder>
<zorder>lbFlyImg</zorder>
<zorder>lbHotImg</zorder>
<zorder>lbBtnNetBG</zorder>
<zorder>btnNet</zorder>
<zorder>lbBtnWifiBG</zorder>
<zorder>btnHotspot</zorder>
<zorder>btnFlyMode</zorder>
<zorder>lbBtnWifiBall</zorder>
<zorder>lbNetListBG</zorder>
<zorder>lbWifiListBG</zorder>
<zorder>lbNetwork</zorder>
<zorder>vLine</zorder>
<zorder>btnNetListImg</zorder>
<zorder>btnNetList</zorder>
<zorder>btnWifiListImg</zorder>
<zorder>btnConfImg</zorder>
<zorder>btnWifiList</zorder>
<zorder>btnAdvConf</zorder>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -1,506 +0,0 @@
#include "new-mainwindow.h"
#include "customstyle.h"
#include <KWindowEffects>
#include <QApplication>
#include <QDebug>
#include <QDBusReply>
#include <QKeyEvent>
#include <QProcess>
#include "kylinnetworkdeviceresource.h"
#include "../backend/dbus-interface/kylinagentinterface.h"
#define MAINWINDOW_WIDTH 420
#define MAINWINDOW_HEIGHT 456
#define THEME_SCHAME "org.ukui.style"
#define COLOR_THEME "styleName"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
firstlyStart();
}
/**
* @brief MainWindow::showMainwindow show主窗口dbus接口提供给外部组件调用
*/
void MainWindow::showMainwindow()
{
if (!m_loadFinished) {
m_secondaryStartTimer->stop();
secondaryStart();
}
this->resetWindowPosition();
this->showNormal();
this->raise();
this->activateWindow();
emit this->mainWindowVisibleChanged(true);
}
/**
* @brief MainWindow::hideMainwindow
*/
void MainWindow::hideMainwindow()
{
this->hide();
emit this->mainWindowVisibleChanged(false);
}
/**
* @brief MainWindow::setWiredDefaultDevice 线
*/
void MainWindow::setWiredDefaultDevice(QString deviceName)
{
m_lanWidget->updateDefaultDevice(deviceName);
}
/**
* @brief MainWindow::hideMainwindow 线
*/
void MainWindow::setWirelessDefaultDevice(QString deviceName)
{
m_wlanWidget->updateDefaultDevice(deviceName);
}
/**
* @brief MainWindow::firstlyStart
*/
void MainWindow::firstlyStart()
{
initWindowProperties();
initUI();
initDbusConnnect();
initWindowTheme();
initTrayIcon();
installEventFilter(this);
m_secondaryStartTimer = new QTimer(this);
connect(m_secondaryStartTimer, &QTimer::timeout, this, [ = ]() {
m_secondaryStartTimer->stop();
secondaryStart();//满足条件后执行比较耗时的二级启动
});
m_secondaryStartTimer->start(5 * 1000);
//加载key ring
agent_init();
}
/**
* @brief MainWindow::secondaryStart
*/
void MainWindow::secondaryStart()
{
if (m_loadFinished)
return;
m_loadFinished = true;
}
/**
* @brief MainWindow::initWindowProperties
*/
void MainWindow::initWindowProperties()
{
this->setWindowTitle(tr("kylin-nm"));
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")));
this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT);
// //绘制毛玻璃特效
// this->setAttribute(Qt::WA_TranslucentBackground, true);
// QPainterPath path;
// auto rect = this->rect();
// path.addRoundedRect(rect, 6, 6);
// KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
/**
* @brief MainWindow::initUI
*/
void MainWindow::initUI()
{
m_centralWidget = new QTabWidget(this);
this->setCentralWidget(m_centralWidget);
m_centralWidget->tabBar()->setFixedWidth(this->width());
m_lanWidget = new LanPage(m_centralWidget);
m_wlanWidget = new WlanPage(m_centralWidget);
connect(this, &MainWindow::mainWindowVisibleChanged, m_wlanWidget, &WlanPage::onMainWindowVisibleChanged);
// m_centralWidget->addTab(m_lanWidget, QIcon::fromTheme("network-wired-connected-symbolic", QIcon::fromTheme("network-wired-symbolic", QIcon(":/res/l/network-online.svg"))), tr("LAN"));
// m_centralWidget->addTab(m_wlanWidget, QIcon::fromTheme("network-wireless-signal-excellent-symbolic", QIcon(":/res/x/wifi-list-bg.svg")), tr("WLAN"));
m_centralWidget->addTab(m_lanWidget, tr(""));
m_centralWidget->addTab(m_wlanWidget,tr(""));
m_tabBarLayout = new QHBoxLayout(this);
m_lanLabel = new QLabel(tr("LAN"));
m_lanLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
m_wlanLabel = new QLabel(tr("WLAN"));
m_wlanLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
m_tabBarLayout->addWidget(m_lanLabel);
m_tabBarLayout->addWidget(m_wlanLabel);
m_centralWidget->tabBar()->setLayout(m_tabBarLayout);
}
/**
* @brief MainWindow::initTrayIcon
*/
void MainWindow::initTrayIcon()
{
m_trayIcon = new QSystemTrayIcon();
m_trayIconMenu = new QMenu();
m_showMainwindowAction = new QAction(tr("Show MainWindow"),this);
m_showSettingsAction = new QAction(tr("Settings"),this);
m_trayIcon->setToolTip(QString(tr("kylin-nm")));
m_showSettingsAction->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) );
m_trayIconMenu->addAction(m_showMainwindowAction);
m_trayIconMenu->addAction(m_showSettingsAction);
m_trayIcon->setContextMenu(m_trayIconMenu);
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated);
connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled);
connect(m_showSettingsAction, &QAction::triggered, this, &MainWindow::onShowSettingsActionTriggled);
m_trayIcon->show();
}
void MainWindow::initDbusConnnect()
{
connect(m_lanWidget, &LanPage::deviceStatusChanged, this, &MainWindow::deviceStatusChanged);
connect(m_lanWidget, &LanPage::deviceNameChanged, this, &MainWindow::deviceNameChanged);
connect(m_wlanWidget, &WlanPage::deviceStatusChanged, this, &MainWindow::deviceStatusChanged);
connect(m_wlanWidget, &WlanPage::deviceNameChanged, this, &MainWindow::deviceNameChanged);
connect(m_wlanWidget, &WlanPage::activateFailed, this, &MainWindow::activateFailed);
connect(m_wlanWidget, &WlanPage::deactivateFailed, this, &MainWindow::deactivateFailed);
connect(m_lanWidget, &LanPage::activateFailed, this, &MainWindow::activateFailed);
connect(m_lanWidget, &LanPage::deactivateFailed, this, &MainWindow::deactivateFailed);
connect(m_lanWidget, &LanPage::lanAdd, this, &MainWindow::lanAdd);
connect(m_lanWidget, &LanPage::lanRemove, this, &MainWindow::lanRemove);
connect(m_lanWidget, &LanPage::lanUpdate, this, &MainWindow::lanUpdate);
connect(m_lanWidget, &LanPage::lanActiveConnectionStateChanged, this, &MainWindow::lanActiveConnectionStateChanged);
connect(m_lanWidget, &LanPage::lanConnectChanged, this, &MainWindow::onRefreshTrayIcon);
connect(m_wlanWidget, &WlanPage::wlanAdd, this, &MainWindow::wlanAdd);
connect(m_wlanWidget, &WlanPage::wlanRemove, this, &MainWindow::wlanRemove);
connect(m_wlanWidget, &WlanPage::wlanActiveConnectionStateChanged, this, &MainWindow::wlanactiveConnectionStateChanged);
connect(m_wlanWidget, &WlanPage::hotspotDeactivated, this, &MainWindow::hotspotDeactivated);
connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated);
connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange);
connect(m_wlanWidget, &WlanPage::signalStrengthChange, this, &MainWindow::signalStrengthChange);
connect(m_wlanWidget, &WlanPage::wlanConnectChanged, this, &MainWindow::onRefreshTrayIcon);
}
/**
* @brief MainWindow::resetWindowPosition
*/
void MainWindow::resetWindowPosition()
{
#define MARGIN 4
#define PANEL_TOP 1
#define PANEL_LEFT 2
#define PANEL_RIGHT 3
//#define PANEL_BOTTOM 4
if (!m_positionInterface) {
m_positionInterface = new QDBusInterface("org.ukui.panel",
"/panel/position",
"org.ukui.panel",
QDBusConnection::sessionBus());
}
QDBusReply<QVariantList> reply = m_positionInterface->call("GetPrimaryScreenGeometry");
//reply获取的参数共5个分别是 主屏可用区域的起点x坐标主屏可用区域的起点y坐标主屏可用区域的宽度主屏可用区域高度任务栏位置
if (!m_positionInterface->isValid() || !reply.isValid() || reply.value().size() < 5) {
qCritical() << QDBusConnection::sessionBus().lastError().message();
this->setGeometry(0, 0, this->width(), this->height());
return;
}
QVariantList position_list = reply.value();
int position = position_list.at(4).toInt();
switch(position){
case PANEL_TOP:
//任务栏位于上方
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + MARGIN,
this->width(), this->height());
break;
//任务栏位于左边
case PANEL_LEFT:
this->setGeometry(position_list.at(0).toInt() + MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
break;
//任务栏位于右边
case PANEL_RIGHT:
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
break;
//任务栏位于下方
default:
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
break;
}
qDebug() << " Position of ukui-panel is " << position << "; Position of mainwindow is " << this->geometry() << "." << Q_FUNC_INFO << __LINE__;
}
/**
* @brief MainWindow::resetTrayIconTool tooltip
*/
void MainWindow::resetTrayIconTool()
{
//ZJP_TODO 检测当前连接的是有线还是无线是否可用设置图标和tooltip,图标最好提前define
// int connectivity = objKyDBus->getNetworkConectivity();
// qDebug() << "Value of current network Connectivity property : "<< connectivity;
// switch (connectivity) {
// case UnknownConnectivity:
// case Portal:
// case Limited:
// setTrayIcon(iconLanOnlineNoInternet);
// trayIcon->setToolTip(QString(tr("Network Connected But Can Not Access Internet")));
// break;
// case NoConnectivity:
// case Full:
// setTrayIcon(iconLanOnline);
// trayIcon->setToolTip(QString(tr("kylin-nm")));
// break;
// }
qDebug() << "Has set tray icon to be XXX." << Q_FUNC_INFO << __LINE__;
}
/**
* @brief MainWindow::initWindowTheme
*/
void MainWindow::initWindowTheme()
{
const QByteArray style_id(THEME_SCHAME);
if (QGSettings::isSchemaInstalled(style_id)) {
m_styleGsettings = new QGSettings(style_id);
// resetWindowTheme();
connect(m_styleGsettings, &QGSettings::changed, this, &MainWindow::onThemeChanged);
} else {
qWarning() << "Gsettings interface \"org.ukui.style\" is not exist!" << Q_FUNC_INFO << __LINE__;
}
}
/**
* @brief MainWindow::resetWindowTheme
*/
void MainWindow::resetWindowTheme()
{
if (!m_styleGsettings) { return; }
QString currentTheme = m_styleGsettings->get(COLOR_THEME).toString();
auto app = static_cast<QApplication*>(QCoreApplication::instance());
if(currentTheme == "ukui-dark" || currentTheme == "ukui-black"){
app->setStyle(new CustomStyle("ukui-dark"));
qDebug() << "Has set color theme to ukui-dark." << Q_FUNC_INFO << __LINE__;
emit qApp->paletteChanged(qApp->palette());
return;
}
app->setStyle(new CustomStyle("ukui-light"));
qDebug() << "Has set color theme to " << currentTheme << Q_FUNC_INFO << __LINE__;
emit qApp->paletteChanged(qApp->palette());
return;
}
/**
* @brief MainWindow::showControlCenter
*/
void MainWindow::showControlCenter()
{
QProcess process;
if (m_lanWidget->m_isLanConnected == false && m_wlanWidget->m_wlanIsConnected == true){
process.startDetached("ukui-control-center --wlanconnect");
} else {
process.startDetached("ukui-control-center --wiredconnect");
}
}
/**
* @brief MainWindow::onTrayIconActivated
*/
void MainWindow::onTrayIconActivated()
{
if (this->isVisible()) {
qDebug() << "Received signal of tray icon activated, will hide mainwindow." << Q_FUNC_INFO << __LINE__;
hideMainwindow();
return;
}
qDebug() << "Received signal of tray icon activated, will show mainwindow." << Q_FUNC_INFO << __LINE__;
this->showMainwindow();
}
void MainWindow::onShowMainwindowActionTriggled()
{
showMainwindow();
}
void MainWindow::onShowSettingsActionTriggled()
{
showControlCenter();
}
void MainWindow::onThemeChanged(const QString &key)
{
if (key == COLOR_THEME) {
qDebug() << "Received signal of theme changed, will reset theme." << Q_FUNC_INFO << __LINE__;
// resetWindowTheme();
emit qApp->paletteChanged(qApp->palette());
} else {
qDebug() << "Received signal of theme changed, key=" << key << " will do nothing." << Q_FUNC_INFO << __LINE__;
}
}
void MainWindow::onRefreshTrayIcon()
{
//更新托盘图标显示
if (m_lanWidget->m_isLanConnected == true){
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
} else if (m_wlanWidget->m_wlanIsConnected == true && m_lanWidget->m_isLanConnected == false){
m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic"));
} else if (m_wlanWidget->m_wlanIsConnected == false && m_lanWidget->m_isLanConnected == false){
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-disconnected-symbolic"));
}
}
/**
* @brief MainWindow::keyPressEvent esc键关闭主界面
* @param event
*/
void MainWindow::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape) {
hideMainwindow();
}
return QWidget::keyPressEvent(event);
}
/**
* @brief MainWindow::eventFilter
* @param watched
* @param event
* @return
*/
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::ActivationChange) {
if(QApplication::activeWindow() != this) {
hideMainwindow();
}
}
return QMainWindow::eventFilter(watched,event);
}
/**
* @brief MainWindow::getWirelessList wifi列表dbus调用
* @param map
*/
void MainWindow::getWirelessList(QMap<QString, QVector<QStringList> > &map)
{
map.clear();
if (nullptr != m_wlanWidget) {
m_wlanWidget->getWirelessList(map);
}
}
/**
* @brief MainWindow::getWiredList lan列表dbus调用
* @param map
*/
void MainWindow::getWiredList(QMap<QString, QVector<QStringList>> &map)
{
map.clear();
if (nullptr != m_lanWidget) {
m_lanWidget->getWiredList(map);
}
}
/**
* @brief MainWindow::activeWirelessAp dbus调用
* @param apName
* @param apPassword
* @param apDevice
*/
void MainWindow::activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice)
{
m_wlanWidget->activeWirelessAp(apName, apPassword, apDevice);
}
/**
* @brief MainWindow::activeWirelessAp dbus调用
* @param apName
*/
void MainWindow::deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice)
{
m_wlanWidget->deactiveWirelessAp(apName, apPassword, apDevice);
}
/**
* @brief MainWindow::activeWirelessAp dbus调用
* @param list
*/
void MainWindow::getStoredApInfo(QStringList &list)
{
m_wlanWidget->getStoredApInfo(list);
}
void MainWindow::setWiredDeviceEnable(const QString& devName, bool enable)
{
m_lanWidget->setWiredDeviceEnable(devName, enable);
}
void MainWindow::showPropertyWidget(QString devName, QString ssid)
{
KyNetworkDeviceResourse *devResourse = new KyNetworkDeviceResourse();
QStringList wiredDeviceList;
wiredDeviceList.clear();
devResourse->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDeviceList);
if (wiredDeviceList.contains(devName)) {
qDebug() << "showPropertyWidget device type wired device name " << devName << " uuid " << ssid;
m_lanWidget->showDetailPage(devName, ssid);
delete devResourse;
devResourse = nullptr;
return;
}
QStringList wirelessDeviceList;
wirelessDeviceList.clear();
devResourse->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDeviceList);
if (wirelessDeviceList.contains(devName)) {
qDebug() << "showPropertyWidget device type wireless device name " << devName << " ssid " << ssid;
m_wlanWidget->showDetailPage(devName, ssid);
delete devResourse;
devResourse = nullptr;
return;
}
qWarning() << "showPropertyWidget no such device " << devName;
delete devResourse;
devResourse = nullptr;
}
void MainWindow::showCreateWiredConnectWidget(const QString devName)
{
qDebug() << "showCreateWiredConnectWidget! devName = " << devName;
NetDetail *netDetail = new NetDetail(devName, "", "", false, false, true, this);
netDetail->show();
}
//有线连接断开
void MainWindow::activateWired(const QString& devName, const QString& connUuid)
{
m_lanWidget->activateWired(devName, connUuid);
}
void MainWindow::deactivateWired(const QString& devName, const QString& connUuid)
{
m_lanWidget->deactivateWired(devName, connUuid);
}
//无线连接断开
void MainWindow::activateWireless(const QString& devName, const QString& ssid)
{
m_wlanWidget->activateWireless(devName, ssid);
}
void MainWindow::deactivateWireless(const QString& devName, const QString& ssid)
{
m_wlanWidget->deactivateWireless(devName, ssid);
}

View File

@ -1,123 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QTableWidget>
#include <QGSettings/QGSettings>
#include <QTimer>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QAction>
#include <QDBusInterface>
#include "lanpage.h"
#include "wlanpage.h"
#include "netdetails/netdetail.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
void showMainwindow();
void hideMainwindow();
void setWiredDefaultDevice(QString deviceName);
void setWirelessDefaultDevice(QString deviceName);
//for dbus
void getWirelessList(QMap<QString, QVector<QStringList> > &map);
void getWiredList(QMap<QString, QVector<QStringList>> &map);
//开启热点
void activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
//断开热点
void deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
//获取热点
void getStoredApInfo(QStringList &list);
//有线连接断开
void activateWired(const QString& devName, const QString& connUuid);
void deactivateWired(const QString& devName, const QString& connUuid);
//无线连接断开
void activateWireless(const QString& devName, const QString& ssid);
void deactivateWireless(const QString& devName, const QString& ssid);
void setWiredDeviceEnable(const QString& devName, bool enable);
//唤起属性页 根据网卡类型 参数2 为ssid/uuid
void showPropertyWidget(QString devName, QString ssid);
//唤起新建有线连接界面
void showCreateWiredConnectWidget(const QString devName);
signals:
//设备插拔
void deviceStatusChanged();
//设备名称变化
void deviceNameChanged(QString oldName, QString newName);
//有线无线列表更新(有线增删、无线增加减少)
void lanAdd(QString devName, QStringList info);
void lanRemove(QString dbusPath);
void lanUpdate(QString devName, QStringList info);
void wlanAdd(QString devName, QStringList info);
void wlanRemove(QString devName,QString ssid);
void wlanactiveConnectionStateChanged(QString devName, QString ssid, int status);
void lanActiveConnectionStateChanged(QString devName, QString uuid, int status);
void activateFailed(QString errorMessage);
void deactivateFailed(QString errorMessage);
//热点断开
void hotspotDeactivated(QString devName, QString ssid);
void hotspotActivated(QString devName, QString ssid);
//信号强度变化
void signalStrengthChange(QString devName, QString ssid, int strength);
//安全性变化
void secuTypeChange(QString devName, QString ssid, QString secuType);
void mainWindowVisibleChanged(const bool &visible);
public slots:
protected:
void keyPressEvent(QKeyEvent *event);
bool eventFilter(QObject *watched, QEvent *event) override;
private:
void firstlyStart(); //一级启动
void secondaryStart(); //二级启动
bool m_loadFinished = false; //是否二级启动已执行完
QTimer * m_secondaryStartTimer = nullptr; //执行二级启动的倒计时
void initWindowProperties();
void initUI();
void initDbusConnnect();
void initTrayIcon();
void resetTrayIconTool();
void initWindowTheme();
void resetWindowTheme();
void showControlCenter();
//主窗口的主要构成控件
QTabWidget * m_centralWidget = nullptr;
QHBoxLayout * m_tabBarLayout = nullptr;
QLabel * m_lanLabel = nullptr;
QLabel * m_wlanLabel = nullptr;
LanPage * m_lanWidget = nullptr;
WlanPage * m_wlanWidget = nullptr;
//监听主题的Gsettings
QGSettings * m_styleGsettings = nullptr;
//获取和重置窗口位置
void resetWindowPosition();
QDBusInterface * m_positionInterface = nullptr;
//托盘图标,托盘图标右键菜单
QSystemTrayIcon * m_trayIcon = nullptr;
QMenu * m_trayIconMenu = nullptr;
QAction * m_showMainwindowAction = nullptr;
QAction * m_showSettingsAction = nullptr;
private slots:
void onTrayIconActivated();
void onShowMainwindowActionTriggled();
void onShowSettingsActionTriggled();
void onThemeChanged(const QString &key);
void onRefreshTrayIcon();
};
#endif // MAINWINDOW_H

View File

@ -1,5 +1,4 @@
#include "nmdemo.h"
#include "../wireless-security/dlghidewifi.h"
#include <QTime>
#include <QTimeZone>

View File

@ -15,6 +15,8 @@
#include "list-items/lanlistitem.h"
#include "tab-pages/tabpage.h"
class LanListItem;
class LanPage : public TabPage
{
Q_OBJECT

View File

@ -1,372 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dlghidewifi.h"
#include "kylinheadfile.h"
#include "ui_dlghidewifi.h"
#include "backthread.h"
#include "mainwindow.h"
#include "kylin-dbus-interface.h"
#include "wpawifidialog.h"
#include <unistd.h>
#include <QPoint>
#include <QStandardItemModel>
#include <QDir>
DlgHideWifi::DlgHideWifi(int type, OldMainWindow *mainWindow, QWidget *parent) :
isUsed(type),
QDialog(parent),
ui(new Ui::DlgHideWifi)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setAttribute(Qt::WA_DeleteOnClose);
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
ui->lbBoder->hide();
ui->lbLeftupTitle->setStyleSheet("QLabel{font-size:20px;}");
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->lbLeftupTitle->setText(tr("Add Hidden WLAN")); //加入隐藏WLAN
ui->lbConn->setText(tr("Connection")); //连接设置:
ui->lbNetName->setText(tr("WLAN name")); //网络名称:
ui->lbSecurity->setText(tr("WLAN security")); //Wi-Fi安全性:
ui->btnCancel->setText(tr("Cancel")); //取消
ui->btnConnect->setText(tr("Connect")); //连接
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
ui->cbxConn->clear();
ui->cbxConn->addItem(tr("C_reate…")); //新建...
KylinDBus mkylindbus;
QStringList wifiList = mkylindbus.getWifiSsidList();
foreach (QString strWifiSsid, wifiList) {
ui->cbxConn->addItem(strWifiSsid);
}
ui->cbxConn->setCurrentIndex(isUsed);
connect(ui->cbxConn,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeWindow()));
ui->cbxSecurity->addItem(tr("None")); //无
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
//ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII)
//ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句
//ui->cbxSecurity->addItem("LEAP");
//ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x)
ui->cbxSecurity->setCurrentIndex(0);
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog()));
if (isUsed == 0) {
ui->btnConnect->setEnabled(false);
} else {
ui->leNetName->setText(ui->cbxConn->currentText());
ui->lbNetName->setEnabled(false);
ui->leNetName->setEnabled(false);
ui->lbSecurity->setEnabled(false);
ui->cbxSecurity->setEnabled(false);
ui->btnConnect->setEnabled(true);
}
ui->leNetName->setContextMenuPolicy(Qt::NoContextMenu); //禁止LineEdit的右键菜单
this->setFixedSize(432,358);
this->mw = mainWindow;
}
DlgHideWifi::~DlgHideWifi()
{
delete ui;
}
void DlgHideWifi::mousePressEvent(QMouseEvent *event){
if(event->button() == Qt::LeftButton){
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
return QDialog::mousePressEvent(event);
}
void DlgHideWifi::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
return QDialog::mouseReleaseEvent(event);
}
void DlgHideWifi::mouseMoveEvent(QMouseEvent *event){
if(this->isPress){
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
return QDialog::mouseMoveEvent(event);
}
//切换到其他Wi-Fi安全类型
void DlgHideWifi::changeDialog()
{
if(ui->cbxSecurity->currentIndex()==0){
qDebug()<<"it's not need to change dialog";
} else if(ui->cbxSecurity->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->close();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(0, mw);
connHidWifiWpa->show();
connect(connHidWifiWpa, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
} else if(ui->cbxSecurity->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->close();
WpaWifiDialog * wpadlg = new WpaWifiDialog(mw, mw, "");
QPoint pos = QCursor::pos();
QRect primaryGeometry;
for (QScreen *screen : qApp->screens()) {
if (screen->geometry().contains(pos)) {
primaryGeometry = screen->geometry();
}
}
if (primaryGeometry.isEmpty()) {
primaryGeometry = qApp->primaryScreen()->geometry();
}
wpadlg->move(primaryGeometry.width() / 2 - wpadlg->width() / 2, primaryGeometry.height() / 2 - wpadlg->height() / 2);
wpadlg->show();
connect(wpadlg, &WpaWifiDialog::conn_done, this, [ = ]() {
QString txt(tr("Conn WLAN Success"));
mw->objKyDBus->showDesktopNotify(txt);
mw->on_btnWifiList_clicked();
});
connect(wpadlg, &WpaWifiDialog::conn_failed, this, [ = ]() {
QString txt(tr("Confirm your WLAN password or usable of wireless card"));
mw->objKyDBus->showDesktopNotify(txt);
mw->on_btnWifiList_clicked();
});
// DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(1, 0, mw);
// connHidWifiEapPeap->show();
} else if(ui->cbxSecurity->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(0);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(1);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==5) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
connHidWifiLeap->show();
} else {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(0, 0, mw);
connHidWifiEapPeap->show();
}
}
//同一 Wi-Fi安全类型的窗口变换
void DlgHideWifi::changeWindow(){
if (ui->cbxConn->currentIndex() == 0){
isUsed = ui->cbxConn->currentIndex();
ui->cbxConn->setCurrentIndex(0);
ui->leNetName->setText("");
ui->lbNetName->setEnabled(true);
ui->leNetName->setEnabled(true);
ui->lbSecurity->setEnabled(true);
ui->cbxSecurity->setEnabled(true);
ui->btnConnect->setEnabled(false);
}else if (ui->cbxConn->currentIndex() >= 1){
QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName();
QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' >" + tmpPath;
int status = system(currStr.toUtf8().data());
qDebug()<<"executed cmd="<<currStr<<". res="<<status;
QFile file(tmpPath);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
file.close();
if (txt.indexOf("802-11-wireless-security.key-mgmt:") != -1) {
if (txt.indexOf("wpa-psk") != -1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(ui->cbxConn->currentIndex(), mw);
connHidWifiWpa->show();
connect(connHidWifiWpa, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
}
if (txt.indexOf("wpa-eap") != -1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
// DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(1, ui->cbxConn->currentIndex(), mw);
// connHidWifiEapPeap->show();
WpaWifiDialog * wpadlg = new WpaWifiDialog(mw, mw, ui->cbxConn->currentText());
QPoint pos = QCursor::pos();
QRect primaryGeometry;
for (QScreen *screen : qApp->screens()) {
if (screen->geometry().contains(pos)) {
primaryGeometry = screen->geometry();
}
}
if (primaryGeometry.isEmpty()) {
primaryGeometry = qApp->primaryScreen()->geometry();
}
wpadlg->move(primaryGeometry.width() / 2 - wpadlg->width() / 2, primaryGeometry.height() / 2 - wpadlg->height() / 2);
wpadlg->show();
connect(wpadlg, &WpaWifiDialog::conn_done, this, [ = ]() {
QString txt(tr("Conn WLAN Success"));
mw->objKyDBus->showDesktopNotify(txt);
mw->on_btnWifiList_clicked();
});
connect(wpadlg, &WpaWifiDialog::conn_failed, this, [ = ]() {
QString txt(tr("Confirm your WLAN password or usable of wireless card"));
mw->objKyDBus->showDesktopNotify(txt);
mw->on_btnWifiList_clicked();
});
}
} else {
isUsed = ui->cbxConn->currentIndex();
ui->leNetName->setText(ui->cbxConn->currentText());
ui->lbNetName->setEnabled(false);
ui->leNetName->setEnabled(false);
ui->lbSecurity->setEnabled(false);
ui->cbxSecurity->setEnabled(false);mw->on_btnWifiList_clicked();
ui->btnConnect->setEnabled(true);
}
}
}
void DlgHideWifi::on_btnCancel_clicked()
{
//this->close();
this->hide();
}
void DlgHideWifi::on_btnConnect_clicked()
{
mw->is_stop_check_net_state = 1;
mw->is_connect_hide_wifi = 1;
QThread *t = new QThread();
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
connect(this, SIGNAL(stopSignal()), t, SLOT(quit()));
QString wifiName = ui->leNetName->text();
strWifiname = wifiName;
BackThread *bt = new BackThread();
if (isUsed == 0) {
bt->moveToThread(t);
connect(t, SIGNAL(started()), this, SLOT(slotStartConnectHiddenOpenWifi()));
connect(this, SIGNAL(sigConnHiddenWifi(QString, QString)), bt, SLOT(execConnHiddenWifiWPA(QString,QString)));
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connWifiDone(int)));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
} else {
bt->moveToThread(t);
connect(t, SIGNAL(started()), this, SLOT(slotStartConnectRememberedHiddenWifi()));
connect(this, SIGNAL(sigConnRememberedHiddenWifi(QString)), bt, SLOT(execConnRememberedHiddenWifi(QString)));
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connWifiDone(int)));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
}
t->start();
//this->close();
this->hide();
}
void DlgHideWifi::on_leNetName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
if (ui->leNetName->text().size() > 32) {
QString cutStr = ui->leNetName->text().mid(0,32);
ui->leNetName->setText(cutStr);
}
}
void DlgHideWifi::slotStartLoading()
{
mw->startLoading();
}
void DlgHideWifi::slotStartConnectHiddenOpenWifi()
{
mw->startLoading();
emit sigConnHiddenWifi(ui->leNetName->text(), QString(""));
}
void DlgHideWifi::slotStartConnectRememberedHiddenWifi()
{
mw->startLoading();
emit sigConnRememberedHiddenWifi(ui->leNetName->text());
}
void DlgHideWifi::on_execSecConn()
{
QString str = "nmcli device wifi connect '" + strWifiname + "' password ''";
int status = system(str.toUtf8().data());
qDebug()<<"executed cmd="<<str<<". res="<<status;
QTimer::singleShot(3*1000, this, SLOT(emitSignal() ));
}
void DlgHideWifi::emitSignal()
{
emit reSetWifiList();
mw->stopLoading();
emit this->stopSignal();
}
void DlgHideWifi::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,83 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DLGCONNHIDWIFI_H
#define DLGCONNHIDWIFI_H
#include <QDialog>
#include <QMouseEvent>
#include <QThread>
#include <QTimer>
#include <QFile>
class OldMainWindow;
namespace Ui {
class DlgHideWifi;
}
class DlgHideWifi : public QDialog
{
Q_OBJECT
public:
explicit DlgHideWifi(int type, OldMainWindow *mw = 0, QWidget *parent = 0);
~DlgHideWifi();
protected:
void paintEvent(QPaintEvent *event);
public slots:
void changeDialog();
void changeWindow();
void emitSignal();
void on_execSecConn();
void slotStartLoading();
void slotStartConnectHiddenOpenWifi();
void slotStartConnectRememberedHiddenWifi();
private slots:
void on_btnCancel_clicked();
void on_btnConnect_clicked();
void on_leNetName_textEdited(const QString &arg1);
signals:
void reSetWifiList();
void stopSignal();
void sigConnHiddenWifi(QString wifiName, QString wifiPasswd);
void sigConnRememberedHiddenWifi(QString wifiName);
private:
Ui::DlgHideWifi *ui;
int isUsed;//=0 current wifi not used before; >=1 used
OldMainWindow *mw;
QString strWifiname;
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss;
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
bool isPress;
QPoint winPos;
QPoint dragPos;
};
#endif // DLGCONNHIDWIFI_H

View File

@ -1,238 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgHideWifi</class>
<widget class="QDialog" name="DlgHideWifi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>358</height>
</rect>
</property>
<property name="windowTitle">
<string>Connect to Hidden WLAN Network</string>
</property>
<widget class="QLabel" name="lbConn">
<property name="geometry">
<rect>
<x>76</x>
<y>80</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxConn">
<property name="geometry">
<rect>
<x>175</x>
<y>75</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbNetName">
<property name="geometry">
<rect>
<x>76</x>
<y>221</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxSecurity">
<property name="geometry">
<rect>
<x>175</x>
<y>170</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbSecurity">
<property name="geometry">
<rect>
<x>76</x>
<y>176</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leNetName">
<property name="geometry">
<rect>
<x>175</x>
<y>215</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="btnConnect">
<property name="geometry">
<rect>
<x>315</x>
<y>310</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>310</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>240</width>
<height>22</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbBoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>358</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>280</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<zorder>lbBoder</zorder>
<zorder>lbConn</zorder>
<zorder>cbxConn</zorder>
<zorder>lbNetName</zorder>
<zorder>cbxSecurity</zorder>
<zorder>lbSecurity</zorder>
<zorder>leNetName</zorder>
<zorder>btnConnect</zorder>
<zorder>btnCancel</zorder>
<zorder>lbLeftupTitle</zorder>
<zorder>lineUp</zorder>
<zorder>lineDown</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,359 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dlghidewifieapfast.h"
#include "ui_dlghidewifieapfast.h"
#include "kylinheadfile.h"
#include "kylin-dbus-interface.h"
DlgHideWifiEapFast::DlgHideWifiEapFast(int type, QWidget *parent) :
WepOrWpa(type),
QDialog(parent),
ui(new Ui::DlgHideWifiEapFast)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
ui->lbBoder->hide();
ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}");
ui->lbConn->setStyleSheet(objQss.labelQss);
ui->lbNetName->setStyleSheet(objQss.labelQss);
ui->lbSecurity->setStyleSheet(objQss.labelQss);
ui->lbAuth->setStyleSheet(objQss.labelQss);
ui->lbAnonyId->setStyleSheet(objQss.labelQss);
ui->checkBoxAutoPCA->setStyleSheet(objQss.checkBoxCAQss);
ui->lbPCAfile->setStyleSheet(objQss.labelQss);
ui->lbInnerAuth->setStyleSheet(objQss.labelQss);
ui->lbUserName->setStyleSheet(objQss.labelQss);
ui->lbPassword->setStyleSheet(objQss.labelQss);
ui->cbxConn->setStyleSheet(objQss.cbxQss);
ui->cbxConn->setView(new QListView());
ui->leNetName->setStyleSheet(objQss.leQss);
ui->cbxSecurity->setStyleSheet(objQss.cbxQss);
ui->cbxSecurity->setView(new QListView());
ui->cbxAuth->setStyleSheet(objQss.cbxQss);
ui->cbxAuth->setView(new QListView());
ui->leAnonyId->setStyleSheet(objQss.leQss);
ui->cbxAutoPCA->setStyleSheet(objQss.cbxQss);
ui->cbxAutoPCA->setView(new QListView());
ui->lePCAfile->setStyleSheet(objQss.leQss);
ui->cbxInnerAuth->setStyleSheet(objQss.cbxQss);
ui->cbxInnerAuth->setView(new QListView());
ui->leUserName->setStyleSheet(objQss.leQss);
ui->lePassword->setStyleSheet(objQss.leQss);
ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss);
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->lbLeftupTitle->setText(tr("Add hidden WLAN")); //加入隐藏WLAN
ui->lbConn->setText(tr("Connection")); //连接设置:
ui->lbNetName->setText(tr("Network name")); //网络名称:
ui->lbSecurity->setText(tr("WLAN security")); //Wi-Fi安全性:
ui->lbAuth->setText(tr("Authentication")); //认证:
ui->lbAnonyId->setText(tr("Anonymous identity")); //匿名身份:
ui->checkBoxAutoPCA->setText(tr("Allow automatic PAC pro_visioning")); //自动PAC配置:
ui->lbPCAfile->setText(tr("PAC file"));//PAC文件:
ui->lbInnerAuth->setText(tr("Inner authentication")); //内部认证:
ui->lbUserName->setText(tr("Username")); //用户名:
ui->lbPassword->setText(tr("Password")); //密码:
ui->btnCancel->setText(tr("Cancel")); //取消
ui->btnConnect->setText(tr("Connect")); //连接
ui->checkBoxAutoPCA->setFocusPolicy(Qt::NoFocus);
ui->checkBoxPwd->setFocusPolicy(Qt::NoFocus);
ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
QStringList txtLine = txt.split("\n");
file.close();
foreach (QString line, txtLine) {
if(line.indexOf("wifi") != -1){
QStringList subLine = line.split(" ");
ui->cbxConn->addItem(subLine[0]);
}
}
ui->cbxConn->setCurrentIndex(0);
ui->cbxSecurity->addItem(tr("None")); //无
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII)
ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句
ui->cbxSecurity->addItem("LEAP");
ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x)
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
if (WepOrWpa == 0) {
ui->cbxSecurity->setCurrentIndex(5);
} else if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(6);
}
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu()));
ui->cbxAuth->addItem("TLS");
ui->cbxAuth->addItem("LEAP");
ui->cbxAuth->addItem("PWD");
ui->cbxAuth->addItem("FAST");
ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS
ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP
ui->cbxAuth->setCurrentIndex(3);
connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth()));
ui->checkBoxAutoPCA->setCheckState(Qt::Checked);
ui->cbxAutoPCA->addItem(tr("Anonymous")); //匿名
ui->cbxAutoPCA->addItem(tr("Authenticated")); //已认证
ui->cbxAutoPCA->addItem(tr("Both")); //两者兼用
ui->cbxAutoPCA->setCurrentIndex(0);
ui->lePCAfile->setText(tr("None")); //(无)
ui->cbxInnerAuth->addItem("GTC");
ui->cbxInnerAuth->addItem("MSCHAPv2");
ui->cbxInnerAuth->setCurrentIndex(0);
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,673);
}
DlgHideWifiEapFast::~DlgHideWifiEapFast()
{
delete ui;
}
void DlgHideWifiEapFast::mousePressEvent(QMouseEvent *event){
if(event->button() == Qt::LeftButton){
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
}
void DlgHideWifiEapFast::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
}
void DlgHideWifiEapFast::mouseMoveEvent(QMouseEvent *event){
if(this->isPress){
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
}
void DlgHideWifiEapFast::changeDialogSecu()
{
if(ui->cbxSecurity->currentIndex()==0){
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0);
connHidWifi->show();
} else if(ui->cbxSecurity->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(0);
connHidWifiWpa->show();
} else if(ui->cbxSecurity->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(0);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(1);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
connHidWifiLeap->show();
} else if(ui->cbxSecurity->currentIndex()==5) {
if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(5);
WepOrWpa = 0;
}
} else {
if (WepOrWpa == 0){
ui->cbxSecurity->setCurrentIndex(6);
WepOrWpa = 1;
}
}
}
void DlgHideWifiEapFast::changeDialogAuth()
{
if(ui->cbxAuth->currentIndex()==0){
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(WepOrWpa);
//connHidWifiEapTls->show();
} else if(ui->cbxAuth->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapLeap *connHidWifiEapLeap = new DlgHideWifiEapLeap(WepOrWpa);
connHidWifiEapLeap->show();
} else if(ui->cbxAuth->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapPwd *connHidWifiEapPwd = new DlgHideWifiEapPwd(WepOrWpa);
connHidWifiEapPwd->show();
} else if(ui->cbxAuth->currentIndex()==3) {
qDebug()<<"it's not need to change dialog";
} else if(ui->cbxAuth->currentIndex()==4) {
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapTTLS *connHidWifiEapTTls = new DlgHideWifiEapTTLS(WepOrWpa);
//connHidWifiEapTTls->show();
} else {
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(WepOrWpa);
//connHidWifiEapPeap->show();
}
}
void DlgHideWifiEapFast::on_btnCancel_clicked()
{
this->close();
}
void DlgHideWifiEapFast::on_btnConnect_clicked()
{
this->close();
}
void DlgHideWifiEapFast::on_checkBoxAutoPCA_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->cbxAutoPCA->setEnabled(false);
} else {
ui->cbxAutoPCA->setEnabled(true);
}
}
void DlgHideWifiEapFast::on_checkBoxPwd_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->lePassword ->setEchoMode(QLineEdit::Password);
} else {
ui->lePassword->setEchoMode(QLineEdit::Normal);
}
}
void DlgHideWifiEapFast::on_leNetName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if(ui->leAnonyId->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapFast::on_leAnonyId_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if(ui->leAnonyId->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapFast::on_leUserName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if(ui->leAnonyId->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapFast::on_lePassword_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if(ui->leAnonyId->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapFast::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,76 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DLGCONNHIDWIFISECFAST_H
#define DLGCONNHIDWIFISECFAST_H
#include <QDialog>
#include <QMouseEvent>
namespace Ui {
class DlgHideWifiEapFast;
}
class DlgHideWifiEapFast : public QDialog
{
Q_OBJECT
public:
explicit DlgHideWifiEapFast(int type, QWidget *parent = 0);
~DlgHideWifiEapFast();
protected:
void paintEvent(QPaintEvent *event);
public slots:
void changeDialogSecu();
void changeDialogAuth();
private slots:
void on_btnCancel_clicked();
void on_btnConnect_clicked();
void on_checkBoxAutoPCA_stateChanged(int arg1);
void on_checkBoxPwd_stateChanged(int arg1);
void on_leNetName_textEdited(const QString &arg1);
void on_leAnonyId_textEdited(const QString &arg1);
void on_leUserName_textEdited(const QString &arg1);
void on_lePassword_textEdited(const QString &arg1);
private:
Ui::DlgHideWifiEapFast *ui;
int WepOrWpa = 0;//0 WEP;1WPA
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss;
bool isPress;
QPoint winPos;
QPoint dragPos;
};
#endif // DLGCONNHIDWIFISECFAST_H

View File

@ -1,505 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgHideWifiEapFast</class>
<widget class="QDialog" name="DlgHideWifiEapFast">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>673</height>
</rect>
</property>
<property name="windowTitle">
<string>Connect to Hidden WLAN Network</string>
</property>
<widget class="QCheckBox" name="checkBoxPwd">
<property name="geometry">
<rect>
<x>332</x>
<y>542</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbNetName">
<property name="geometry">
<rect>
<x>76</x>
<y>176</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leNetName">
<property name="geometry">
<rect>
<x>180</x>
<y>170</y>
<width>182</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbConn">
<property name="geometry">
<rect>
<x>76</x>
<y>80</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxAuth">
<property name="geometry">
<rect>
<x>180</x>
<y>260</y>
<width>182</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLineEdit" name="lePassword">
<property name="geometry">
<rect>
<x>180</x>
<y>530</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QLineEdit" name="leUserName">
<property name="geometry">
<rect>
<x>180</x>
<y>485</y>
<width>182</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbUserName">
<property name="geometry">
<rect>
<x>76</x>
<y>491</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxSecurity">
<property name="geometry">
<rect>
<x>180</x>
<y>215</y>
<width>182</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbPassword">
<property name="geometry">
<rect>
<x>76</x>
<y>536</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnConnect">
<property name="geometry">
<rect>
<x>315</x>
<y>620</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxConn">
<property name="geometry">
<rect>
<x>180</x>
<y>75</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbAuth">
<property name="geometry">
<rect>
<x>76</x>
<y>266</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbSecurity">
<property name="geometry">
<rect>
<x>76</x>
<y>221</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>620</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbAnonyId">
<property name="geometry">
<rect>
<x>76</x>
<y>311</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leAnonyId">
<property name="geometry">
<rect>
<x>180</x>
<y>305</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxAutoPCA">
<property name="geometry">
<rect>
<x>76</x>
<y>356</y>
<width>100</width>
<height>25</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxAutoPCA">
<property name="geometry">
<rect>
<x>180</x>
<y>350</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbPCAfile">
<property name="geometry">
<rect>
<x>76</x>
<y>401</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="lePCAfile">
<property name="geometry">
<rect>
<x>180</x>
<y>395</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbInnerAuth">
<property name="geometry">
<rect>
<x>76</x>
<y>446</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxInnerAuth">
<property name="geometry">
<rect>
<x>180</x>
<y>440</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>140</width>
<height>22</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbBoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>673</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>590</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<zorder>lbBoder</zorder>
<zorder>lbNetName</zorder>
<zorder>leNetName</zorder>
<zorder>lbConn</zorder>
<zorder>cbxAuth</zorder>
<zorder>lePassword</zorder>
<zorder>leUserName</zorder>
<zorder>lbUserName</zorder>
<zorder>cbxSecurity</zorder>
<zorder>lbPassword</zorder>
<zorder>btnConnect</zorder>
<zorder>cbxConn</zorder>
<zorder>lbAuth</zorder>
<zorder>lbSecurity</zorder>
<zorder>btnCancel</zorder>
<zorder>lbAnonyId</zorder>
<zorder>leAnonyId</zorder>
<zorder>checkBoxAutoPCA</zorder>
<zorder>cbxAutoPCA</zorder>
<zorder>lbPCAfile</zorder>
<zorder>lePCAfile</zorder>
<zorder>lbInnerAuth</zorder>
<zorder>cbxInnerAuth</zorder>
<zorder>checkBoxPwd</zorder>
<zorder>lbLeftupTitle</zorder>
<zorder>lineUp</zorder>
<zorder>lineDown</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,299 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dlghidewifieapleap.h"
#include "ui_dlghidewifieapleap.h"
#include "kylinheadfile.h"
#include "kylin-dbus-interface.h"
DlgHideWifiEapLeap::DlgHideWifiEapLeap(int type, QWidget *parent) :
WepOrWpa(type),
QDialog(parent),
ui(new Ui::DlgHideWifiEapLeap)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
ui->lbBoder->hide();
ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}");
ui->lbConn->setStyleSheet(objQss.labelQss);
ui->lbNetName->setStyleSheet(objQss.labelQss);
ui->lbSecurity->setStyleSheet(objQss.labelQss);
ui->lbAuth->setStyleSheet(objQss.labelQss);
ui->lbUserName->setStyleSheet(objQss.labelQss);
ui->lbPassword->setStyleSheet(objQss.labelQss);
ui->cbxConn->setStyleSheet(objQss.cbxQss);
ui->cbxConn->setView(new QListView());
ui->leNetName->setStyleSheet(objQss.leQss);
ui->cbxSecurity->setStyleSheet(objQss.cbxQss);
ui->cbxSecurity->setView(new QListView());
ui->cbxAuth->setStyleSheet(objQss.cbxQss);
ui->cbxAuth->setView(new QListView());
ui->leUserName->setStyleSheet(objQss.leQss);
ui->lePassword->setStyleSheet(objQss.leQss);
ui->checkBox->setStyleSheet(objQss.checkBoxQss);
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->lbLeftupTitle->setText(tr("Add hidden WLAN")); //加入隐藏WLAN
ui->lbConn->setText(tr("Connection")); //连接设置:
ui->lbNetName->setText(tr("Network name")); //网络名称:
ui->lbSecurity->setText(tr("WLAN security")); //Wi-Fi安全性:
ui->lbAuth->setText(tr("Authentication")); //认证:
ui->lbUserName->setText(tr("Username")); //用户名:
ui->lbPassword->setText(tr("Password")); //密码:
ui->btnCancel->setText(tr("Cancel")); //取消
ui->btnConnect->setText(tr("Connect")); //连接
ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
QStringList txtLine = txt.split("\n");
file.close();
foreach (QString line, txtLine) {
if(line.indexOf("wifi") != -1){
QStringList subLine = line.split(" ");
ui->cbxConn->addItem(subLine[0]);
}
}
ui->cbxConn->setCurrentIndex(0);
ui->cbxSecurity->addItem(tr("None")); //无
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII)
ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句
ui->cbxSecurity->addItem("LEAP");
ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x)
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
if (WepOrWpa == 0) {
ui->cbxSecurity->setCurrentIndex(5);
} else if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(6);
}
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu()));
ui->cbxAuth->addItem("TLS");
ui->cbxAuth->addItem("LEAP");
ui->cbxAuth->addItem("PWD");
ui->cbxAuth->addItem("FAST");
ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS
ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP
ui->cbxAuth->setCurrentIndex(1);
connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth()));
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,487);
}
DlgHideWifiEapLeap::~DlgHideWifiEapLeap()
{
delete ui;
}
void DlgHideWifiEapLeap::mousePressEvent(QMouseEvent *event){
if(event->button() == Qt::LeftButton){
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
}
void DlgHideWifiEapLeap::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
}
void DlgHideWifiEapLeap::mouseMoveEvent(QMouseEvent *event){
if(this->isPress){
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
}
void DlgHideWifiEapLeap::changeDialogSecu()
{
if(ui->cbxSecurity->currentIndex()==0){
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0);
connHidWifi->show();
} else if(ui->cbxSecurity->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(0);
connHidWifiWpa->show();
} else if(ui->cbxSecurity->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(0);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(1);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
connHidWifiLeap->show();
} else if(ui->cbxSecurity->currentIndex()==5) {
if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(5);
WepOrWpa = 0;
}
} else {
if (WepOrWpa == 0){
ui->cbxSecurity->setCurrentIndex(6);
WepOrWpa = 1;
}
}
}
void DlgHideWifiEapLeap::changeDialogAuth()
{
if(ui->cbxAuth->currentIndex()==0){
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(WepOrWpa);
//connHidWifiEapTls->show();
} else if(ui->cbxAuth->currentIndex()==1) {
qDebug()<<"it's not need to change dialog";
} else if(ui->cbxAuth->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapPwd *connHidWifiEapPwd = new DlgHideWifiEapPwd(WepOrWpa);
connHidWifiEapPwd->show();
} else if(ui->cbxAuth->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapFast *connHidWifiEapFast = new DlgHideWifiEapFast(WepOrWpa);
connHidWifiEapFast->show();
} else if(ui->cbxAuth->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapTTLS *connHidWifiEapTTls = new DlgHideWifiEapTTLS(WepOrWpa);
connHidWifiEapTTls->show();
} else {
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(WepOrWpa);
//connHidWifiEapPeap->show();
}
}
void DlgHideWifiEapLeap::on_btnCancel_clicked()
{
this->close();
}
void DlgHideWifiEapLeap::on_btnConnect_clicked()
{
this->close();
}
void DlgHideWifiEapLeap::on_checkBox_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->lePassword ->setEchoMode(QLineEdit::Password);
} else {
ui->lePassword->setEchoMode(QLineEdit::Normal);
}
}
void DlgHideWifiEapLeap::on_leNetName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapLeap::on_leUserName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapLeap::on_lePassword_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapLeap::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,72 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DLGCONNHIDWIFISECLEAP_H
#define DLGCONNHIDWIFISECLEAP_H
#include <QDialog>
#include <QMouseEvent>
namespace Ui {
class DlgHideWifiEapLeap;
}
class DlgHideWifiEapLeap : public QDialog
{
Q_OBJECT
public:
explicit DlgHideWifiEapLeap(int type, QWidget *parent = 0);
~DlgHideWifiEapLeap();
protected:
void paintEvent(QPaintEvent *event);
public slots:
void changeDialogSecu();
void changeDialogAuth();
private slots:
void on_btnCancel_clicked();
void on_btnConnect_clicked();
void on_checkBox_stateChanged(int arg1);
void on_leNetName_textEdited(const QString &arg1);
void on_leUserName_textEdited(const QString &arg1);
void on_lePassword_textEdited(const QString &arg1);
private:
Ui::DlgHideWifiEapLeap *ui;
int WepOrWpa = 0;//0 WEP;1WPA
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss;
bool isPress;
QPoint winPos;
QPoint dragPos;
};
#endif // DLGCONNHIDWIFISECLEAP_H

View File

@ -1,354 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgHideWifiEapLeap</class>
<widget class="QDialog" name="DlgHideWifiEapLeap">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>487</height>
</rect>
</property>
<property name="windowTitle">
<string>Connect to Hidden WLAN Network</string>
</property>
<widget class="QComboBox" name="cbxSecurity">
<property name="geometry">
<rect>
<x>175</x>
<y>215</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLineEdit" name="lePassword">
<property name="geometry">
<rect>
<x>175</x>
<y>350</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QCheckBox" name="checkBox">
<property name="geometry">
<rect>
<x>332</x>
<y>362</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbNetName">
<property name="geometry">
<rect>
<x>76</x>
<y>176</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbSecurity">
<property name="geometry">
<rect>
<x>76</x>
<y>221</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leUserName">
<property name="geometry">
<rect>
<x>175</x>
<y>305</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="btnConnect">
<property name="geometry">
<rect>
<x>315</x>
<y>440</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxConn">
<property name="geometry">
<rect>
<x>175</x>
<y>75</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbUserName">
<property name="geometry">
<rect>
<x>76</x>
<y>311</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>440</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxAuth">
<property name="geometry">
<rect>
<x>175</x>
<y>260</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbAuth">
<property name="geometry">
<rect>
<x>76</x>
<y>266</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leNetName">
<property name="geometry">
<rect>
<x>175</x>
<y>170</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbPassword">
<property name="geometry">
<rect>
<x>76</x>
<y>356</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbConn">
<property name="geometry">
<rect>
<x>76</x>
<y>80</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>140</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbBoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>487</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>410</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<zorder>lbBoder</zorder>
<zorder>cbxSecurity</zorder>
<zorder>lePassword</zorder>
<zorder>checkBox</zorder>
<zorder>lbNetName</zorder>
<zorder>lbSecurity</zorder>
<zorder>leUserName</zorder>
<zorder>btnConnect</zorder>
<zorder>cbxConn</zorder>
<zorder>lbUserName</zorder>
<zorder>btnCancel</zorder>
<zorder>cbxAuth</zorder>
<zorder>lbAuth</zorder>
<zorder>leNetName</zorder>
<zorder>lbPassword</zorder>
<zorder>lbConn</zorder>
<zorder>lbLeftupTitle</zorder>
<zorder>lineUp</zorder>
<zorder>lineDown</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,541 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dlghidewifieappeap.h"
#include "ui_dlghidewifieappeap.h"
#include "kylinheadfile.h"
#include "mainwindow.h"
#include "kylin-dbus-interface.h"
#include <QStandardItemModel>
#include <QDir>
DlgHideWifiEapPeap::DlgHideWifiEapPeap(int type, int beUsed, OldMainWindow *mainWindow, QWidget *parent) :
WepOrWpa(type),
isUsed(beUsed),
QDialog(parent),
ui(new Ui::DlgHideWifiEapPeap)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
ui->lbBoder->hide();
ui->lbLeftupTitle->setStyleSheet("QLabel{font-size:20px;}");
ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss);
ui->checkBoxPwdSec->setStyleSheet(objQss.checkBoxQss);
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->lbLeftupTitle->setText(tr("Add hidden WLAN")); //加入隐藏WLAN
ui->lbConn->setText(tr("Connection")); //连接设置:
ui->lbNetName->setText(tr("Network name")); //网络名称:
ui->lbSecurity->setText(tr("WLAN security")); //Wi-Fi安全性:
ui->lbAuth->setText(tr("Authentication")); //认证:
ui->lbAnonyId->setText(tr("Anonymous identity")); //匿名身份:
ui->lbDomain->setText(tr("Domain")); //域名:
ui->lbCA->setText(tr("CA certificate")); //CA 证书:
ui->lbCaPwd->setText(tr("CA certificate password")); //CA 证书密码:
ui->checkBoxCA->setText(tr("No CA certificate is required")); //不需要CA证书
ui->lbPEAPver->setText(tr("PEAP version")); //PEAP版本:
ui->lbInnerAuth->setText(tr("Inner authentication")); //内部认证:
ui->lbUserName->setText(tr("Username")); //用户名:
ui->lbPassword->setText(tr("Password")); //密码:
ui->btnCancel->setText(tr("Cancel")); //取消
ui->btnConnect->setText(tr("Connect")); //连接
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
ui->cbxConn->addItem("新建...");
int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
QStringList txtLine = txt.split("\n");
file.close();
foreach (QString line, txtLine) {
if (line.indexOf("wifi") != -1) {
QStringList subLine = line.split(" ");
ui->cbxConn->addItem(subLine[0]);
}
}
ui->cbxConn->setCurrentIndex(0);
connect(ui->cbxConn,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeWindow()));
ui->cbxSecurity->addItem(tr("None")); //无
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
//ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII)
//ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句
//ui->cbxSecurity->addItem("LEAP");
//ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x)
if (WepOrWpa == 0) {
ui->cbxSecurity->setCurrentIndex(5);
} else if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(2);
}
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu()));
//ui->cbxAuth->addItem("TLS");
//ui->cbxAuth->addItem("LEAP");
//ui->cbxAuth->addItem("PWD");
//ui->cbxAuth->addItem("FAST");
//ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS
ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP
ui->cbxAuth->setCurrentIndex(0);
//connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth()));
ui->cbxCA->addItem(tr("None")); //无
ui->cbxCA->addItem(tr("Choose from file")); //从文件选择...
ui->cbxCA->setCurrentIndex(0);
ui->cbxPEAPver->addItem(tr("Automatic")); //自动
ui->cbxPEAPver->addItem(tr("Version 0")); //版本 0
ui->cbxPEAPver->addItem(tr("Version 1")); //版本 1
ui->cbxPEAPver->setCurrentIndex(0);
ui->cbxInnerAuth->addItem("MSCHAPv2");
ui->cbxInnerAuth->addItem("MDS");
ui->cbxInnerAuth->addItem("GTC");
ui->cbxInnerAuth->setCurrentIndex(0);
if (isUsed == 0) {
ui->btnConnect->setEnabled(false);
} else {
ui->cbxConn->setCurrentIndex(isUsed);
ui->leNetName->setText(ui->cbxConn->currentText());
ui->leNetName->setEnabled(false);
ui->cbxSecurity->setEnabled(false);
ui->cbxAuth->setEnabled(false);
ui->leAnonyId->setEnabled(false);
ui->leDomain->setEnabled(false);
ui->cbxCA->setEnabled(false);
ui->leCaPwd->setEnabled(false);
ui->checkBoxCA->setEnabled(false);
ui->cbxPEAPver->setEnabled(false);
ui->cbxInnerAuth->setEnabled(false);
ui->leUserName->setText("<Hidden>");
ui->leUserName->setEnabled(false);
ui->lePassword->setText("<Hidden>");
ui->lePassword->setEnabled(false);
ui->btnConnect->setEnabled(true);
}
this->setFixedSize(432,700);
this->mw = mainWindow;
}
DlgHideWifiEapPeap::~DlgHideWifiEapPeap()
{
delete ui;
}
void DlgHideWifiEapPeap::mousePressEvent(QMouseEvent *event){
if (event->button() == Qt::LeftButton) {
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
}
void DlgHideWifiEapPeap::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
}
void DlgHideWifiEapPeap::mouseMoveEvent(QMouseEvent *event){
if (this->isPress) {
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
}
//切换到其他Wi-Fi安全类型
void DlgHideWifiEapPeap::changeDialogSecu()
{
if (ui->cbxSecurity->currentIndex()==0) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0);
connHidWifi->show();
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
} else if(ui->cbxSecurity->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(0);
connHidWifiWpa->show();
connect(connHidWifiWpa, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
} else if(ui->cbxSecurity->currentIndex()==2) {
if (WepOrWpa == 0) {
ui->cbxSecurity->setCurrentIndex(6);
WepOrWpa = 1;
}
} else if(ui->cbxSecurity->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(0);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(1);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==5) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
connHidWifiLeap->show();
} else {
if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(5);
WepOrWpa = 0;
}
}
}
//同一 Wi-Fi安全类型的Authentication变换
void DlgHideWifiEapPeap::changeDialogAuth()
{
if (ui->cbxAuth->currentIndex()==0) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(WepOrWpa, 0, mw);
connHidWifiEapTls->show();
} else if(ui->cbxAuth->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapLeap *connHidWifiEapLeap = new DlgHideWifiEapLeap(WepOrWpa);
connHidWifiEapLeap->show();
} else if(ui->cbxAuth->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapPwd *connHidWifiEapPwd = new DlgHideWifiEapPwd(WepOrWpa);
connHidWifiEapPwd->show();
} else if(ui->cbxAuth->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapFast *connHidWifiEapFast = new DlgHideWifiEapFast(WepOrWpa);
connHidWifiEapFast->show();
} else if(ui->cbxAuth->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapTTLS *connHidWifiEapTTls = new DlgHideWifiEapTTLS(WepOrWpa);
connHidWifiEapTTls->show();
} else {
qDebug()<<"it's not need to change dialog";
}
}
//同一 Wi-Fi安全类型的窗口变换
void DlgHideWifiEapPeap::changeWindow(){
if (ui->cbxConn->currentIndex() == 0) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0, mw);
connHidWifi->show();
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
} else if (ui->cbxConn->currentIndex() >= 1) {
QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName();
QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' > " + tmpPath;
int status = system(currStr.toUtf8().data());
qDebug()<<"executed cmd="<<currStr<<". res="<<status;
QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
file.close();
if (txt.indexOf("802-11-wireless-security.key-mgmt:") != -1) {
if (txt.indexOf("wpa-psk") != -1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(ui->cbxConn->currentIndex(), mw);
connHidWifiWpa->show();
connect(connHidWifiWpa, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
}
if (txt.indexOf("wpa-eap") != -1) {
isUsed = ui->cbxConn->currentIndex();
ui->leNetName->setText(ui->cbxConn->currentText());
ui->leNetName->setEnabled(false);
ui->cbxSecurity->setEnabled(false);
ui->cbxAuth->setEnabled(false);
ui->leAnonyId->setEnabled(false);
ui->leDomain->setEnabled(false);
ui->cbxCA->setEnabled(false);
ui->leCaPwd->setEnabled(false);
ui->checkBoxCA->setEnabled(false);
ui->cbxPEAPver->setEnabled(false);
ui->cbxInnerAuth->setEnabled(false);
ui->leUserName->setText("<Hidden>");
ui->leUserName->setEnabled(false);
ui->lePassword->setText("<Hidden>");
ui->lePassword->setEnabled(false);
ui->btnConnect->setEnabled(true);
}
} else {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(ui->cbxConn->currentIndex(), mw);
connHidWifi->show();
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
}
}
}
//CA证书的Index变化
void DlgHideWifiEapPeap::on_cbxCA_currentIndexChanged(const QString &arg1)
{
if (ui->cbxCA->currentIndex() == 0) {
ui->leCaPwd->setText("");
ui->lbCaPwd->setEnabled(false);
ui->leCaPwd->setEnabled(false);
} else {
ui->leCaPwd->setText("");
ui->lbCaPwd->setEnabled(true);
ui->leCaPwd->setEnabled(true);
}
}
void DlgHideWifiEapPeap::on_btnCancel_clicked()
{
this->close();
}
void DlgHideWifiEapPeap::on_btnConnect_clicked()
{
this->close();
}
//是否显示密码
void DlgHideWifiEapPeap::on_checkBoxPwd_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->leCaPwd->setEchoMode(QLineEdit::Password);
} else {
ui->leCaPwd->setEchoMode(QLineEdit::Normal);
}
}
//是否是不需要CA证书
void DlgHideWifiEapPeap::on_checkBoxCA_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->cbxCA->setCurrentIndex(0);
ui->leCaPwd->setText("");
ui->lbCA->setEnabled(true);
ui->cbxCA->setEnabled(true);
} else {
ui->cbxCA->setCurrentIndex(0);
ui->leCaPwd->setText("");
ui->lbCA->setEnabled(false);
ui->cbxCA->setEnabled(false);
}
}
//是否显示密码
void DlgHideWifiEapPeap::on_checkBoxPwdSec_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->lePassword->setEchoMode(QLineEdit::Password);
} else {
ui->lePassword->setEchoMode(QLineEdit::Normal);
}
}
//编辑网络名称
void DlgHideWifiEapPeap::on_leNetName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
if (ui->checkBoxCA->isChecked()) {
//勾选"不需要CA证书"
ui->btnConnect->setEnabled(true);
} else {
//未勾选"不需要CA证书"
if (ui->cbxCA->currentIndex() == 0) {
ui->btnConnect->setEnabled(true);
} else if(ui->leCaPwd->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
}
}
//编辑匿名身份
void DlgHideWifiEapPeap::on_leAnonyId_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leAnonyId->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leDomain->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxCA->currentIndex() == 0) {
ui->btnConnect->setEnabled(true);
} else if(ui->leCaPwd->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
}
//编辑域名
void DlgHideWifiEapPeap::on_leDomain_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leAnonyId->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leDomain->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxCA->currentIndex() == 0) {
ui->btnConnect->setEnabled(true);
} else if(ui->leCaPwd->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
}
//编辑CA证书密码
void DlgHideWifiEapPeap::on_leCaPwd_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leAnonyId->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leDomain->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leCaPwd->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
//编辑用户名
void DlgHideWifiEapPeap::on_leUserName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
if (ui->checkBoxCA->isChecked()) {
//勾选"不需要CA证书"
ui->btnConnect->setEnabled(true);
} else {
//未勾选"不需要CA证书"
if (ui->cbxCA->currentIndex() == 0) {
ui->btnConnect->setEnabled(true);
} else if(ui->leCaPwd->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
}
}
//编辑密码
void DlgHideWifiEapPeap::on_lePassword_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == "") {
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
if (ui->checkBoxCA->isChecked()) {
//勾选"不需要CA证书"
ui->btnConnect->setEnabled(true);
} else {
//未勾选"不需要CA证书"
if (ui->cbxCA->currentIndex() == 0) {
ui->btnConnect->setEnabled(true);
} else if(ui->leCaPwd->text() == "") {
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
}
}
void DlgHideWifiEapPeap::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,90 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DLGCONNHIDWIFISECPEAP_H
#define DLGCONNHIDWIFISECPEAP_H
#include <QDialog>
#include <QMouseEvent>
class OldMainWindow;
namespace Ui {
class DlgHideWifiEapPeap;
}
class DlgHideWifiEapPeap : public QDialog
{
Q_OBJECT
public:
//type: 0是动态 WEP 1是企业wpa, beUsed:是否是之前已经连接过多网络
explicit DlgHideWifiEapPeap(int type, int beUsed, OldMainWindow *mw = 0, QWidget *parent = 0);
~DlgHideWifiEapPeap();
protected:
void paintEvent(QPaintEvent *event);
public slots:
void changeDialogSecu();
void changeDialogAuth();
void changeWindow();
private slots:
void on_btnCancel_clicked();
void on_btnConnect_clicked();
void on_cbxCA_currentIndexChanged(const QString &arg1);
void on_checkBoxPwd_stateChanged(int arg1);
void on_checkBoxCA_stateChanged(int arg1);
void on_checkBoxPwdSec_stateChanged(int arg1);
void on_leNetName_textEdited(const QString &arg1);
void on_leAnonyId_textEdited(const QString &arg1);
void on_leDomain_textEdited(const QString &arg1);
void on_leCaPwd_textEdited(const QString &arg1);
void on_leUserName_textEdited(const QString &arg1);
void on_lePassword_textEdited(const QString &arg1);
private:
Ui::DlgHideWifiEapPeap *ui;
int WepOrWpa = 0;//0 WEP;1 WPA
int isUsed;//=0 current wifi not used before; >=1 used
OldMainWindow *mw;
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss;
bool isPress;
QPoint winPos;
QPoint dragPos;
};
#endif // DLGCONNHIDWIFISECPEAP_H

View File

@ -1,614 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgHideWifiEapPeap</class>
<widget class="QDialog" name="DlgHideWifiEapPeap">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>700</height>
</rect>
</property>
<property name="windowTitle">
<string>Connect to Hidden WLAN Network</string>
</property>
<widget class="QLineEdit" name="leNetName">
<property name="geometry">
<rect>
<x>180</x>
<y>141</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QComboBox" name="cbxCA">
<property name="geometry">
<rect>
<x>180</x>
<y>341</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbConn">
<property name="geometry">
<rect>
<x>76</x>
<y>76</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leDomain">
<property name="geometry">
<rect>
<x>180</x>
<y>301</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QComboBox" name="cbxConn">
<property name="geometry">
<rect>
<x>180</x>
<y>71</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLineEdit" name="leCaPwd">
<property name="geometry">
<rect>
<x>180</x>
<y>381</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QPushButton" name="btnConnect">
<property name="geometry">
<rect>
<x>315</x>
<y>650</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxSecurity">
<property name="geometry">
<rect>
<x>180</x>
<y>181</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLineEdit" name="leAnonyId">
<property name="geometry">
<rect>
<x>180</x>
<y>261</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxCA">
<property name="geometry">
<rect>
<x>183</x>
<y>421</y>
<width>200</width>
<height>25</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbNetName">
<property name="geometry">
<rect>
<x>76</x>
<y>146</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>650</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbDomain">
<property name="geometry">
<rect>
<x>76</x>
<y>306</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbCaPwd">
<property name="geometry">
<rect>
<x>76</x>
<y>386</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxPwdSec">
<property name="geometry">
<rect>
<x>357</x>
<y>593</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxPwd">
<property name="geometry">
<rect>
<x>357</x>
<y>393</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbSecurity">
<property name="geometry">
<rect>
<x>76</x>
<y>186</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxPEAPver">
<property name="geometry">
<rect>
<x>180</x>
<y>461</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbAuth">
<property name="geometry">
<rect>
<x>76</x>
<y>226</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbPEAPver">
<property name="geometry">
<rect>
<x>76</x>
<y>466</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxAuth">
<property name="geometry">
<rect>
<x>180</x>
<y>221</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbCA">
<property name="geometry">
<rect>
<x>76</x>
<y>346</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbAnonyId">
<property name="geometry">
<rect>
<x>76</x>
<y>266</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbPassword">
<property name="geometry">
<rect>
<x>76</x>
<y>586</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leUserName">
<property name="geometry">
<rect>
<x>180</x>
<y>541</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QComboBox" name="cbxInnerAuth">
<property name="geometry">
<rect>
<x>180</x>
<y>501</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLineEdit" name="lePassword">
<property name="geometry">
<rect>
<x>180</x>
<y>581</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QLabel" name="lbInnerAuth">
<property name="geometry">
<rect>
<x>76</x>
<y>506</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbUserName">
<property name="geometry">
<rect>
<x>76</x>
<y>546</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbBoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>700</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>28</y>
<width>140</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>121</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>631</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<zorder>lbBoder</zorder>
<zorder>leNetName</zorder>
<zorder>cbxCA</zorder>
<zorder>lbConn</zorder>
<zorder>leDomain</zorder>
<zorder>cbxConn</zorder>
<zorder>leCaPwd</zorder>
<zorder>btnConnect</zorder>
<zorder>cbxSecurity</zorder>
<zorder>leAnonyId</zorder>
<zorder>checkBoxCA</zorder>
<zorder>lbNetName</zorder>
<zorder>btnCancel</zorder>
<zorder>lbDomain</zorder>
<zorder>lbCaPwd</zorder>
<zorder>checkBoxPwd</zorder>
<zorder>lbSecurity</zorder>
<zorder>cbxPEAPver</zorder>
<zorder>lbAuth</zorder>
<zorder>lbPEAPver</zorder>
<zorder>cbxAuth</zorder>
<zorder>lbCA</zorder>
<zorder>lbAnonyId</zorder>
<zorder>lbPassword</zorder>
<zorder>leUserName</zorder>
<zorder>cbxInnerAuth</zorder>
<zorder>lePassword</zorder>
<zorder>lbInnerAuth</zorder>
<zorder>lbUserName</zorder>
<zorder>checkBoxPwdSec</zorder>
<zorder>lbLeftupTitle</zorder>
<zorder>lineUp</zorder>
<zorder>lineDown</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,300 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dlghidewifieappwd.h"
#include "ui_dlghidewifieappwd.h"
#include "kylinheadfile.h"
#include "kylin-dbus-interface.h"
DlgHideWifiEapPwd::DlgHideWifiEapPwd(int type, QWidget *parent) :
WepOrWpa(type),
QDialog(parent),
ui(new Ui::DlgHideWifiEapPwd)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
ui->lbBoder->hide();
ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}");
ui->lbConn->setStyleSheet(objQss.labelQss);
ui->lbNetName->setStyleSheet(objQss.labelQss);
ui->lbSecurity->setStyleSheet(objQss.labelQss);
ui->lbAuth->setStyleSheet(objQss.labelQss);
ui->lbUserName->setStyleSheet(objQss.labelQss);
ui->lbPassword->setStyleSheet(objQss.labelQss);
ui->cbxConn->setStyleSheet(objQss.cbxQss);
ui->cbxConn->setView(new QListView());
ui->leNetName->setStyleSheet(objQss.leQss);
ui->cbxSecurity->setStyleSheet(objQss.cbxQss);
ui->cbxSecurity->setView(new QListView());
ui->cbxAuth->setStyleSheet(objQss.cbxQss);
ui->cbxAuth->setView(new QListView());
ui->leUserName->setStyleSheet(objQss.leQss);
ui->lePassword->setStyleSheet(objQss.leQss);
ui->checkBox->setStyleSheet(objQss.checkBoxQss);
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->lbLeftupTitle->setText(tr("Add hidden WLAN")); //加入隐藏WLAN
ui->lbConn->setText(tr("Connection")); //连接设置:
ui->lbNetName->setText(tr("Network name")); //网络名称:
ui->lbSecurity->setText(tr("WLAN security")); //Wi-Fi安全性:
ui->lbAuth->setText(tr("Authentication")); //认证:
ui->lbUserName->setText(tr("Username")); //用户名:
ui->lbPassword->setText(tr("Password")); //密码:
ui->btnCancel->setText(tr("Cancel")); //取消
ui->btnConnect->setText(tr("Connect")); //连接
ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
QStringList txtLine = txt.split("\n");
file.close();
foreach (QString line, txtLine) {
if(line.indexOf("wifi") != -1){
QStringList subLine = line.split(" ");
ui->cbxConn->addItem(subLine[0]);
}
}
ui->cbxConn->setCurrentIndex(0);
ui->cbxSecurity->addItem(tr("None")); //无
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII)
ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句
ui->cbxSecurity->addItem("LEAP");
ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x)
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
if (WepOrWpa == 0) {
ui->cbxSecurity->setCurrentIndex(5);
} else if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(6);
}
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu()));
ui->cbxAuth->addItem("TLS");
ui->cbxAuth->addItem("LEAP");
ui->cbxAuth->addItem("PWD");
ui->cbxAuth->addItem("FAST");
ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS
ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP
ui->cbxAuth->setCurrentIndex(2);
connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth()));
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,487);
}
DlgHideWifiEapPwd::~DlgHideWifiEapPwd()
{
delete ui;
}
void DlgHideWifiEapPwd::mousePressEvent(QMouseEvent *event){
if(event->button() == Qt::LeftButton){
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
}
void DlgHideWifiEapPwd::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
}
void DlgHideWifiEapPwd::mouseMoveEvent(QMouseEvent *event){
if(this->isPress){
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
}
void DlgHideWifiEapPwd::changeDialogSecu()
{
if(ui->cbxSecurity->currentIndex()==0){
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0);
connHidWifi->show();
} else if(ui->cbxSecurity->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(0);
connHidWifiWpa->show();
} else if(ui->cbxSecurity->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(0);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(1);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
connHidWifiLeap->show();
} else if(ui->cbxSecurity->currentIndex()==5) {
if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(5);
WepOrWpa = 0;
}
} else {
if (WepOrWpa == 0){
ui->cbxSecurity->setCurrentIndex(6);
WepOrWpa = 1;
}
}
}
void DlgHideWifiEapPwd::changeDialogAuth()
{
if(ui->cbxAuth->currentIndex()==0){
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(WepOrWpa);
//connHidWifiEapTls->show();
} else if(ui->cbxAuth->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapLeap *connHidWifiEapLeap = new DlgHideWifiEapLeap(WepOrWpa);
connHidWifiEapLeap->show();
} else if(ui->cbxAuth->currentIndex()==2) {
qDebug()<<"it's not need to change dialog";
} else if(ui->cbxAuth->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapFast *connHidWifiEapFast = new DlgHideWifiEapFast(WepOrWpa);
connHidWifiEapFast->show();
} else if(ui->cbxAuth->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapTTLS *connHidWifiEapTTls = new DlgHideWifiEapTTLS(WepOrWpa);
connHidWifiEapTTls->show();
} else {
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(WepOrWpa);
//connHidWifiEapPeap->show();
}
}
void DlgHideWifiEapPwd::on_btnCancel_clicked()
{
this->close();
}
void DlgHideWifiEapPwd::on_btnConnect_clicked()
{
this->close();
}
void DlgHideWifiEapPwd::on_checkBox_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->lePassword ->setEchoMode(QLineEdit::Password);
} else {
ui->lePassword->setEchoMode(QLineEdit::Normal);
}
}
void DlgHideWifiEapPwd::on_leNetName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapPwd::on_leUserName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapPwd::on_lePassword_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapPwd::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,72 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DLGCONNHIDWIFISECPWD_H
#define DLGCONNHIDWIFISECPWD_H
#include <QDialog>
#include <QMouseEvent>
namespace Ui {
class DlgHideWifiEapPwd;
}
class DlgHideWifiEapPwd : public QDialog
{
Q_OBJECT
public:
explicit DlgHideWifiEapPwd(int type, QWidget *parent = 0);
~DlgHideWifiEapPwd();
protected:
void paintEvent(QPaintEvent *event);
public slots:
void changeDialogSecu();
void changeDialogAuth();
private slots:
void on_btnCancel_clicked();
void on_btnConnect_clicked();
void on_checkBox_stateChanged(int arg1);
void on_leNetName_textEdited(const QString &arg1);
void on_leUserName_textEdited(const QString &arg1);
void on_lePassword_textEdited(const QString &arg1);
private:
Ui::DlgHideWifiEapPwd *ui;
int WepOrWpa = 0;//0 WEP;1WPA
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss;
bool isPress;
QPoint winPos;
QPoint dragPos;
};
#endif // DLGCONNHIDWIFISECPWD_H

View File

@ -1,354 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgHideWifiEapPwd</class>
<widget class="QDialog" name="DlgHideWifiEapPwd">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>487</height>
</rect>
</property>
<property name="windowTitle">
<string>Connect to Hidden WLAN Network</string>
</property>
<widget class="QCheckBox" name="checkBox">
<property name="geometry">
<rect>
<x>333</x>
<y>363</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>440</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbBoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>487</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>140</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leNetName">
<property name="geometry">
<rect>
<x>175</x>
<y>170</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbAuth">
<property name="geometry">
<rect>
<x>76</x>
<y>266</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbUserName">
<property name="geometry">
<rect>
<x>76</x>
<y>311</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbConn">
<property name="geometry">
<rect>
<x>76</x>
<y>80</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxConn">
<property name="geometry">
<rect>
<x>175</x>
<y>75</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QPushButton" name="btnConnect">
<property name="geometry">
<rect>
<x>315</x>
<y>440</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxSecurity">
<property name="geometry">
<rect>
<x>175</x>
<y>215</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLineEdit" name="leUserName">
<property name="geometry">
<rect>
<x>175</x>
<y>305</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLineEdit" name="lePassword">
<property name="geometry">
<rect>
<x>175</x>
<y>350</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QLabel" name="lbNetName">
<property name="geometry">
<rect>
<x>76</x>
<y>176</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbSecurity">
<property name="geometry">
<rect>
<x>76</x>
<y>221</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbPassword">
<property name="geometry">
<rect>
<x>76</x>
<y>356</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxAuth">
<property name="geometry">
<rect>
<x>175</x>
<y>260</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>410</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<zorder>lbBoder</zorder>
<zorder>btnCancel</zorder>
<zorder>leNetName</zorder>
<zorder>lbAuth</zorder>
<zorder>lbUserName</zorder>
<zorder>lbConn</zorder>
<zorder>cbxConn</zorder>
<zorder>btnConnect</zorder>
<zorder>cbxSecurity</zorder>
<zorder>leUserName</zorder>
<zorder>lePassword</zorder>
<zorder>lbNetName</zorder>
<zorder>lbSecurity</zorder>
<zorder>lbPassword</zorder>
<zorder>cbxAuth</zorder>
<zorder>lbLeftupTitle</zorder>
<zorder>lineUp</zorder>
<zorder>lineDown</zorder>
<zorder>checkBox</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,652 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "ui_dlghidewifieaptls.h"
#include "kylinheadfile.h"
#include "mainwindow.h"
#include "kylin-dbus-interface.h"
#include <QStandardItemModel>
#include <QDir>
DlgHideWifiEapTls::DlgHideWifiEapTls(int type, int beUsed, OldMainWindow *mainWindow, QWidget *parent) :
WepOrWpa(type),
isUsed(beUsed),
QDialog(parent),
ui(new Ui::DlgHideWifiEapTls)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
ui->lbBoder->hide();
ui->lbLeftupTitle->setStyleSheet("QLabel{font-size:20px;}");
ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss);
ui->checkBoxPwdSec->setStyleSheet(objQss.checkBoxQss);
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->lbLeftupTitle->setText(tr("Add hidden WLAN")); //加入隐藏WLAN
ui->lbConn->setText(tr("Connection")); //连接设置:
ui->lbNetName->setText(tr("Network name")); //网络名称:
ui->lbSecurity->setText(tr("WLAN security")); //Wi-Fi安全性:
ui->lbAuth->setText(tr("Authentication")); //认证:
ui->lbIdentity->setText(tr("Identity")); //身份:
ui->lbDomain->setText(tr("Domain")); //域名:
ui->lbCA->setText(tr("CA certificate")); //CA 证书:
ui->lbCaPwd->setText(tr("CA certificate password")); //CA 证书密码:
ui->checkBoxCA->setText(tr("No CA certificate is required")); //不需要CA证书
ui->lbUserCertify->setText(tr("User certificate")); //用户证书:
ui->lbUserCertifyPwd->setText(tr("User certificate password")); //用户证书密码:
ui->lbUserPriKey->setText(tr("User private key")); //用户私钥:
ui->lbUserKeyPwd->setText(tr("User key password")); //用户密钥密码:
ui->btnCancel->setText(tr("Cancel")); //取消
ui->btnConnect->setText(tr("Connect")); //连接
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
QStringList txtLine = txt.split("\n");
file.close();
foreach (QString line, txtLine) {
if(line.indexOf("wifi") != -1){
QStringList subLine = line.split(" ");
ui->cbxConn->addItem(subLine[0]);
}
}
ui->cbxConn->setCurrentIndex(0);
connect(ui->cbxConn,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeWindow()));
ui->cbxSecurity->addItem(tr("None")); //无
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
//ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII)
//ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句
//ui->cbxSecurity->addItem("LEAP");
//ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x)
if (WepOrWpa == 0) {
ui->cbxSecurity->setCurrentIndex(5);
} else if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(2);
}
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu()));
ui->cbxAuth->addItem("TLS");
ui->cbxAuth->addItem("LEAP");
ui->cbxAuth->addItem("PWD");
ui->cbxAuth->addItem("FAST");
ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS
ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP
ui->cbxAuth->setCurrentIndex(0);
connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth()));
ui->cbxCA->addItem(tr("None")); //无
ui->cbxCA->addItem(tr("Choose from file")); //从文件选择...
ui->cbxCA->setCurrentIndex(0);
ui->cbxUserCertify->addItem(tr("None")); //无
ui->cbxUserCertify->addItem(tr("Choose from file")); //从文件选择...
ui->cbxUserCertify->setCurrentIndex(0);
ui->cbxUserPriKey->addItem(tr("None")); //无
ui->cbxUserPriKey->addItem(tr("Choose from file")); //从文件选择...
ui->cbxUserPriKey->setCurrentIndex(0);
ui->btnConnect->setEnabled(false);
ui->lbCaPwd->setEnabled(false);
ui->leCaPwd->setEnabled(false);
ui->lbUserCertifyPwd->setEnabled(false);
ui->leUserCertifyPwd->setEnabled(false);
ui->lbUserPriKey->setEnabled(false);
ui->cbxUserPriKey->setEnabled(false);
ui->lbUserKeyPwd->setEnabled(false);
ui->leUserKeyPwd->setEnabled(false);
this->setFixedSize(432,705);
this->mw = mainWindow;
}
DlgHideWifiEapTls::~DlgHideWifiEapTls()
{
delete ui;
}
void DlgHideWifiEapTls::mousePressEvent(QMouseEvent *event){
if(event->button() == Qt::LeftButton){
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
}
void DlgHideWifiEapTls::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
}
void DlgHideWifiEapTls::mouseMoveEvent(QMouseEvent *event){
if(this->isPress){
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
}
//切换到其他Wi-Fi安全类型
void DlgHideWifiEapTls::changeDialogSecu()
{
if(ui->cbxSecurity->currentIndex()==0){
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0, mw);
connHidWifi->show();
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
} else if(ui->cbxSecurity->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(0);
connHidWifiWpa->show();
connect(connHidWifiWpa, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
} else if(ui->cbxSecurity->currentIndex()==2) {
qDebug()<<"it's not need to change dialog";
//if (WepOrWpa == 0) {
// ui->cbxSecurity->setCurrentIndex(6);
// WepOrWpa = 1;
//}
} else if(ui->cbxSecurity->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(0);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(1);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==5) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
connHidWifiLeap->show();
} else {
if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(5);
WepOrWpa = 0;
}
}
}
//同一 Wi-Fi安全类型的Authentication变换
void DlgHideWifiEapTls::changeDialogAuth()
{
if(ui->cbxAuth->currentIndex()==0){
qDebug()<<"it's not need to change dialog";
} else if(ui->cbxAuth->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapLeap *connHidWifiEapLeap = new DlgHideWifiEapLeap(WepOrWpa);
connHidWifiEapLeap->show();
} else if(ui->cbxAuth->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapPwd *connHidWifiEapPwd = new DlgHideWifiEapPwd(WepOrWpa);
connHidWifiEapPwd->show();
} else if(ui->cbxAuth->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapFast *connHidWifiEapFast = new DlgHideWifiEapFast(WepOrWpa);
connHidWifiEapFast->show();
} else if(ui->cbxAuth->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapTTLS *connHidWifiEapTTls = new DlgHideWifiEapTTLS(WepOrWpa);
connHidWifiEapTTls->show();
} else {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(WepOrWpa, 0, mw);
connHidWifiEapPeap->show();
}
}
//同一 Wi-Fi安全类型的窗口变换
void DlgHideWifiEapTls::changeWindow(){
if (ui->cbxConn->currentIndex() == 0){
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0, mw);
connHidWifi->show();
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
}else if (ui->cbxConn->currentIndex() >= 1){
QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName();
QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' >" + tmpPath;
int status = system(currStr.toUtf8().data());
qDebug()<<"executed cmd="<<currStr<<". res="<<status;
QFile file(tmpPath);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
file.close();
if (txt.indexOf("802-11-wireless-security.key-mgmt:") != -1){
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(ui->cbxConn->currentIndex(), mw);
connHidWifiWpa->show();
connect(connHidWifiWpa, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
} else {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(ui->cbxConn->currentIndex(), mw);
connHidWifi->show();
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
}
}
}
void DlgHideWifiEapTls::on_cbxCA_currentIndexChanged(const QString &arg1)
{
if (ui->cbxCA->currentIndex() == 0){
ui->leCaPwd->setText("");
ui->lbCaPwd->setEnabled(false);
ui->leCaPwd->setEnabled(false);
}else{
ui->leCaPwd->setText("");
ui->lbCaPwd->setEnabled(true);
ui->leCaPwd->setEnabled(true);
}
}
void DlgHideWifiEapTls::on_cbxUserCertify_currentIndexChanged(const QString &arg1)
{
if (ui->cbxUserCertify->currentIndex() == 0){
ui->leUserCertifyPwd->setText("");
ui->lbUserCertifyPwd->setEnabled(false);
ui->leUserCertifyPwd->setEnabled(false);
ui->lbUserPriKey->setEnabled(false);
ui->cbxUserPriKey->setEnabled(false);
ui->cbxUserPriKey->setCurrentIndex(0);
ui->leUserKeyPwd->setText("");
ui->lbUserKeyPwd->setEnabled(false);
ui->leUserKeyPwd->setEnabled(false);
}else{
ui->leUserCertifyPwd->setText("");
ui->lbUserCertifyPwd->setEnabled(true);
ui->leUserCertifyPwd->setEnabled(true);
ui->lbUserPriKey->setEnabled(true);
ui->cbxUserPriKey->setEnabled(true);
ui->cbxUserPriKey->setCurrentIndex(0);
ui->leUserKeyPwd->setText("");
ui->lbUserKeyPwd->setEnabled(false);
ui->leUserKeyPwd->setEnabled(false);
}
}
void DlgHideWifiEapTls::on_cbxUserPriKey_currentIndexChanged(const QString &arg1)
{
if (ui->cbxUserPriKey->currentIndex() == 0){
ui->leUserKeyPwd->setText("");
ui->lbUserKeyPwd->setEnabled(false);
ui->leUserKeyPwd->setEnabled(false);
}else{
ui->leUserKeyPwd->setText("");
ui->lbUserKeyPwd->setEnabled(true);
ui->leUserKeyPwd->setEnabled(true);
}
}
void DlgHideWifiEapTls::on_btnCancel_clicked()
{
this->close();
}
void DlgHideWifiEapTls::on_btnConnect_clicked()
{
this->close();
}
void DlgHideWifiEapTls::on_checkBoxCA_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->cbxCA->setCurrentIndex(0);
ui->lbCA->setEnabled(true);
ui->cbxCA->setEnabled(true);
} else {
ui->cbxCA->setCurrentIndex(0);
ui->lbCA->setEnabled(false);
ui->cbxCA->setEnabled(false);
}
}
void DlgHideWifiEapTls::on_checkBoxPwd_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->leCaPwd->setEchoMode(QLineEdit::Password);
} else {
ui->leCaPwd->setEchoMode(QLineEdit::Normal);
}
}
void DlgHideWifiEapTls::on_checkBoxPwdSec_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->leUserCertifyPwd->setEchoMode(QLineEdit::Password);
ui->leUserKeyPwd->setEchoMode(QLineEdit::Password);
} else {
ui->leUserCertifyPwd->setEchoMode(QLineEdit::Normal);
ui->leUserKeyPwd->setEchoMode(QLineEdit::Normal);
}
}
void DlgHideWifiEapTls::on_leNetName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leIdentity->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxCA->currentIndex() == 0){
if (ui->cbxUserCertify->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else {
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserPriKey->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
}
}
} else {
if (ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserCertify->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else {
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserPriKey->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
}
}
}
}
}
}
void DlgHideWifiEapTls::on_leIdentity_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leIdentity->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxCA->currentIndex() == 0){
if (ui->cbxUserCertify->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else {
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserPriKey->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
}
}
} else {
if (ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserCertify->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else {
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserPriKey->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
}
}
}
}
}
}
void DlgHideWifiEapTls::on_leDomain_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leIdentity->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxCA->currentIndex() == 0){
if (ui->cbxUserCertify->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else {
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserPriKey->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
}
}
} else {
if (ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserCertify->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else {
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserPriKey->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
}
}
}
}
}
}
void DlgHideWifiEapTls::on_leCaPwd_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leIdentity->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
} else if(ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserCertify->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else {
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxUserPriKey->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
}
}
}
}
void DlgHideWifiEapTls::on_leUserCertifyPwd_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leIdentity->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxCA->currentIndex() == 0){
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
if (ui->cbxUserPriKey->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
}
} else {
if (ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
if (ui->cbxUserPriKey->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
}
}
}
}
}
void DlgHideWifiEapTls::on_leUserKeyPwd_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leIdentity->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
if (ui->cbxCA->currentIndex() == 0){
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
} else {
if (ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
if (ui->leUserCertifyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leUserKeyPwd->text() == ""){
ui->btnConnect->setEnabled(false);
} else{
ui->btnConnect->setEnabled(true);
}
}
}
}
}
void DlgHideWifiEapTls::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,93 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DLGCONNHIDWIFISECTLS_H
#define DLGCONNHIDWIFISECTLS_H
#include <QDialog>
#include <QMouseEvent>
class OldMainWindow;
namespace Ui {
class DlgHideWifiEapTls;
}
class DlgHideWifiEapTls : public QDialog
{
Q_OBJECT
public:
explicit DlgHideWifiEapTls(int type, int beUsed, OldMainWindow *mw = 0, QWidget *parent = 0);
~DlgHideWifiEapTls();
protected:
void paintEvent(QPaintEvent *event);
public slots:
void changeDialogSecu();
void changeDialogAuth();
void changeWindow();
private slots:
void on_btnCancel_clicked();
void on_btnConnect_clicked();
void on_checkBoxCA_stateChanged(int arg1);
void on_checkBoxPwd_stateChanged(int arg1);
void on_checkBoxPwdSec_stateChanged(int arg1);
void on_leNetName_textEdited(const QString &arg1);
void on_leIdentity_textEdited(const QString &arg1);
void on_leDomain_textEdited(const QString &arg1);
void on_leCaPwd_textEdited(const QString &arg1);
void on_leUserCertifyPwd_textEdited(const QString &arg1);
void on_leUserKeyPwd_textEdited(const QString &arg1);
void on_cbxCA_currentIndexChanged(const QString &arg1);
void on_cbxUserCertify_currentIndexChanged(const QString &arg1);
void on_cbxUserPriKey_currentIndexChanged(const QString &arg1);
private:
Ui::DlgHideWifiEapTls *ui;
int WepOrWpa = 0;//0 WEP;1WPA
int isUsed;//=0 current wifi not used before; >=1 used
OldMainWindow *mw;
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss;
bool isPress;
QPoint winPos;
QPoint dragPos;
};
#endif // DLGCONNHIDWIFISECTLS_H

View File

@ -1,617 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgHideWifiEapTls</class>
<widget class="QDialog" name="DlgHideWifiEapTls">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>705</height>
</rect>
</property>
<property name="windowTitle">
<string>Connect to Hidden WLAN Network</string>
</property>
<widget class="QComboBox" name="cbxSecurity">
<property name="geometry">
<rect>
<x>180</x>
<y>185</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLineEdit" name="leNetName">
<property name="geometry">
<rect>
<x>180</x>
<y>145</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLineEdit" name="leUserCertifyPwd">
<property name="geometry">
<rect>
<x>180</x>
<y>505</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QLineEdit" name="leCaPwd">
<property name="geometry">
<rect>
<x>180</x>
<y>385</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxPwd">
<property name="geometry">
<rect>
<x>357</x>
<y>397</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbConn">
<property name="geometry">
<rect>
<x>76</x>
<y>80</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbNetName">
<property name="geometry">
<rect>
<x>76</x>
<y>150</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbDomain">
<property name="geometry">
<rect>
<x>76</x>
<y>310</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbCA">
<property name="geometry">
<rect>
<x>76</x>
<y>350</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxUserCertify">
<property name="geometry">
<rect>
<x>180</x>
<y>465</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbIdentity">
<property name="geometry">
<rect>
<x>76</x>
<y>270</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbUserCertifyPwd">
<property name="geometry">
<rect>
<x>76</x>
<y>510</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>660</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbUserKeyPwd">
<property name="geometry">
<rect>
<x>76</x>
<y>590</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxCA">
<property name="geometry">
<rect>
<x>180</x>
<y>345</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbUserPriKey">
<property name="geometry">
<rect>
<x>76</x>
<y>550</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbCaPwd">
<property name="geometry">
<rect>
<x>76</x>
<y>390</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leDomain">
<property name="geometry">
<rect>
<x>180</x>
<y>305</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxPwdSec">
<property name="geometry">
<rect>
<x>357</x>
<y>597</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leIdentity">
<property name="geometry">
<rect>
<x>180</x>
<y>265</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLineEdit" name="leUserKeyPwd">
<property name="geometry">
<rect>
<x>180</x>
<y>585</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QLabel" name="lbUserCertify">
<property name="geometry">
<rect>
<x>76</x>
<y>470</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbAuth">
<property name="geometry">
<rect>
<x>76</x>
<y>230</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxAuth">
<property name="geometry">
<rect>
<x>180</x>
<y>225</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QPushButton" name="btnConnect">
<property name="geometry">
<rect>
<x>315</x>
<y>660</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxCA">
<property name="geometry">
<rect>
<x>180</x>
<y>425</y>
<width>200</width>
<height>25</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxConn">
<property name="geometry">
<rect>
<x>180</x>
<y>75</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QComboBox" name="cbxUserPriKey">
<property name="geometry">
<rect>
<x>180</x>
<y>545</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbSecurity">
<property name="geometry">
<rect>
<x>76</x>
<y>190</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbBoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>705</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>140</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>125</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>640</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<zorder>lbBoder</zorder>
<zorder>cbxSecurity</zorder>
<zorder>leNetName</zorder>
<zorder>leUserCertifyPwd</zorder>
<zorder>leCaPwd</zorder>
<zorder>checkBoxPwd</zorder>
<zorder>lbConn</zorder>
<zorder>lbNetName</zorder>
<zorder>lbDomain</zorder>
<zorder>lbCA</zorder>
<zorder>cbxUserCertify</zorder>
<zorder>lbIdentity</zorder>
<zorder>lbUserCertifyPwd</zorder>
<zorder>btnCancel</zorder>
<zorder>lbUserKeyPwd</zorder>
<zorder>cbxCA</zorder>
<zorder>lbUserPriKey</zorder>
<zorder>lbCaPwd</zorder>
<zorder>leDomain</zorder>
<zorder>leIdentity</zorder>
<zorder>leUserKeyPwd</zorder>
<zorder>lbUserCertify</zorder>
<zorder>lbAuth</zorder>
<zorder>cbxAuth</zorder>
<zorder>btnConnect</zorder>
<zorder>checkBoxCA</zorder>
<zorder>cbxConn</zorder>
<zorder>cbxUserPriKey</zorder>
<zorder>lbSecurity</zorder>
<zorder>lbLeftupTitle</zorder>
<zorder>checkBoxPwdSec</zorder>
<zorder>lineUp</zorder>
<zorder>lineDown</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,466 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dlghidewifieapttls.h"
#include "ui_dlghidewifieapttls.h"
#include "kylinheadfile.h"
#include "kylin-dbus-interface.h"
DlgHideWifiEapTTLS::DlgHideWifiEapTTLS(int type, QWidget *parent) :
WepOrWpa(type),
QDialog(parent),
ui(new Ui::DlgHideWifiEapTTLS)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
ui->lbBoder->hide();
ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}");
ui->lbConn->setStyleSheet(objQss.labelQss);
ui->lbNetName->setStyleSheet(objQss.labelQss);
ui->lbSecurity->setStyleSheet(objQss.labelQss);
ui->lbAuth->setStyleSheet(objQss.labelQss);
ui->lbAnonyId->setStyleSheet(objQss.labelQss);
ui->lbDomain->setStyleSheet(objQss.labelQss);
ui->lbCA->setStyleSheet(objQss.labelQss);
ui->lbCaPwd->setStyleSheet(objQss.labelQss);
ui->lbInnerAuth->setStyleSheet(objQss.labelQss);
ui->lbUserName->setStyleSheet(objQss.labelQss);
ui->lbPassword->setStyleSheet(objQss.labelQss);
ui->cbxConn->setStyleSheet(objQss.cbxQss);
ui->cbxConn->setView(new QListView());
ui->leNetName->setStyleSheet(objQss.leQss);
ui->cbxSecurity->setStyleSheet(objQss.cbxQss);
ui->cbxSecurity->setView(new QListView());
ui->cbxAuth->setStyleSheet(objQss.cbxQss);
ui->cbxAuth->setView(new QListView());
ui->leAnonyId->setStyleSheet(objQss.leQss);
ui->leDomain->setStyleSheet(objQss.leQss);
ui->cbxCA->setStyleSheet(objQss.cbxQss);
ui->cbxCA->setView(new QListView());
ui->leCaPwd->setStyleSheet(objQss.leQss);
ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss);
ui->checkBoxCA->setStyleSheet(objQss.checkBoxCAQss);
ui->cbxInnerAuth->setStyleSheet(objQss.cbxQss);
ui->cbxInnerAuth->setView(new QListView());
ui->leUserName->setStyleSheet(objQss.leQss);
ui->lePassword->setStyleSheet(objQss.leQss);
ui->checkBoxPwdSec->setStyleSheet(objQss.checkBoxQss);
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->checkBoxCA->setFocusPolicy(Qt::NoFocus);
ui->lbLeftupTitle->setText(tr("Add hidden WLAN")); //加入隐藏WLAN
ui->lbConn->setText(tr("Connection")); //连接设置:
ui->lbNetName->setText(tr("Network name")); //网络名称:
ui->lbSecurity->setText(tr("WLAN security")); //Wi-Fi安全性:
ui->lbAuth->setText(tr("Authentication")); //认证:
ui->lbAnonyId->setText(tr("Anonymous identity")); //匿名身份:
ui->lbDomain->setText(tr("Domain")); //域名:
ui->lbCA->setText(tr("CA certificate")); //CA 证书:
ui->lbCaPwd->setText(tr("CA certificate password")); //CA 证书密码:
ui->checkBoxCA->setText(tr("No CA certificate is required")); //不需要CA证书
ui->lbInnerAuth->setText(tr("Inner authentication")); //内部认证:
ui->lbUserName->setText(tr("Username")); //用户名:
ui->lbPassword->setText(tr("Password")); //密码:
ui->btnCancel->setText(tr("Cancel")); //取消
ui->btnConnect->setText(tr("Connect")); //连接
ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
QStringList txtLine = txt.split("\n");
file.close();
foreach (QString line, txtLine) {
if(line.indexOf("wifi") != -1){
QStringList subLine = line.split(" ");
ui->cbxConn->addItem(subLine[0]);
}
}
ui->cbxConn->setCurrentIndex(0);
ui->cbxSecurity->addItem(tr("None")); //无
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII)
ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句
ui->cbxSecurity->addItem("LEAP");
ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x)
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
if (WepOrWpa == 0) {
ui->cbxSecurity->setCurrentIndex(5);
} else if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(6);
}
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu()));
ui->cbxAuth->addItem("TLS");
ui->cbxAuth->addItem("LEAP");
ui->cbxAuth->addItem("PWD");
ui->cbxAuth->addItem("FAST");
ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS
ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP
ui->cbxAuth->setCurrentIndex(4);
connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth()));
ui->cbxCA->addItem(tr("None")); //无
ui->cbxCA->addItem(tr("Choose from file")); //从文件选择...
ui->cbxCA->setCurrentIndex(0);
ui->cbxInnerAuth->addItem("PAP");
ui->cbxInnerAuth->addItem("MSCHAP");
ui->cbxInnerAuth->addItem("MSCHAPv2");
ui->cbxInnerAuth->addItem("MSCHAPv2(no EAP)");
ui->cbxInnerAuth->addItem("CHAP");
ui->cbxInnerAuth->addItem("MDS");
ui->cbxInnerAuth->addItem("GTC");
ui->cbxInnerAuth->setCurrentIndex(0);
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,665);
}
DlgHideWifiEapTTLS::~DlgHideWifiEapTTLS()
{
delete ui;
}
void DlgHideWifiEapTTLS::mousePressEvent(QMouseEvent *event){
if(event->button() == Qt::LeftButton){
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
}
void DlgHideWifiEapTTLS::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
}
void DlgHideWifiEapTTLS::mouseMoveEvent(QMouseEvent *event){
if(this->isPress){
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
}
void DlgHideWifiEapTTLS::changeDialogSecu()
{
if(ui->cbxSecurity->currentIndex()==0){
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0);
connHidWifi->show();
} else if(ui->cbxSecurity->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(0);
connHidWifiWpa->show();
} else if(ui->cbxSecurity->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(0);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(1);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
connHidWifiLeap->show();
} else if(ui->cbxSecurity->currentIndex()==5) {
if (WepOrWpa == 1) {
ui->cbxSecurity->setCurrentIndex(5);
WepOrWpa = 0;
}
} else {
if (WepOrWpa == 0){
ui->cbxSecurity->setCurrentIndex(6);
WepOrWpa = 1;
}
}
}
void DlgHideWifiEapTTLS::changeDialogAuth()
{
if(ui->cbxAuth->currentIndex()==0){
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(WepOrWpa);
//connHidWifiEapTls->show();
} else if(ui->cbxAuth->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapLeap *connHidWifiEapLeap = new DlgHideWifiEapLeap(WepOrWpa);
connHidWifiEapLeap->show();
} else if(ui->cbxAuth->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapPwd *connHidWifiEapPwd = new DlgHideWifiEapPwd(WepOrWpa);
connHidWifiEapPwd->show();
} else if(ui->cbxAuth->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapFast *connHidWifiEapFast = new DlgHideWifiEapFast(WepOrWpa);
connHidWifiEapFast->show();
} else if(ui->cbxAuth->currentIndex()==4) {
qDebug()<<"it's not need to change dialog";
} else {
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(WepOrWpa);
//connHidWifiEapPeap->show();
}
}
void DlgHideWifiEapTTLS::on_cbxCA_currentIndexChanged(const QString &arg1)
{
if (ui->cbxCA->currentIndex() == 0){
ui->leCaPwd->setText("");
ui->lbCaPwd->setEnabled(false);
ui->leCaPwd->setEnabled(false);
} else {
ui->leCaPwd->setText("");
ui->lbCaPwd->setEnabled(true);
ui->leCaPwd->setEnabled(true);
}
}
void DlgHideWifiEapTTLS::on_btnCancel_clicked()
{
this->close();
}
void DlgHideWifiEapTTLS::on_btnConnect_clicked()
{
this->close();
}
void DlgHideWifiEapTTLS::on_checkBoxPwd_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->leCaPwd->setEchoMode(QLineEdit::Password);
} else {
ui->leCaPwd->setEchoMode(QLineEdit::Normal);
}
}
void DlgHideWifiEapTTLS::on_checkBoxCA_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->cbxCA->setCurrentIndex(0);
ui->leCaPwd->setText("");
ui->lbCA->setEnabled(true);
ui->cbxCA->setEnabled(true);
} else {
ui->cbxCA->setCurrentIndex(0);
ui->leCaPwd->setText("");
ui->lbCA->setEnabled(false);
ui->cbxCA->setEnabled(false);
}
}
void DlgHideWifiEapTTLS::on_checkBoxPwdSec_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->lePassword->setEchoMode(QLineEdit::Password);
} else {
ui->lePassword->setEchoMode(QLineEdit::Normal);
}
}
void DlgHideWifiEapTTLS::on_leNetName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leAnonyId->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
if (ui->cbxCA->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if(ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
ui->btnConnect->setEnabled(true);
}
}
}
void DlgHideWifiEapTTLS::on_leAnonyId_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leAnonyId->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
if (ui->cbxCA->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if(ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
ui->btnConnect->setEnabled(true);
}
}
}
void DlgHideWifiEapTTLS::on_leDomain_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leAnonyId->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
if (ui->cbxCA->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if(ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
ui->btnConnect->setEnabled(true);
}
}
}
void DlgHideWifiEapTTLS::on_leCaPwd_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leAnonyId->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiEapTTLS::on_leUserName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leAnonyId->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
if (ui->cbxCA->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if(ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
ui->btnConnect->setEnabled(true);
}
}
}
void DlgHideWifiEapTTLS::on_lePwd_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leAnonyId->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leDomain->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
}else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
if (ui->cbxCA->currentIndex() == 0){
ui->btnConnect->setEnabled(true);
}else if(ui->leCaPwd->text() == ""){
ui->btnConnect->setEnabled(false);
}else{
ui->btnConnect->setEnabled(true);
}
}
}
void DlgHideWifiEapTTLS::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,84 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DLGCONNHIDWIFISECTUNNELTLS_H
#define DLGCONNHIDWIFISECTUNNELTLS_H
#include <QDialog>
#include <QMouseEvent>
namespace Ui {
class DlgHideWifiEapTTLS;
}
class DlgHideWifiEapTTLS : public QDialog
{
Q_OBJECT
public:
explicit DlgHideWifiEapTTLS(int type, QWidget *parent = 0);
~DlgHideWifiEapTTLS();
protected:
void paintEvent(QPaintEvent *event);
public slots:
void changeDialogSecu();
void changeDialogAuth();
private slots:
void on_btnCancel_clicked();
void on_btnConnect_clicked();
void on_cbxCA_currentIndexChanged(const QString &arg1);
void on_checkBoxPwd_stateChanged(int arg1);
void on_checkBoxCA_stateChanged(int arg1);
void on_checkBoxPwdSec_stateChanged(int arg1);
void on_leNetName_textEdited(const QString &arg1);
void on_leAnonyId_textEdited(const QString &arg1);
void on_leDomain_textEdited(const QString &arg1);
void on_leCaPwd_textEdited(const QString &arg1);
void on_leUserName_textEdited(const QString &arg1);
void on_lePwd_textEdited(const QString &arg1);
private:
Ui::DlgHideWifiEapTTLS *ui;
int WepOrWpa = 0;//0 WEP;1WPA
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss;
bool isPress;
QPoint winPos;
QPoint dragPos;
};
#endif // DLGCONNHIDWIFISECTUNNELTLS_H

View File

@ -1,579 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgHideWifiEapTTLS</class>
<widget class="QDialog" name="DlgHideWifiEapTTLS">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>665</height>
</rect>
</property>
<property name="windowTitle">
<string>Connect to Hidden Wi-Fi Network</string>
</property>
<widget class="QComboBox" name="cbxConn">
<property name="geometry">
<rect>
<x>180</x>
<y>75</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLineEdit" name="leCaPwd">
<property name="geometry">
<rect>
<x>180</x>
<y>385</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QLineEdit" name="leNetName">
<property name="geometry">
<rect>
<x>180</x>
<y>145</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="btnConnect">
<property name="geometry">
<rect>
<x>315</x>
<y>620</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="lePassword">
<property name="geometry">
<rect>
<x>180</x>
<y>545</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>620</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbDomain">
<property name="geometry">
<rect>
<x>76</x>
<y>310</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxPwdSec">
<property name="geometry">
<rect>
<x>357</x>
<y>557</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbUserName">
<property name="geometry">
<rect>
<x>76</x>
<y>510</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbSecurity">
<property name="geometry">
<rect>
<x>76</x>
<y>190</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxSecurity">
<property name="geometry">
<rect>
<x>180</x>
<y>185</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QComboBox" name="cbxCA">
<property name="geometry">
<rect>
<x>180</x>
<y>345</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QComboBox" name="cbxInnerAuth">
<property name="geometry">
<rect>
<x>180</x>
<y>465</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLineEdit" name="leUserName">
<property name="geometry">
<rect>
<x>180</x>
<y>505</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Normal</enum>
</property>
</widget>
<widget class="QLabel" name="lbCA">
<property name="geometry">
<rect>
<x>76</x>
<y>350</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxAuth">
<property name="geometry">
<rect>
<x>180</x>
<y>225</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbAnonyId">
<property name="geometry">
<rect>
<x>76</x>
<y>270</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbNetName">
<property name="geometry">
<rect>
<x>76</x>
<y>150</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxCA">
<property name="geometry">
<rect>
<x>180</x>
<y>425</y>
<width>200</width>
<height>25</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbInnerAuth">
<property name="geometry">
<rect>
<x>76</x>
<y>470</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leDomain">
<property name="geometry">
<rect>
<x>180</x>
<y>305</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbAuth">
<property name="geometry">
<rect>
<x>76</x>
<y>230</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbConn">
<property name="geometry">
<rect>
<x>76</x>
<y>80</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbCaPwd">
<property name="geometry">
<rect>
<x>76</x>
<y>390</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbPassword">
<property name="geometry">
<rect>
<x>76</x>
<y>550</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxPwd">
<property name="geometry">
<rect>
<x>357</x>
<y>397</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leAnonyId">
<property name="geometry">
<rect>
<x>180</x>
<y>265</y>
<width>200</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbBoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>665</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>140</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>125</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>600</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<zorder>lbBoder</zorder>
<zorder>cbxConn</zorder>
<zorder>leCaPwd</zorder>
<zorder>leNetName</zorder>
<zorder>btnConnect</zorder>
<zorder>lePassword</zorder>
<zorder>btnCancel</zorder>
<zorder>lbDomain</zorder>
<zorder>checkBoxPwdSec</zorder>
<zorder>lbUserName</zorder>
<zorder>lbSecurity</zorder>
<zorder>cbxSecurity</zorder>
<zorder>cbxCA</zorder>
<zorder>cbxInnerAuth</zorder>
<zorder>leUserName</zorder>
<zorder>lbCA</zorder>
<zorder>cbxAuth</zorder>
<zorder>lbAnonyId</zorder>
<zorder>lbNetName</zorder>
<zorder>checkBoxCA</zorder>
<zorder>lbInnerAuth</zorder>
<zorder>leDomain</zorder>
<zorder>lbAuth</zorder>
<zorder>lbConn</zorder>
<zorder>lbCaPwd</zorder>
<zorder>lbPassword</zorder>
<zorder>checkBoxPwd</zorder>
<zorder>leAnonyId</zorder>
<zorder>lbLeftupTitle</zorder>
<zorder>lineUp</zorder>
<zorder>lineDown</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,246 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "ui_dlghidewifileap.h"
#include "kylinheadfile.h"
#include "kylin-dbus-interface.h"
DlgHideWifiLeap::DlgHideWifiLeap(QWidget *parent) :
QDialog(parent),
ui(new Ui::DlgHideWifiLeap)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
ui->lbBoder->hide();
ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}");
ui->lbConn->setStyleSheet(objQss.labelQss);
ui->lbNetName->setStyleSheet(objQss.labelQss);
ui->lbSecurity->setStyleSheet(objQss.labelQss);
ui->lbUserName->setStyleSheet(objQss.labelQss);
ui->lbPassword->setStyleSheet(objQss.labelQss);
ui->cbxConn->setStyleSheet(objQss.cbxQss);
ui->cbxConn->setView(new QListView());
ui->leNetName->setStyleSheet(objQss.leQss);
ui->leUserName->setStyleSheet(objQss.leQss);
ui->lePassword->setStyleSheet(objQss.leQss);
ui->cbxSecurity->setStyleSheet(objQss.cbxQss);
ui->cbxSecurity->setView(new QListView());
ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss);
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi
ui->lbConn->setText(tr("Connection")); //连接设置:
ui->lbNetName->setText(tr("Network name")); //网络名称:
ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi安全性:
ui->lbUserName->setText(tr("Username")); //用户名:
ui->lbPassword->setText(tr("Password")); //密码:
ui->btnCancel->setText(tr("Cancel")); //取消
ui->btnConnect->setText(tr("Connect")); //连接
ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
QStringList txtLine = txt.split("\n");
file.close();
foreach (QString line, txtLine) {
if(line.indexOf("wifi") != -1){
QStringList subLine = line.split(" ");
ui->cbxConn->addItem(subLine[0]);
}
}
ui->cbxConn->setCurrentIndex(0);
ui->cbxSecurity->addItem(tr("None")); //无
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII)
ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句
ui->cbxSecurity->addItem("LEAP");
ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x)
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
ui->cbxSecurity->setCurrentIndex(4);
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog()));
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,434);
}
DlgHideWifiLeap::~DlgHideWifiLeap()
{
delete ui;
}
void DlgHideWifiLeap::mousePressEvent(QMouseEvent *event){
if(event->button() == Qt::LeftButton){
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
}
void DlgHideWifiLeap::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
}
void DlgHideWifiLeap::mouseMoveEvent(QMouseEvent *event){
if(this->isPress){
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
}
//切换到其他Wi-Fi安全类型
void DlgHideWifiLeap::changeDialog()
{
if(ui->cbxSecurity->currentIndex()==0){
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0);
connHidWifi->show();
} else if(ui->cbxSecurity->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(0);
connHidWifiWpa->show();
} else if(ui->cbxSecurity->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(0);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(1);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==4) {
qDebug()<<"it's not need to change dialog";
} else if(ui->cbxSecurity->currentIndex()==5) {
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(0);
//connHidWifiEapTls->show();
} else {
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(1);
//connHidWifiEapTls->show();
}
}
void DlgHideWifiLeap::on_btnCancel_clicked()
{
this->close();
}
void DlgHideWifiLeap::on_btnConnect_clicked()
{
this->close();
}
void DlgHideWifiLeap::on_checkBoxPwd_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->lePassword ->setEchoMode(QLineEdit::Password);
} else {
ui->lePassword->setEchoMode(QLineEdit::Normal);
}
}
void DlgHideWifiLeap::on_leNetName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "" || ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leNetName->text() == "" || ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == "" || ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiLeap::on_leUserName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiLeap::on_lePassword_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->leUserName->text() == ""){
ui->btnConnect->setEnabled(false);
} else if (ui->lePassword->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiLeap::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,70 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DLGCONNHIDWIFILEAP_H
#define DLGCONNHIDWIFILEAP_H
#include <QDialog>
#include <QMouseEvent>
namespace Ui {
class DlgHideWifiLeap;
}
class DlgHideWifiLeap : public QDialog
{
Q_OBJECT
public:
explicit DlgHideWifiLeap(QWidget *parent = 0);
~DlgHideWifiLeap();
protected:
void paintEvent(QPaintEvent *event);
public slots:
void changeDialog();
private slots:
void on_btnCancel_clicked();
void on_btnConnect_clicked();
void on_checkBoxPwd_stateChanged(int arg1);
void on_leNetName_textEdited(const QString &arg1);
void on_leUserName_textEdited(const QString &arg1);
void on_lePassword_textEdited(const QString &arg1);
private:
Ui::DlgHideWifiLeap *ui;
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss;
bool isPress;
QPoint winPos;
QPoint dragPos;
};
#endif // DLGCONNHIDWIFILEAP_H

View File

@ -1,319 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgHideWifiLeap</class>
<widget class="QDialog" name="DlgHideWifiLeap">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>434</height>
</rect>
</property>
<property name="windowTitle">
<string>Connect to Hidden Wi-Fi Network</string>
</property>
<widget class="QLineEdit" name="leUserName">
<property name="geometry">
<rect>
<x>175</x>
<y>264</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QComboBox" name="cbxSecurity">
<property name="geometry">
<rect>
<x>175</x>
<y>219</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>390</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbConn">
<property name="geometry">
<rect>
<x>76</x>
<y>84</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxConn">
<property name="geometry">
<rect>
<x>175</x>
<y>79</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbUserName">
<property name="geometry">
<rect>
<x>76</x>
<y>270</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxPwd">
<property name="geometry">
<rect>
<x>332</x>
<y>321</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbPassword">
<property name="geometry">
<rect>
<x>76</x>
<y>315</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbNetName">
<property name="geometry">
<rect>
<x>76</x>
<y>180</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbSecurity">
<property name="geometry">
<rect>
<x>76</x>
<y>225</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnConnect">
<property name="geometry">
<rect>
<x>315</x>
<y>390</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="lePassword">
<property name="geometry">
<rect>
<x>175</x>
<y>309</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QLineEdit" name="leNetName">
<property name="geometry">
<rect>
<x>175</x>
<y>174</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbBoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>434</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>32</y>
<width>140</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>134</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>364</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<zorder>lbBoder</zorder>
<zorder>leUserName</zorder>
<zorder>cbxSecurity</zorder>
<zorder>btnCancel</zorder>
<zorder>lbConn</zorder>
<zorder>cbxConn</zorder>
<zorder>lbUserName</zorder>
<zorder>lbPassword</zorder>
<zorder>lbNetName</zorder>
<zorder>lbSecurity</zorder>
<zorder>btnConnect</zorder>
<zorder>lePassword</zorder>
<zorder>leNetName</zorder>
<zorder>checkBoxPwd</zorder>
<zorder>lbLeftupTitle</zorder>
<zorder>lineUp</zorder>
<zorder>lineDown</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,248 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "ui_dlghidewifiwep.h"
#include "kylinheadfile.h"
#include "kylin-dbus-interface.h"
DlgHideWifiWep::DlgHideWifiWep(int type, QWidget *parent) :
WepPwdOrCode(type),
QDialog(parent),
ui(new Ui::DlgHideWifiWep)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
//需要添加 void paintEvent(QPaintEvent *event) 函数
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
ui->lbBoder->hide();
ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}");
ui->lbConn->setStyleSheet(objQss.labelQss);
ui->lbNetName->setStyleSheet(objQss.labelQss);
ui->lbSecurity->setStyleSheet(objQss.labelQss);
ui->lbKey->setStyleSheet(objQss.labelQss);
ui->lbWEPindex->setStyleSheet(objQss.labelQss);
ui->lbAuth->setStyleSheet(objQss.labelQss);
ui->cbxConn->setStyleSheet(objQss.cbxQss);
ui->cbxConn->setView(new QListView());
ui->leNetName->setStyleSheet(objQss.leQss);
ui->leKey->setStyleSheet(objQss.leQss);
ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss);
ui->cbxSecurity->setStyleSheet(objQss.cbxQss);
ui->cbxSecurity->setView(new QListView());
ui->cbxWEPindex->setStyleSheet(objQss.cbxQss);
ui->cbxWEPindex->setView(new QListView());
ui->cbxAuth->setStyleSheet(objQss.cbxQss);
ui->cbxAuth->setView(new QListView());
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi
ui->lbConn->setText(tr("Connection")); //连接设置:
ui->lbNetName->setText(tr("Network name")); //网络名称:
ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi 安全性:
ui->lbKey->setText(tr("Key")); //密钥:
ui->lbWEPindex->setText(tr("WEP index")); //WEP 检索:
ui->lbAuth->setText(tr("Authentication")); //认证:
ui->btnCancel->setText(tr("Cancel")); //取消
ui->btnConnect->setText(tr("Connect")); //连接
ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
QStringList txtLine = txt.split("\n");
file.close();
foreach (QString line, txtLine) {
if(line.indexOf("wifi") != -1){
QStringList subLine = line.split(" ");
ui->cbxConn->addItem(subLine[0]);
}
}
ui->cbxConn->setCurrentIndex(0);
ui->cbxSecurity->addItem(tr("None")); //无
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII)
ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句
ui->cbxSecurity->addItem("LEAP");
ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x)
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
if (WepPwdOrCode == 0) {
ui->cbxSecurity->setCurrentIndex(2);
} else if (WepPwdOrCode == 1) {
ui->cbxSecurity->setCurrentIndex(3);
}
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog()));
ui->cbxWEPindex->addItem(tr("1(default)")); //1(默认)
ui->cbxWEPindex->addItem("2");
ui->cbxWEPindex->addItem("3");
ui->cbxWEPindex->addItem("4");
ui->cbxWEPindex->setCurrentIndex(0);
ui->cbxAuth->addItem(tr("Open System")); //开放式系统
ui->cbxAuth->addItem(tr("Shared Key")); //共享密钥
ui->cbxAuth->setCurrentIndex(0);
ui->btnConnect->setEnabled(false);
this->setFixedSize(432,493);
}
DlgHideWifiWep::~DlgHideWifiWep()
{
delete ui;
}
void DlgHideWifiWep::mousePressEvent(QMouseEvent *event){
if(event->button() == Qt::LeftButton){
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
}
void DlgHideWifiWep::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
}
void DlgHideWifiWep::mouseMoveEvent(QMouseEvent *event){
if(this->isPress){
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
}
//切换到其他Wi-Fi安全类型
void DlgHideWifiWep::changeDialog()
{
if(ui->cbxSecurity->currentIndex()==0){
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0);
connHidWifi->show();
} else if(ui->cbxSecurity->currentIndex()==1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(0);
connHidWifiWpa->show();
} else if(ui->cbxSecurity->currentIndex()==2) {
if (WepPwdOrCode == 1) {
ui->cbxSecurity->setCurrentIndex(2);
WepPwdOrCode = 0;
}
} else if(ui->cbxSecurity->currentIndex()==3) {
if (WepPwdOrCode == 0) {
ui->cbxSecurity->setCurrentIndex(3);
WepPwdOrCode = 1;
}
} else if(ui->cbxSecurity->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
connHidWifiLeap->show();
} else if(ui->cbxSecurity->currentIndex()==5) {
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(0);
//connHidWifiEapTls->show();
} else {
//QApplication::setQuitOnLastWindowClosed(false);
//this->hide();
//DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(1);
//connHidWifiEapTls->show();
}
}
void DlgHideWifiWep::on_btnCancel_clicked()
{
this->close();
}
void DlgHideWifiWep::on_btnConnect_clicked()
{
this->close();
}
void DlgHideWifiWep::on_checkBoxPwd_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->leKey->setEchoMode(QLineEdit::Password);
} else {
ui->leKey->setEchoMode(QLineEdit::Normal);
}
}
void DlgHideWifiWep::on_leKey_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "" || ui->leKey->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiWep::on_leNetName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "" || ui->leKey->text() == ""){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiWep::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,69 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DLGCONNHIDWIFIWEP_H
#define DLGCONNHIDWIFIWEP_H
#include <QDialog>
#include <QMouseEvent>
namespace Ui {
class DlgHideWifiWep;
}
class DlgHideWifiWep : public QDialog
{
Q_OBJECT
public:
explicit DlgHideWifiWep(int type, QWidget *parent = 0);
~DlgHideWifiWep();
protected:
void paintEvent(QPaintEvent *event);
public slots:
void changeDialog();
private slots:
void on_btnCancel_clicked();
void on_btnConnect_clicked();
void on_checkBoxPwd_stateChanged(int arg1);
void on_leKey_textEdited(const QString &arg1);
void on_leNetName_textEdited(const QString &arg1);
private:
Ui::DlgHideWifiWep *ui;
int WepPwdOrCode = 0; //0 WEP password;1 WEP Code Sentence
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss;
bool isPress;
QPoint winPos;
QPoint dragPos;
};
#endif // DLGCONNHIDWIFIWEP_H

View File

@ -1,360 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgHideWifiWep</class>
<widget class="QDialog" name="DlgHideWifiWep">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>493</height>
</rect>
</property>
<property name="windowTitle">
<string>Connect to Hidden Wi-Fi Network</string>
</property>
<widget class="QLabel" name="lbKey">
<property name="geometry">
<rect>
<x>76</x>
<y>266</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbWEPindex">
<property name="geometry">
<rect>
<x>76</x>
<y>311</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbAuth">
<property name="geometry">
<rect>
<x>76</x>
<y>356</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxSecurity">
<property name="geometry">
<rect>
<x>175</x>
<y>215</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QPushButton" name="btnConnect">
<property name="geometry">
<rect>
<x>315</x>
<y>440</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxAuth">
<property name="geometry">
<rect>
<x>175</x>
<y>350</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbConn">
<property name="geometry">
<rect>
<x>76</x>
<y>80</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxWEPindex">
<property name="geometry">
<rect>
<x>175</x>
<y>305</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>440</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxPwd">
<property name="geometry">
<rect>
<x>332</x>
<y>272</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbNetName">
<property name="geometry">
<rect>
<x>76</x>
<y>176</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leKey">
<property name="geometry">
<rect>
<x>175</x>
<y>260</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QLineEdit" name="leNetName">
<property name="geometry">
<rect>
<x>175</x>
<y>170</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbSecurity">
<property name="geometry">
<rect>
<x>76</x>
<y>221</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxConn">
<property name="geometry">
<rect>
<x>175</x>
<y>75</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="lbBoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>493</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>140</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>410</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<zorder>lbBoder</zorder>
<zorder>leKey</zorder>
<zorder>lbKey</zorder>
<zorder>lbWEPindex</zorder>
<zorder>lbAuth</zorder>
<zorder>cbxSecurity</zorder>
<zorder>btnConnect</zorder>
<zorder>cbxAuth</zorder>
<zorder>lbConn</zorder>
<zorder>cbxWEPindex</zorder>
<zorder>btnCancel</zorder>
<zorder>checkBoxPwd</zorder>
<zorder>lbNetName</zorder>
<zorder>leNetName</zorder>
<zorder>lbSecurity</zorder>
<zorder>cbxConn</zorder>
<zorder>lbLeftupTitle</zorder>
<zorder>lineUp</zorder>
<zorder>lineDown</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,450 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dlghidewifiwpa.h"
#include "ui_dlghidewifiwpa.h"
#include "kylinheadfile.h"
#include "backthread.h"
#include "mainwindow.h"
#include "wpawifidialog.h"
#include <unistd.h>
#include <stdlib.h>
#include <QDir>
#include <QtConcurrent>
#include <QFuture>
DlgHideWifiWpa::DlgHideWifiWpa(int type, OldMainWindow *mainWindow, QWidget *parent) :
isUsed(type),
QDialog(parent),
ui(new Ui::DlgHideWifiWpa)
{
ui->setupUi(this);
this->setAttribute(Qt::WA_DeleteOnClose);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
//需要添加 void paintEvent(QPaintEvent *event) 函数
QPainterPath path;
auto rect = this->rect();
rect.adjust(1, 1, -1, -1);
path.addRoundedRect(rect, 6, 6);
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
MyQss objQss;
ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}");
ui->lbBoder->hide();
ui->lbLeftupTitle->setStyleSheet("QLabel{font-size:20px;}");
ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss);
ui->lineUp->setStyleSheet(objQss.lineQss);
ui->lineDown->setStyleSheet(objQss.lineQss);
ui->btnCancel->setFocusPolicy(Qt::NoFocus);
ui->checkBoxPwd->setFocusPolicy(Qt::NoFocus);
ui->lbLeftupTitle->setText(tr("Add Hidden Wi-Fi")); //加入隐藏Wi-Fi
ui->lbConn->setText(tr("Connection")); //连接设置:
ui->lbNetName->setText(tr("Wi-Fi name")); //网络名称:
ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi 安全性:
ui->lbPassword->setText(tr("Password")); //密码:
ui->btnCancel->setText(tr("Cancel")); //取消
ui->btnConnect->setText(tr("Connect")); //连接
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
ui->cbxConn->addItem(tr("C_reate…")); //新建...
KylinDBus mkylindbus;
QStringList wifiList = mkylindbus.getWifiSsidList();
foreach (QString strWifiSsid, wifiList) {
ui->cbxConn->addItem(strWifiSsid);
}
ui->cbxConn->setCurrentIndex(0);
connect(ui->cbxConn,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeWindow()));
ui->cbxSecurity->addItem(tr("None")); //无
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
//ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII)
//ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句
//ui->cbxSecurity->addItem("LEAP");
//ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x)
ui->cbxSecurity->setCurrentIndex(1);
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog()));
if (isUsed == 0) {
ui->btnConnect->setEnabled(false);
} else {
ui->cbxConn->setCurrentIndex(isUsed);
ui->leNetName->setText(ui->cbxConn->currentText());
ui->leNetName->setEnabled(false);
ui->lbNetName->setEnabled(false);
ui->lbSecurity->setEnabled(false);
ui->cbxSecurity->setEnabled(false);
ui->lbPassword->setEnabled(false);
ui->lePassword->setText("<Hidden>");
ui->lePassword->setEnabled(false);
ui->btnConnect->setEnabled(true);
ui->checkBoxPwd->setEnabled(false);
}
ui->leNetName->setContextMenuPolicy(Qt::NoContextMenu);//禁止LineEdit的右键菜单
ui->lePassword->setContextMenuPolicy(Qt::NoContextMenu);
this->setFixedSize(432,397);
this->mw = mainWindow;
}
DlgHideWifiWpa::~DlgHideWifiWpa()
{
delete ui;
}
void DlgHideWifiWpa::mousePressEvent(QMouseEvent *event){
if(event->button() == Qt::LeftButton){
this->isPress = true;
this->winPos = this->pos();
this->dragPos = event->globalPos();
event->accept();
}
return QDialog::mousePressEvent(event);
}
void DlgHideWifiWpa::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
return QDialog::mouseReleaseEvent(event);
}
void DlgHideWifiWpa::mouseMoveEvent(QMouseEvent *event){
if(this->isPress){
this->move(this->winPos - (this->dragPos - event->globalPos()));
event->accept();
}
return QDialog::mouseMoveEvent(event);
}
//切换到其他Wi-Fi安全类型
void DlgHideWifiWpa::changeDialog()
{
if (ui->cbxSecurity->currentIndex()==0) {
QApplication::setQuitOnLastWindowClosed(false);
this->close();
DlgHideWifi *connHidWifi = new DlgHideWifi(0,mw);
connHidWifi->show();
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
} else if(ui->cbxSecurity->currentIndex()==1) {
qDebug()<<"it's not need to change dialog";
} else if(ui->cbxSecurity->currentIndex()==2) {
QApplication::setQuitOnLastWindowClosed(false);
this->close();
WpaWifiDialog * wpadlg = new WpaWifiDialog(mw, mw, "");
QPoint pos = QCursor::pos();
QRect primaryGeometry;
for (QScreen *screen : qApp->screens()) {
if (screen->geometry().contains(pos)) {
primaryGeometry = screen->geometry();
}
}
if (primaryGeometry.isEmpty()) {
primaryGeometry = qApp->primaryScreen()->geometry();
}
wpadlg->move(primaryGeometry.width() / 2 - wpadlg->width() / 2, primaryGeometry.height() / 2 - wpadlg->height() / 2);
wpadlg->show();
connect(wpadlg, &WpaWifiDialog::conn_done, this, [ = ]() {
QString txt(tr("Conn Wifi Success"));
mw->objKyDBus->showDesktopNotify(txt);
mw->on_btnWifiList_clicked();
});
connect(wpadlg, &WpaWifiDialog::conn_failed, this, [ = ]() {
QString txt(tr("Confirm your Wi-Fi password or usable of wireless card"));
mw->objKyDBus->showDesktopNotify(txt);
mw->on_btnWifiList_clicked();
});
// DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(1, 0, mw);
// connHidWifiEapPeap->show();
} else if(ui->cbxSecurity->currentIndex()==3) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(0);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==4) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(1);
connHidWifiWep->show();
} else if(ui->cbxSecurity->currentIndex()==5) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
connHidWifiLeap->show();
} else {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(0, 0, mw);
connHidWifiEapPeap->show();
}
}
//同一 Wi-Fi安全类型的窗口变换
void DlgHideWifiWpa::changeWindow()
{
if (ui->cbxConn->currentIndex() == 0){
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(0, mw);
connHidWifi->show();
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
}else if (ui->cbxConn->currentIndex() >= 1){
QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName();
QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' > " + tmpPath;
int status = system(currStr.toUtf8().data());
qDebug()<<"executed cmd="<<currStr<<". res="<<status;
QFile file(tmpPath);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!";
}
QString txt = file.readAll();
file.close();
if (txt.indexOf("802-11-wireless-security.key-mgmt:") != -1){
if (txt.indexOf("wpa-psk") != -1) {
isUsed = ui->cbxConn->currentIndex();
ui->lbNetName->setEnabled(false);
ui->leNetName->setText(ui->cbxConn->currentText());
ui->leNetName->setEnabled(false);
ui->lbSecurity->setEnabled(false);
ui->cbxSecurity->setEnabled(false);
ui->lePassword->setText("<Hidden>");
ui->lbPassword->setEnabled(false);
ui->lePassword->setEnabled(false);
ui->btnConnect->setEnabled(true);
}
if (txt.indexOf("wpa-eap") != -1) {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
// DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(1, ui->cbxConn->currentIndex(), mw);
// connHidWifiEapPeap->show();
WpaWifiDialog * wpadlg = new WpaWifiDialog(mw, mw, ui->cbxConn->currentText());
QPoint pos = QCursor::pos();
QRect primaryGeometry;
for (QScreen *screen : qApp->screens()) {
if (screen->geometry().contains(pos)) {
primaryGeometry = screen->geometry();
}
}
if (primaryGeometry.isEmpty()) {
primaryGeometry = qApp->primaryScreen()->geometry();
}
wpadlg->move(primaryGeometry.width() / 2 - wpadlg->width() / 2, primaryGeometry.height() / 2 - wpadlg->height() / 2);
wpadlg->show();
connect(wpadlg, &WpaWifiDialog::conn_done, this, [ = ]() {
QString txt(tr("Conn Wifi Success"));
mw->objKyDBus->showDesktopNotify(txt);
mw->on_btnWifiList_clicked();
});
connect(wpadlg, &WpaWifiDialog::conn_failed, this, [ = ]() {
QString txt(tr("Confirm your Wi-Fi password or usable of wireless card"));
mw->objKyDBus->showDesktopNotify(txt);
mw->on_btnWifiList_clicked();
});
}
}else {
QApplication::setQuitOnLastWindowClosed(false);
this->hide();
DlgHideWifi *connHidWifi = new DlgHideWifi(ui->cbxConn->currentIndex(), mw);
connHidWifi->show();
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
}
}
}
void DlgHideWifiWpa::on_btnCancel_clicked()
{
//this->close();
this->hide();
}
void DlgHideWifiWpa::on_btnConnect_clicked()
{
mw->is_stop_check_net_state = 1;
mw->is_connect_hide_wifi = 1;
QThread *t = new QThread();
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
connect(this, SIGNAL(stopSignal()), t, SLOT(quit()));
QString wifiName = ui->leNetName->text();
QString wifiPassword = ui->lePassword->text();
strWifiname = wifiName;
strWifiPassword = wifiPassword;
BackThread *bt = new BackThread();
if (isUsed == 0) {
bt->moveToThread(t);
connect(t, SIGNAL(started()), this, SLOT(slotStartConnectHiddenWifi()));
connect(this, SIGNAL(sigConnHiddenWifi(QString, QString)), bt, SLOT(execConnHiddenWifiWPA(QString,QString)));
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connWifiDone(int)));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
} else {
bt->moveToThread(t);
connect(t, SIGNAL(started()), this, SLOT(slotStartConnectRememberedHiddenWifi()));
connect(this, SIGNAL(sigConnRememberedHiddenWifi(QString)), bt, SLOT(execConnRememberedHiddenWifi(QString)));
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connWifiDone(int)));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
}
t->start();
// this->close();
this->hide();
}
//void DlgHideWifiWpa::finishedProcess(int state) {
// wlist = shellOutput.split("\n");
// bool is_hidden = true;
// foreach (QString wifi, wlist) {
// if (wifi.trimmed() == ui->leNetName->text()) {
// is_hidden = false;
// }
// }
// if (! is_hidden) {
// BackThread *bt = new BackThread();
// bt->execConnWifi(ui->leNetName->text());
// QTimer::singleShot(4*1000, this, SLOT(emitSignal() ));
// } else {
// //已保存的wifi没有在wifi列表找到隐藏wifi保存后也会出现在wifi列表则当前区域无法连接此wifi
// QString txt(tr("Selected Wifi has not been scanned."));
// mw->objKyDBus->showDesktopNotify(txt);
// emit this->stopSignal();
// emit reSetWifiList();
// }
// shellProcess->deleteLater();
//}
//切换密码明文
void DlgHideWifiWpa::on_checkBoxPwd_clicked()
{
if (ui->lePassword->echoMode() == QLineEdit::Password) {
ui->checkBoxPwd->setChecked(true);
ui->lePassword->setEchoMode(QLineEdit::Normal);
} else {
ui->checkBoxPwd->setChecked(false);
ui->lePassword->setEchoMode(QLineEdit::Password);
}
}
//void DlgHideWifiWpa::on_checkBoxPwd_released()
//{
// ui->checkBoxPwd->setChecked(false);
// ui->lePassword->setEchoMode(QLineEdit::Password);
//}
void DlgHideWifiWpa::on_leNetName_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "" || ui->lePassword->text().size() < 6){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
if (ui->leNetName->text().size() > 32) {
QString cutStr = ui->leNetName->text().mid(0,32);
ui->leNetName->setText(cutStr);
}
}
void DlgHideWifiWpa::on_lePassword_textEdited(const QString &arg1)
{
if (ui->leNetName->text() == "" || ui->lePassword->text().size() < 6){
ui->btnConnect->setEnabled(false);
} else {
ui->btnConnect->setEnabled(true);
}
}
void DlgHideWifiWpa::slotStartConnectHiddenWifi()
{
mw->startLoading();
emit sigConnHiddenWifi(ui->leNetName->text(), ui->lePassword->text());
}
void DlgHideWifiWpa::slotStartConnectRememberedHiddenWifi()
{
mw->startLoading();
emit sigConnRememberedHiddenWifi(ui->leNetName->text());
}
void DlgHideWifiWpa::on_execSecConn()
{
QString str = "nmcli device wifi connect '" + strWifiname + "' password '" + strWifiPassword + "'";
int status = system(str.toUtf8().data());
qDebug()<<"executed cmd="<<str<<". res="<<status;
qDebug() << "debug: 准备等待7秒";
QTimer::singleShot(7*1000, this, SLOT(emitSignal() ));
}
void DlgHideWifiWpa::emitSignal()
{
emit this->stopSignal();
QFuture < void > future = QtConcurrent::run([=](){
int xx = 1;
int nn = 0;
do {
BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface();
sleep(1);
nn += 1;
if (nn == 8) {
xx = 0;
} else {
if (iface->wstate != 2) {
qDebug() << "debug: 发出信号";
emit reSetWifiList();
mw->stopLoading();
xx = 0;
}
}
delete iface;
bt->deleteLater();
} while(xx == 1);
});
}
void DlgHideWifiWpa::paintEvent(QPaintEvent *event)
{
KylinDBus mkylindbus;
double trans = mkylindbus.getTransparentData();
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QRect rect = this->rect();
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setBrush(opt.palette.color(QPalette::Base));
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}

View File

@ -1,96 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DLGCONNHIDWIFIWPA_H
#define DLGCONNHIDWIFIWPA_H
#include <QDialog>
#include <QMouseEvent>
#include <QThread>
#include <QProcess>
class OldMainWindow;
namespace Ui {
class DlgHideWifiWpa;
}
class DlgHideWifiWpa : public QDialog
{
Q_OBJECT
public:
explicit DlgHideWifiWpa(int type, OldMainWindow *mw = 0, QWidget *parent = 0);
~DlgHideWifiWpa();
protected:
void paintEvent(QPaintEvent *event);
public slots:
void changeDialog();
void changeWindow();
void emitSignal();
void on_execSecConn();
void slotStartConnectHiddenWifi();
void slotStartConnectRememberedHiddenWifi();
private slots:
void on_btnCancel_clicked();
void on_btnConnect_clicked();
void on_leNetName_textEdited(const QString &arg1);
void on_lePassword_textEdited(const QString &arg1);
// void finishedProcess(int res);
void on_checkBoxPwd_clicked();
// void on_checkBoxPwd_released();
signals:
void reSetWifiList();
void stopSignal();
void stopSignalAgain();
void sigConnHiddenWifi(QString wifiName, QString wifiPasswd);
void sigConnRememberedHiddenWifi(QString wifiName);
private:
Ui::DlgHideWifiWpa *ui;
int isUsed;//=0 current wifi not used before; >=1 used
OldMainWindow *mw;
QString strWifiname;
QString strWifiPassword;
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss;
bool isPress;
QPoint winPos;
QPoint dragPos;
QString shellOutput = "";
QStringList wlist;
QProcess * shellProcess;
};
#endif // DLGCONNHIDWIFIWPA_H

View File

@ -1,284 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgHideWifiWpa</class>
<widget class="QDialog" name="DlgHideWifiWpa">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>397</height>
</rect>
</property>
<property name="windowTitle">
<string>Connect to Hidden Wi-Fi Network</string>
</property>
<widget class="QLabel" name="lbNetName">
<property name="geometry">
<rect>
<x>76</x>
<y>221</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbSecurity">
<property name="geometry">
<rect>
<x>76</x>
<y>176</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>215</x>
<y>350</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxConn">
<property name="geometry">
<rect>
<x>175</x>
<y>75</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxPwd">
<property name="geometry">
<rect>
<x>370</x>
<y>270</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbPassword">
<property name="geometry">
<rect>
<x>76</x>
<y>266</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="cbxSecurity">
<property name="geometry">
<rect>
<x>175</x>
<y>170</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLineEdit" name="lePassword">
<property name="geometry">
<rect>
<x>175</x>
<y>261</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QPushButton" name="btnConnect">
<property name="geometry">
<rect>
<x>315</x>
<y>350</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbConn">
<property name="geometry">
<rect>
<x>76</x>
<y>80</y>
<width>90</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="leNetName">
<property name="geometry">
<rect>
<x>175</x>
<y>215</y>
<width>182</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="lbBoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>397</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbLeftupTitle">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>240</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="Line" name="lineUp">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="lineDown">
<property name="geometry">
<rect>
<x>10</x>
<y>320</y>
<width>412</width>
<height>1</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<zorder>lbBoder</zorder>
<zorder>lePassword</zorder>
<zorder>lbNetName</zorder>
<zorder>lbSecurity</zorder>
<zorder>btnCancel</zorder>
<zorder>cbxConn</zorder>
<zorder>checkBoxPwd</zorder>
<zorder>lbPassword</zorder>
<zorder>cbxSecurity</zorder>
<zorder>btnConnect</zorder>
<zorder>lbConn</zorder>
<zorder>leNetName</zorder>
<zorder>lbLeftupTitle</zorder>
<zorder>lineUp</zorder>
<zorder>lineDown</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,49 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "kylinheadfile.h"
MyQss::MyQss()
{
labelQss = "QLabel{border:0px;color:rgba(255,255,255,0.97);background-color:transparent;}";
cbxQss = "QComboBox{padding-left:20px;font-size:13px;color:rgba(255,255,255,0.91);"
"border:1px solid rgba(255, 255, 255, 0.05);border-radius:4px;background:rgba(255,255,255,0.08);}"
"QComboBox::drop-down{border:0px;width:30px;}"
"QComboBox::down-arrow{image:url(:/res/g/down_arrow.png);}"
"QComboBox QAbstractItemView {margin:0px 0px 0px 0px;padding: 0px 0px;border-radius:0px;background-color:#48484C;outline:0px;}"
"QComboBox QAbstractItemView::item{padding-left:17px;border-radius:0px;font-size:13px;color:rgba(255,255,255,0.91);height: 32px;background-color:#48484C;outline:0px;}"
"QComboBox QAbstractItemView::item:hover{padding-left:17px;border-radius:0px;font-size:13px;color:rgba(255,255,255,0.91);background-color:#3D6BE5;outline:0px;}";
leQss = "QLineEdit{padding-left:20px;color:rgba(255,255,255,0.97);background:rgba(255,255,255,0.08);}";
checkBoxQss = "QCheckBox {border:none;background:transparent;}"
"QCheckBox::indicator {width: 18px; height: 9px;}"
"QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}"
"QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}";
checkBoxCAQss = "QCheckBox{boder:none;color:rgba(255,255,255,0.97);background-color:transparent;}";
btnCancelQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}"
"QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}"
"QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}";
btnConnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}"
"QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}"
"QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}";
lineQss = "background:rgba(156,156,156,0.1);";
btnOffQss = "QPushButton[on=false]{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:grey;font-size:14px;}"
"QPushButton[on=true]{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}"
"QPushButton[on=true]:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}"
"QPushButton[on=true]:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);";
}

View File

@ -1,50 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef KYLINHEADFILE_H
#define KYLINHEADFILE_H
#include "dlghidewifi.h"
#include "dlghidewifileap.h"
#include "dlghidewifieapfast.h"
#include "dlghidewifieapleap.h"
#include "dlghidewifieappeap.h"
#include "dlghidewifieappwd.h"
#include "dlghidewifieaptls.h"
#include "dlghidewifieapttls.h"
#include "dlghidewifiwep.h"
#include "dlghidewifiwpa.h"
#include <QDebug>
#include <QFile>
#include <QPainter>
#include <QPainterPath>
#include <QListView>
#include <QString>
#include <KWindowEffects>
class MyQss
{
public:
MyQss();
QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss, btnOffQss;
};
#endif // KYLINHEADFILE_H

View File

@ -1,40 +0,0 @@
INCLUDEPATH += $$PWD
FORMS += \
$$PWD/dlghidewifi.ui \
$$PWD/dlghidewifieapfast.ui \
$$PWD/dlghidewifieapleap.ui \
$$PWD/dlghidewifieappeap.ui \
$$PWD/dlghidewifieappwd.ui \
$$PWD/dlghidewifieaptls.ui \
$$PWD/dlghidewifieapttls.ui \
$$PWD/dlghidewifileap.ui \
$$PWD/dlghidewifiwep.ui \
$$PWD/dlghidewifiwpa.ui
HEADERS += \
$$PWD/dlghidewifi.h \
$$PWD/dlghidewifieapfast.h \
$$PWD/dlghidewifieapleap.h \
$$PWD/dlghidewifieappeap.h \
$$PWD/dlghidewifieappwd.h \
$$PWD/dlghidewifieaptls.h \
$$PWD/dlghidewifieapttls.h \
$$PWD/dlghidewifileap.h \
$$PWD/dlghidewifiwep.h \
$$PWD/dlghidewifiwpa.h \
$$PWD/kylinheadfile.h
SOURCES += \
$$PWD/dlghidewifi.cpp \
$$PWD/dlghidewifieapfast.cpp \
$$PWD/dlghidewifieapleap.cpp \
$$PWD/dlghidewifieappeap.cpp \
$$PWD/dlghidewifieappwd.cpp \
$$PWD/dlghidewifieaptls.cpp \
$$PWD/dlghidewifieapttls.cpp \
$$PWD/dlghidewifileap.cpp \
$$PWD/dlghidewifiwep.cpp \
$$PWD/dlghidewifiwpa.cpp \
$$PWD/kylinheadfile.cpp

File diff suppressed because it is too large Load Diff

View File

@ -1,285 +0,0 @@
/*
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef WPAWIFIDIALOG_H
#define WPAWIFIDIALOG_H
#include <QDialog>
#include <QWidget>
#include <QComboBox>
#include <QLineEdit>
#include <QPushButton>
#include <QCheckBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFrame>
#include <QLabel>
#include <QMouseEvent>
#include <QPoint>
#include <QThread>
#include <QSettings>
#include <QSharedPointer>
#include <QTableView>
#include <QListView>
#include <QModelIndex>
#include <QList>
#define WINDOW_WIDTH 360
#define WINDOW_HEIGHT_PEAP 540
#define WINDOW_HEIGHT_TLP 670
#define WINDOW_HEIGHT_ELSE 360
class OldMainWindow;
typedef QList<QObject*> QObjectList;
namespace Ui {
class WpaWifiDialog;
}
class UpConnThread : public QThread
{
Q_OBJECT
public:
explicit UpConnThread(const QString &, const QString &);
~UpConnThread();
public:
void run();
QString conn_name = 0;
QString m_user = 0;
QString m_pwd = 0;
Q_SIGNALS:
void connRes(int respond);
};
/**
* @brief The wifiProperty struct
* 802-1x,wifi的配置
*/
struct WifiConfig
{
QString connectName;
/*802-1x属性*/
QString eap;
QString identity;
QString anonymousIdentity;
QString caCert;//ca证书配置路径
QString clientCert;//用户证书配置路径
QString privateKey;//用户私钥配置路径
};
class WpaWifiDialog : public QDialog
{
Q_OBJECT
public:
explicit WpaWifiDialog(QWidget *parent = nullptr, OldMainWindow *mw = 0, QString conname = 0);
explicit WpaWifiDialog(QWidget *parent = nullptr, OldMainWindow *mw = 0, WifiConfig *wifiConfig = nullptr);
~WpaWifiDialog();
private:
Ui::WpaWifiDialog *ui;
void initUI(); //初始化UI界面
void initCombox(); //初始化所有下拉框
void initConnect(); //初始化连接
void getPwdFlag(); //获取是否每次询问密码
bool setPwdFlag(const int&); //设置是否每次询问密码
/*初始化CA证书的配置界面*/
void initCAConfigUI();
/*初始化用户证书、私钥和密码的配置界面*/
void initUserConfig4TLSUI();
/*清空布局 delete all item of layout*/
void deleteAllItemOfLayout(QLayout *layout);
protected:
void paintEvent(QPaintEvent *event);
private:
int pwd_flag = 2; //是否每次询问密码0保存密码2询问默认不保存密码
QString connectionName;
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
bool isPress;
QPoint winPos;
QPoint dragPos;
QStringList wifi_info;
bool has_config;
QStringList user_list;
QString key_mgmt = "wpa-eap";
OldMainWindow *mw;
QObjectList m_frameList;
void setEditorEnable(bool is_checking); //设置是否禁用输入
void activateConnection();
QStringList getWifiInfo(QString wifiName);
bool appendWifiInfo(QString name, QString eap, QString inner, QString user, bool ask);
bool appendWifiUser(QString name, QString user);
private:
QWidget * mainWidget = nullptr;
QVBoxLayout * mainLyt = nullptr; //弹窗整体布局
QFrame * titleFrame = nullptr; //标题栏
QHBoxLayout * titleLyt = nullptr;
QLabel * titleLabel = nullptr;
QFrame * nameFrame = nullptr; //网络名称
QHBoxLayout * nameLyt = nullptr;
QLabel * nameLabel = nullptr;
QLineEdit * nameEditor = nullptr;
QFrame * securityFrame = nullptr; //网络安全性
QHBoxLayout * securityLyt = nullptr;
QLabel * securityLabel = nullptr;
QComboBox * securityCombox = nullptr;
QFrame * hLine = nullptr; //分割线
QFrame * eapFrame = nullptr; //EAP方法
QHBoxLayout * eapLyt = nullptr;
QLabel * eapLabel = nullptr;
QComboBox * eapCombox = nullptr;
QFrame * innerFrame = nullptr; //阶段2身份认证
QHBoxLayout * innerLyt = nullptr;
QLabel * innerLabel = nullptr;
QComboBox * innerCombox = nullptr;
QFrame * userFrame = nullptr; //用户名
QHBoxLayout * userLyt = nullptr;
QLabel * userLabel = nullptr;
QLineEdit * userEditor = nullptr;
QFrame * pwdFrame = nullptr; //密码
QVBoxLayout * pwdLyt = nullptr;
QFrame * pwdEditFrame = nullptr; //输入密码
QHBoxLayout * pwdEditLyt = nullptr;
QLabel * pwdLabel = nullptr;
QLineEdit * pwdEditor = nullptr;
QFrame * pwdShowFrame = nullptr; //显示密码
QHBoxLayout * pwdShowLyt = nullptr;
QCheckBox * pwdShowBtn = nullptr;
QLabel * pwdShowLabel = nullptr;
QFrame * askPwdFrame = nullptr; //每次询问密码
QHBoxLayout * askPwdLyt = nullptr;
QCheckBox * askPwdBtn = nullptr;
QLabel * askPwdlabel = nullptr;
QFrame * buttonFrame = nullptr; //按钮
QHBoxLayout * buttonLyt = nullptr;
QPushButton * cancelBtn = nullptr; //取消
QPushButton * connectBtn = nullptr; //连接
/**************** 802-1x layout *****************
EAP方法 TTS QLabel QComboBox
QLabel QLineEdit
QLabel QLineEdit
CA证书 QLabel QComboBox V
QCheckBox
CA证书 QCheckBox
QComboBox
QComboBox
QLineEdit
QCheckBox
**/
enum EapType {
TLS = 0,
PEAP,
PWD,
FAST,
TTLS,
LEAP
};
WifiConfig *m_wifiConfig = nullptr;
/*身份 identity*/
QFrame *m_identityFrame = nullptr;
QHBoxLayout *m_identityLyt = nullptr;
QLabel *m_identityLabel = nullptr;
QLineEdit *m_identityEditor = nullptr;
/*匿名身份 anonymous identity*/
QFrame *m_anonymousIdentityFrame = nullptr;
QHBoxLayout *m_anonymousIdentityLyt = nullptr;
QLabel *m_anonymousIdentityLabel = nullptr;
QLineEdit *m_anonymousIdentityEditor = nullptr;
/*域 domain*/
QFrame *m_domainFrame = nullptr;
QHBoxLayout *m_domainLyt = nullptr;
QLabel *m_domainLabel = nullptr;
QLineEdit *m_domainEditor = nullptr;
/*CA证书 certificate*/
QFrame *m_CAFrame = nullptr;
QHBoxLayout *m_CALyt = nullptr;
QLabel *m_CALabel = nullptr;
QComboBox *m_CAComboBox = nullptr;// 默认为(无)、QFileDialog
/*不需要CA证书 no need for CA certificate*/
QFrame *m_isCANeededFrame = nullptr;
QHBoxLayout *m_isCANeededShowLyt = nullptr;
QCheckBox *m_isCANeededShowBtn = nullptr;
QLabel *m_isCANeededShowLabel = nullptr;
/*用户证书 user certificate*/
QFrame *m_UserCertificateFrame = nullptr;
QHBoxLayout *m_UserCertificateLyt = nullptr;
QLabel *m_UserCertificateLabel = nullptr;
QComboBox *m_UserCertificateComboBox = nullptr;// 默认为(无)、QFileDialog
/*用户私钥 user private key*/
QFrame *m_UserPrivateKeyFrame = nullptr;
QHBoxLayout *m_UserPrivateKeyLyt = nullptr;
QLabel *m_UserPrivateKeyLabel = nullptr;
QComboBox *m_UserPrivateKeyComboBox = nullptr;// 默认为(无)、QFileDialog
/*私钥密码 password for private key*/
QFrame *m_pwd4PrivateKeyPWDFrame = nullptr;
QHBoxLayout *m_pwd4PrivateKeyPWDLyt = nullptr;
QLabel *m_pwd4PrivateKeyPWDLabel = nullptr;
QLineEdit *m_pwd4PrivateKeyPWDEditor = nullptr;// 未添加用户私钥时,该编辑栏不可用
Q_SIGNALS:
void conn_done();
void conn_failed();
private slots:
void slot_on_connectBtn_clicked();
void slot_line_edit_changed();
void changeDialog();
void eapTypeChange();//
void checkConnectBtnIsEnabled();
};
#endif // WPAWIFIDIALOG_H

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WpaWifiDialog</class>
<widget class="QDialog" name="WpaWifiDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>660</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>360</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>360</width>
<height>680</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -17,10 +17,7 @@
*/
//#include "mainwindow.h"
#include "new-mainwindow.h" //ZJP_TODO 载入新的主窗口
#include "ksimplenm.h"
#include "kylin-network-interface.h"
#include "wireless-security/dlghidewifi.h"
#include "mainwindow.h"
#include "dbusadaptor.h"
#include <QTranslator>
#include <QLocale>