feat:初始化wuhan_QT界面代码

This commit is contained in:
xu
2026-09-09 17:00:37 +08:00
commit 40473ad10b
537 changed files with 23934 additions and 0 deletions
+105
View File
@@ -0,0 +1,105 @@
#include "passwordmgmtloginpage.h"
#include "numpaddialog.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QLabel>
#include <QPushButton>
#include <QTimer>
#include "global.h"
PasswordMgmtLoginPage::PasswordMgmtLoginPage(AppContext* ctx, QWidget* parent)
: BasePage(ctx, parent)
{
QVBoxLayout* root = new QVBoxLayout(this);
root->addStretch(1);
QWidget* col = new QWidget(this);
col->setFixedWidth(700);
QVBoxLayout* lay = new QVBoxLayout(col);
lay->setSpacing(24);
lay->setAlignment(Qt::AlignHCenter);
QLabel* title = label("密码管理登录界面", 28, C::TEXT, true, col);
title->setAlignment(Qt::AlignCenter);
lay->addWidget(title);
QLabel* sub = label("请输入管理员密码", 18, C::TEXT_SUB, false, col);
sub->setAlignment(Qt::AlignCenter);
lay->addWidget(sub);
m_input = new QLineEdit(col);
m_input->setReadOnly(true);
m_input->setEchoMode(QLineEdit::Password);
m_input->setAlignment(Qt::AlignCenter);
m_input->setFixedSize(400, 88);
m_input->setFocusPolicy(Qt::NoFocus);
m_input->installEventFilter(this);
lay->addWidget(m_input, 0, Qt::AlignHCenter);
m_error = label("管理员密码错误", 18, C::DANGER, true, col);
m_error->setAlignment(Qt::AlignCenter);
m_error->hide();
lay->addWidget(m_error);
QHBoxLayout* btnRow = new QHBoxLayout();
btnRow->addStretch(1);
QPushButton* ok = button("确认", "primary", col);
ok->setFixedSize(180, 72);
connect(ok, &QPushButton::clicked, this, &PasswordMgmtLoginPage::onConfirm);
QPushButton* cancel = button("取消", "", col);
cancel->setFixedSize(180, 72);
connect(cancel, &QPushButton::clicked, this, &PasswordMgmtLoginPage::onCancel);
btnRow->addWidget(ok);
btnRow->addWidget(cancel);
btnRow->addStretch(1);
lay->addLayout(btnRow);
root->addWidget(col, 0, Qt::AlignHCenter);
root->addStretch(1);
}
bool PasswordMgmtLoginPage::eventFilter(QObject* obj, QEvent* ev)
{
if (obj == m_input && ev->type() == QEvent::MouseButtonPress) {
onInputClicked();
return true;
}
return BasePage::eventFilter(obj, ev);
}
void PasswordMgmtLoginPage::onInputClicked()
{
NumPadDialog dlg(this);
dlg.setMaxLen(4);
dlg.setValue(m_value);
if (dlg.exec() == QDialog::Accepted) {
m_value = dlg.value();
m_input->setText(m_value);
m_error->hide();
}
}
void PasswordMgmtLoginPage::onConfirm()
{
if (m_value == ctx()->adminPassword()) {
clearInput();
emit navigate(PageMgmt);
} else {
m_error->show();
QTimer::singleShot(3000, this, [this]() { m_error->hide(); });
}
}
void PasswordMgmtLoginPage::onCancel()
{
clearInput();
emit navigate(PageBoot);
}
void PasswordMgmtLoginPage::clearInput()
{
m_value.clear();
m_input->setText(m_value);
m_error->hide();
}