调完开机登录和密码管理界面
This commit is contained in:
+9
-5
@@ -34,6 +34,15 @@ void stopBlink(QWidget* w, const char* prop)
|
|||||||
w->update();
|
w->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString cancelButtonStyle(int fontPx)
|
||||||
|
{
|
||||||
|
return QString(
|
||||||
|
"QPushButton{font-size:%1px;}"
|
||||||
|
"QPushButton:hover,QPushButton:pressed,QPushButton:focus"
|
||||||
|
"{background-color:%2;color:#FFFFFF;border:2px solid #FFA6A9;}")
|
||||||
|
.arg(fontPx).arg(C::DANGER);
|
||||||
|
}
|
||||||
|
|
||||||
QString appStyleSheet()
|
QString appStyleSheet()
|
||||||
{
|
{
|
||||||
const QString s = QString(R"QSS(
|
const QString s = QString(R"QSS(
|
||||||
@@ -151,11 +160,6 @@ QPushButton[numpad="true"]:focus {
|
|||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
border: 2px solid #8ABFFF;
|
border: 2px solid #8ABFFF;
|
||||||
}
|
}
|
||||||
QPushButton[cancel="true"]:focus {
|
|
||||||
background-color: DAN;
|
|
||||||
color: #FFFFFF;
|
|
||||||
border: 2px solid #FFA6A9;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== 告警文字(红色闪烁由 blink 属性驱动) ===== */
|
/* ===== 告警文字(红色闪烁由 blink 属性驱动) ===== */
|
||||||
QLabel[alert="true"] { color: DAN; font-weight: 700; }
|
QLabel[alert="true"] { color: DAN; font-weight: 700; }
|
||||||
|
|||||||
@@ -115,6 +115,9 @@ QTimer* startBlink(QWidget* w, const char* prop = "blink");
|
|||||||
// 关闭闪烁定时器并复位属性
|
// 关闭闪烁定时器并复位属性
|
||||||
void stopBlink(QWidget* w, const char* prop = "blink");
|
void stopBlink(QWidget* w, const char* prop = "blink");
|
||||||
|
|
||||||
|
// 退出/取消按钮预设样式:被选中(悬停/按下/焦点)时红底白字
|
||||||
|
QString cancelButtonStyle(int fontPx = 60);
|
||||||
|
|
||||||
// 全局 QSS 样式表
|
// 全局 QSS 样式表
|
||||||
QString appStyleSheet();
|
QString appStyleSheet();
|
||||||
|
|
||||||
|
|||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+19
-48
@@ -6,7 +6,6 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTimer>
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
BootPasswordPage::BootPasswordPage(AppContext* ctx, QWidget* parent)
|
BootPasswordPage::BootPasswordPage(AppContext* ctx, QWidget* parent)
|
||||||
@@ -21,7 +20,7 @@ BootPasswordPage::BootPasswordPage(AppContext* ctx, QWidget* parent)
|
|||||||
col->setProperty("card", true); // 登录主体框体背景(面板色 + 圆角边框)
|
col->setProperty("card", true); // 登录主体框体背景(面板色 + 圆角边框)
|
||||||
QVBoxLayout* lay = new QVBoxLayout(col);
|
QVBoxLayout* lay = new QVBoxLayout(col);
|
||||||
lay->setContentsMargins(40, 40, 40, 40); // 框体内边距
|
lay->setContentsMargins(40, 40, 40, 40); // 框体内边距
|
||||||
lay->setSpacing(50);
|
lay->setSpacing(30);
|
||||||
lay->setAlignment(Qt::AlignHCenter);
|
lay->setAlignment(Qt::AlignHCenter);
|
||||||
|
|
||||||
|
|
||||||
@@ -40,15 +39,15 @@ BootPasswordPage::BootPasswordPage(AppContext* ctx, QWidget* parent)
|
|||||||
m_input->setStyleSheet("font-size:80px");
|
m_input->setStyleSheet("font-size:80px");
|
||||||
m_input->setProperty("clickable", true);
|
m_input->setProperty("clickable", true);
|
||||||
lay->addWidget(m_input, 0, Qt::AlignHCenter);
|
lay->addWidget(m_input, 0, Qt::AlignHCenter);
|
||||||
lay->addSpacing(40);
|
//lay->addSpacing(20);
|
||||||
m_input->installEventFilter(this);
|
m_input->installEventFilter(this);
|
||||||
m_input->setFocusPolicy(Qt::StrongFocus);
|
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->setAlignment(Qt::AlignCenter);
|
||||||
m_error->setStyleSheet("font-size:80px");
|
//m_error->setFixedHeight(30);
|
||||||
m_error->hide();
|
m_error->setStyleSheet("color:#E5484D;font-size:40px;font-weight:700;");
|
||||||
lay->addWidget(m_error);
|
lay->addWidget(m_error);
|
||||||
|
|
||||||
// 确认 / 取消
|
// 确认 / 取消
|
||||||
@@ -61,33 +60,22 @@ BootPasswordPage::BootPasswordPage(AppContext* ctx, QWidget* parent)
|
|||||||
connect(ok, &QPushButton::clicked, this, &BootPasswordPage::onConfirm);
|
connect(ok, &QPushButton::clicked, this, &BootPasswordPage::onConfirm);
|
||||||
QPushButton* cancel = button("取消", "", col);
|
QPushButton* cancel = button("取消", "", col);
|
||||||
cancel->setFixedSize(160, 140);
|
cancel->setFixedSize(160, 140);
|
||||||
// 取消语义:选中时红底白字(内联 :focus,确保覆盖全局蓝色选中态)
|
cancel->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
|
||||||
cancel->setStyleSheet("font-size:60px;QPushButton:focus{background-color:#E5484D;color:#FFFFFF;border:2px solid #FFA6A9;}");
|
|
||||||
connect(cancel, &QPushButton::clicked, this, &BootPasswordPage::onCancel);
|
connect(cancel, &QPushButton::clicked, this, &BootPasswordPage::onCancel);
|
||||||
btnRow->addWidget(ok);
|
btnRow->addWidget(ok);
|
||||||
btnRow->addWidget(cancel);
|
btnRow->addWidget(cancel);
|
||||||
btnRow->addStretch(1);
|
btnRow->addStretch(1);
|
||||||
lay->addLayout(btnRow);
|
lay->addLayout(btnRow);
|
||||||
|
|
||||||
// 忘记密码 / 修改密码(平时红字透明底,按下红底白字)
|
// 密码管理入口(平时红字透明底,按下红底白字)
|
||||||
const QString linkBtnStyle =
|
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;}";
|
"QPushButton:hover,QPushButton:pressed,QPushButton:focus{background-color:#E5484D;color:#FFFFFF;border:1px solid #FFA6A9;}";
|
||||||
QHBoxLayout* forgetRow = new QHBoxLayout();
|
QPushButton* mgmt = button("密码管理", "", col);
|
||||||
forgetRow->setSpacing(80);
|
mgmt->setFixedSize(170, 60);
|
||||||
forgetRow->addStretch(1);
|
mgmt->setStyleSheet(linkBtnStyle);
|
||||||
QPushButton* forget = button("忘记密码", "", col);
|
connect(mgmt, &QPushButton::clicked, this, &BootPasswordPage::onMgmt);
|
||||||
forget->setFixedSize(130, 60);
|
lay->addWidget(mgmt, 0, Qt::AlignHCenter);
|
||||||
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);
|
|
||||||
|
|
||||||
root->addWidget(col, 0, Qt::AlignHCenter);
|
root->addWidget(col, 0, Qt::AlignHCenter);
|
||||||
root->addStretch(1);
|
root->addStretch(1);
|
||||||
@@ -116,43 +104,24 @@ bool BootPasswordPage::eventFilter(QObject* obj, QEvent* ev)
|
|||||||
|
|
||||||
void BootPasswordPage::onInputClicked()
|
void BootPasswordPage::onInputClicked()
|
||||||
{
|
{
|
||||||
if (m_locked)
|
|
||||||
return;
|
|
||||||
NumPadDialog dlg(this);
|
NumPadDialog dlg(this);
|
||||||
dlg.setMaxLen(4);
|
dlg.setMaxLen(4);
|
||||||
dlg.setValue(m_value);
|
dlg.setValue(m_value);
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
m_value = dlg.value();
|
m_value = dlg.value();
|
||||||
m_error->hide();
|
m_error->setText("");
|
||||||
refreshInput();
|
refreshInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BootPasswordPage::onConfirm()
|
void BootPasswordPage::onConfirm()
|
||||||
{
|
{
|
||||||
if (m_locked)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_value == ctx()->password()) {
|
if (m_value == ctx()->password()) {
|
||||||
m_wrongCount = 0;
|
|
||||||
clearInput();
|
clearInput();
|
||||||
emit navigate(PageSelfCheck);
|
emit navigate(PageSelfCheck);
|
||||||
} else {
|
} else {
|
||||||
m_wrongCount++;
|
|
||||||
clearInput();
|
clearInput();
|
||||||
if (m_wrongCount >= 5) {
|
m_error->setText("密码错误!");
|
||||||
// 【设计建议】连续 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,15 +130,17 @@ void BootPasswordPage::onCancel()
|
|||||||
clearInput();
|
clearInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BootPasswordPage::onForget()
|
void BootPasswordPage::onMgmt()
|
||||||
{
|
{
|
||||||
clearInput();
|
clearInput();
|
||||||
|
// 密码管理:进入管理员登录界面
|
||||||
emit navigate(PageMgmtLogin);
|
emit navigate(PageMgmtLogin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BootPasswordPage::clearInput()
|
void BootPasswordPage::clearInput()
|
||||||
{
|
{
|
||||||
m_value.clear();
|
m_value.clear();
|
||||||
|
m_error->setText("");
|
||||||
refreshInput();
|
refreshInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ private slots:
|
|||||||
void onInputClicked();
|
void onInputClicked();
|
||||||
void onConfirm();
|
void onConfirm();
|
||||||
void onCancel();
|
void onCancel();
|
||||||
void onForget();
|
void onMgmt();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void refreshInput();
|
void refreshInput();
|
||||||
@@ -31,8 +31,6 @@ private:
|
|||||||
QLineEdit* m_input = nullptr;
|
QLineEdit* m_input = nullptr;
|
||||||
QLabel* m_error = nullptr;
|
QLabel* m_error = nullptr;
|
||||||
QString m_value;
|
QString m_value;
|
||||||
int m_wrongCount = 0;
|
|
||||||
bool m_locked = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BOOTPASSWORDPAGE_H
|
#endif // BOOTPASSWORDPAGE_H
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ PasswordMgmtPage::PasswordMgmtPage(AppContext* ctx, QWidget* parent)
|
|||||||
QWidget* col = new QWidget(this);
|
QWidget* col = new QWidget(this);
|
||||||
col->setFixedWidth(700);
|
col->setFixedWidth(700);
|
||||||
QVBoxLayout* lay = new QVBoxLayout(col);
|
QVBoxLayout* lay = new QVBoxLayout(col);
|
||||||
lay->setSpacing(24);
|
lay->setSpacing(50);
|
||||||
lay->setAlignment(Qt::AlignHCenter);
|
lay->setAlignment(Qt::AlignHCenter);
|
||||||
|
|
||||||
QLabel* title = label("密码管理界面", 28, C::TEXT, true, col);
|
QLabel* title = label("密码管理界面", 60, C::TEXT, true, col);
|
||||||
title->setAlignment(Qt::AlignCenter);
|
title->setAlignment(Qt::AlignCenter);
|
||||||
lay->addWidget(title);
|
lay->addWidget(title);
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ PasswordMgmtPage::PasswordMgmtPage(AppContext* ctx, QWidget* parent)
|
|||||||
m_reset = new QCheckBox("重置密码功能", option);
|
m_reset = new QCheckBox("重置密码功能", option);
|
||||||
m_reset->setChecked(true);
|
m_reset->setChecked(true);
|
||||||
m_reset->setStyleSheet(QString(
|
m_reset->setStyleSheet(QString(
|
||||||
"QCheckBox{color:%1;font-size:26px;spacing:12px;}"
|
"QCheckBox{color:%1;font-size:40px;spacing:16px;}"
|
||||||
"QCheckBox::indicator{width:32px;height:32px;border:2px solid %2;border-radius:6px;background-color:%3;}"
|
"QCheckBox::indicator{width:40px;height:40px;border:2px solid %2;border-radius:6px;background-color:%3;}"
|
||||||
"QCheckBox::indicator:checked{background-color:%4;border-color:%4;image:none;}")
|
"QCheckBox::indicator:checked{background-color:%4;border-color:%4;image:none;}")
|
||||||
.arg(C::TEXT, C::BORDER, C::BG, C::PRIMARY));
|
.arg(C::TEXT, C::BORDER, C::BG, C::PRIMARY));
|
||||||
optLay->addWidget(m_reset);
|
optLay->addWidget(m_reset);
|
||||||
@@ -40,12 +40,15 @@ PasswordMgmtPage::PasswordMgmtPage(AppContext* ctx, QWidget* parent)
|
|||||||
|
|
||||||
// 确认 / 退出
|
// 确认 / 退出
|
||||||
QHBoxLayout* btnRow = new QHBoxLayout();
|
QHBoxLayout* btnRow = new QHBoxLayout();
|
||||||
|
btnRow->setSpacing(80);
|
||||||
btnRow->addStretch(1);
|
btnRow->addStretch(1);
|
||||||
QPushButton* ok = button("确认", "", col);
|
QPushButton* ok = button("确认", "", col);
|
||||||
ok->setFixedSize(180, 72);
|
ok->setFixedSize(160, 140);
|
||||||
|
ok->setStyleSheet("font-size:60px;");
|
||||||
connect(ok, &QPushButton::clicked, this, [this]() { emit navigate(PageReset); });
|
connect(ok, &QPushButton::clicked, this, [this]() { emit navigate(PageReset); });
|
||||||
QPushButton* exit = button("退出", "", col);
|
QPushButton* exit = button("退出", "", col);
|
||||||
exit->setFixedSize(180, 72);
|
exit->setFixedSize(160, 140);
|
||||||
|
exit->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
|
||||||
connect(exit, &QPushButton::clicked, this, [this]() { emit navigate(PageBoot); });
|
connect(exit, &QPushButton::clicked, this, [this]() { emit navigate(PageBoot); });
|
||||||
btnRow->addWidget(ok);
|
btnRow->addWidget(ok);
|
||||||
btnRow->addWidget(exit);
|
btnRow->addWidget(exit);
|
||||||
|
|||||||
+19
-13
@@ -6,7 +6,6 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTimer>
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
PasswordMgmtLoginPage::PasswordMgmtLoginPage(AppContext* ctx, QWidget* parent)
|
PasswordMgmtLoginPage::PasswordMgmtLoginPage(AppContext* ctx, QWidget* parent)
|
||||||
@@ -18,14 +17,14 @@ PasswordMgmtLoginPage::PasswordMgmtLoginPage(AppContext* ctx, QWidget* parent)
|
|||||||
QWidget* col = new QWidget(this);
|
QWidget* col = new QWidget(this);
|
||||||
col->setFixedWidth(700);
|
col->setFixedWidth(700);
|
||||||
QVBoxLayout* lay = new QVBoxLayout(col);
|
QVBoxLayout* lay = new QVBoxLayout(col);
|
||||||
lay->setSpacing(24);
|
lay->setSpacing(50);
|
||||||
lay->setAlignment(Qt::AlignHCenter);
|
lay->setAlignment(Qt::AlignHCenter);
|
||||||
|
|
||||||
QLabel* title = label("密码管理登录界面", 28, C::TEXT, true, col);
|
QLabel* title = label("密码管理登录界面", 60, C::TEXT, true, col);
|
||||||
title->setAlignment(Qt::AlignCenter);
|
title->setAlignment(Qt::AlignCenter);
|
||||||
lay->addWidget(title);
|
lay->addWidget(title);
|
||||||
|
|
||||||
QLabel* sub = label("请输入管理员密码", 18, C::TEXT_SUB, false, col);
|
QLabel* sub = label("请输入管理员密码", 40, C::TEXT_SUB, false, col);
|
||||||
sub->setAlignment(Qt::AlignCenter);
|
sub->setAlignment(Qt::AlignCenter);
|
||||||
lay->addWidget(sub);
|
lay->addWidget(sub);
|
||||||
|
|
||||||
@@ -33,23 +32,29 @@ PasswordMgmtLoginPage::PasswordMgmtLoginPage(AppContext* ctx, QWidget* parent)
|
|||||||
m_input->setReadOnly(true);
|
m_input->setReadOnly(true);
|
||||||
m_input->setEchoMode(QLineEdit::Password);
|
m_input->setEchoMode(QLineEdit::Password);
|
||||||
m_input->setAlignment(Qt::AlignCenter);
|
m_input->setAlignment(Qt::AlignCenter);
|
||||||
m_input->setFixedSize(400, 88);
|
m_input->setFixedSize(400, 90);
|
||||||
|
m_input->setStyleSheet("font-size:60px;");
|
||||||
m_input->setFocusPolicy(Qt::StrongFocus);
|
m_input->setFocusPolicy(Qt::StrongFocus);
|
||||||
m_input->installEventFilter(this);
|
m_input->installEventFilter(this);
|
||||||
lay->addWidget(m_input, 0, Qt::AlignHCenter);
|
lay->addWidget(m_input, 0, Qt::AlignHCenter);
|
||||||
|
|
||||||
m_error = label("管理员密码错误", 18, C::DANGER, true, col);
|
// 错误提示(预留固定高度,出现/消失不影响下方按钮位置)
|
||||||
|
m_error = new QLabel(col);
|
||||||
m_error->setAlignment(Qt::AlignCenter);
|
m_error->setAlignment(Qt::AlignCenter);
|
||||||
m_error->hide();
|
m_error->setFixedHeight(56);
|
||||||
|
m_error->setStyleSheet("color:#E5484D;font-size:40px;font-weight:700;");
|
||||||
lay->addWidget(m_error);
|
lay->addWidget(m_error);
|
||||||
|
|
||||||
QHBoxLayout* btnRow = new QHBoxLayout();
|
QHBoxLayout* btnRow = new QHBoxLayout();
|
||||||
|
btnRow->setSpacing(80);
|
||||||
btnRow->addStretch(1);
|
btnRow->addStretch(1);
|
||||||
QPushButton* ok = button("确认", "", col);
|
QPushButton* ok = button("确认", "", col);
|
||||||
ok->setFixedSize(180, 72);
|
ok->setFixedSize(160, 140);
|
||||||
|
ok->setStyleSheet("font-size:60px;");
|
||||||
connect(ok, &QPushButton::clicked, this, &PasswordMgmtLoginPage::onConfirm);
|
connect(ok, &QPushButton::clicked, this, &PasswordMgmtLoginPage::onConfirm);
|
||||||
QPushButton* cancel = button("取消", "", col);
|
QPushButton* cancel = button("取消", "", col);
|
||||||
cancel->setFixedSize(180, 72);
|
cancel->setFixedSize(160, 140);
|
||||||
|
cancel->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
|
||||||
connect(cancel, &QPushButton::clicked, this, &PasswordMgmtLoginPage::onCancel);
|
connect(cancel, &QPushButton::clicked, this, &PasswordMgmtLoginPage::onCancel);
|
||||||
btnRow->addWidget(ok);
|
btnRow->addWidget(ok);
|
||||||
btnRow->addWidget(cancel);
|
btnRow->addWidget(cancel);
|
||||||
@@ -86,7 +91,7 @@ void PasswordMgmtLoginPage::onInputClicked()
|
|||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
m_value = dlg.value();
|
m_value = dlg.value();
|
||||||
m_input->setText(m_value);
|
m_input->setText(m_value);
|
||||||
m_error->hide();
|
m_error->setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,8 +101,9 @@ void PasswordMgmtLoginPage::onConfirm()
|
|||||||
clearInput();
|
clearInput();
|
||||||
emit navigate(PageMgmt);
|
emit navigate(PageMgmt);
|
||||||
} else {
|
} else {
|
||||||
m_error->show();
|
m_value.clear(); // 输错后清空输入框
|
||||||
QTimer::singleShot(3000, this, [this]() { m_error->hide(); });
|
m_input->setText(m_value);
|
||||||
|
m_error->setText("管理员密码错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,5 +117,5 @@ void PasswordMgmtLoginPage::clearInput()
|
|||||||
{
|
{
|
||||||
m_value.clear();
|
m_value.clear();
|
||||||
m_input->setText(m_value);
|
m_input->setText(m_value);
|
||||||
m_error->hide();
|
m_error->setText("");
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-16
@@ -19,10 +19,10 @@ PasswordResetPage::PasswordResetPage(AppContext* ctx, QWidget* parent)
|
|||||||
QWidget* col = new QWidget(this);
|
QWidget* col = new QWidget(this);
|
||||||
col->setFixedWidth(700);
|
col->setFixedWidth(700);
|
||||||
QVBoxLayout* lay = new QVBoxLayout(col);
|
QVBoxLayout* lay = new QVBoxLayout(col);
|
||||||
lay->setSpacing(24);
|
lay->setSpacing(50);
|
||||||
lay->setAlignment(Qt::AlignHCenter);
|
lay->setAlignment(Qt::AlignHCenter);
|
||||||
|
|
||||||
QLabel* title = label("重置密码界面", 28, C::TEXT, true, col);
|
QLabel* title = label("重置密码界面", 60, C::TEXT, true, col);
|
||||||
title->setAlignment(Qt::AlignCenter);
|
title->setAlignment(Qt::AlignCenter);
|
||||||
lay->addWidget(title);
|
lay->addWidget(title);
|
||||||
|
|
||||||
@@ -30,26 +30,31 @@ PasswordResetPage::PasswordResetPage(AppContext* ctx, QWidget* parent)
|
|||||||
m_input->setReadOnly(true);
|
m_input->setReadOnly(true);
|
||||||
m_input->setEchoMode(QLineEdit::Password);
|
m_input->setEchoMode(QLineEdit::Password);
|
||||||
m_input->setAlignment(Qt::AlignCenter);
|
m_input->setAlignment(Qt::AlignCenter);
|
||||||
m_input->setFixedSize(400, 88);
|
m_input->setFixedSize(400, 90);
|
||||||
|
m_input->setStyleSheet("font-size:60px;");
|
||||||
m_input->setFocusPolicy(Qt::StrongFocus);
|
m_input->setFocusPolicy(Qt::StrongFocus);
|
||||||
m_input->installEventFilter(this);
|
m_input->installEventFilter(this);
|
||||||
lay->addWidget(m_input, 0, Qt::AlignHCenter);
|
lay->addWidget(m_input, 0, Qt::AlignHCenter);
|
||||||
|
|
||||||
m_hint = label("请输入 4 位有效密码", 18, C::TEXT_SUB, false, col);
|
m_hint = label("请输入 4 位有效密码", 50, C::TEXT_SUB, false, col);
|
||||||
m_hint->setAlignment(Qt::AlignCenter);
|
m_hint->setAlignment(Qt::AlignCenter);
|
||||||
lay->addWidget(m_hint);
|
lay->addWidget(m_hint);
|
||||||
|
|
||||||
QHBoxLayout* btnRow = new QHBoxLayout();
|
QHBoxLayout* btnRow = new QHBoxLayout();
|
||||||
|
btnRow->setSpacing(80);
|
||||||
btnRow->addStretch(1);
|
btnRow->addStretch(1);
|
||||||
QPushButton* ok = button("确认", "", col);
|
QPushButton* ok = button("确认", "", col);
|
||||||
ok->setFixedSize(160, 72);
|
ok->setFixedSize(160, 140);
|
||||||
|
ok->setStyleSheet("font-size:60px;");
|
||||||
connect(ok, &QPushButton::clicked, this, &PasswordResetPage::onConfirm);
|
connect(ok, &QPushButton::clicked, this, &PasswordResetPage::onConfirm);
|
||||||
QPushButton* cancel = button("取消", "", col);
|
QPushButton* cancel = button("取消", "", col);
|
||||||
cancel->setFixedSize(160, 72);
|
cancel->setFixedSize(160, 140);
|
||||||
connect(cancel, &QPushButton::clicked, this, &PasswordResetPage::onCancel);
|
cancel->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
|
||||||
|
connect(cancel, &QPushButton::clicked, this, &PasswordResetPage::onBack);
|
||||||
QPushButton* exit = button("退出", "", col);
|
QPushButton* exit = button("退出", "", col);
|
||||||
exit->setFixedSize(160, 72);
|
exit->setFixedSize(160, 140);
|
||||||
connect(exit, &QPushButton::clicked, this, &PasswordResetPage::onCancel);
|
exit->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
|
||||||
|
connect(exit, &QPushButton::clicked, this, &PasswordResetPage::onExit);
|
||||||
btnRow->addWidget(ok);
|
btnRow->addWidget(ok);
|
||||||
btnRow->addWidget(cancel);
|
btnRow->addWidget(cancel);
|
||||||
btnRow->addWidget(exit);
|
btnRow->addWidget(exit);
|
||||||
@@ -87,7 +92,7 @@ void PasswordResetPage::onInputClicked()
|
|||||||
m_value = dlg.value();
|
m_value = dlg.value();
|
||||||
m_input->setText(m_value);
|
m_input->setText(m_value);
|
||||||
m_hint->setText("请输入 4 位有效密码");
|
m_hint->setText("请输入 4 位有效密码");
|
||||||
m_hint->setStyleSheet(QString("color:%1;font-size:20px;").arg(C::TEXT_SUB));
|
m_hint->setStyleSheet(QString("color:%1;font-size:60px;").arg(C::TEXT_SUB));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,20 +101,28 @@ void PasswordResetPage::onConfirm()
|
|||||||
// 校验:4 位数字
|
// 校验:4 位数字
|
||||||
static const QRegularExpression re("^\\d{4}$");
|
static const QRegularExpression re("^\\d{4}$");
|
||||||
if (!re.match(m_value).hasMatch()) {
|
if (!re.match(m_value).hasMatch()) {
|
||||||
|
m_value.clear(); // 校验失败后清空输入框
|
||||||
|
m_input->setText(m_value);
|
||||||
m_hint->setText("密码须为 4 位数字");
|
m_hint->setText("密码须为 4 位数字");
|
||||||
m_hint->setStyleSheet(QString("color:%1;font-size:20px;font-weight:700;").arg(C::DANGER));
|
m_hint->setStyleSheet(QString("color:%1;font-size:60px;font-weight:700;").arg(C::DANGER));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ctx()->setPassword(m_value);
|
ctx()->setPassword(m_value);
|
||||||
clearInput();
|
clearInput();
|
||||||
ConfirmDialog::toast(this, "修改成功");
|
ConfirmDialog::toast(this, "修改成功"); // 2s 后自动消失
|
||||||
emit navigate(PageBoot);
|
emit navigate(PageBoot); // 修改完成,返回开机密码界面
|
||||||
}
|
}
|
||||||
|
|
||||||
void PasswordResetPage::onCancel()
|
void PasswordResetPage::onBack()
|
||||||
{
|
{
|
||||||
clearInput();
|
clearInput();
|
||||||
emit navigate(PageBoot);
|
emit navigate(PageMgmt); // 取消:返回上一界面(密码管理界面)
|
||||||
|
}
|
||||||
|
|
||||||
|
void PasswordResetPage::onExit()
|
||||||
|
{
|
||||||
|
clearInput();
|
||||||
|
emit navigate(PageBoot); // 退出:返回开机密码界面
|
||||||
}
|
}
|
||||||
|
|
||||||
void PasswordResetPage::clearInput()
|
void PasswordResetPage::clearInput()
|
||||||
@@ -117,5 +130,5 @@ void PasswordResetPage::clearInput()
|
|||||||
m_value.clear();
|
m_value.clear();
|
||||||
m_input->setText(m_value);
|
m_input->setText(m_value);
|
||||||
m_hint->setText("请输入 4 位有效密码");
|
m_hint->setText("请输入 4 位有效密码");
|
||||||
m_hint->setStyleSheet(QString("color:%1;font-size:20px;").arg(C::TEXT_SUB));
|
m_hint->setStyleSheet(QString("color:%1;font-size:60px;").arg(C::TEXT_SUB));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
void onInputClicked();
|
void onInputClicked();
|
||||||
void onConfirm();
|
void onConfirm();
|
||||||
void onCancel();
|
void onBack(); // 取消:返回上一界面(密码管理界面)
|
||||||
|
void onExit(); // 退出:返回开机密码界面
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLineEdit* m_input = nullptr;
|
QLineEdit* m_input = nullptr;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ ConfirmDialog::ConfirmDialog(QWidget* parent)
|
|||||||
connect(ok, &QPushButton::clicked, this, &ConfirmDialog::accept);
|
connect(ok, &QPushButton::clicked, this, &ConfirmDialog::accept);
|
||||||
QPushButton* cancel = new QPushButton("取消", panel);
|
QPushButton* cancel = new QPushButton("取消", panel);
|
||||||
cancel->setFixedSize(160, 72);
|
cancel->setFixedSize(160, 72);
|
||||||
|
cancel->setStyleSheet(cancelButtonStyle(40)); // 选中时红底白字
|
||||||
connect(cancel, &QPushButton::clicked, this, &ConfirmDialog::reject);
|
connect(cancel, &QPushButton::clicked, this, &ConfirmDialog::reject);
|
||||||
btnLay->addWidget(ok);
|
btnLay->addWidget(ok);
|
||||||
btnLay->addWidget(cancel);
|
btnLay->addWidget(cancel);
|
||||||
@@ -81,7 +82,7 @@ void ConfirmDialog::toast(QWidget* parent, const QString& text, int ms)
|
|||||||
QLabel* lbl = new QLabel(text, d);
|
QLabel* lbl = new QLabel(text, d);
|
||||||
lbl->setAlignment(Qt::AlignCenter);
|
lbl->setAlignment(Qt::AlignCenter);
|
||||||
lbl->setStyleSheet(QString(
|
lbl->setStyleSheet(QString(
|
||||||
"background-color:%1;color:%2;font-size:28px;font-weight:700;border:2px solid %3;border-radius:16px;padding:32px 48px;")
|
"background-color:%1;color:%2;font-size:50px;font-weight:700;border:2px solid %3;border-radius:16px;padding:56px 88px;")
|
||||||
.arg(C::PANEL, C::SUCCESS, C::BORDER));
|
.arg(C::PANEL, C::SUCCESS, C::BORDER));
|
||||||
lbl->adjustSize();
|
lbl->adjustSize();
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ NumPadDialog::NumPadDialog(QWidget* parent)
|
|||||||
"QWidget#NumPadPanel{background-color:%1;border:4px solid %2;border-radius:16px;}"
|
"QWidget#NumPadPanel{background-color:%1;border:4px solid %2;border-radius:16px;}"
|
||||||
"QPushButton[numpad=\"true\"]{background-color:#2D3947;color:#E6EDF3;border:1px solid #3D4A59;border-radius:12px;font-size:40px;}"
|
"QPushButton[numpad=\"true\"]{background-color:#2D3947;color:#E6EDF3;border:1px solid #3D4A59;border-radius:12px;font-size:40px;}"
|
||||||
"QPushButton[numpad=\"true\"]:pressed{background-color:#2E7BE6;color:#FFFFFF;}"
|
"QPushButton[numpad=\"true\"]:pressed{background-color:#2E7BE6;color:#FFFFFF;}"
|
||||||
"QPushButton[numpad=\"true\"]:focus{background-color:#3D8BFD;color:#FFFFFF;border:2px solid #8ABFFF;}"
|
"QPushButton[numpad=\"true\"]:focus{background-color:#3D8BFD;color:#FFFFFF;border:2px solid #8ABFFF;}")
|
||||||
"QPushButton[numpad=\"true\"][cancel=\"true\"]:focus{background-color:#E5484D;color:#FFFFFF;border:2px solid #FFA6A9;}")
|
|
||||||
.arg(C::PANEL, C::BORDER));
|
.arg(C::PANEL, C::BORDER));
|
||||||
|
|
||||||
QVBoxLayout* panelLay = new QVBoxLayout(panel);
|
QVBoxLayout* panelLay = new QVBoxLayout(panel);
|
||||||
@@ -89,8 +88,7 @@ NumPadDialog::NumPadDialog(QWidget* parent)
|
|||||||
|
|
||||||
QPushButton* bCancel = new QPushButton("取消", panel);
|
QPushButton* bCancel = new QPushButton("取消", panel);
|
||||||
bCancel->setProperty("numpad", true);
|
bCancel->setProperty("numpad", true);
|
||||||
bCancel->setProperty("cancel", true); // 取消语义:选中时红底白字
|
bCancel->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
|
||||||
bCancel->setStyleSheet("font-size:60px;");
|
|
||||||
bCancel->setFixedSize(160, 140);
|
bCancel->setFixedSize(160, 140);
|
||||||
connect(bCancel, &QPushButton::clicked, this, &NumPadDialog::reject);
|
connect(bCancel, &QPushButton::clicked, this, &NumPadDialog::reject);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user