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 "dlghidewifiwpa.h"
|
|
|
|
#include "ui_dlghidewifiwpa.h"
|
2019-10-31 09:56:53 +08:00
|
|
|
#include "kylinheadfile.h"
|
2020-03-30 15:14:10 +08:00
|
|
|
#include "src/backthread.h"
|
|
|
|
#include "src/mainwindow.h"
|
2020-12-21 17:10:00 +08:00
|
|
|
#include "src/wpawifidialog.h"
|
2020-03-16 10:34:14 +08:00
|
|
|
|
2019-10-31 09:56:53 +08:00
|
|
|
#include <unistd.h>
|
2020-02-25 21:52:01 +08:00
|
|
|
#include <stdlib.h>
|
2019-10-31 09:56:53 +08:00
|
|
|
|
2020-06-01 20:19:02 +08:00
|
|
|
#include <QDir>
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiWpa::DlgHideWifiWpa(int type, MainWindow *mainWindow, QWidget *parent) :
|
2019-10-31 09:56:53 +08:00
|
|
|
isUsed(type),
|
|
|
|
QDialog(parent),
|
2020-11-24 15:41:24 +08:00
|
|
|
ui(new Ui::DlgHideWifiWpa)
|
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);
|
2020-09-24 16:53:57 +08:00
|
|
|
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) );
|
2020-02-26 11:31:26 +08:00
|
|
|
//需要添加 void paintEvent(QPaintEvent *event) 函数
|
2020-03-12 08:51:39 +08:00
|
|
|
|
|
|
|
QPainterPath path;
|
|
|
|
auto rect = this->rect();
|
2020-03-25 10:21:44 +08:00
|
|
|
rect.adjust(1, 1, -1, -1);
|
2020-03-12 08:51:39 +08:00
|
|
|
path.addRoundedRect(rect, 6, 6);
|
|
|
|
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
|
|
|
|
|
2020-03-16 10:34:14 +08:00
|
|
|
MyQss objQss;
|
|
|
|
|
2020-10-15 13:52:09 +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);}");
|
2020-02-21 08:50:52 +08:00
|
|
|
ui->lbBoder->hide();
|
2020-10-15 13:52:09 +08:00
|
|
|
ui->lbLeftupTitle->setStyleSheet("QLabel{font-size:20px;}");
|
2020-10-11 15:02:18 +08:00
|
|
|
|
2020-03-16 10:34:14 +08:00
|
|
|
ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss);
|
2019-10-31 09:56:53 +08:00
|
|
|
|
2020-03-16 10:34:14 +08:00
|
|
|
ui->lineUp->setStyleSheet(objQss.lineQss);
|
|
|
|
ui->lineDown->setStyleSheet(objQss.lineQss);
|
2020-02-21 17:19:51 +08:00
|
|
|
ui->btnCancel->setFocusPolicy(Qt::NoFocus);
|
2020-02-27 16:13:38 +08:00
|
|
|
ui->checkBoxPwd->setFocusPolicy(Qt::NoFocus);
|
2020-02-21 08:50:52 +08:00
|
|
|
|
|
|
|
|
2020-04-16 15:27:41 +08:00
|
|
|
ui->lbLeftupTitle->setText(tr("Add Hidden Wi-Fi")); //加入隐藏Wi-Fi
|
2019-10-31 09:56:53 +08:00
|
|
|
ui->lbConn->setText(tr("Connection")); //连接设置:
|
2020-04-16 15:27:41 +08:00
|
|
|
ui->lbNetName->setText(tr("Wi-Fi name")); //网络名称:
|
2019-10-31 09:56:53 +08:00
|
|
|
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->cbxConn->addItem(tr("C_reate…")); //新建...
|
2020-06-01 20:19:02 +08:00
|
|
|
QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName();
|
|
|
|
QString cmd = "nmcli connection show > " + tmpPath;
|
2020-04-13 15:15:35 +08:00
|
|
|
int status = system(cmd.toUtf8().data());
|
2020-06-01 20:19:02 +08:00
|
|
|
if (status != 0) {
|
2020-11-24 15:41:24 +08:00
|
|
|
syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifiWpa' failed");
|
2020-06-01 20:19:02 +08:00
|
|
|
}
|
|
|
|
QFile file(tmpPath);
|
2019-10-31 09:56:53 +08:00
|
|
|
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) {
|
2020-06-04 13:49:12 +08:00
|
|
|
if (line.indexOf("wifi") != -1 || line.indexOf("802-11-wireless") != -1) {
|
2019-10-31 09:56:53 +08:00
|
|
|
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")); //无
|
2020-11-30 14:14:54 +08:00
|
|
|
ui->cbxSecurity->addItem(tr("WPA and WPA2 Personal")); //WPA 及 WPA2 个人
|
|
|
|
ui->cbxSecurity->addItem(tr("WPA and WPA2 Enterprise")); //WPA 及 WPA2 企业
|
2020-04-16 15:27:41 +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-05-20 15:32:59 +08:00
|
|
|
ui->cbxSecurity->setCurrentIndex(1);
|
2019-10-31 09:56:53 +08:00
|
|
|
connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog()));
|
|
|
|
|
2020-11-24 14:43:37 +08:00
|
|
|
if (isUsed == 0) {
|
2019-10-31 09:56:53 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-03-19 21:24:36 +08:00
|
|
|
this->setFixedSize(432,397);
|
2019-10-31 09:56:53 +08:00
|
|
|
|
|
|
|
this->mw = mainWindow;
|
2020-03-24 08:59:18 +08:00
|
|
|
|
2020-03-25 10:21:44 +08:00
|
|
|
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
|
2019-10-31 09:56:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiWpa::~DlgHideWifiWpa()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::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 DlgHideWifiWpa::mouseReleaseEvent(QMouseEvent *event){
|
2019-10-31 09:56:53 +08:00
|
|
|
this->isPress = false;
|
|
|
|
}
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::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 DlgHideWifiWpa::changeDialog()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
2020-11-24 14:43:37 +08:00
|
|
|
if (ui->cbxSecurity->currentIndex()==0) {
|
2019-10-31 09:56:53 +08:00
|
|
|
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();
|
|
|
|
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->hide();
|
2020-12-21 17:10:00 +08:00
|
|
|
WpaWifiDialog * wpadlg = new WpaWifiDialog(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();
|
2019-10-31 09:56:53 +08:00
|
|
|
} else if(ui->cbxSecurity->currentIndex()==3) {
|
|
|
|
QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
this->hide();
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(0);
|
2019-10-31 09:56:53 +08:00
|
|
|
connHidWifiWep->show();
|
|
|
|
} else if(ui->cbxSecurity->currentIndex()==4) {
|
|
|
|
QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
this->hide();
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiWep *connHidWifiWep = new DlgHideWifiWep(1);
|
2020-11-24 14:43:37 +08:00
|
|
|
connHidWifiWep->show();
|
2019-10-31 09:56:53 +08:00
|
|
|
} else if(ui->cbxSecurity->currentIndex()==5) {
|
|
|
|
QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
this->hide();
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiLeap *connHidWifiLeap = new DlgHideWifiLeap();
|
2020-11-24 14:43:37 +08:00
|
|
|
connHidWifiLeap->show();
|
2019-10-31 09:56:53 +08:00
|
|
|
} else {
|
|
|
|
QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
this->hide();
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(0, 0, mw);
|
|
|
|
connHidWifiEapPeap->show();
|
2019-10-31 09:56:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-09 16:32:16 +08:00
|
|
|
//同一 Wi-Fi安全类型的窗口变换
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::changeWindow()
|
2020-06-01 20:19:02 +08:00
|
|
|
{
|
2019-10-31 09:56:53 +08:00
|
|
|
if (ui->cbxConn->currentIndex() == 0){
|
|
|
|
QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
this->hide();
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifi *connHidWifi = new DlgHideWifi(0, mw);
|
2019-10-31 09:56:53 +08:00
|
|
|
connHidWifi->show();
|
|
|
|
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
|
|
|
|
}else if (ui->cbxConn->currentIndex() >= 1){
|
2020-06-01 20:19:02 +08:00
|
|
|
QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName();
|
|
|
|
QString currStr = "nmcli connection show " + ui->cbxConn->currentText() + " > " + tmpPath;
|
2020-04-13 15:15:35 +08:00
|
|
|
|
2020-03-19 10:55:40 +08:00
|
|
|
int status = system(currStr.toUtf8().data());
|
2020-06-01 20:19:02 +08:00
|
|
|
if(status != 0){
|
|
|
|
syslog(LOG_ERR, "execute 'nmcli connection show' in function 'changeWindow' failed");
|
|
|
|
}
|
|
|
|
QFile file(tmpPath);
|
2019-10-31 09:56:53 +08:00
|
|
|
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){
|
2020-11-24 14:43:37 +08:00
|
|
|
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();
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifiEapPeap *connHidWifiEapPeap = new DlgHideWifiEapPeap(1, ui->cbxConn->currentIndex(), mw);
|
|
|
|
connHidWifiEapPeap->show();
|
2020-11-24 14:43:37 +08:00
|
|
|
}
|
2019-10-31 09:56:53 +08:00
|
|
|
}else {
|
|
|
|
QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
this->hide();
|
2020-11-24 15:41:24 +08:00
|
|
|
DlgHideWifi *connHidWifi = new DlgHideWifi(ui->cbxConn->currentIndex(), mw);
|
2019-10-31 09:56:53 +08:00
|
|
|
connHidWifi->show();
|
|
|
|
connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::on_btnCancel_clicked()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
2020-11-04 16:54:15 +08:00
|
|
|
//this->close();
|
|
|
|
this->hide();
|
2019-10-31 09:56:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::on_btnConnect_clicked()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
QThread *t = new QThread();
|
|
|
|
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
|
|
|
|
connect(t, SIGNAL(started()), this, SLOT(slotStartLoading()));
|
|
|
|
connect(this, SIGNAL(stopSignal()), t, SLOT(quit()));
|
|
|
|
t->start();
|
|
|
|
|
|
|
|
QString wifiName = ui->leNetName->text();
|
|
|
|
QString wifiPassword = ui->lePassword->text();
|
|
|
|
BackThread *bt = new BackThread();
|
|
|
|
strWifiname = wifiName;
|
|
|
|
strWifiPassword = wifiPassword;
|
|
|
|
if (isUsed == 0){
|
|
|
|
int x = 0;
|
|
|
|
do{
|
|
|
|
sleep(1);
|
2020-06-01 20:19:02 +08:00
|
|
|
QString tmpPath = "/tmp/kylin-nm-btoutput-" + QDir::home().dirName();
|
|
|
|
QString cmd = "nmcli device wifi connect " + wifiName + " password " + wifiPassword + " hidden yes > " + tmpPath;
|
2020-04-13 15:15:35 +08:00
|
|
|
|
2020-03-19 10:55:40 +08:00
|
|
|
int status = system(cmd.toUtf8().data());
|
2020-06-01 20:19:02 +08:00
|
|
|
if (status != 0) {
|
|
|
|
syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'on_btnConnect_clicked' failed");
|
|
|
|
}
|
2019-10-31 09:56:53 +08:00
|
|
|
|
2020-06-01 20:19:02 +08:00
|
|
|
QFile file(tmpPath);
|
|
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
2019-10-31 09:56:53 +08:00
|
|
|
qDebug()<<"Can't open the file!"<<endl;
|
|
|
|
}
|
|
|
|
QString text = file.readAll();
|
|
|
|
file.close();
|
|
|
|
if(text.indexOf("Scanning not allowed") != -1){x = 1;} else { x = 0;}
|
|
|
|
} while(x == 1);
|
|
|
|
|
|
|
|
QTimer::singleShot(5*1000, this, SLOT(on_execSecConn() ));
|
|
|
|
} else {
|
|
|
|
bt->execConnWifi(wifiName);
|
2020-12-07 10:32:00 +08:00
|
|
|
QTimer::singleShot(6*1000, this, SLOT(emitSignal() ));
|
2019-10-31 09:56:53 +08:00
|
|
|
}
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::on_checkBoxPwd_stateChanged(int arg1)
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
if (arg1 == 0) {
|
|
|
|
ui->lePassword ->setEchoMode(QLineEdit::Password);
|
|
|
|
} else {
|
|
|
|
ui->lePassword->setEchoMode(QLineEdit::Normal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::on_leNetName_textEdited(const QString &arg1)
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
if (ui->leNetName->text() == "" || ui->lePassword->text() == ""){
|
|
|
|
ui->btnConnect->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
ui->btnConnect->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::on_lePassword_textEdited(const QString &arg1)
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
if (ui->leNetName->text() == "" || ui->lePassword->text() == ""){
|
|
|
|
ui->btnConnect->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
ui->btnConnect->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::slotStartLoading()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
mw->startLoading();
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::on_execSecConn()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
QString str = "nmcli device wifi connect " + strWifiname + " password " + strWifiPassword;
|
2020-03-19 10:55:40 +08:00
|
|
|
int status = system(str.toUtf8().data());
|
|
|
|
if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'on_execSecConn' failed");}
|
2019-10-31 09:56:53 +08:00
|
|
|
QTimer::singleShot(3*1000, this, SLOT(emitSignal() ));
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::emitSignal()
|
2019-10-31 09:56:53 +08:00
|
|
|
{
|
|
|
|
emit reSetWifiList();
|
|
|
|
mw->stopLoading();
|
|
|
|
emit this->stopSignal();
|
|
|
|
}
|
2020-02-26 11:31:26 +08:00
|
|
|
|
2020-11-24 15:41:24 +08:00
|
|
|
void DlgHideWifiWpa::paintEvent(QPaintEvent *event)
|
2020-02-26 11:31:26 +08:00
|
|
|
{
|
2020-10-11 16:05:30 +08:00
|
|
|
KylinDBus mkylindbus;
|
|
|
|
double trans = mkylindbus.getTransparentData();
|
|
|
|
|
2020-02-26 11:31:26 +08:00
|
|
|
QStyleOption opt;
|
2020-06-01 20:19:02 +08:00
|
|
|
opt.init(this);
|
|
|
|
QPainter p(this);
|
|
|
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
2020-10-11 15:02:18 +08:00
|
|
|
|
|
|
|
QRect rect = this->rect();
|
|
|
|
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
|
|
|
p.setBrush(opt.palette.color(QPalette::Base));
|
2020-10-11 16:05:30 +08:00
|
|
|
p.setOpacity(trans);
|
2020-10-11 15:02:18 +08:00
|
|
|
p.setPen(Qt::NoPen);
|
|
|
|
p.drawRoundedRect(rect, 6, 6);
|
2020-06-01 20:19:02 +08:00
|
|
|
QWidget::paintEvent(event);
|
2020-02-26 11:31:26 +08:00
|
|
|
}
|