134 lines
3.7 KiB
C
134 lines
3.7 KiB
C
|
|
#ifndef LIGHTSTRIPMANAGER_H
|
|||
|
|
#define LIGHTSTRIPMANAGER_H
|
|||
|
|
|
|||
|
|
#include <QWidget>
|
|||
|
|
#include <QVBoxLayout>
|
|||
|
|
#include <QHBoxLayout>
|
|||
|
|
#include <QGroupBox>
|
|||
|
|
#include <QScrollArea>
|
|||
|
|
#include <QCheckBox>
|
|||
|
|
#include <QLabel>
|
|||
|
|
#include <QPushButton>
|
|||
|
|
#include <QLineEdit>
|
|||
|
|
#include <QSpinBox>
|
|||
|
|
#include <QComboBox>
|
|||
|
|
#include <QSettings>
|
|||
|
|
#include <QSet>
|
|||
|
|
#include <QList>
|
|||
|
|
#include <QMessageBox>
|
|||
|
|
#include <QScreen>
|
|||
|
|
#include <QGuiApplication>
|
|||
|
|
#include <QTimer>
|
|||
|
|
#include <QGridLayout>
|
|||
|
|
#include <QSplitter>
|
|||
|
|
#include <QResizeEvent>
|
|||
|
|
|
|||
|
|
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); // 新增:灯条数量变化信号
|
|||
|
|
|
|||
|
|
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 onRandomColorClicked();
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
void setupUI();
|
|||
|
|
void setupControlPanel();
|
|||
|
|
void setupSnDisplayArea();
|
|||
|
|
void setupLightControlArea();
|
|||
|
|
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);
|
|||
|
|
|
|||
|
|
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 *randomColorBtn;
|
|||
|
|
|
|||
|
|
// 数据存储
|
|||
|
|
QSettings *settings;
|
|||
|
|
QSet<QString> snSet;
|
|||
|
|
|
|||
|
|
// 新增:主窗口引用
|
|||
|
|
MainWindow *m_mainWindow;
|
|||
|
|
|
|||
|
|
// 新增:缺失的成员变量
|
|||
|
|
QTimer *resizeTimer; // 调整大小定时器
|
|||
|
|
QSet<QString> uniqueSnSet; // 唯一SN集合
|
|||
|
|
QList<QWidget*> lightStripWidgets; // 灯条控件列表
|
|||
|
|
QList<QCheckBox*> lightStripCheckBoxes; // 灯条复选框列表
|
|||
|
|
int columnsPerRow; // 每行列数
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
#endif // LIGHTSTRIPMANAGER_H
|