🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
PilotRecorder.hpp
浏览该文件的文档.
1
7
8#pragma once
9
10#include "AstGlobal.h"
11#include "RecordStep.hpp"
12#include <QObject>
13#include <QElapsedTimer>
14#include <QList>
15#include <QString>
16#include <string>
17
18class QWidget;
19class QMouseEvent;
20class QKeyEvent;
21class QFocusEvent;
22class QComboBox;
23class QDialog;
24
25AST_NAMESPACE_BEGIN
26
27class PilotAgent;
28class PilotSession;
29
38class AST_UIPILOT_API PilotRecorder : public QObject
39{
40 Q_OBJECT
41
42public:
43 explicit PilotRecorder(PilotAgent* agent, QObject* parent = nullptr);
44 ~PilotRecorder() override;
45 PilotRecorder(const PilotRecorder&) = delete;
46 PilotRecorder& operator=(const PilotRecorder&) = delete;
47
48 // ---- 生命周期 ----
49 void start();
50 void stop();
51 void pause();
52 void resume();
53 bool isRecording() const { return recording_; }
54 bool isPaused() const { return paused_; }
55
56 // ---- 导出 ----
57 int stepCount() const { return steps_.size(); }
58 const RecordStep& stepAt(int index) const;
59 std::string toJson() const;
60 bool saveToFile(const std::string& path) const;
61
62 // ---- LLM 润色 ----
63 std::string polish();
64
65Q_SIGNALS:
66 void stepRecorded(int index, const std::string& description);
67 void recordingStarted();
68 void recordingStopped();
69 void recordingPaused();
70 void recordingResumed();
71
72protected:
73 bool eventFilter(QObject* obj, QEvent* event) override;
74
75private:
76 // ---- 事件处理(handleComboChange/handleDialogFinished 需公开供信号连接调用)----
77 void handleMousePress(QWidget* w, QMouseEvent* e);
78 void handleMouseRelease(QWidget* w, QMouseEvent* e);
79 void handleKeyRelease(QWidget* w, QKeyEvent* e);
80 void handleFocusIn(QWidget* w, QFocusEvent* e);
81 void handleFocusOut(QWidget* w, QFocusEvent* e);
82
83public:
84 void handleComboChange(QComboBox* combo);
85 void handleDialogFinished(QDialog* dlg, int result);
86
87private:
88 // ---- 辅助 ----
89 void addStep(const RecordStep& step);
90 void flushPendingEdit();
91 void populateWidgetInfo(RecordStep& step, QWidget* w);
92
93 PilotAgent* agent_{};
94 QList<RecordStep> steps_{};
95 bool recording_ = false;
96 bool paused_ = false;
97 int64_t startTime_ = 0;
98
99 // 双击检测
100 QWidget* lastClickedWidget_ = nullptr;
101 int clickCount_ = 0;
102 QElapsedTimer clickTimer_{};
103
104 // 拖拽跟踪
105 QWidget* dragSourceWidget_ = nullptr;
106 QString dragSourceText_{};
107
108 // 输入框编辑跟踪
109 QWidget* editWidget_ = nullptr;
110 QString editBeforeText_{};
111};
112
115AST_NAMESPACE_END
录制步骤数据结构
Qt控件生命周期管理与界面快照生成
定义 PilotAgent.hpp:46
界面操作录制器
定义 PilotRecorder.hpp:39
录制步骤结构
定义 RecordStep.hpp:70