255 lines
6.9 KiB
C++
255 lines
6.9 KiB
C++
|
|
#include "loginwidget.h"
|
|||
|
|
#include "ui_loginwidget.h"
|
|||
|
|
#include <QSettings>
|
|||
|
|
#include <QDir>
|
|||
|
|
#include "passworddialog.h"
|
|||
|
|
#include "dataformate.h"
|
|||
|
|
#include <QDebug>
|
|||
|
|
#include <QProcess>
|
|||
|
|
#include "fescontroldialog.h"
|
|||
|
|
#include "cmainwindow.h"
|
|||
|
|
#include "languagemanager.h"
|
|||
|
|
|
|||
|
|
|
|||
|
|
LoginWidget::LoginWidget(QDialog *parent) :
|
|||
|
|
QDialog(parent),
|
|||
|
|
ui(new Ui::LoginWidget),
|
|||
|
|
passworldDialog(nullptr)
|
|||
|
|
{
|
|||
|
|
//PC版默认密码111111,TV版默认密码666666
|
|||
|
|
ui->setupUi(this);
|
|||
|
|
setWindowFlags(Qt::FramelessWindowHint);
|
|||
|
|
//设置为模态对话框
|
|||
|
|
// setModal(true);
|
|||
|
|
connect(this,&LoginWidget::signalResult,this,&LoginWidget::done);
|
|||
|
|
// setAttribute(Qt::WA_DeleteOnClose,true);
|
|||
|
|
ui->userNameTips_Label->setVisible(false);
|
|||
|
|
ui->passwordTips_Label->setVisible(false);
|
|||
|
|
|
|||
|
|
passworldDialog = new PasswordDialog();
|
|||
|
|
m_shutdownDialog = new ShutdeonDialog();
|
|||
|
|
|
|||
|
|
ui->password_LineEdit->setEchoMode(QLineEdit::Password);
|
|||
|
|
|
|||
|
|
// ui->password_LineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
|||
|
|
ui->remember_RadioButton->setChecked(true);
|
|||
|
|
|
|||
|
|
QString dirPath = "./DependFile/conf/";
|
|||
|
|
QDir confdir(dirPath);
|
|||
|
|
if(!confdir.exists())
|
|||
|
|
confdir.mkdir(dirPath);
|
|||
|
|
QString confFile(dirPath + "remberIDconf.ini");
|
|||
|
|
QSettings iniSetting(confFile, QSettings::IniFormat);
|
|||
|
|
QString password = iniSetting.value("password").toString();
|
|||
|
|
QString userName = iniSetting.value("userName").toString();
|
|||
|
|
ui->userName_LineEdit->setText(userName);
|
|||
|
|
ui->password_LineEdit->setText(password);
|
|||
|
|
ui->forgetPasswordTips_Label->setVisible(false);
|
|||
|
|
m_timer = new QTimer(this);
|
|||
|
|
m_bleItem = new BLEItem();
|
|||
|
|
|
|||
|
|
connect(m_timer,SIGNAL(timeout()),this,SLOT(slotCleanTimes()));
|
|||
|
|
|
|||
|
|
// qDebug()<<"password"<< ui->userName_LineEdit->text()<<ui->password_LineEdit->text();
|
|||
|
|
// connect(this,SIGNAL(signalCloseApp(),FesControlDialog::getInstance(),FesControlDialog::getInstance()->);
|
|||
|
|
/*
|
|||
|
|
#ifdef NORMALEXE
|
|||
|
|
ui->label_2->setStyleSheet("border-image: url(:/DependFile/Source/login/upDown_limp.jpg);");
|
|||
|
|
#endif
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#ifdef ONLYUPLIMP
|
|||
|
|
ui->label_2->setStyleSheet("border-image: url(:/DependFile/Source/login/upLimp.png);");
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifdef ONLYDOWNLIMP
|
|||
|
|
ui->label_2->setStyleSheet("border-image: url(:/DependFile/Source/login/downLimp.png);");
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
LoginWidget::~LoginWidget()
|
|||
|
|
{
|
|||
|
|
if(passworldDialog)
|
|||
|
|
delete passworldDialog;
|
|||
|
|
if(m_shutdownDialog)
|
|||
|
|
delete m_shutdownDialog;
|
|||
|
|
if(m_bleItem)
|
|||
|
|
delete m_bleItem;
|
|||
|
|
delete ui;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LoginWidget::slotShowCompleted()
|
|||
|
|
{
|
|||
|
|
this->close();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LoginWidget::slotCleanTimes()
|
|||
|
|
{
|
|||
|
|
m_clockTime = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LoginWidget::on_forgetPassword_Btn_clicked()
|
|||
|
|
{
|
|||
|
|
//弹出提示框,告知获取密码的方式
|
|||
|
|
ui->forgetPasswordTips_Label->setText(tr("请联系管理员获取初始密码"));
|
|||
|
|
ui->forgetPasswordTips_Label->setVisible(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LoginWidget::on_confirm_Btn_clicked()
|
|||
|
|
{
|
|||
|
|
QString dirPath = "./DependFile/conf/";
|
|||
|
|
QDir confdir(dirPath);
|
|||
|
|
if(!confdir.exists())
|
|||
|
|
confdir.mkdir(dirPath);
|
|||
|
|
QString confFile(dirPath + "IDconf.ini");
|
|||
|
|
QSettings iniSetting(confFile, QSettings::IniFormat);
|
|||
|
|
QString password = iniSetting.value("password").toString();
|
|||
|
|
QString userName = iniSetting.value("userName").toString();
|
|||
|
|
qDebug()<<userName<<password;
|
|||
|
|
|
|||
|
|
QString rememberConfFile(dirPath + "remberIDconf.ini");
|
|||
|
|
QSettings remIniSetting(confFile, QSettings::IniFormat);
|
|||
|
|
QString remPassword = iniSetting.value("password").toString();
|
|||
|
|
QString remUserName = iniSetting.value("userName").toString();
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(ui->userName_LineEdit->text() != userName)
|
|||
|
|
{
|
|||
|
|
ui->userNameTips_Label->setVisible(true);
|
|||
|
|
ui->userNameTips_Label->setText(tr("用户名输入错误"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(ui->password_LineEdit->text() != password)
|
|||
|
|
{
|
|||
|
|
ui->passwordTips_Label->setVisible(true);
|
|||
|
|
ui->passwordTips_Label->setText(tr("密码输入错误"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//设置返回值结果
|
|||
|
|
emit signalResult(1);
|
|||
|
|
if(ui->remember_RadioButton->isChecked())
|
|||
|
|
{
|
|||
|
|
QString confFile(dirPath + "remberIDconf.ini");
|
|||
|
|
QSettings iniSetting(confFile, QSettings::IniFormat);
|
|||
|
|
iniSetting.setValue("password",ui->password_LineEdit->text());
|
|||
|
|
iniSetting.setValue("userName",ui->userName_LineEdit->text());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LoginWidget::on_userName_LineEdit_textChanged(const QString &arg1)
|
|||
|
|
{
|
|||
|
|
Q_UNUSED(arg1)
|
|||
|
|
ui->userNameTips_Label->setVisible(false);
|
|||
|
|
ui->forgetPasswordTips_Label->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void LoginWidget::on_password_LineEdit_textChanged(const QString &arg1)
|
|||
|
|
{
|
|||
|
|
Q_UNUSED(arg1)
|
|||
|
|
ui->passwordTips_Label->setVisible(false);
|
|||
|
|
ui->forgetPasswordTips_Label->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void LoginWidget::changeEvent(QEvent* event)
|
|||
|
|
{
|
|||
|
|
switch (event->type())
|
|||
|
|
{
|
|||
|
|
case QEvent::LanguageChange:
|
|||
|
|
{
|
|||
|
|
ui->retranslateUi(this);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
QWidget::changeEvent(event);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
m_clockTime = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LoginWidget::showEvent(QShowEvent *event)
|
|||
|
|
{
|
|||
|
|
Q_UNUSED(event)
|
|||
|
|
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
|
|||
|
|
|
|||
|
|
if(language == Chinese_E)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
ui->company_Label->setStyleSheet("border-image: url(:/DependFile/Source/login/company.png);");
|
|||
|
|
QFont font;
|
|||
|
|
font.setFamily("黑体");
|
|||
|
|
font.setPointSize(18);
|
|||
|
|
ui->productionName_Label->setFont(font);
|
|||
|
|
}
|
|||
|
|
//
|
|||
|
|
else if(language == English_E)
|
|||
|
|
{
|
|||
|
|
ui->company_Label->setStyleSheet("border-image: url(:/DependFile/Source/login/company_En.png);");
|
|||
|
|
//
|
|||
|
|
QFont font;
|
|||
|
|
font.setFamily("Arial");
|
|||
|
|
font.setPointSize(18);
|
|||
|
|
ui->productionName_Label->setFont(font);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
void LoginWidget::on_pushButton_clicked()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
m_shutdownDialog->exec(); //关闭窗口
|
|||
|
|
qDebug()<<"关机值:"<< m_shutdownDialog->getResult();
|
|||
|
|
if(m_shutdownDialog->getResult() == 0)
|
|||
|
|
return;
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
FesControlDialog::getInstance()->turnoffDevice(1,1);
|
|||
|
|
Sleep(100);
|
|||
|
|
// FesControlDialog::getInstance()->turnoffDevice(1,1);
|
|||
|
|
|
|||
|
|
QCoreApplication::quit(); //关闭程序
|
|||
|
|
Sleep(3500); //睡眠
|
|||
|
|
}
|
|||
|
|
// emit signalCloseWindow();
|
|||
|
|
/*
|
|||
|
|
QString program = "C:/WINDOWS/system32/shutdown.exe";
|
|||
|
|
QStringList arguments;
|
|||
|
|
arguments << "-s";
|
|||
|
|
QProcess *myProcess = new QProcess();
|
|||
|
|
myProcess->start(program,arguments);
|
|||
|
|
*/
|
|||
|
|
system("shutdown -s -t 00");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void LoginWidget::on_company_Label_clicked()
|
|||
|
|
{
|
|||
|
|
m_clockTime++;
|
|||
|
|
if(m_clockTime == 1)
|
|||
|
|
m_timer->start(5000);
|
|||
|
|
qDebug()<<m_clockTime;
|
|||
|
|
if(m_clockTime == 10)
|
|||
|
|
{
|
|||
|
|
//m_bleItem->setDeviceState(false);
|
|||
|
|
FesControlDialog::getInstance()->turnoffDevice(1,1);
|
|||
|
|
Sleep(100);
|
|||
|
|
// emit signalCloseApp();
|
|||
|
|
//FesControlDialog::getInstance()->turnoffDevice(1,1);
|
|||
|
|
|
|||
|
|
QApplication *app;
|
|||
|
|
app->exit(0);
|
|||
|
|
this->close();
|
|||
|
|
//关闭所有设备
|
|||
|
|
//FesControlDialog::getInstance()->turnoffDevice(1,1);
|
|||
|
|
//emit signalCloseApp();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|