调完开机登录和密码管理界面
This commit is contained in:
+19
-48
@@ -6,7 +6,6 @@
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
#include "global.h"
|
||||
|
||||
BootPasswordPage::BootPasswordPage(AppContext* ctx, QWidget* parent)
|
||||
@@ -21,7 +20,7 @@ BootPasswordPage::BootPasswordPage(AppContext* ctx, QWidget* parent)
|
||||
col->setProperty("card", true); // 登录主体框体背景(面板色 + 圆角边框)
|
||||
QVBoxLayout* lay = new QVBoxLayout(col);
|
||||
lay->setContentsMargins(40, 40, 40, 40); // 框体内边距
|
||||
lay->setSpacing(50);
|
||||
lay->setSpacing(30);
|
||||
lay->setAlignment(Qt::AlignHCenter);
|
||||
|
||||
|
||||
@@ -40,15 +39,15 @@ BootPasswordPage::BootPasswordPage(AppContext* ctx, QWidget* parent)
|
||||
m_input->setStyleSheet("font-size:80px");
|
||||
m_input->setProperty("clickable", true);
|
||||
lay->addWidget(m_input, 0, Qt::AlignHCenter);
|
||||
lay->addSpacing(40);
|
||||
//lay->addSpacing(20);
|
||||
m_input->installEventFilter(this);
|
||||
m_input->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
// 错误提示(默认隐藏)
|
||||
m_error = label("密码输入有误,请重新输入", 80, C::DANGER, true, col);
|
||||
// 错误提示(预留固定高度,出现/消失不影响下方按钮位置)
|
||||
m_error = new QLabel(col);
|
||||
m_error->setAlignment(Qt::AlignCenter);
|
||||
m_error->setStyleSheet("font-size:80px");
|
||||
m_error->hide();
|
||||
//m_error->setFixedHeight(30);
|
||||
m_error->setStyleSheet("color:#E5484D;font-size:40px;font-weight:700;");
|
||||
lay->addWidget(m_error);
|
||||
|
||||
// 确认 / 取消
|
||||
@@ -61,33 +60,22 @@ BootPasswordPage::BootPasswordPage(AppContext* ctx, QWidget* parent)
|
||||
connect(ok, &QPushButton::clicked, this, &BootPasswordPage::onConfirm);
|
||||
QPushButton* cancel = button("取消", "", col);
|
||||
cancel->setFixedSize(160, 140);
|
||||
// 取消语义:选中时红底白字(内联 :focus,确保覆盖全局蓝色选中态)
|
||||
cancel->setStyleSheet("font-size:60px;QPushButton:focus{background-color:#E5484D;color:#FFFFFF;border:2px solid #FFA6A9;}");
|
||||
cancel->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
|
||||
connect(cancel, &QPushButton::clicked, this, &BootPasswordPage::onCancel);
|
||||
btnRow->addWidget(ok);
|
||||
btnRow->addWidget(cancel);
|
||||
btnRow->addStretch(1);
|
||||
lay->addLayout(btnRow);
|
||||
|
||||
// 忘记密码 / 修改密码(平时红字透明底,按下红底白字)
|
||||
// 密码管理入口(平时红字透明底,按下红底白字)
|
||||
const QString linkBtnStyle =
|
||||
"QPushButton{color:#E5484D;background:transparent;border:1px solid transparent;border-radius:6px;font-size:30px;}"
|
||||
"QPushButton{color:#E5484D;background:transparent;border:1px solid transparent;border-radius:6px;font-size:40px;}"
|
||||
"QPushButton:hover,QPushButton:pressed,QPushButton:focus{background-color:#E5484D;color:#FFFFFF;border:1px solid #FFA6A9;}";
|
||||
QHBoxLayout* forgetRow = new QHBoxLayout();
|
||||
forgetRow->setSpacing(80);
|
||||
forgetRow->addStretch(1);
|
||||
QPushButton* forget = button("忘记密码", "", col);
|
||||
forget->setFixedSize(130, 60);
|
||||
forget->setStyleSheet(linkBtnStyle);
|
||||
connect(forget, &QPushButton::clicked, this, &BootPasswordPage::onForget);
|
||||
QPushButton* modify = button("修改密码", "", col);
|
||||
modify->setFixedSize(130, 60);
|
||||
modify->setStyleSheet(linkBtnStyle);
|
||||
connect(modify, &QPushButton::clicked, this, &BootPasswordPage::onForget);
|
||||
forgetRow->addWidget(forget);
|
||||
forgetRow->addWidget(modify);
|
||||
forgetRow->addStretch(1);
|
||||
lay->addLayout(forgetRow);
|
||||
QPushButton* mgmt = button("密码管理", "", col);
|
||||
mgmt->setFixedSize(170, 60);
|
||||
mgmt->setStyleSheet(linkBtnStyle);
|
||||
connect(mgmt, &QPushButton::clicked, this, &BootPasswordPage::onMgmt);
|
||||
lay->addWidget(mgmt, 0, Qt::AlignHCenter);
|
||||
|
||||
root->addWidget(col, 0, Qt::AlignHCenter);
|
||||
root->addStretch(1);
|
||||
@@ -116,43 +104,24 @@ bool BootPasswordPage::eventFilter(QObject* obj, QEvent* ev)
|
||||
|
||||
void BootPasswordPage::onInputClicked()
|
||||
{
|
||||
if (m_locked)
|
||||
return;
|
||||
NumPadDialog dlg(this);
|
||||
dlg.setMaxLen(4);
|
||||
dlg.setValue(m_value);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
m_value = dlg.value();
|
||||
m_error->hide();
|
||||
m_error->setText("");
|
||||
refreshInput();
|
||||
}
|
||||
}
|
||||
|
||||
void BootPasswordPage::onConfirm()
|
||||
{
|
||||
if (m_locked)
|
||||
return;
|
||||
|
||||
if (m_value == ctx()->password()) {
|
||||
m_wrongCount = 0;
|
||||
clearInput();
|
||||
emit navigate(PageSelfCheck);
|
||||
} else {
|
||||
m_wrongCount++;
|
||||
clearInput();
|
||||
if (m_wrongCount >= 5) {
|
||||
// 【设计建议】连续 5 次错误锁定 30s
|
||||
m_locked = true;
|
||||
m_error->setText("连续输入错误,已锁定 30 秒");
|
||||
m_error->show();
|
||||
QTimer::singleShot(30000, this, [this]() {
|
||||
m_locked = false;
|
||||
m_wrongCount = 0;
|
||||
m_error->hide();
|
||||
});
|
||||
} else {
|
||||
emit navigate(PageWarning);
|
||||
}
|
||||
m_error->setText("密码错误!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,15 +130,17 @@ void BootPasswordPage::onCancel()
|
||||
clearInput();
|
||||
}
|
||||
|
||||
void BootPasswordPage::onForget()
|
||||
void BootPasswordPage::onMgmt()
|
||||
{
|
||||
clearInput();
|
||||
// 密码管理:进入管理员登录界面
|
||||
emit navigate(PageMgmtLogin);
|
||||
}
|
||||
|
||||
void BootPasswordPage::clearInput()
|
||||
{
|
||||
m_value.clear();
|
||||
m_error->setText("");
|
||||
refreshInput();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user