You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Cigarette/Cigarette/dialogsetuppasswd.cpp

99 lines
2.6 KiB
C++

#include "dialogsetuppasswd.hpp"
#include <QCryptographicHash>
#include <qdebug.h>
#include <qmessagebox.h>
extern bool g_admin_mode; //是否管理员模式
extern QString g_admin_pswd; //管理员密码
DialogSetupPasswd::DialogSetupPasswd(QWidget* parent) : QDialog(parent) {
ui.setupUi(this);
m_pswd = "";
this->setWindowFlags(Qt::FramelessWindowHint);
}
DialogSetupPasswd::~DialogSetupPasswd() {
}
void DialogSetupPasswd::on_pushButton_close_released()
{
this->close();
}
void DialogSetupPasswd::on_pushButton_clr_released()
{
m_pswd = "";
ui.lineEdit->setText("");
}
void DialogSetupPasswd::on_pushButton_ok_released()
{
QString md5Str = QCryptographicHash::hash(m_pswd.toLatin1(), QCryptographicHash::Md5).toHex();
qDebug() << "m_pswd:" << m_pswd;
qDebug() << "m_pswd md5:" << md5Str;
qDebug() << "g_admin_pswd md5:" << g_admin_pswd;
if (md5Str.compare(g_admin_pswd, Qt::CaseInsensitive) == 0)
{
g_admin_mode = true;
//QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("验证通过,进入管理员模式"), QMessageBox::Ok);
emit enter_admin();
this->close();
}
else {
QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("密码错误,请重新输入"), QMessageBox::Ok);
on_pushButton_clr_released();
}
}
void DialogSetupPasswd::on_pushButton_0_released()
{
m_pswd += "0";
ui.lineEdit->setText(ui.lineEdit->text() + "*");
}
void DialogSetupPasswd::on_pushButton_1_released()
{
m_pswd += "1";
ui.lineEdit->setText(ui.lineEdit->text() + "*");
}
void DialogSetupPasswd::on_pushButton_2_released()
{
m_pswd += "2";
ui.lineEdit->setText(ui.lineEdit->text() + "*");
}
void DialogSetupPasswd::on_pushButton_3_released()
{
m_pswd += "3";
ui.lineEdit->setText(ui.lineEdit->text() + "*");
}
void DialogSetupPasswd::on_pushButton_4_released()
{
m_pswd += "4";
ui.lineEdit->setText(ui.lineEdit->text() + "*");
}
void DialogSetupPasswd::on_pushButton_5_released()
{
m_pswd += "5";
ui.lineEdit->setText(ui.lineEdit->text() + "*");
}
void DialogSetupPasswd::on_pushButton_6_released()
{
m_pswd += "6";
ui.lineEdit->setText(ui.lineEdit->text() + "*");
}
void DialogSetupPasswd::on_pushButton_7_released()
{
m_pswd += "7";
ui.lineEdit->setText(ui.lineEdit->text() + "*");
}
void DialogSetupPasswd::on_pushButton_8_released()
{
m_pswd += "8";
ui.lineEdit->setText(ui.lineEdit->text() + "*");
}
void DialogSetupPasswd::on_pushButton_9_released()
{
m_pswd += "9";
ui.lineEdit->setText(ui.lineEdit->text() + "*");
}