2020-01-09 16:32:16 +08:00
|
|
|
/*
|
2020-06-23 12:01:21 +08:00
|
|
|
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
2020-01-09 16:32:16 +08:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
#include "ui_dlghidewifiwep.h"
|
2019-10-31 09:56:53 +08:00
|
|
|
#include "kylinheadfile.h"
|
2021-04-10 16:08:45 +08:00
|
|
|
#include "src/kylin-dbus-interface.h"
|
2019-10-31 09:56:53 +08:00
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiWep::DlgHideWifiWep(int type, QWidget *parent) :
|
2019-10-31 09:56:53 +08:00
|
|
|
WepPwdOrCode(type),
|
|
|
|
QDialog(parent),
|
2020-11-24 15:41:24 +08:00
|
|
|
ui(new Ui::DlgHideWifiWep)
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
this->setWindowFlags(Qt::FramelessWindowHint);
|
2020-02-26 11:31:26 +08:00
|
|
|
this->setAttribute(Qt::WA_TranslucentBackground);
|
|
|
|
//需要添加 void paintEvent(QPaintEvent *event) 函数
|
2020-03-12 08:51:39 +08:00
|
|
|
|
2020-03-28 21:21:29 +08:00
|
|
|
this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}");
|
2020-02-21 08:50:52 +08:00
|
|
|
|
2021-05-03 15:17:00 +08:00
|
|
|
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()));
|
|
|
|
|
2020-03-16 10:34:14 +08:00
|
|
|
MyQss objQss;
|
|
|
|
|
2020-02-21 08:50:52 +08:00
|
|
|
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();
|
2020-02-22 18:03:38 +08:00
|
|
|
ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}");
|
2020-03-16 10:34:14 +08:00
|
|
|
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);
|
2020-02-21 08:50:52 +08:00
|
|
|
|
2020-03-16 10:34:14 +08:00
|
|
|
ui->cbxConn->setStyleSheet(objQss.cbxQss);
|
2020-02-29 17:49:27 +08:00
|
|
|
ui->cbxConn->setView(new QListView());
|
2020-03-16 10:34:14 +08:00
|
|
|
ui->leNetName->setStyleSheet(objQss.leQss);
|
|
|
|
ui->leKey->setStyleSheet(objQss.leQss);
|
|
|
|
ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss);
|
|
|
|
ui->cbxSecurity->setStyleSheet(objQss.cbxQss);
|
2020-02-29 17:49:27 +08:00
|
|
|
ui->cbxSecurity->setView(new QListView());
|
2020-03-16 10:34:14 +08:00
|
|
|
ui->cbxWEPindex->setStyleSheet(objQss.cbxQss);
|
2020-02-29 17:49:27 +08:00
|
|
|
ui->cbxWEPindex->setView(new QListView());
|
2020-03-16 10:34:14 +08:00
|
|
|
ui->cbxAuth->setStyleSheet(objQss.cbxQss);
|
2020-02-29 17:49:27 +08:00
|
|
|
ui->cbxAuth->setView(new QListView());
|
2020-02-21 08:50:52 +08:00
|
|
|
|
2021-05-27 16:20:41 +08:00
|
|
|
ui->btnCancel->setStyleSheet(objQss.btnOffQss);
|
|
|
|
ui->btnConnect->setStyleSheet(objQss.btnOffQss);
|
2020-03-16 10:34:14 +08:00
|
|
|
ui->lineUp->setStyleSheet(objQss.lineQss);
|
|
|
|
ui->lineDown->setStyleSheet(objQss.lineQss);
|
2019-10-31 09:56:53 +08:00
|
|
|
|
|
|
|
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…")); //新建...
|
2020-03-19 10:55:40 +08:00
|
|
|
int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
|
2021-05-31 17:16:50 +08:00
|
|
|
qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
|
2019-10-31 09:56:53 +08:00
|
|
|
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")); //无
|
2020-11-30 14:14:54 +08:00
|
|
|
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
|
2019-10-31 09:56:53 +08:00
|
|
|
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)
|
2020-11-30 14:14:54 +08:00
|
|
|
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
|
2019-10-31 09:56:53 +08:00
|
|
|
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);
|
|
|
|
|
2020-03-19 21:24:36 +08:00
|
|
|
this->setFixedSize(432,493);
|
2019-10-31 09:56:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiWep::~DlgHideWifiWep()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWep::mousePressEvent(QMouseEvent *event){
|
2019-10-31 09:56:53 +08:00
|
|
|
if(event->button() == Qt::LeftButton){
|
|
|
|
this->isPress = true;
|
|
|
|
this->winPos = this->pos();
|
|
|
|
this->dragPos = event->globalPos();
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
}
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWep::mouseReleaseEvent(QMouseEvent *event){
|
2019-10-31 09:56:53 +08:00
|
|
|
this->isPress = false;
|
|
|
|
}
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWep::mouseMoveEvent(QMouseEvent *event){
|
2019-10-31 09:56:53 +08:00
|
|
|
if(this->isPress){
|
|
|
|
this->move(this->winPos - (this->dragPos - event->globalPos()));
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-09 16:32:16 +08:00
|
|
|
//切换到其他Wi-Fi安全类型
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWep::changeDialog()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
if(ui->cbxSecurity->currentIndex()==0){
|
|
|
|
QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
this->hide();
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifi *connHidWifi = new DlgHideWifi(0);
|
2019-10-31 09:56:53 +08:00
|
|
|
connHidWifi->show();
|
|
|
|
} else if(ui->cbxSecurity->currentIndex()==1) {
|
|
|
|
QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
this->hide();
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiWpa *connHidWifiWpa = new DlgHideWifiWpa(0);
|
2019-10-31 09:56:53 +08:00
|
|
|
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();
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
|
2019-10-31 09:56:53 +08:00
|
|
|
connHidWifiLeap->show();
|
|
|
|
} else if(ui->cbxSecurity->currentIndex()==5) {
|
2020-12-08 14:45:58 +08:00
|
|
|
//QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
//this->hide();
|
|
|
|
//DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(0);
|
|
|
|
//connHidWifiEapTls->show();
|
2019-10-31 09:56:53 +08:00
|
|
|
} else {
|
2020-12-08 14:45:58 +08:00
|
|
|
//QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
//this->hide();
|
|
|
|
//DlgHideWifiEapTls *connHidWifiEapTls = new DlgHideWifiEapTls(1);
|
|
|
|
//connHidWifiEapTls->show();
|
2019-10-31 09:56:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWep::on_btnCancel_clicked()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWep::on_btnConnect_clicked()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWep::on_checkBoxPwd_stateChanged(int arg1)
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
if (arg1 == 0) {
|
|
|
|
ui->leKey->setEchoMode(QLineEdit::Password);
|
|
|
|
} else {
|
|
|
|
ui->leKey->setEchoMode(QLineEdit::Normal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWep::on_leKey_textEdited(const QString &arg1)
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
if (ui->leNetName->text() == "" || ui->leKey->text() == ""){
|
|
|
|
ui->btnConnect->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
ui->btnConnect->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWep::on_leNetName_textEdited(const QString &arg1)
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
if (ui->leNetName->text() == "" || ui->leKey->text() == ""){
|
|
|
|
ui->btnConnect->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
ui->btnConnect->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
2020-02-26 11:31:26 +08:00
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWep::paintEvent(QPaintEvent *event)
|
2020-02-26 11:31:26 +08:00
|
|
|
{
|
2021-04-10 16:08:45 +08:00
|
|
|
KylinDBus mkylindbus;
|
|
|
|
double trans = mkylindbus.getTransparentData();
|
|
|
|
|
2020-02-26 11:31:26 +08:00
|
|
|
QStyleOption opt;
|
2021-04-10 16:08:45 +08:00
|
|
|
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);
|
2020-02-26 11:31:26 +08:00
|
|
|
}
|