nsbaci 1.0
Loading...
Searching...
No Matches
mainwindow.h
Go to the documentation of this file.
1
9
10#ifndef MAINWINDOW_H
11#define MAINWINDOW_H
12
13#include <QFileDialog>
14#include <QFrame>
15#include <QLabel>
16#include <QMainWindow>
17#include <QShortcut>
18#include <QStackedWidget>
19#include <QToolButton>
20
21#include "codeeditor.h"
22#include "errorDialogFactory.h"
23#include "runtimeView.h"
24#include "uiError.h"
25
26QT_BEGIN_NAMESPACE
27namespace Ui {
28class MainWindow;
29}
30QT_END_NAMESPACE
31
32class MainWindow : public QMainWindow {
33 Q_OBJECT
34
35 public:
36 explicit MainWindow(QWidget* parent = nullptr);
37 ~MainWindow() override = default;
38
39 signals:
40 void saveRequested(const QString& filePath, const QString& contents);
41 void openRequested(const QString& filePath);
42 void compileRequested(const QString& contents);
43 void runRequested();
44
45 // Runtime control signals
46 void stepRequested();
47 void stepThreadRequested(nsbaci::types::ThreadID threadId);
48 void runContinueRequested();
49 void pauseRequested();
50 void resetRequested();
51 void stopRequested();
52 void inputProvided(const QString& input);
53
54 public slots:
55 void setEditorContents(const QString& contents);
56 void setStatusMessage(const QString& message);
57 void setCurrentFile(const QString& fileName, bool modified = false);
58
59 // Controller response slots
60 void onSaveSucceeded();
61 void onSaveFailed(std::vector<nsbaci::UIError> errors);
62 void onLoadSucceeded(const QString& contents);
63 void onLoadFailed(std::vector<nsbaci::UIError> errors);
64 void onCompileSucceeded();
65 void onCompileFailed(std::vector<nsbaci::UIError> errors);
66
67 // Runtime slots
68 void onRunStarted(const QString& programName);
69 void onRuntimeStateChanged(bool running, bool halted);
70 void onThreadsUpdated(const std::vector<nsbaci::ui::ThreadInfo>& threads);
71 void onVariablesUpdated(
72 const std::vector<nsbaci::ui::VariableInfo>& variables);
73 void onOutputReceived(const QString& output);
74 void onInputRequested(const QString& prompt);
75
76 private slots:
77 // File menu
78 void onNew();
79 void onSave();
80 void onSaveAs();
81 void onOpen();
82 void onExit();
83 void onCompile();
84 void onRun();
85
86 // Edit menu
87 void onUndo();
88 void onRedo();
89 void onCut();
90 void onCopy();
91 void onPaste();
92 void onSelectAll();
93
94 // View menu
95 void onToggleSidebar();
96 void onToggleFullscreen();
97
98 // Help menu
99 void onAbout();
100
101 // Editor
102 void onTextChanged();
103
104 // Runtime view
105 void onStopRuntime();
106
107 private:
108 // Stacked widget for switching views
109 QStackedWidget* centralStack = nullptr;
110
111 // Editor view container
112 QWidget* editorView = nullptr;
113
114 // File info bar
115 QFrame* fileInfoBar = nullptr;
116 QLabel* fileNameLabel = nullptr;
117 QLabel* fileModifiedIndicator = nullptr;
118 QLabel* compileStatusIndicator = nullptr;
119
120 // Central widget
121 CodeEditor* codeEditor = nullptr;
122
123 // Sidebar
124 QFrame* sideBar = nullptr;
125 QToolButton* compileButton = nullptr;
126 QToolButton* runButton = nullptr;
127
128 // Runtime view
129 nsbaci::ui::RuntimeView* runtimeView = nullptr;
130
131 // File actions
132 QAction* actionNew = nullptr;
133 QAction* actionSave = nullptr;
134 QAction* actionSaveAs = nullptr;
135 QAction* actionOpen = nullptr;
136 QAction* actionExit = nullptr;
137
138 // Edit actions
139 QAction* actionUndo = nullptr;
140 QAction* actionRedo = nullptr;
141 QAction* actionCut = nullptr;
142 QAction* actionCopy = nullptr;
143 QAction* actionPaste = nullptr;
144 QAction* actionSelectAll = nullptr;
145
146 // View actions
147 QAction* actionToggleSidebar = nullptr;
148 QAction* actionFullscreen = nullptr;
149
150 // Build actions
151 QAction* actionCompile = nullptr;
152 QAction* actionRun = nullptr;
153
154 // Help actions
155 QAction* actionAbout = nullptr;
156
157 // State
158 QString currentFileName; // Just the filename for display
159 QString currentFilePath; // Full path for saving
160 bool isModified = false;
161 bool hasName = false;
162 bool isCompiled =
163 false; // True when program is compiled and code hasn't changed
164
165 private:
166 void createCentralWidget();
167 void createEditorView();
168 void createRuntimeView();
169 void createMenuBar();
170 void createStatusBar();
171 void setupShortcuts();
172 void applyStyleSheet();
173
174 void switchToEditor();
175 void switchToRuntime();
176};
177#endif // MAINWINDOW_H
Definition codeeditor.h:18
Widget displaying runtime execution state.
Definition runtimeView.h:66
CodeEditor class with line numbers for nsbaci.
Factory for creating error dialogs from UIError objects.
RuntimeView widget declaration for nsbaci.
UI Error type definitions for nsbaci.