调试初版

This commit is contained in:
xu
2026-10-14 18:22:41 +08:00
parent d3a355bd3f
commit e5efdea06e
26 changed files with 289 additions and 140 deletions
+57 -5
View File
@@ -4,8 +4,53 @@
#include <QLabel>
#include <QPushButton>
#include <QCheckBox>
#include <QEvent>
#include <QColor>
#include <QGraphicsDropShadowEffect>
#include "global.h"
namespace {
class CardFocusGlow : public QObject
{
public:
CardFocusGlow(QWidget* card, const QString& normalQss, const QString& focusQss,
const QColor& glow, QObject* parent = nullptr)
: QObject(parent), m_card(card), m_normal(normalQss), m_focus(focusQss), m_glow(glow) {}
protected:
bool eventFilter(QObject* obj, QEvent* ev) override
{
if (ev->type() == QEvent::FocusIn) {
m_card->setStyleSheet(m_focus);
if (!m_card->graphicsEffect()) {
QGraphicsDropShadowEffect* g = new QGraphicsDropShadowEffect(m_card); // 偏移 0 → 四周光晕
g->setBlurRadius(40);
g->setOffset(0, 0);
g->setColor(m_glow);
m_card->setGraphicsEffect(g);
}
} else if (ev->type() == QEvent::FocusOut) {
m_card->setStyleSheet(m_normal);
QWidget* parent = m_card->parentWidget();
// 光晕溢出卡片矩形,只重绘卡片自身会留下残影,把父控件一并标脏
m_card->setGraphicsEffect(nullptr); // Qt 会删除旧效果
m_card->update();
if (parent)
parent->update(parent->rect());
}
return QObject::eventFilter(obj, ev);
}
private:
QWidget* m_card;
QString m_normal;
QString m_focus;
QColor m_glow;
};
} // namespace
PasswordMgmtPage::PasswordMgmtPage(AppContext* ctx, QWidget* parent)
: BasePage(ctx, parent)
{
@@ -25,16 +70,23 @@ PasswordMgmtPage::PasswordMgmtPage(AppContext* ctx, QWidget* parent)
// 功能选项列表
QWidget* option = new QWidget(col);
option->setProperty("card", true);
option->setStyleSheet(QString("QWidget[card=\"true\"]{background-color:%1;border:2px solid %2;border-radius:12px;}")
.arg(C::PANEL, C::BORDER));
const QString cardQss = QString("QWidget[card=\"true\"]{background-color:%1;border:2px solid %2;border-radius:12px;}")
.arg(C::PANEL, C::BORDER);
const QString cardFocusQss = QString("QWidget[card=\"true\"]{background-color:%1;border:3px solid %2;border-radius:12px;}")
.arg(C::PANEL, "#8ABFFF");
option->setStyleSheet(cardQss);
QVBoxLayout* optLay = new QVBoxLayout(option);
m_reset = new QCheckBox("重置密码功能", option);
m_reset->setChecked(true);
m_reset->setStyleSheet(QString(
"QCheckBox{color:%1;font-size:40px;spacing:16px;}"
"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;}"
"QCheckBox:focus{color:#FFFFFF;}"
"QCheckBox:focus::indicator{border:4px solid #8ABFFF;}")
.arg(C::TEXT, C::BORDER, C::BG, C::PRIMARY));
// 复选框获得焦点(Tab 选中)时点亮整个卡片
m_reset->installEventFilter(new CardFocusGlow(option, cardQss, cardFocusQss, QColor("#7FBBFF"), m_reset));
optLay->addWidget(m_reset);
lay->addWidget(option);
@@ -43,11 +95,11 @@ PasswordMgmtPage::PasswordMgmtPage(AppContext* ctx, QWidget* parent)
btnRow->setSpacing(80);
btnRow->addStretch(1);
QPushButton* ok = button("确认", "", col);
ok->setFixedSize(160, 140);
ok->setFixedSize(160, 120);
ok->setStyleSheet("font-size:60px;");
connect(ok, &QPushButton::clicked, this, [this]() { emit navigate(PageReset); });
QPushButton* exit = button("退出", "", col);
exit->setFixedSize(160, 140);
exit->setFixedSize(160, 120);
exit->setStyleSheet(cancelButtonStyle(60)); // 选中时红底白字
connect(exit, &QPushButton::clicked, this, [this]() { emit navigate(PageBoot); });
btnRow->addWidget(ok);