|
@@ -0,0 +1,87 @@
|
|
|
+#include "mainwindowlogin.h"
|
|
|
+#include "ui_mainwindowlogin.h"
|
|
|
+
|
|
|
+#include <QMessageBox>
|
|
|
+
|
|
|
+#include "mainwindow.h"
|
|
|
+#include "mainwindowlogin.h"
|
|
|
+
|
|
|
+extern MainWindow * gwmain;
|
|
|
+extern MainWindowLogin * gwlogin;
|
|
|
+
|
|
|
+MainWindowLogin::MainWindowLogin(QWidget *parent) :
|
|
|
+ QMainWindow(parent),
|
|
|
+ ui(new Ui::MainWindowLogin)
|
|
|
+{
|
|
|
+ ui->setupUi(this);
|
|
|
+
|
|
|
+ ui->lineEdit_password->setEchoMode(QLineEdit::Password);
|
|
|
+
|
|
|
+ ui->pushButton_Login->setDefault(true); //When Click Enter, click
|
|
|
+
|
|
|
+ mpcheckdisplay = new QCheckBox(ui->lineEdit_password);
|
|
|
+ connect(mpcheckdisplay,SIGNAL(stateChanged(int)),this, SLOT(slot_checkbox_state_changed(int)));
|
|
|
+
|
|
|
+ // 设置样式表(图片为眼睛样式)
|
|
|
+ mpcheckdisplay->setStyleSheet("QCheckBox {spacing: 5px;border: none;background-color: transparent;}"
|
|
|
+ "QCheckBox::indicator {width: 20px;height: 20px;border: none;image: url(:/no_display.png);}"
|
|
|
+ "QCheckBox::indicator:checked {image: url(:/display.png);}");
|
|
|
+
|
|
|
+// mpcheckdisplay->setGeometry(ui->lineEdit_password->pos().x() + 100,ui->lineEdit_password->pos().y() + 4,20,20);
|
|
|
+
|
|
|
+ mpcheckdisplay->setGeometry(ui->lineEdit_password->size().width() - 30, (ui->lineEdit_password->size().height() -20)/2,20,20);
|
|
|
+
|
|
|
+ connect(this,SIGNAL(loginstate(int,char *)),this,SLOT(onloginstate(int,char *)));
|
|
|
+
|
|
|
+ setWindowTitle("Login");
|
|
|
+}
|
|
|
+
|
|
|
+MainWindowLogin::~MainWindowLogin()
|
|
|
+{
|
|
|
+ delete ui;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindowLogin::on_pushButton_Login_clicked()
|
|
|
+{
|
|
|
+ ui->pushButton_Login->setText("Loging....");
|
|
|
+ ui->pushButton_Login->setEnabled(false);
|
|
|
+
|
|
|
+ mpthread = new std::thread(&MainWindowLogin::threadlogin,this);
|
|
|
+
|
|
|
+// this->hide();
|
|
|
+// gwmain->show();
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindowLogin::slot_checkbox_state_changed(int state)
|
|
|
+{
|
|
|
+ if(state){
|
|
|
+ ui->lineEdit_password->setEchoMode(QLineEdit::Normal);
|
|
|
+ }else{
|
|
|
+ ui->lineEdit_password->setEchoMode(QLineEdit::Password);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindowLogin::onloginstate(int nstate, char * strerr)
|
|
|
+{
|
|
|
+ if(nstate == 1)
|
|
|
+ {
|
|
|
+ this->hide();
|
|
|
+ gwmain->show();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(nstate == 0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning",strerr,QMessageBox::YesAll);
|
|
|
+ ui->pushButton_Login->setText("Login");
|
|
|
+ ui->pushButton_Login->setEnabled(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindowLogin::threadlogin()
|
|
|
+{
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(3000));
|
|
|
+ emit loginstate(0,"password error");
|
|
|
+}
|