change the style of password QLineEdit,change the loading animation when connecting network

This commit is contained in:
chenlelin 2020-02-21 17:19:51 +08:00
parent 05b8f7080b
commit 43bface275
23 changed files with 693 additions and 488 deletions

View File

@ -1494,6 +1494,9 @@ void MainWindow::on_setNetSpeed()
}
void MainWindow::connLanDone(int connFlag){
//停止加载动画
emit this->waitLanStop();
// Lan连接结果0点击连接成功 1失败 3开机启动网络工具时已经连接
if(connFlag == 0){
syslog(LOG_DEBUG, "Wired net already connected by clicking button");
@ -1892,7 +1895,8 @@ void MainWindow::activeLanDisconn()
{
syslog(LOG_DEBUG, "Wired net is disconnected");
currSelNetName = "";
this->startLoading();
//this->startLoading();
emit this->waitLanStop();
this->ksnm->execGetLanList();
}
@ -1912,12 +1916,12 @@ void MainWindow::activeStartLoading()
{
syslog(LOG_DEBUG, "Wi-Fi is disconnected");
currSelNetName = "";
this->startLoading();
//this->startLoading();
emit this->deleteRedundantNet();
}
void MainWindow::activeGetWifiList()
{
emit this->waitWifiStop();
this->ksnm->execGetWifiList();
}

View File

@ -237,6 +237,9 @@ private slots:
void on_btnAddNet_clicked();
signals:
void deleteRedundantNet();
void waitWifiStop();
void waitLanStop();
};
#endif // MAINWINDOW_H

View File

@ -91,5 +91,13 @@
<file>res/w/wifi-medium-pwd.png</file>
<file>res/w/wifi-none.png</file>
<file>res/w/wifi-none-pwd.png</file>
<file>res/s/conning-a/1.png</file>
<file>res/s/conning-a/2.png</file>
<file>res/s/conning-a/3.png</file>
<file>res/s/conning-a/4.png</file>
<file>res/s/conning-a/5.png</file>
<file>res/s/conning-a/6.png</file>
<file>res/s/conning-a/7.png</file>
<file>res/s/conning-a/8.png</file>
</qresource>
</RCC>

View File

@ -34,6 +34,7 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
ui->btnConnPWD->setText(tr("Connect"));//"连接"
ui->btnDisConn->setText(tr("Disconnect"));//"断开连接"
ui->btnHideConn->setText(tr("Connect"));//"连接"
ui->lePassword->setText(tr(""));//"连接"
ui->lbConned->setAlignment(Qt::AlignLeft);
ui->lbLoadUp->setAlignment(Qt::AlignLeft);
@ -50,7 +51,7 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
ui->lbConned->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}");
ui->lbLoadUp->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}");
ui->lbLoadDown->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}");
ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(28, 47, 146, 1);border-radius:4px;"
ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;"
"background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.35);font-size:14px;}");
ui->checkBoxPwd->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}"
"QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}"
@ -61,9 +62,9 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
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->btnConnPWD->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->btnConnPWD->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(255,255,255,0.2);}"
"QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}");
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(255,255,255,0.2);}"
"QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}");
@ -72,6 +73,8 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
"QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}");
ui->lbLoadDownImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-down.png);}");
ui->lbLoadUpImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-up.png);}");
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->checkBoxPwd->setFocusPolicy(Qt::NoFocus);
ui->btnConnSub->setFocusPolicy(Qt::NoFocus);
@ -95,6 +98,8 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
ui->line->show();
ui->lbLoadDownImg->hide();
ui->lbLoadUpImg->hide();
ui->lbWaiting->hide();
ui->lbWaitingIcon->hide();
this->mw = mainWindow;
this->cf = confForm;
@ -110,7 +115,11 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
connect(ui->lePassword, SIGNAL(returnPressed()), this, SLOT(on_btnConnPWD_clicked()));
ui->btnConn->setShortcut(Qt::Key_Return);//将字母区回车键与登录按钮绑定在一起
// ui->btnHideConn->setShortcut(Qt::Key_Return);
this->waitTimer = new QTimer(this);
connect(waitTimer, SIGNAL(timeout()), this, SLOT(waitAnimStep()));
connect(mw, SIGNAL(waitWifiStop()), this, SLOT(stopWaiting()));
}
OneConnForm::~OneConnForm()
@ -196,7 +205,11 @@ void OneConnForm::setTopItem(bool isSelected){
// ui->lbLoadDown->setText("0Kb/s");
ui->lbLoadUp->hide();
ui->lbLoadDown->hide();
ui->btnDisConn->show();
if (this->isWaiting){
ui->btnDisConn->hide();
}else{
ui->btnDisConn->show();
}
}else{
// ui->lbLoadUp->setText("0Kb/s");
// ui->lbLoadDown->setText("0Kb/s");
@ -220,7 +233,10 @@ void OneConnForm::setSelected(bool isSelected){
this->isSelected = true;
}else{
resize(422, 60);
ui->lePassword->setText("");
ui->lePassword->setText(tr(""));//"连接"
ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;"
"background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.35);font-size:14px;}");
ui->lePassword->setEchoMode(QLineEdit::Normal);
ui->line->show();
ui->wbg->show();
@ -359,14 +375,29 @@ void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3)
void OneConnForm::slotConnWifi()
{
mw->startLoading();
// mw->startLoading();
this->startWaiting(true);
emit sigConnWifi(ui->lbName->text());
}
void OneConnForm::slotConnWifiPWD(){
mw->startLoading();
// mw->startLoading();
this->startWaiting(true);
emit sigConnWifiPWD(ui->lbName->text(), ui->lePassword->text());
}
//点击后断开wifi网络
void OneConnForm::on_btnDisConn_clicked()
{
this->startWaiting(false);
mw->is_stop_check_net_state = 1;
mw->on_btnHotspotState();
kylin_network_set_con_down(ui->lbName->text().toUtf8().data());
disconnect(this, SIGNAL(selectedOneWifiForm(QString)), mw, SLOT(oneWifiFormSelected(QString)));
emit disconnActiveWifi();
}
//点击列表item扩展时会出现该按钮 用于连接网络
void OneConnForm::on_btnConnSub_clicked()
{
if (ui->lbConned->text() == "--" || ui->lbConned->text() == " "){
@ -387,16 +418,6 @@ void OneConnForm::on_btnConnSub_clicked()
t->start();
}
//点击后断开wifi网络
void OneConnForm::on_btnDisConn_clicked()
{
mw->is_stop_check_net_state = 1;
mw->on_btnHotspotState();
kylin_network_set_con_down(ui->lbName->text().toUtf8().data());
disconnect(this, SIGNAL(selectedOneWifiForm(QString)), mw, SLOT(oneWifiFormSelected(QString)));
emit disconnActiveWifi();
}
//无需密码的wifi连接
void OneConnForm::on_btnConn_clicked()
{
@ -455,16 +476,15 @@ void OneConnForm::on_checkBoxPwd_stateChanged(int arg1)
void OneConnForm::on_lePassword_textEdited(const QString &arg1)
{
ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(28, 47, 146, 1);border-radius:4px;"
"background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.91);font-size:14px;}");
if (ui->lePassword->text().size() < 5){
ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(28, 47, 146, 1);border-radius:4px;"
"background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.35);font-size:14px;}");
ui->btnConnPWD->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(0,0,0,0.2);}"
"QPushButton:Pressed{border-radius:4px;background-color:rgba(0,0,0,0.6);}");
"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);}");
ui->btnConnPWD->setEnabled(false);
} else {
ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(28, 47, 146, 1);border-radius:4px;"
"background:rgba(0,0,0,0.2);color:rgba(255,255,255,1);font-size:14px;}");
ui->btnConnPWD->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);}");
@ -509,7 +529,46 @@ void OneConnForm::slotConnWifiResult(int connFlag){
// 设置全局变量当前连接Wifi的信号强度
currentActWifiSignalLv = signalLv;
if (connFlag != 0){
mw->stopLoading();
this->stopWaiting();
// if (connFlag != 0){
// mw->stopLoading();
// }
}
void OneConnForm::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 < 1){
this->waitPage = 8;
}
}
void OneConnForm::startWaiting(bool isConn){
this->isWaiting = true;
if (isConn){
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}");
}else{
ui->btnDisConn->hide();
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);}");
}
this->waitPage = 8;
this->waitTimer->start(150);
ui->lbWaiting->show();
ui->lbWaitingIcon->show();
mw->setTrayLoading(true);
}
void OneConnForm::stopWaiting(){
this->isWaiting = false;
this->waitTimer->stop();
ui->lbWaiting->hide();
ui->lbWaitingIcon->hide();
mw->setTrayLoading(false);
}

View File

@ -97,7 +97,15 @@ private slots:
void on_btnConnSub_clicked();
void waitAnimStep();
void startWaiting(bool isConn);
void stopWaiting();
private:
QTimer *waitTimer;
int waitPage;
bool isWaiting = false;
Ui::OneConnForm *ui;
MainWindow *mw;
ConfForm *cf;

View File

@ -251,6 +251,32 @@
<string/>
</property>
</widget>
<widget class="QLabel" name="lbWaiting">
<property name="geometry">
<rect>
<x>316</x>
<y>14</y>
<width>100</width>
<height>34</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbWaitingIcon">
<property name="geometry">
<rect>
<x>356</x>
<y>20</y>
<width>20</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<zorder>lbLoadUp</zorder>
<zorder>lbLoadDown</zorder>
<zorder>wbg_3</zorder>
@ -267,6 +293,8 @@
<zorder>btnConnPWD</zorder>
<zorder>btnDisConn</zorder>
<zorder>btnHideConn</zorder>
<zorder>lbWaiting</zorder>
<zorder>lbWaitingIcon</zorder>
</widget>
<resources/>
<connections/>

View File

@ -55,6 +55,8 @@ OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
"QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}");
ui->lbLoadDownImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-down.png);}");
ui->lbLoadUpImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-up.png);}");
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->btnConnSub->setFocusPolicy(Qt::NoFocus);
ui->btnConn->setFocusPolicy(Qt::NoFocus);
@ -69,6 +71,8 @@ OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
ui->line->show();
ui->lbLoadDownImg->hide();
ui->lbLoadUpImg->hide();
ui->lbWaiting->hide();
ui->lbWaitingIcon->hide();
this->mw = mainWindow;
this->cf = confForm;
@ -82,6 +86,10 @@ OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
ui->btnConn->setAttribute(Qt::WA_Hover,true);//开启悬停事件
ui->btnConn->installEventFilter(this); //安装事件过滤器
this->waitTimer = new QTimer(this);
connect(waitTimer, SIGNAL(timeout()), this, SLOT(waitAnimStep()));
connect(mw, SIGNAL(waitLanStop()), this, SLOT(stopWaiting()));
srand((unsigned)time(NULL));
}
@ -235,26 +243,16 @@ void OneLancForm::setLine(bool isShow)
}
}
void OneLancForm::on_btnConnSub_clicked()
{
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)), bt, SLOT(execConnLan(QString)));
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connLanDone(int)));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
t->start();
}
void OneLancForm::slotConnLan(){
mw->startLoading();
//mw->startLoading();
this->startWaiting(true);
emit sigConnLan(ui->lbName->text());
}
void OneLancForm::on_btnDisConn_clicked()
{
this->startWaiting(false);
kylin_network_set_con_down(ui->lbName->text().toUtf8().data());
disconnect(this, SIGNAL(selectedOneLanForm(QString)), mw, SLOT(oneLanFormSelected(QString)));
@ -274,3 +272,52 @@ void OneLancForm::on_btnConn_clicked()
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
t->start();
}
void OneLancForm::on_btnConnSub_clicked()
{
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)), bt, SLOT(execConnLan(QString)));
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connLanDone(int)));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
t->start();
}
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 < 1){
this->waitPage = 8;
}
}
void OneLancForm::startWaiting(bool isConn){
if (isConn){
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}");
}else{
ui->btnDisConn->hide();
ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);}");
}
this->waitPage = 8;
this->waitTimer->start(150);
ui->lbWaiting->show();
ui->lbWaitingIcon->show();
mw->setTrayLoading(true);
}
void OneLancForm::stopWaiting(){
this->waitTimer->stop();
ui->lbWaiting->hide();
ui->lbWaitingIcon->hide();
mw->setTrayLoading(false);
}

View File

@ -77,7 +77,14 @@ private slots:
void slotConnLan();
void waitAnimStep();
void startWaiting(bool isConn);
void stopWaiting();
private:
QTimer *waitTimer;
int waitPage;
Ui::OneLancForm *ui;
MainWindow *mw;
ConfForm *cf;

View File

@ -192,6 +192,32 @@
</rect>
</property>
</widget>
<widget class="QLabel" name="lbWaiting">
<property name="geometry">
<rect>
<x>316</x>
<y>14</y>
<width>100</width>
<height>34</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbWaitingIcon">
<property name="geometry">
<rect>
<x>356</x>
<y>20</y>
<width>20</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<zorder>lbLoadUp</zorder>
<zorder>lbLoadDown</zorder>
<zorder>lbName</zorder>
@ -205,6 +231,8 @@
<zorder>btnConnSub</zorder>
<zorder>btnDisConn</zorder>
<zorder>btnConn</zorder>
<zorder>lbWaiting</zorder>
<zorder>lbWaitingIcon</zorder>
</widget>
<resources/>
<connections/>

BIN
res/s/conning-a/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

BIN
res/s/conning-a/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
res/s/conning-a/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

BIN
res/s/conning-a/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
res/s/conning-a/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

BIN
res/s/conning-a/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
res/s/conning-a/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

BIN
res/s/conning-a/8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -87,6 +87,7 @@ DlgConnHidWifiSecTls::DlgConnHidWifiSecTls(int type, QWidget *parent) :
"QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}");
ui->lineUp->setStyleSheet("background:rgba(255,255,255,0.08);");
ui->lineDown->setStyleSheet("background:rgba(255,255,255,0.08);");
ui->checkBoxCA->setFocusPolicy(Qt::NoFocus);
ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi
ui->lbConn->setText(tr("Connection")); //连接设置:

View File

@ -84,6 +84,7 @@ DlgConnHidWifiSecTunnelTLS::DlgConnHidWifiSecTunnelTLS(int type, QWidget *parent
"QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}");
ui->lineUp->setStyleSheet("background:rgba(255,255,255,0.08);");
ui->lineDown->setStyleSheet("background:rgba(255,255,255,0.08);");
ui->checkBoxCA->setFocusPolicy(Qt::NoFocus);
ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi

View File

@ -62,6 +62,7 @@ DlgConnHidWifiWpa::DlgConnHidWifiWpa(int type, MainWindow *mainWindow, QWidget *
"QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}");
ui->lineUp->setStyleSheet("background:rgba(255,255,255,0.08);");
ui->lineDown->setStyleSheet("background:rgba(255,255,255,0.08);");
ui->btnCancel->setFocusPolicy(Qt::NoFocus);
ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi