增加通讯协议

This commit is contained in:
xu
2026-10-14 09:59:42 +08:00
parent 32878a9a80
commit 950e9e6c9e
102 changed files with 5538 additions and 2679 deletions
+32 -4
View File
@@ -1,8 +1,10 @@
#include "global.h"
#include <QStyle>
#include <QApplication>
#include <QAbstractButton>
#include <QPushButton>
#include <QEvent>
#include <QKeyEvent>
#include <QGraphicsDropShadowEffect>
// 启动 500ms 闪烁:每 500ms 切换一次动态属性,QSS 据此在 40%↔100% 透明度间切换
@@ -61,7 +63,7 @@ bool ButtonFocusGlow::eventFilter(QObject* obj, QEvent* ev)
if (ev->type() == QEvent::FocusIn) {
if (!w->graphicsEffect()) { // 挂一圈发光(偏移 0 → 四周光晕)
QGraphicsDropShadowEffect* g = new QGraphicsDropShadowEffect(w);
g->setBlurRadius(55); // 光晕大小(越大越强)
g->setBlurRadius(40); // 光晕大小(越大越强)
g->setOffset(0, 0);
g->setColor(m_glow);
w->setGraphicsEffect(g);
@@ -80,6 +82,33 @@ void installButtonFocusGlow(QApplication* app)
app->installEventFilter(new ButtonFocusGlow(QColor("#7FBBFF"), app)); // 亮蓝,深色底更醒目
}
// ===================== 方向键(旋钮)隔离 =====================
ArrowKeyGuard::ArrowKeyGuard(QObject* parent)
: QObject(parent)
{
}
bool ArrowKeyGuard::eventFilter(QObject* obj, QEvent* ev)
{
if (ev->type() == QEvent::KeyPress) {
// 只在焦点落在按钮上时拦截:否则 QAbstractButton 会拿方向键去换焦
QWidget* fw = QApplication::focusWidget();
if (fw && qobject_cast<QAbstractButton*>(fw)) {
const int k = static_cast<QKeyEvent*>(ev)->key();
if (k == Qt::Key_Up || k == Qt::Key_Down
|| k == Qt::Key_Left || k == Qt::Key_Right)
return true;
}
}
return QObject::eventFilter(obj, ev);
}
void installArrowKeyGuard(QApplication* app)
{
if (app)
app->installEventFilter(new ArrowKeyGuard(app));
}
QString appStyleSheet()
{
const QString s = QString(R"QSS(
@@ -108,7 +137,6 @@ QPushButton {
border: 1px solid BD;
border-radius: 12px;
font-size: 40px;
min-height: 56px;
}
QPushButton:hover { background-color: PRI; color: TXT; border-color: PRI; }
QPushButton:pressed { background-color: PRI; color: #FFFFFF; border-color: PRI; }
@@ -165,7 +193,7 @@ QHeaderView::section {
font-size: 40px;
}
QTableWidget::item { padding: 6px; }
QTableWidget::item:selected { background-color: rgba(61,139,253,0.15); color: TXT; }
QTableWidget::item:selected { background-color: PRI; color: #FFFFFF; }
/* ===== 数字键盘 ===== */
QPushButton[numpad="true"] {
@@ -177,7 +205,7 @@ QPushButton[numpad="true"]:pressed { background-color: PRI; color: #FFFFFF; }
QPushButton:focus {
background-color: PRI;
color: #FFFFFF;
border: 2px solid #8ABFFF;
border: 4px solid #8ABFFF;
}
QPushButton:focus:disabled {
background-color: DIS; color: DIST; border: 1px solid DIS;