connect wifi by pressing enter key; solve the problem unable turn on wifi switch in some notebook; solve taskbar small window when click trayicon; speed up the connection of wifi; set full visible when click the bottom item in wifi window; switch visibility when input wifi password; set correct position of network window whem using multi-screen

This commit is contained in:
chenlelin 2019-11-29 17:55:39 +08:00
parent 33b6ec070d
commit 8d1a4169c5
11 changed files with 335 additions and 1187 deletions

1007
Makefile

File diff suppressed because it is too large Load Diff

View File

@ -96,7 +96,11 @@ void BackThread::execDisNet(){
}
void BackThread::execEnWifi(){
system("nmcli radio wifi on;sleep 6");
if (execGetIface()->lstate == 2){
system("nmcli networking on;sleep 1");
emit launchLanDone();
}
system("nmcli radio wifi on;sleep 5");
emit enWifiDone();
emit btFinish();
}

View File

@ -45,6 +45,7 @@ signals:
void enNetDone();
void disNetDone();
void enWifiDone();
void launchLanDone();
void disWifiDone();
void connDone(int connFlag);

BIN
kylin-nm

Binary file not shown.

View File

@ -32,11 +32,11 @@ MainWindow::MainWindow(QWidget *parent) :
checkSingle();
// 如果使用Qt::Popup 任务栏不显示且保留X事件如XCB_FOCUS_OUT, 但如果indicator点击鼠标右键触发XCB_FOCUS_OUT事件依然会失效
// 如果使用Qt::ToolTip, Qt::Tool + Qt::WindowStaysOnTopHint, Qt::X11BypassWindowManagerHint等flag则会导致X事件失效
// this->setWindowFlags(Qt::Popup);
// 如果使用Qt::Popup 任务栏不显示且保留X事件如XCB_FOCUS_OUT, 但如果indicator点击鼠标右键触发XCB_FOCUS_OUT事件依然会失效
// 如果使用Qt::ToolTip, Qt::Tool + Qt::WindowStaysOnTopHint, Qt::X11BypassWindowManagerHint等flag则会导致X事件失效
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
// this->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint);
this->setWindowFlags(Qt::FramelessWindowHint);
// this->setWindowFlags(Qt::FramelessWindowHint);
this->setWindowOpacity(0.95);
@ -143,7 +143,8 @@ MainWindow::~MainWindow()
delete ui;
}
void MainWindow::checkSingle(){
void MainWindow::checkSingle()
{
int fd = open("/tmp/kylin-nm-lock", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd < 0) {
exit(1);
@ -155,7 +156,8 @@ void MainWindow::checkSingle(){
}
}
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result){
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
Q_UNUSED(result);
if(eventType != "xcb_generic_event_t"){
@ -177,6 +179,7 @@ void MainWindow::createTrayIcon()
{
trayIconMenu = new QMenu(this);
trayIcon = new QSystemTrayIcon(this);
trayIcon->setToolTip(QString(tr("kylin-nm")));
trayIcon->setContextMenu(trayIconMenu);
// 初始化托盘所有Icon
@ -206,7 +209,8 @@ void MainWindow::createTrayIcon()
setTrayIcon(iconLanOnline);
}
void MainWindow::iconStep(){
void MainWindow::iconStep()
{
if(currentIconIndex < 0){
currentIconIndex = 11;
}
@ -227,19 +231,22 @@ void MainWindow::setTrayLoading(bool isLoading){
}
}
void MainWindow::startLoading(){
void MainWindow::startLoading()
{
loading->startLoading();
setTrayLoading(true);
}
void MainWindow::stopLoading(){
void MainWindow::stopLoading()
{
loading->stopLoading();
setTrayLoading(false);
getActiveInfo();
}
// 获取当前连接的网络和状态并设置图标
void MainWindow::getActiveInfo(){
void MainWindow::getActiveInfo()
{
QString actLanName = "--";
QString actWifiName = "--";
@ -294,7 +301,8 @@ void MainWindow::getActiveInfo(){
}
// 初始化网络
void MainWindow::getIface(){
void MainWindow::getIface()
{
BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface();
@ -365,38 +373,63 @@ void MainWindow::getIface(){
void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
moveBottomRight();
if(this->isHidden()){
this->showNormal();
}else{
this->hide();
// switch (reason) {
// case QSystemTrayIcon::Trigger:
// case QSystemTrayIcon::DoubleClick:
// case QSystemTrayIcon::MiddleClick:
// break;
// }
switch(reason){
case QSystemTrayIcon::Trigger:
case QSystemTrayIcon::MiddleClick:
//这里右键点击托盘图标无效
moveBottomRight();
if(this->isHidden()){
this->showNormal();
}else{
this->hide();
}
break;
default:
break;
}
// switch (reason) {
// case QSystemTrayIcon::Trigger:
// case QSystemTrayIcon::DoubleClick:
// case QSystemTrayIcon::MiddleClick:
// break;
// }
}
void MainWindow::moveBottomRight()
{
QPoint pos = QCursor::pos();
QRect primaryGeometry;
for (QScreen *screen : qApp->screens()) {
if (screen->geometry().contains(pos)) {
primaryGeometry = screen->geometry();
}
QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
QRect screenGeometry = qApp->primaryScreen()->geometry();
QDesktopWidget* pDesktopWidget = QApplication::desktop();
// int nScreenCount = QApplication::desktop()->screenCount();
// QRect deskRect = pDesktopWidget->availableGeometry();//可用区域
QRect screenRect = pDesktopWidget->screenGeometry();//屏幕区域
// qDebug()<<"screenRect.x(): "<<screenRect.x()<<" screenRect.height(): "<<screenRect.height();
// qDebug()<<"availableGeometry.y(): "<<availableGeometry.y()<<" availableGeometry.height(): "<<availableGeometry.height();
if (screenRect.height() != availableGeometry.height()) {
this->move(availableGeometry.x() + availableGeometry.width() - this->width(), availableGeometry.height() - this->height());
}else {
this->move(availableGeometry.x() + availableGeometry.width() - this->width(), availableGeometry.height() - this->height() - 40);
}
if (primaryGeometry.isEmpty()) {
primaryGeometry = qApp->primaryScreen()->geometry();
}
this->move(primaryGeometry.x() + primaryGeometry.width() - this->width(), primaryGeometry.height() - this->height());
// 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();
// }
// this->move(primaryGeometry.x() + primaryGeometry.width() - this->width(), primaryGeometry.height() - this->height());
}
bool MainWindow::checkLanOn(){
bool MainWindow::checkLanOn()
{
BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface();
@ -407,7 +440,8 @@ bool MainWindow::checkLanOn(){
}
}
bool MainWindow::checkWlOn(){
bool MainWindow::checkWlOn()
{
BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface();
@ -419,7 +453,8 @@ bool MainWindow::checkWlOn(){
}
// 获取lan列表回调
void MainWindow::getLanListDone(QStringList slist){
void MainWindow::getLanListDone(QStringList slist)
{
// 清空lan列表
lanListWidget = new QWidget(scrollAreal);
lanListWidget->resize(314, 8 + 60 + 46 + 51);
@ -495,13 +530,16 @@ void MainWindow::getLanListDone(QStringList slist){
this->lanListWidget->show();
this->wifiListWidget->hide();
this->stopLoading();
}
// 获取wifi列表回调
void MainWindow::getWifiListDone(QStringList slist){
void MainWindow::getWifiListDone(QStringList slist)
{
if (updateFlag == 0){
loadWifiListDone(slist);
this->stopLoading();
} else {
updateWifiListDone(slist);
updateFlag = 0;
@ -510,7 +548,8 @@ void MainWindow::getWifiListDone(QStringList slist){
}
// 加载wifi列表
void MainWindow::loadWifiListDone(QStringList slist){
void MainWindow::loadWifiListDone(QStringList slist)
{
// 清空wifi列表
wifiListWidget = new QWidget(scrollAreaw);
wifiListWidget->resize(314, 8 + 60 + 46 + 51);
@ -617,7 +656,7 @@ void MainWindow::loadWifiListDone(QStringList slist){
this->lanListWidget->hide();
this->wifiListWidget->show();
this->stopLoading();
// this->stopLoading();
}
// 更新wifi列表
@ -635,6 +674,12 @@ void MainWindow::updateWifiListDone(QStringList slist)
index ++;
}
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
if (wifiList.size() <= 1){
loadWifiListDone(slist); //通常为关闭wifi开关再打开 或是 拔出无线网卡后再插入的情况
return;
}
//获取表头信息
QString lastHeadLine = lastSlist.at(0);
lastHeadLine = lastHeadLine.trimmed();
@ -654,7 +699,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
QString line = slist.at(j);
QString wname = line.mid(indexName).trimmed();
if (lastWname == wname){break;} //到slist最后一个都没找到
if (lastWname == wname){break;} //在slist最后之前找到了lastWname则停止
if (j == slist.size()-1){
qDebug()<<"will delete a wifi named "<<lastWname;
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
@ -703,9 +748,8 @@ void MainWindow::updateWifiListDone(QStringList slist)
QString line = lastSlist.at(j);
QString lastWname = line.mid(lastIndexName).trimmed();
if (lastWname == wname){break;}
//到lastSlist最后一个都没找到
if (j == lastSlist.size()-1){
if (lastWname == wname){break;} //上一次的wifi列表已经有名为wname的wifi则停止
if (j == lastSlist.size()-1){ //到lastSlist最后一个都没找到执行下面流程
qDebug()<<"will insert a wifi named "<<wname;
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
int n = wifiList.size();
@ -793,7 +837,6 @@ void MainWindow::on_btnWifi_clicked()
connect(bt, SIGNAL(disWifiDone()), this, SLOT(disWifiDone()));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
t->start();
}else{
QThread *t = new QThread();
BackThread *bt = new BackThread();
@ -801,21 +844,33 @@ void MainWindow::on_btnWifi_clicked()
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
connect(t, SIGNAL(started()), bt, SLOT(execEnWifi()));
connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone()));
connect(bt, SIGNAL(launchLanDone()), this, SLOT(launchLanDone()));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
t->start();
}
}else{
if(!checkWlOn()){
QString txt(tr("keep wired network switch is on before turning on wireless switch"));
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
system(cmd.toUtf8().data());
this->startLoading();
QThread *t = new QThread();
BackThread *bt = new BackThread();
bt->moveToThread(t);
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
connect(t, SIGNAL(started()), bt, SLOT(execEnWifi()));
connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone()));
connect(bt, SIGNAL(launchLanDone()), this, SLOT(launchLanDone()));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
t->start();
}
}
this->startLoading();
} else {
QThread *t = new QThread();
BackThread *bt = new BackThread();
bt->moveToThread(t);
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
connect(t, SIGNAL(started()), bt, SLOT(execDisWifi()));
connect(bt, SIGNAL(disWifiDone()), this, SLOT(keepDisWifiState()));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
t->start();
QString txt(tr("please insert the wireless network adapter"));
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
system(cmd.toUtf8().data());
keepDisWifiState();
}
}
@ -913,11 +968,11 @@ void MainWindow::on_btnWifiList_clicked()
on_btnWifiList_pressed();
}
// Lan连接结果0点击连接成功 1失败 3开机直连成功
// Lan连接结果0点击连接成功 1失败 3开机启动网络工具时已经连接
void MainWindow::connLanDone(int connFlag){
if(connFlag == 0){
this->is_NetLineReady = 1;
this->isByClickConnect = 1;
this->is_wired_line_ready = 1;
this->is_by_click_connect = 1;
this->ksnm->execGetLanList();
QString txt(tr("Conn Ethernet Success"));
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
@ -930,14 +985,14 @@ void MainWindow::connLanDone(int connFlag){
}
if(connFlag == 1){
this->is_NetLineReady = 0; //without net line connect to computer
this->is_wired_line_ready = 0; //without net line connect to computer
QString txt(tr("Conn Ethernet Fail"));
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
system(cmd.toUtf8().data());
}
if(connFlag == 3){
this->is_NetLineReady = 1;
this->is_wired_line_ready = 1;
check_isLanConnect = new QTimer(this);
check_isLanConnect->setTimerType(Qt::PreciseTimer);
QObject::connect(check_isLanConnect, SIGNAL(timeout()), this, SLOT(on_isLanConnect()));
@ -960,7 +1015,7 @@ void MainWindow::on_isLanConnect()
if(this->is_btnWifiList_clicked== 1) {
this->ksnm->execGetWifiList();
}
this->isByClickConnect = 0;
this->is_by_click_connect = 0;
check_isLanConnect->stop();
if (iface->wstate != 0){
@ -980,17 +1035,18 @@ void MainWindow::on_isLanConnect()
}
}
if (iface->wstate == 2) {
if (iface->wstate == 2 && this->is_on_btnConn_clicked == 0) {
//点击wifi连接按钮时可能iface->wstate == 2设置is_on_btnConn_clicked参数
//用来阻止keepDisWifiState()执行,另外两处同理
keepDisWifiState();
is_exec_func = 1;
is_exec_on_btnWifiList_clicked = 1;
} else {
//only execute once
if (is_exec_func == 1) {
//出无线网卡再插入需要执行一次
if (is_exec_on_btnWifiList_clicked == 1) {
ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-line.png);}");
ui->lbBtnWifiBG->setStyleSheet(btnOnQss);
ui->lbBtnWifiT1->setText(tr("Enabled"));
on_btnWifiList_clicked();
is_exec_func = 0;
is_exec_on_btnWifiList_clicked = 0;
}
}
}
@ -1000,7 +1056,7 @@ void MainWindow::on_isNetOn()
BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface();
if (iface->lstate == 0 && this->isByClickConnect == 0 && this->is_NetLineReady == 1){
if (iface->lstate == 0 && this->is_by_click_connect == 0 && this->is_wired_line_ready == 1){
qDebug()<<"注意:有线网络已经重新连接";
if(this->is_btnNetList_clicked == 1) {
this->ksnm->execGetLanList();
@ -1015,10 +1071,10 @@ void MainWindow::on_isNetOn()
check_isLanConnect->setTimerType(Qt::PreciseTimer);
QObject::connect(check_isLanConnect, SIGNAL(timeout()), this, SLOT(on_isLanConnect()));
check_isLanConnect->start(4000);
} else if (iface->lstate == 0 && this->isByClickConnect == 1){
} else if (iface->lstate == 0 && this->is_by_click_connect == 1){
qDebug()<<"注意:有线网络已经重新连接";
check_isNetOn->stop();
} else if (iface->wstate == 0 && this->isByClickConnect == 0){
} else if (iface->wstate == 0 && this->is_by_click_connect == 0){
qDebug()<<"注意Wifi网络已经重新连接";
if(this->is_btnNetList_clicked == 1) {
this->ksnm->execGetLanList();
@ -1033,7 +1089,7 @@ void MainWindow::on_isNetOn()
check_isWifiConnect->setTimerType(Qt::PreciseTimer);
QObject::connect(check_isWifiConnect, SIGNAL(timeout()), this, SLOT(on_isWifiConnect()));
check_isWifiConnect->start(4000);
} else if (iface->wstate == 0 && this->isByClickConnect == 1){
} else if (iface->wstate == 0 && this->is_by_click_connect == 1){
qDebug()<<"注意Wifi网络已经重新连接";
check_isNetOn->stop();
} else if (iface->wstate != 2) {
@ -1046,26 +1102,26 @@ void MainWindow::on_isNetOn()
}
}
if (iface->wstate == 2) {
if (iface->wstate == 2 && this->is_on_btnConn_clicked == 0) {
keepDisWifiState();
is_exec_func = 1;
is_exec_on_btnWifiList_clicked = 1;
} else {
//only execute once
if (is_exec_func == 1) {
//拔出无线网卡再插入需要执行一次
if (is_exec_on_btnWifiList_clicked == 1) {
ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-line.png);}");
ui->lbBtnWifiBG->setStyleSheet(btnOnQss);
ui->lbBtnWifiT1->setText(tr("Enabled"));
on_btnWifiList_clicked();
is_exec_func = 0;
is_exec_on_btnWifiList_clicked = 0;
}
}
}
// Wifi连接结果0点击连接成功 1失败 2没有配置文件 3开机直连成功
void MainWindow::connDone(int connFlag){
// Wifi连接结果0点击连接成功 1失败 2没有配置文件 3开机启动网络工具时已经连接
void MainWindow::connDone(int connFlag)
{
if(connFlag == 0){
qDebug()<<"Wifi connected successfully";
this->isByClickConnect = 1;
this->is_on_btnConn_clicked = 0;
this->is_by_click_connect = 1;
this->ksnm->execGetWifiList();
QString txt(tr("Conn Wifi Success"));
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
@ -1096,7 +1152,7 @@ void MainWindow::on_isWifiConnect()
if(this->is_btnWifiList_clicked== 1) {
this->ksnm->execGetWifiList();
}
this->isByClickConnect = 0;
this->is_by_click_connect = 0;
check_isWifiConnect->stop();
if (iface->lstate != 0){
@ -1116,17 +1172,16 @@ void MainWindow::on_isWifiConnect()
}
}
if (iface->wstate == 2) {
if (iface->wstate == 2 && this->is_on_btnConn_clicked ==0) {
keepDisWifiState();
is_exec_func = 1;
is_exec_on_btnWifiList_clicked = 1;
} else {
//only execute once
if (is_exec_func == 1) {
//拔出无线网卡再插入需要执行一次
if (is_exec_on_btnWifiList_clicked == 1) {
ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-line.png);}");
ui->lbBtnWifiBG->setStyleSheet(btnOnQss);
ui->lbBtnWifiT1->setText(tr("Enabled"));
on_btnWifiList_clicked();
is_exec_func = 0;
is_exec_on_btnWifiList_clicked = 0;
}
}
}
@ -1150,7 +1205,8 @@ void MainWindow::on_btnWifiList_pressed()
"#btnNetList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}");
}
void MainWindow::oneLanFormSelected(QString lanName){
void MainWindow::oneLanFormSelected(QString lanName)
{
QList<OneLancForm *> lanList = lanListWidget->findChildren<OneLancForm *>();
// 所有元素回到原位
@ -1204,7 +1260,8 @@ void MainWindow::oneLanFormSelected(QString lanName){
}
void MainWindow::oneWifiFormSelected(QString wifiName){
void MainWindow::oneWifiFormSelected(QString wifiName)
{
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
// 所有元素回到原位
@ -1231,11 +1288,11 @@ void MainWindow::oneWifiFormSelected(QString wifiName){
ocf->setSelected(false);
}
}
currSelNetName = "";
} else {
// 设置选中,放大缩小所有选项卡
// 设置选中,放大缩小所有选项卡
int selectY = 0;
int selectWidgetY = 0;
for(int i = 0;i < wifiList.size(); i ++){
OneConnForm *ocf = wifiList.at(i);
if(ocf->wifiName == wifiName){
@ -1245,6 +1302,7 @@ void MainWindow::oneWifiFormSelected(QString wifiName){
ocf->setSelected(true);
}
selectY = ocf->y();
selectWidgetY = wifiListWidget->y();
}else{
if (ocf->wifiName == hideWiFiConn){
ocf->setHideSelected(false);
@ -1253,6 +1311,20 @@ void MainWindow::oneWifiFormSelected(QString wifiName){
}
}
}
// wifi界面可见部分最下的一个wifi被选中有近一半被挡住,所有元素上移51或60
if (selectY + selectWidgetY == 294){
wifiListWidget->move(wifiListWidget->x(), wifiListWidget->y()-51);
if (selectY == 294){
QScrollBar *pScrollBar = scrollAreaw->verticalScrollBar();
pScrollBar->setSliderPosition(51);
}
}else if(selectY + selectWidgetY == 303){
wifiListWidget->move(wifiListWidget->x(), wifiListWidget->y()-60);
if (selectY == 294){
QScrollBar *pScrollBar = scrollAreaw->verticalScrollBar();
pScrollBar->setSliderPosition(60);
}
}
// 选中元素下面的所有元素下移51
for(int i = 0;i < wifiList.size(); i ++){
@ -1270,7 +1342,8 @@ void MainWindow::oneWifiFormSelected(QString wifiName){
}
void MainWindow::oneHideFormSelected(QString wifiName){
void MainWindow::oneHideFormSelected(QString wifiName)
{
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
// 所有元素回到原位
@ -1314,13 +1387,15 @@ void MainWindow::oneHideFormSelected(QString wifiName){
}
}
void MainWindow::activeLanDisconn(){
void MainWindow::activeLanDisconn()
{
this->startLoading();
this->ksnm->execGetLanList();
currSelNetName = "";
}
void MainWindow::activeWifiDisconn(){
void MainWindow::activeWifiDisconn()
{
this->startLoading();
this->ksnm->execGetWifiList();
currSelNetName = "";
@ -1336,7 +1411,8 @@ void MainWindow::on_btnAdvConf_released()
ui->lbBtnConfBG->setStyleSheet(btnOffQss);
}
void MainWindow::enNetDone(){
void MainWindow::enNetDone()
{
BackThread *bt = new BackThread();
bandWidth = bt->execChkLanWidth(lname);
@ -1356,7 +1432,8 @@ void MainWindow::enNetDone(){
on_btnNetList_clicked(1);
}
void MainWindow::disNetDone(){
void MainWindow::disNetDone()
{
// 清空lan列表
lanListWidget = new QWidget(scrollAreal);
lanListWidget->resize(314, 8 + 60 + 46 + 51);
@ -1399,7 +1476,15 @@ void MainWindow::disNetDone(){
this->stopLoading();
}
void MainWindow::enWifiDone(){
void MainWindow::launchLanDone()
{
ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-line.png);}");
ui->lbBtnNetBG->setStyleSheet(btnOnQss);
ui->lbBtnNetT1->setText(tr("Enabled"));//"已开启"
}
void MainWindow::enWifiDone()
{
ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-line.png);}");
ui->lbBtnWifiBG->setStyleSheet(btnOnQss);
ui->lbBtnWifiT1->setText(tr("Enabled"));//"已开启"
@ -1409,7 +1494,9 @@ void MainWindow::enWifiDone(){
on_btnWifiList_clicked();
}
void MainWindow::disWifiDone(){
void MainWindow::disWifiDone()
{
wifiListWidget->resize(314, 8 + 60 + 46 + 51);
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
for(int i = 0; i < wifiList.size(); i ++){
OneConnForm *ocf = wifiList.at(i);
@ -1450,6 +1537,7 @@ void MainWindow::keepDisWifiState()
ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭"
}
if(this->is_btnWifiList_clicked== 1) {
wifiListWidget->resize(314, 8 + 60 + 46 + 51);
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
for(int i = 0; i < wifiList.size(); i ++){
OneConnForm *ocf = wifiList.at(i);
@ -1477,6 +1565,6 @@ void MainWindow::keepDisWifiState()
this->scrollAreal->hide();
this->scrollAreaw->show();
this->stopLoading();
// this->stopLoading();
}
}

View File

@ -69,6 +69,14 @@ public:
QIcon iconConnecting;
QList<QIcon> loadIcons;
//状态设置,0为假1为真
int is_by_click_connect = 0; //是否是通过点击连接按钮进行的连接
int is_btnNetList_clicked = 1; //是否处于有线网界面
int is_btnWifiList_clicked = 0; //是否处于无线网界面
int is_wired_line_ready = 1; //主机是否连接网线
int is_exec_on_btnWifiList_clicked = 1; //是否要执行on_btnWifiList_clicked()
int is_on_btnConn_clicked = 0;//是否已经点击连接wifi按钮
private:
void checkSingle();
void getActiveInfo();
@ -84,6 +92,7 @@ private:
LoadingDiv *loading;
QDesktopWidget desktop;
KSimpleNM *ksnm;
ConfForm *confForm;
QWidget *lanListWidget;
@ -117,13 +126,6 @@ private:
QTimer *check_isWifiConnect;
QTimer *check_isNetOn;
//按钮点击状态,0为假1为真
int isByClickConnect = 0;
int is_btnNetList_clicked = 1;
int is_btnWifiList_clicked = 0;
int is_NetLineReady = 1;
int is_exec_func = 1;
int currentIconIndex;
int updateFlag = 0;
@ -160,6 +162,7 @@ private slots:
void enNetDone();
void disNetDone();
void enWifiDone();
void launchLanDone();
void disWifiDone();
void keepDisWifiState();
void connLanDone(int connFlag);

View File

@ -36,10 +36,10 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
ui->btnDisConn->setText(tr("Disconnect"));//"断开连接"
ui->btnHideConn->setText(tr("Connect"));//"连接"
ui->lePassword->setEchoMode(QLineEdit::Password);
ui->wbg->hide();
ui->lbPassword->hide();
ui->lePassword->hide();
ui->checkBoxPwd->hide();
ui->btnConf->hide();
ui->btnConn->hide();
ui->btnDisConn->hide();
@ -54,6 +54,9 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
ui->lbSafe->setStyleSheet("QLabel{font-size:13px;color:#aaaaaa;}");
ui->lbConned->setStyleSheet("QLabel{font-size:13px;color:#ffffff;}");
ui->lePassword->setStyleSheet("QLineEdit{border: 1px solid #cccccc;background-color:#ffffff;}");
ui->checkBoxPwd->setStyleSheet("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);}");
ui->btnConf->setStyleSheet("QPushButton{border:0px;background-color:rgba(0,0,0,0.4);color:white;font-size:12px;}"
"QPushButton:Hover{border:1px solid rgba(255,255,255,0.2);background-color:rgba(0,0,0,0.2);}"
"QPushButton:Pressed{background-color:rgba(0,0,0,0.6);}");
@ -76,6 +79,8 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
this->isSelected = false;
this->isActive = false;
connect(ui->lePassword, SIGNAL(returnPressed()), this, SLOT(on_btnConnPWD_clicked()));
}
OneConnForm::~OneConnForm()
@ -135,6 +140,7 @@ void OneConnForm::setSelected(bool isSelected){
ui->lbPassword->hide();
ui->lePassword->hide();
ui->checkBoxPwd->hide();
ui->btnConnPWD->hide();
ui->lbName->show();
@ -158,6 +164,7 @@ void OneConnForm::setHideSelected(bool isSelected){
ui->lbPassword->hide();
ui->lePassword->hide();
ui->checkBoxPwd->hide();
ui->btnConnPWD->hide();
ui->lbName->show();
@ -177,6 +184,7 @@ void OneConnForm::setHideSelected(bool isSelected){
ui->lbPassword->hide();
ui->lePassword->hide();
ui->checkBoxPwd->hide();
ui->btnConnPWD->hide();
ui->lbName->show();
@ -205,15 +213,6 @@ void OneConnForm::setShowPoint(bool flag){
}
}
void OneConnForm::slotConnWifi(){
mw->startLoading();
emit sigConnWifi(ui->lbName->text());
}
void OneConnForm::slotConnWifiPWD(){
mw->startLoading();
emit sigConnWifiPWD(ui->lbName->text(), ui->lePassword->text());
}
void OneConnForm::setName(QString name){
ui->lbName->setText(name);
wifiName = name;
@ -299,6 +298,16 @@ void OneConnForm::setSignal(QString lv){
}
}
void OneConnForm::slotConnWifi(){
mw->startLoading();
emit sigConnWifi(ui->lbName->text());
}
void OneConnForm::slotConnWifiPWD(){
mw->startLoading();
emit sigConnWifiPWD(ui->lbName->text(), ui->lePassword->text());
}
//点击后设置wifi网络
void OneConnForm::on_btnConf_clicked()
{
QPoint pos = QCursor::pos();
@ -343,6 +352,7 @@ void OneConnForm::on_btnConf_clicked()
cf->raise();
}
//点击后断开wifi网络
void OneConnForm::on_btnDisConn_clicked()
{
kylin_network_set_con_down(ui->lbName->text().toUtf8().data());
@ -352,8 +362,10 @@ void OneConnForm::on_btnDisConn_clicked()
emit disconnActiveWifi();
}
//无需密码的wifi连接
void OneConnForm::on_btnConn_clicked()
{
mw->is_on_btnConn_clicked = 1;
QThread *t = new QThread();
BackThread *bt = new BackThread();
bt->moveToThread(t);
@ -366,6 +378,7 @@ void OneConnForm::on_btnConn_clicked()
t->start();
}
//需要密码的wifi连接
void OneConnForm::on_btnConnPWD_clicked()
{
QThread *t = new QThread();
@ -380,6 +393,7 @@ void OneConnForm::on_btnConnPWD_clicked()
t->start();
}
//点击后弹出连接隐藏wifi网络窗口
void OneConnForm::on_btnHideConn_clicked()
{
QApplication::setQuitOnLastWindowClosed(false);
@ -395,6 +409,7 @@ void OneConnForm::slotConnDone(int connFlag){
if(connFlag == 2){
ui->lbPassword->show();
ui->lePassword->show();
ui->checkBoxPwd->show();
ui->btnConnPWD->show();
ui->lbName->hide();
@ -417,3 +432,12 @@ void OneConnForm::slotConnDone(int connFlag){
mw->stopLoading();
}
void OneConnForm::on_checkBoxPwd_stateChanged(int arg1)
{
if (arg1 == 0) {
ui->lePassword ->setEchoMode(QLineEdit::Password);
} else {
ui->lePassword->setEchoMode(QLineEdit::Normal);
}
}

View File

@ -89,6 +89,8 @@ private slots:
void on_btnHideConn_clicked();
void on_checkBoxPwd_stateChanged(int arg1);
private:
Ui::OneConnForm *ui;
MainWindow *mw;

View File

@ -176,6 +176,19 @@
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxPwd">
<property name="geometry">
<rect>
<x>264</x>
<y>30</y>
<width>18</width>
<height>9</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<zorder>wbg</zorder>
<zorder>lbName</zorder>
<zorder>btnConf</zorder>
@ -189,6 +202,7 @@
<zorder>lbPassword</zorder>
<zorder>btnConnPWD</zorder>
<zorder>btnHideConn</zorder>
<zorder>checkBoxPwd</zorder>
</widget>
<resources/>
<connections/>

Binary file not shown.

View File

@ -72,67 +72,67 @@
<context>
<name>DlgConnHidWifi</name>
<message>
<location filename="../dlgconnhidwifi.cpp" line="39"/>
<location filename="../dlgconnhidwifi.cpp" line="40"/>
<source>Add hidden Wi-Fi</source>
<translation>Wi-Fi</translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="40"/>
<location filename="../dlgconnhidwifi.cpp" line="41"/>
<source>Connection</source>
<translation>:</translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="41"/>
<location filename="../dlgconnhidwifi.cpp" line="42"/>
<source>Network name</source>
<translation>:</translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="42"/>
<location filename="../dlgconnhidwifi.cpp" line="43"/>
<source>Wi-Fi security</source>
<translation>Wi-Fi :</translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="43"/>
<location filename="../dlgconnhidwifi.cpp" line="44"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="44"/>
<location filename="../dlgconnhidwifi.cpp" line="45"/>
<source>Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="46"/>
<location filename="../dlgconnhidwifi.cpp" line="47"/>
<source>C_reate</source>
<translation>...</translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="64"/>
<location filename="../dlgconnhidwifi.cpp" line="65"/>
<source>None</source>
<translation></translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="65"/>
<location filename="../dlgconnhidwifi.cpp" line="66"/>
<source>WPA &amp; WPA2 Personal</source>
<translation>WPA WPA2 </translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="66"/>
<location filename="../dlgconnhidwifi.cpp" line="67"/>
<source>WEP 40/128-bit Key (Hex or ASCII)</source>
<translation>WEP 40/128 (ASCII)</translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="67"/>
<location filename="../dlgconnhidwifi.cpp" line="68"/>
<source>WEP 128-bit Passphrase</source>
<translation>WEP 128 </translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="69"/>
<location filename="../dlgconnhidwifi.cpp" line="70"/>
<source>Dynamic WEP (802.1X)</source>
<translation> WEP (802.1x)</translation>
</message>
<message>
<location filename="../dlgconnhidwifi.cpp" line="70"/>
<location filename="../dlgconnhidwifi.cpp" line="71"/>
<source>WPA &amp; WPA2 Enterprise</source>
<translation>WPA WPA2 </translation>
</message>
@ -1092,72 +1092,72 @@
<translation> Wi-Fi </translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="34"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="35"/>
<source>Add hidden Wi-Fi</source>
<translation type="unfinished">Wi-Fi</translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="35"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="36"/>
<source>Connection</source>
<translation type="unfinished">:</translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="36"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="37"/>
<source>Network name</source>
<translation type="unfinished">:</translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="37"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="38"/>
<source>Wi-Fi security</source>
<translation type="unfinished">Wi-Fi :</translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="38"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="39"/>
<source>Password</source>
<translation type="unfinished">:</translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="39"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="40"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="40"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="41"/>
<source>Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="42"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="43"/>
<source>C_reate</source>
<translation type="unfinished">...</translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="60"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="61"/>
<source>None</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="61"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="62"/>
<source>WPA &amp; WPA2 Personal</source>
<translation type="unfinished">WPA WPA2 </translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="62"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="63"/>
<source>WEP 40/128-bit Key (Hex or ASCII)</source>
<translation type="unfinished">WEP 40/128 (ASCII)</translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="63"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="64"/>
<source>WEP 128-bit Passphrase</source>
<translation type="unfinished">WEP 128 </translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="65"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="66"/>
<source>Dynamic WEP (802.1X)</source>
<translation type="unfinished"> WEP (802.1x)</translation>
</message>
<message>
<location filename="../dlgconnhidwifiwpa.cpp" line="66"/>
<location filename="../dlgconnhidwifiwpa.cpp" line="67"/>
<source>WPA &amp; WPA2 Enterprise</source>
<translation type="unfinished">WPA WPA2 </translation>
</message>
@ -1166,6 +1166,7 @@
<name>MainWindow</name>
<message>
<location filename="../mainwindow.ui" line="14"/>
<location filename="../mainwindow.cpp" line="182"/>
<source>kylin-nm</source>
<translation></translation>
</message>
@ -1190,75 +1191,93 @@
<translation>线</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="314"/>
<location filename="../mainwindow.cpp" line="319"/>
<location filename="../mainwindow.cpp" line="1313"/>
<location filename="../mainwindow.cpp" line="1319"/>
<location filename="../mainwindow.cpp" line="1373"/>
<location filename="../mainwindow.cpp" line="320"/>
<location filename="../mainwindow.cpp" line="325"/>
<location filename="../mainwindow.cpp" line="1046"/>
<location filename="../mainwindow.cpp" line="1112"/>
<location filename="../mainwindow.cpp" line="1183"/>
<location filename="../mainwindow.cpp" line="1408"/>
<location filename="../mainwindow.cpp" line="1414"/>
<location filename="../mainwindow.cpp" line="1470"/>
<location filename="../mainwindow.cpp" line="1474"/>
<source>Enabled</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="323"/>
<location filename="../mainwindow.cpp" line="329"/>
<location filename="../mainwindow.cpp" line="333"/>
<location filename="../mainwindow.cpp" line="1354"/>
<location filename="../mainwindow.cpp" line="1358"/>
<location filename="../mainwindow.cpp" line="1401"/>
<location filename="../mainwindow.cpp" line="335"/>
<location filename="../mainwindow.cpp" line="339"/>
<location filename="../mainwindow.cpp" line="1450"/>
<location filename="../mainwindow.cpp" line="1454"/>
<location filename="../mainwindow.cpp" line="1505"/>
<location filename="../mainwindow.cpp" line="1523"/>
<location filename="../mainwindow.cpp" line="1547"/>
<source>Disabled</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="450"/>
<location filename="../mainwindow.cpp" line="541"/>
<location filename="../mainwindow.cpp" line="842"/>
<location filename="../mainwindow.cpp" line="886"/>
<location filename="../mainwindow.cpp" line="1335"/>
<location filename="../mainwindow.cpp" line="1386"/>
<location filename="../mainwindow.cpp" line="473"/>
<location filename="../mainwindow.cpp" line="567"/>
<location filename="../mainwindow.cpp" line="900"/>
<location filename="../mainwindow.cpp" line="943"/>
<location filename="../mainwindow.cpp" line="1431"/>
<location filename="../mainwindow.cpp" line="1490"/>
<location filename="../mainwindow.cpp" line="1532"/>
<source>Not connected</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="452"/>
<location filename="../mainwindow.cpp" line="545"/>
<location filename="../mainwindow.cpp" line="844"/>
<location filename="../mainwindow.cpp" line="891"/>
<location filename="../mainwindow.cpp" line="1337"/>
<location filename="../mainwindow.cpp" line="1390"/>
<location filename="../mainwindow.cpp" line="475"/>
<location filename="../mainwindow.cpp" line="571"/>
<location filename="../mainwindow.cpp" line="902"/>
<location filename="../mainwindow.cpp" line="948"/>
<location filename="../mainwindow.cpp" line="1433"/>
<location filename="../mainwindow.cpp" line="1494"/>
<location filename="../mainwindow.cpp" line="1536"/>
<source>Disconnected</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="461"/>
<location filename="../mainwindow.cpp" line="853"/>
<location filename="../mainwindow.cpp" line="1346"/>
<location filename="../mainwindow.cpp" line="484"/>
<location filename="../mainwindow.cpp" line="911"/>
<location filename="../mainwindow.cpp" line="1442"/>
<source>Ethernet Networks</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="486"/>
<location filename="../mainwindow.cpp" line="594"/>
<location filename="../mainwindow.cpp" line="509"/>
<location filename="../mainwindow.cpp" line="620"/>
<source>Connected</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="552"/>
<location filename="../mainwindow.cpp" line="898"/>
<location filename="../mainwindow.cpp" line="578"/>
<location filename="../mainwindow.cpp" line="955"/>
<source>Wifi Networks</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="921"/>
<location filename="../mainwindow.cpp" line="850"/>
<source>keep wired network switch is on before turning on wireless switch</source>
<translation>线线</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="867"/>
<source>please insert the wireless network adapter</source>
<translation>线</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="975"/>
<source>Conn Ethernet Success</source>
<translation>线</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="934"/>
<location filename="../mainwindow.cpp" line="987"/>
<source>Conn Ethernet Fail</source>
<translation>线</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1044"/>
<location filename="../mainwindow.cpp" line="1126"/>
<source>Conn Wifi Success</source>
<translation>线</translation>
</message>
@ -1293,27 +1312,27 @@
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="225"/>
<location filename="../oneconnform.cpp" line="216"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation> Wi-Fi </translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="237"/>
<location filename="../oneconnform.cpp" line="228"/>
<source>Public</source>
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="240"/>
<location filename="../oneconnform.cpp" line="231"/>
<source>Safe</source>
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="245"/>
<location filename="../oneconnform.cpp" line="236"/>
<source>Rate</source>
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="415"/>
<location filename="../oneconnform.cpp" line="417"/>
<source>Conn Wifi Failed</source>
<translation>线</translation>
</message>