增加通讯协议

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
+29
View File
@@ -2,11 +2,16 @@
#define NUMPADDIALOG_H
#include <QDialog>
#include <QVector>
class QLineEdit;
class QPushButton;
class QGridLayout;
class QVBoxLayout;
// ===================== 数字键盘弹窗(模态) =====================
// 半透明遮罩 + 键盘面板:顶部输入回显,数字键 1-9、0,退格、清除,确认/取消
// 两种尺寸:默认大字版(密码页用)、紧凑版(参数输入用,setCompact(true))
class NumPadDialog : public QDialog
{
Q_OBJECT
@@ -18,17 +23,41 @@ public:
QString value() const { return m_value; }
void clear();
void setOpacity(qreal opacity); // 整体不透明度(默认 1.0)
void setAnchorWidget(QWidget* ref, int gap = 20); // 面板贴参照控件左侧弹出
// 参数输入模式:回显显示实际数字(不掩码),并把“清除”键换成“小数点”
void setParamMode(bool on);
// 紧凑尺寸(按键/面板更小);默认 false = 大字版
void setCompact(bool on);
private slots:
void onDigit(const QString& d);
void onBackspace();
void onClear();
void onDot();
private:
void refreshEcho();
void placePanel();
void applySizes();
QWidget* m_panel = nullptr;
QWidget* m_anchor = nullptr; // 定位参照控件(如参数输入框)
QGridLayout* m_grid = nullptr;
QVBoxLayout* m_panelLay = nullptr;
QLineEdit* m_echo = nullptr;
QVector<QPushButton*> m_digits; // 数字键 0-9
QPushButton* m_backKey = nullptr;
QPushButton* m_clearKey = nullptr;
QPushButton* m_okKey = nullptr;
QPushButton* m_cancelKey = nullptr;
QString m_value;
int m_maxLen = 4;
int m_gap = 20;
bool m_paramMode = false;
bool m_compact = false;
};
#endif // NUMPADDIALOG_H