调完开机登录和密码管理界面
This commit is contained in:
+19
-13
@@ -6,7 +6,6 @@
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
#include "global.h"
|
||||
|
||||
PasswordMgmtLoginPage::PasswordMgmtLoginPage(AppContext* ctx, QWidget* parent)
|
||||
@@ -18,14 +17,14 @@ PasswordMgmtLoginPage::PasswordMgmtLoginPage(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);
|
||||
|
||||
QLabel* sub = label("请输入管理员密码", 18, C::TEXT_SUB, false, col);
|
||||
QLabel* sub = label("请输入管理员密码", 40, C::TEXT_SUB, false, col);
|
||||
sub->setAlignment(Qt::AlignCenter);
|
||||
lay->addWidget(sub);
|
||||
|
||||
@@ -33,23 +32,29 @@ PasswordMgmtLoginPage::PasswordMgmtLoginPage(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_error = label("管理员密码错误", 18, C::DANGER, true, col);
|
||||
// 错误提示(预留固定高度,出现/消失不影响下方按钮位置)
|
||||
m_error = new QLabel(col);
|
||||
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);
|
||||
|
||||
QHBoxLayout* btnRow = new QHBoxLayout();
|
||||
btnRow->setSpacing(80);
|
||||
btnRow->addStretch(1);
|
||||
QPushButton* ok = button("确认", "", col);
|
||||
ok->setFixedSize(180, 72);
|
||||
ok->setFixedSize(160, 140);
|
||||
ok->setStyleSheet("font-size:60px;");
|
||||
connect(ok, &QPushButton::clicked, this, &PasswordMgmtLoginPage::onConfirm);
|
||||
QPushButton* cancel = button("取消", "", col);
|
||||
cancel->setFixedSize(180, 72);
|
||||
cancel->setFixedSize(160, 140);
|
||||
cancel->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
|
||||
connect(cancel, &QPushButton::clicked, this, &PasswordMgmtLoginPage::onCancel);
|
||||
btnRow->addWidget(ok);
|
||||
btnRow->addWidget(cancel);
|
||||
@@ -86,7 +91,7 @@ void PasswordMgmtLoginPage::onInputClicked()
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
m_value = dlg.value();
|
||||
m_input->setText(m_value);
|
||||
m_error->hide();
|
||||
m_error->setText("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,8 +101,9 @@ void PasswordMgmtLoginPage::onConfirm()
|
||||
clearInput();
|
||||
emit navigate(PageMgmt);
|
||||
} else {
|
||||
m_error->show();
|
||||
QTimer::singleShot(3000, this, [this]() { m_error->hide(); });
|
||||
m_value.clear(); // 输错后清空输入框
|
||||
m_input->setText(m_value);
|
||||
m_error->setText("管理员密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,5 +117,5 @@ void PasswordMgmtLoginPage::clearInput()
|
||||
{
|
||||
m_value.clear();
|
||||
m_input->setText(m_value);
|
||||
m_error->hide();
|
||||
m_error->setText("");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user