🛰️航天仿真算法库 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
46 // ---- 生命周期 ----
47 void start();
48 void stop();
49 void pause();
50 void resume();
51 bool isRecording() const { return recording_; }
52 bool isPaused() const { return paused_; }
53
54 // ---- 导出 ----
55 int stepCount() const { return steps_.size(); }
56 const RecordStep& stepAt(int index) const;
57 std::string toJson() const;
58 bool saveToFile(const std::string& path) const;
59
60 // ---- LLM 润色 ----
61 std::string polish();
62
63Q_SIGNALS:
64 void stepRecorded(int index, const std::string& description);
65 void recordingStarted();
66 void recordingStopped();
67 void recordingPaused();
68 void recordingResumed();
69
70protected:
71 bool eventFilter(QObject* obj, QEvent* event) override;
72
73private:
74 // ---- 事件处理(handleComboChange/handleDialogFinished 需公开供信号连接调用)----
75 void handleMousePress(QWidget* w, QMouseEvent* e);
76 void handleMouseRelease(QWidget* w, QMouseEvent* e);
77 void handleKeyRelease(QWidget* w, QKeyEvent* e);
78 void handleFocusIn(QWidget* w, QFocusEvent* e);
79 void handleFocusOut(QWidget* w, QFocusEvent* e);
80
81public:
82 void handleComboChange(QComboBox* combo);
83 void handleDialogFinished(QDialog* dlg, int result);
84
85private:
86 // ---- 辅助 ----
87 void addStep(const RecordStep& step);
88 void flushPendingEdit();
89 void populateWidgetInfo(RecordStep& step, QWidget* w);
90
91 PilotAgent* agent_;
92 QList<RecordStep> steps_;
93 bool recording_ = false;
94 bool paused_ = false;
95 int64_t startTime_ = 0;
96
97 // 双击检测
98 QWidget* lastClickedWidget_ = nullptr;
99 int clickCount_ = 0;
100 QElapsedTimer clickTimer_;
101
102 // 拖拽跟踪
103 QWidget* dragSourceWidget_ = nullptr;
104 QString dragSourceText_;
105
106 // 输入框编辑跟踪
107 QWidget* editWidget_ = nullptr;
108 QString editBeforeText_;
109};
110
113AST_NAMESPACE_END
录制步骤数据结构
Qt控件生命周期管理与界面快照生成
定义 PilotAgent.hpp:46
界面操作录制器
定义 PilotRecorder.hpp:39
录制步骤结构
定义 RecordStep.hpp:70