自检页面调试完成

This commit is contained in:
xu
2026-09-10 14:10:40 +08:00
parent 0baf228c67
commit 32878a9a80
34 changed files with 595 additions and 1568 deletions
+37
View File
@@ -1,5 +1,9 @@
#include "global.h"
#include <QStyle>
#include <QApplication>
#include <QPushButton>
#include <QEvent>
#include <QGraphicsDropShadowEffect>
// 启动 500ms 闪烁:每 500ms 切换一次动态属性,QSS 据此在 40%↔100% 透明度间切换
QTimer* startBlink(QWidget* w, const char* prop)
@@ -43,6 +47,39 @@ QString cancelButtonStyle(int fontPx)
.arg(fontPx).arg(C::DANGER);
}
// ===================== 按钮焦点光圈 =====================
ButtonFocusGlow::ButtonFocusGlow(const QColor& glow, QObject* parent)
: QObject(parent), m_glow(glow)
{
}
bool ButtonFocusGlow::eventFilter(QObject* obj, QEvent* ev)
{
if (ev->type() == QEvent::FocusIn || ev->type() == QEvent::FocusOut) {
QWidget* w = qobject_cast<QWidget*>(obj);
if (w && qobject_cast<QPushButton*>(w)) {
if (ev->type() == QEvent::FocusIn) {
if (!w->graphicsEffect()) { // 挂一圈发光(偏移 0 → 四周光晕)
QGraphicsDropShadowEffect* g = new QGraphicsDropShadowEffect(w);
g->setBlurRadius(55); // 光晕大小(越大越强)
g->setOffset(0, 0);
g->setColor(m_glow);
w->setGraphicsEffect(g);
}
} else {
w->setGraphicsEffect(nullptr); // Qt 会删除旧效果
}
}
}
return QObject::eventFilter(obj, ev);
}
void installButtonFocusGlow(QApplication* app)
{
if (app)
app->installEventFilter(new ButtonFocusGlow(QColor("#7FBBFF"), app)); // 亮蓝,深色底更醒目
}
QString appStyleSheet()
{
const QString s = QString(R"QSS(