103 lines
2.7 KiB
C
103 lines
2.7 KiB
C
|
|
#ifndef MAINWINDOW_H
|
||
|
|
#define MAINWINDOW_H
|
||
|
|
|
||
|
|
#include <QMainWindow>
|
||
|
|
#include <QMouseEvent>
|
||
|
|
#include <thread>
|
||
|
|
#include "DemoControlPresenter.h"
|
||
|
|
#include "WorkflowWidget.h"
|
||
|
|
#include "DeviceStatusWidget.h"
|
||
|
|
#include "DetectLogHelper.h"
|
||
|
|
#include "DialogConfig.h"
|
||
|
|
|
||
|
|
QT_BEGIN_NAMESPACE
|
||
|
|
namespace Ui { class MainWindow; }
|
||
|
|
QT_END_NAMESPACE
|
||
|
|
|
||
|
|
class MainWindow : public QMainWindow
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
public:
|
||
|
|
MainWindow(QWidget *parent = nullptr);
|
||
|
|
~MainWindow();
|
||
|
|
|
||
|
|
void Init();
|
||
|
|
void updateStatusLog(const QString& message);
|
||
|
|
|
||
|
|
protected:
|
||
|
|
// 重写事件处理函数,实现窗口拖动和边缘缩放
|
||
|
|
void mousePressEvent(QMouseEvent *event) override;
|
||
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||
|
|
|
||
|
|
private:
|
||
|
|
// 获取鼠标位置对应的缩放区域
|
||
|
|
enum ResizeRegion {
|
||
|
|
None = 0,
|
||
|
|
Top = 1,
|
||
|
|
Bottom = 2,
|
||
|
|
Left = 4,
|
||
|
|
Right = 8,
|
||
|
|
TopLeft = Top | Left,
|
||
|
|
TopRight = Top | Right,
|
||
|
|
BottomLeft = Bottom | Left,
|
||
|
|
BottomRight = Bottom | Right
|
||
|
|
};
|
||
|
|
ResizeRegion getResizeRegion(const QPoint& pos);
|
||
|
|
void updateCursor(ResizeRegion region);
|
||
|
|
|
||
|
|
private slots:
|
||
|
|
void on_btn_start_clicked();
|
||
|
|
void on_btn_stop_clicked();
|
||
|
|
void on_btn_pause_clicked();
|
||
|
|
void on_btn_step_clicked();
|
||
|
|
void on_btn_config_clicked();
|
||
|
|
void on_btn_fullscreen_clicked();
|
||
|
|
void on_btn_hide_clicked();
|
||
|
|
void on_btn_close_clicked();
|
||
|
|
|
||
|
|
// Presenter信号槽
|
||
|
|
void onStatusMessageUpdated(const QString& message);
|
||
|
|
void onWorkflowStepChanged(WorkflowStep step, const QString& message);
|
||
|
|
void onControllerConnectionChanged(bool connected);
|
||
|
|
void onRobotConnectionChanged(bool connected);
|
||
|
|
void onDetectionResultUpdated(const DetectionResult& result);
|
||
|
|
|
||
|
|
private:
|
||
|
|
Ui::MainWindow *ui;
|
||
|
|
|
||
|
|
// 业务逻辑处理类
|
||
|
|
DemoControlPresenter* m_presenter = nullptr;
|
||
|
|
|
||
|
|
// 工作流程显示组件
|
||
|
|
WorkflowWidget* m_workflowWidget = nullptr;
|
||
|
|
|
||
|
|
// 设备状态显示组件
|
||
|
|
DeviceStatusWidget* m_deviceStatusWidget = nullptr;
|
||
|
|
|
||
|
|
// 日志辅助类
|
||
|
|
DetectLogHelper* m_logHelper = nullptr;
|
||
|
|
|
||
|
|
// 配置对话框
|
||
|
|
DialogConfig* m_dialogConfig = nullptr;
|
||
|
|
|
||
|
|
// 窗口拖动相关
|
||
|
|
bool m_isDragging = false;
|
||
|
|
QPoint m_dragPosition;
|
||
|
|
|
||
|
|
// 窗口缩放相关
|
||
|
|
bool m_isResizing = false;
|
||
|
|
ResizeRegion m_resizeRegion = None;
|
||
|
|
QPoint m_resizeStartPos;
|
||
|
|
QRect m_resizeStartGeometry;
|
||
|
|
static const int RESIZE_BORDER_WIDTH = 8; // 边缘缩放区域宽度
|
||
|
|
|
||
|
|
// 全屏相关
|
||
|
|
bool m_isFullScreen = false;
|
||
|
|
QRect m_normalGeometry; // 保存正常窗口的几何信息
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif // MAINWINDOW_H
|