#ifndef LIGHTSTRIPMANAGER_H #define LIGHTSTRIPMANAGER_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // 新增身份信息绑定需要的头文件 #include #include #include class MainWindow; // 前向声明 class LightStripManager : public QWidget { Q_OBJECT public: explicit LightStripManager(QWidget *parent = nullptr); ~LightStripManager(); // 公共接口 void addSnToList(const QString &sn); QStringList getSelectedSns() const; QStringList getAllSns() const; int getSnCount() const; void clearSnList(); // 新增:设置主窗口引用 void setMainWindow(MainWindow *mainWindow); signals: void snSelectionChanged(const QStringList &selectedSns); void lightControlRequested(const QStringList &sns, const QString &color, bool flash, int interval, int duration, bool sound); void clearAllRequested(); void snCountChanged(int count); // 新增:身份信息绑定信号 void identityBindingRequested(const QString &sn, const QString &label1, const QString &label2, const QString &label3); // 修改:分组点亮信号(添加sound和flashInterval参数) void groupLightRequested(const QString &label1, const QString &label2, const QString &label3, int rule1, int rule2, int rule3, const QString &color, int blink, int duration, bool sound, int flashInterval); private slots: void onClearSnListClicked(); void onSelectAllClicked(); void onDeselectAllClicked(); void onDeleteSelectedClicked(); void onAddSnManuallyClicked(); void onSearchTextChanged(const QString &text); void onSendLightSelectedClicked(); void onSendLightAllClicked(); void onCheckBoxStateChanged(); void onRefreshClicked(); // 新增:身份信息绑定相关槽函数 void onBindIdentitySelectedClicked(); void onBindIdentityAllClicked(); void onLabel1Changed(const QString &text); void onLabel2Changed(const QString &text); void onLabel3Changed(const QString &text); // 新增:分组点亮槽函数 void onGroupLightClicked(); private: void setupUI(); void setupControlPanel(); void setupSnDisplayArea(); void setupLightControlArea(); // 新增:身份信息绑定区域 void setupIdentityBindingArea(); void saveSnList(); void loadSnList(); void updateSnCount(); void updateControlButtons(); void filterSnDisplay(const QString &searchText); QWidget* createSnWidget(const QString &sn); void applyResponsiveLayout(); // 新增:MQTT发送功能 void sendLightControlMessage(const QStringList &sns); // 新增:身份信息绑定相关私有函数 void sendIdentityBindingMessage(const QString &sn); QString generateMessageId() const; void saveIdentitySettings(); void loadIdentitySettings(); protected: void resizeEvent(QResizeEvent *event) override; private: // UI组件 QVBoxLayout *mainLayout; QSplitter *mainSplitter; // 控制面板 QGroupBox *controlGroup; QHBoxLayout *controlLayout; QPushButton *selectAllBtn; QPushButton *deselectAllBtn; QPushButton *deleteSelectedBtn; QPushButton *clearAllBtn; QPushButton *refreshBtn; QLineEdit *searchEdit; QLineEdit *manualSnEdit; QPushButton *addSnBtn; QLabel *snCountLabel; // SN显示区域 QGroupBox *snDisplayGroup; QScrollArea *snScrollArea; QWidget *snContainerWidget; QGridLayout *snGridLayout; // 点亮控制区域 QGroupBox *lightControlGroup; QComboBox *colorCombo; QComboBox *flashCombo; QSpinBox *flashIntervalSpin; QSpinBox *lightDurationSpin; QComboBox *soundCombo; QPushButton *sendLightSelectedBtn; QPushButton *sendLightAllBtn; // 新增:分组点亮按钮 QPushButton *groupLightBtn; // 新增:身份信息绑定区域 QGroupBox *identityBindingGroup; QLineEdit *label1Edit; QLineEdit *label2Edit; QLineEdit *label3Edit; QComboBox *rule1ComboBox; // label1的匹配规则 QComboBox *rule2ComboBox; // label2的匹配规则 QComboBox *rule3ComboBox; // label3的匹配规则 QPushButton *bindIdentitySelectedBtn; QPushButton *bindIdentityAllBtn; QLabel *bindingStatusLabel; // 数据存储 QSettings *settings; QSet snSet; // 新增:主窗口引用 MainWindow *m_mainWindow; // 新增:缺失的成员变量 QTimer *resizeTimer; QSet uniqueSnSet; QList lightStripWidgets; QList lightStripCheckBoxes; int columnsPerRow; // 新增:身份信息绑定相关数据 QString currentLabel1; QString currentLabel2; QString currentLabel3; public: enum MatchRule { EQUAL = 0, // = (00) GREATER = 1, // > (01) LESS = 2, // < (02) NOT_EQUAL = 3, // ≠ (03) NO_MATCH = 4 // ∅ (04) 不参与匹配 }; }; #endif // LIGHTSTRIPMANAGER_H