|
- #ifndef HMIMODULE_H
- #define HMIMODULE_H
-
- #include <QObject>
- #include "ui_MainWindow.h"
- // #include "customgraphics.h" // 已被 customgraphicsscene.h 包含
- #include "customgraphicsscene.h" // 引入新的场景头文件
-
- class HMIModule : public QObject
- {
- Q_OBJECT
- public:
- explicit HMIModule(Ui::MainWindow* ui, QObject *parent = nullptr);
- void setButtonIcon(QAbstractButton* button, const QString& iconPath);
- void init();
-
- private slots:
- // 准备创建组件,而不是直接创建
- void prepareToCreateButton();
- void prepareToCreateIndicator();
-
- // 当场景创建了一个组件后,进行后续处理
- void onComponentCreated(HmiComponent* item);
-
- void onComponentSelected(HmiComponent* item);
-
- // 处理复制、粘贴、删除的槽函数
- void onCopyRequested();
- void onPasteRequested(const QPointF& scenePos);
- void onDeleteRequested();
-
- // 一个用于发送日志消息的信号
- signals:
- void logMessageGenerated(const QString& message);
-
- private:
- void setupNewComponent(HmiComponent* item);
-
- private:
- Ui::MainWindow* ui_;
- CustomGraphicsScene* m_scene;
-
- // 用于实现剪贴板功能的成员变量
- ComponentType m_copiedType;
- QColor m_copiedColor;
- bool m_hasCopiedItem = false;
- };
-
- #endif // HMIMODULE_H
|