调整开机登录页面、数字键盘

This commit is contained in:
xu
2026-09-09 21:57:25 +08:00
parent bc17390d83
commit 7650e2983d
20 changed files with 17820 additions and 626 deletions
+42 -23
View File
@@ -21,72 +21,91 @@ NumPadDialog::NumPadDialog(QWidget* parent)
// 面板(居中)
QWidget* panel = new QWidget(this);
panel->setObjectName("NumPadPanel");
panel->setFixedSize(960, 486);
panel->setFixedSize(600, 730);
panel->setStyleSheet(QString(
"QWidget#NumPadPanel{background-color:%1;border:2px 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\"]:pressed{background-color:#2E7BE6;color:#FFFFFF;}"
"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));
QVBoxLayout* panelLay = new QVBoxLayout(panel);
panelLay->setContentsMargins(24, 24, 24, 24);
panelLay->setSpacing(16);
panelLay->setContentsMargins(24, 40, 24, 50);
panelLay->setSpacing(50);
// 输入回显
m_echo = new QLineEdit(panel);
m_echo->setReadOnly(true);
m_echo->setEchoMode(QLineEdit::Password);
m_echo->setAlignment(Qt::AlignCenter);
m_echo->setFixedHeight(64);
panelLay->addWidget(m_echo);
m_echo->setFixedSize(510, 100);
m_echo->setStyleSheet("font-size:70px;");
m_echo->setFocusPolicy(Qt::NoFocus); // 纯显示回显:不参与 Tab 选中
m_echo->setAttribute(Qt::WA_TransparentForMouseEvents); // 且点击穿透,不响应鼠标
panelLay->addWidget(m_echo, 0, Qt::AlignHCenter);
// 数字键区(1-9, 0, 退格, 清除)
QGridLayout* grid = new QGridLayout();
grid->setSpacing(10);
grid->setSpacing(30);
const QString digits[3][3] = {{"1","2","3"},{"4","5","6"},{"7","8","9"}};
for (int r = 0; r < 3; ++r)
for (int c = 0; c < 3; ++c) {
QPushButton* b = new QPushButton(digits[r][c], panel);
b->setProperty("numpad", true);
b->setFixedSize(130, 98);
b->setStyleSheet("font-size:50px;");
b->setFixedSize(150, 120);
connect(b, &QPushButton::clicked, this, [this, d = digits[r][c]](){ onDigit(d); });
grid->addWidget(b, r, c);
}
QPushButton* b0 = new QPushButton("0", panel);
b0->setProperty("numpad", true);
b0->setFixedSize(130, 98);
b0->setStyleSheet("font-size:50px;");
b0->setFixedSize(150, 120);
connect(b0, &QPushButton::clicked, this, [this](){ onDigit("0"); });
grid->addWidget(b0, 3, 0);
grid->addWidget(b0, 3, 1);
QPushButton* bBack = new QPushButton("退格", panel);
bBack->setProperty("numpad", true);
bBack->setStyleSheet("font-size:28px;background-color:#2D3947;color:#E6EDF3;border:1px solid #3D4A59;border-radius:12px;");
bBack->setFixedSize(130, 98);
bBack->setStyleSheet("font-size:40px;");
bBack->setFixedSize(150, 120);
connect(bBack, &QPushButton::clicked, this, &NumPadDialog::onBackspace);
grid->addWidget(bBack, 3, 1);
grid->addWidget(bBack, 3, 0);
QPushButton* bClear = new QPushButton("清除", panel);
bClear->setProperty("numpad", true);
bClear->setStyleSheet("font-size:28px;background-color:#2D3947;color:#E6EDF3;border:1px solid #3D4A59;border-radius:12px;");
bClear->setFixedSize(130, 98);
bClear->setStyleSheet("font-size:40px;");
bClear->setFixedSize(150, 108);
connect(bClear, &QPushButton::clicked, this, &NumPadDialog::onClear);
grid->addWidget(bClear, 3, 2);
// 确认 / 取消
// 确认 / 取消(与数字键一致的灰底,选中时发亮)
QPushButton* bOk = new QPushButton("确认", panel);
bOk->setProperty("variant", "primary");
bOk->setFixedSize(130, 98);
bOk->setProperty("numpad", true);
bOk->setStyleSheet("font-size:60px;");
bOk->setFixedSize(160, 140);
connect(bOk, &QPushButton::clicked, this, &NumPadDialog::accept);
QPushButton* bCancel = new QPushButton("取消", panel);
bCancel->setFixedSize(130, 98);
bCancel->setProperty("numpad", true);
bCancel->setProperty("cancel", true); // 取消语义:选中时红底白字
bCancel->setStyleSheet("font-size:60px;");
bCancel->setFixedSize(160, 140);
connect(bCancel, &QPushButton::clicked, this, &NumPadDialog::reject);
grid->addWidget(bOk, 3, 3);
grid->addWidget(bCancel, 3, 4);
grid->setColumnStretch(4, 0);
grid->setColumnStretch(5, 1);
// 确认 / 取消:单独一行、水平居中,并与数字键盘留出间隔
QHBoxLayout* okRow = new QHBoxLayout();
okRow->setSpacing(80);
okRow->addStretch(1);
okRow->addWidget(bOk);
okRow->addWidget(bCancel);
okRow->addStretch(1);
panelLay->addLayout(grid);
panelLay->setAlignment(grid, Qt::AlignHCenter);
//panelLay->addSpacing(20);
panelLay->addLayout(okRow);
panelLay->addStretch(1);
// 居中放置面板