调完开机登录和密码管理界面
This commit is contained in:
+29
-16
@@ -19,10 +19,10 @@ PasswordResetPage::PasswordResetPage(AppContext* ctx, QWidget* parent)
|
||||
QWidget* col = new QWidget(this);
|
||||
col->setFixedWidth(700);
|
||||
QVBoxLayout* lay = new QVBoxLayout(col);
|
||||
lay->setSpacing(24);
|
||||
lay->setSpacing(50);
|
||||
lay->setAlignment(Qt::AlignHCenter);
|
||||
|
||||
QLabel* title = label("重置密码界面", 28, C::TEXT, true, col);
|
||||
QLabel* title = label("重置密码界面", 60, C::TEXT, true, col);
|
||||
title->setAlignment(Qt::AlignCenter);
|
||||
lay->addWidget(title);
|
||||
|
||||
@@ -30,26 +30,31 @@ PasswordResetPage::PasswordResetPage(AppContext* ctx, QWidget* parent)
|
||||
m_input->setReadOnly(true);
|
||||
m_input->setEchoMode(QLineEdit::Password);
|
||||
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->installEventFilter(this);
|
||||
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);
|
||||
lay->addWidget(m_hint);
|
||||
|
||||
QHBoxLayout* btnRow = new QHBoxLayout();
|
||||
btnRow->setSpacing(80);
|
||||
btnRow->addStretch(1);
|
||||
QPushButton* ok = button("确认", "", col);
|
||||
ok->setFixedSize(160, 72);
|
||||
ok->setFixedSize(160, 140);
|
||||
ok->setStyleSheet("font-size:60px;");
|
||||
connect(ok, &QPushButton::clicked, this, &PasswordResetPage::onConfirm);
|
||||
QPushButton* cancel = button("取消", "", col);
|
||||
cancel->setFixedSize(160, 72);
|
||||
connect(cancel, &QPushButton::clicked, this, &PasswordResetPage::onCancel);
|
||||
cancel->setFixedSize(160, 140);
|
||||
cancel->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
|
||||
connect(cancel, &QPushButton::clicked, this, &PasswordResetPage::onBack);
|
||||
QPushButton* exit = button("退出", "", col);
|
||||
exit->setFixedSize(160, 72);
|
||||
connect(exit, &QPushButton::clicked, this, &PasswordResetPage::onCancel);
|
||||
exit->setFixedSize(160, 140);
|
||||
exit->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
|
||||
connect(exit, &QPushButton::clicked, this, &PasswordResetPage::onExit);
|
||||
btnRow->addWidget(ok);
|
||||
btnRow->addWidget(cancel);
|
||||
btnRow->addWidget(exit);
|
||||
@@ -87,7 +92,7 @@ void PasswordResetPage::onInputClicked()
|
||||
m_value = dlg.value();
|
||||
m_input->setText(m_value);
|
||||
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 位数字
|
||||
static const QRegularExpression re("^\\d{4}$");
|
||||
if (!re.match(m_value).hasMatch()) {
|
||||
m_value.clear(); // 校验失败后清空输入框
|
||||
m_input->setText(m_value);
|
||||
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;
|
||||
}
|
||||
ctx()->setPassword(m_value);
|
||||
clearInput();
|
||||
ConfirmDialog::toast(this, "修改成功");
|
||||
emit navigate(PageBoot);
|
||||
ConfirmDialog::toast(this, "修改成功"); // 2s 后自动消失
|
||||
emit navigate(PageBoot); // 修改完成,返回开机密码界面
|
||||
}
|
||||
|
||||
void PasswordResetPage::onCancel()
|
||||
void PasswordResetPage::onBack()
|
||||
{
|
||||
clearInput();
|
||||
emit navigate(PageBoot);
|
||||
emit navigate(PageMgmt); // 取消:返回上一界面(密码管理界面)
|
||||
}
|
||||
|
||||
void PasswordResetPage::onExit()
|
||||
{
|
||||
clearInput();
|
||||
emit navigate(PageBoot); // 退出:返回开机密码界面
|
||||
}
|
||||
|
||||
void PasswordResetPage::clearInput()
|
||||
@@ -117,5 +130,5 @@ void PasswordResetPage::clearInput()
|
||||
m_value.clear();
|
||||
m_input->setText(m_value);
|
||||
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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user