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 "preferencesDialog.h"
24#include "runtimeView.h"
25#include "uiError.h"
26#include "userGuideDialog.h"
27
28QT_BEGIN_NAMESPACE
29namespace Ui {
30class MainWindow;
31}
32QT_END_NAMESPACE
33
34class MainWindow : public QMainWindow {
35 Q_OBJECT
36
37 public:
38 explicit MainWindow(QWidget* parent = nullptr);
39 ~MainWindow() override = default;
40
41 signals:
42 void saveRequested(const QString& filePath, const QString& contents);
43 void openRequested(const QString& filePath);
44 void compileRequested(const QString& contents);
45 void runRequested();
46
47 // Runtime control signals
48 void stepRequested();
49 void stepThreadRequested(nsbaci::types::ThreadID threadId);
50 void runContinueRequested();
51 void pauseRequested();
52 void resetRequested();
53 void stopRequested();
54 void inputProvided(const QString& input);
55
56 public slots:
57 void setEditorContents(const QString& contents);
58 void setStatusMessage(const QString& message);
59 void setCurrentFile(const QString& fileName, bool modified = false);
60
61 // Controller response slots
62 void onSaveSucceeded();
63 void onSaveFailed(std::vector<nsbaci::UIError> errors);
64 void onLoadSucceeded(const QString& contents);
65 void onLoadFailed(std::vector<nsbaci::UIError> errors);
66 void onCompileSucceeded();
67 void onCompileFailed(std::vector<nsbaci::UIError> errors);
68
69 // Runtime slots
70 void onRunStarted(const QString& programName);
71 void onRuntimeStateChanged(bool running, bool halted);
72 void onThreadsUpdated(const std::vector<nsbaci::ui::ThreadInfo>& threads);
73 void onVariablesUpdated(
74 const std::vector<nsbaci::ui::VariableInfo>& variables);
75 void onOutputReceived(const QString& output);
76 void onInputRequested(const QString& prompt);
77
78 private slots:
79 // File menu
80 void onNew();
81 void onSave();
82 void onSaveAs();
83 void onOpen();
84 void onExit();
85 void onCompile();
86 void onRun();
87
88 // Edit menu
89 void onUndo();
90 void onRedo();
91 void onCut();
92 void onCopy();
93 void onPaste();
94 void onSelectAll();
95
96 // View menu
97 void onToggleSidebar();
98 void onToggleFullscreen();
99
100 // Edit menu (preferences)
101 void onPreferences();
102
103 // Help menu
104 void onUserGuide();
105 void onAbout();
106
107 // Editor
108 void onTextChanged();
109
110 // Runtime view
111 void onStopRuntime();
112
113 private:
114 // Stacked widget for switching views
115 QStackedWidget* centralStack = nullptr;
116
117 // Editor view container
118 QWidget* editorView = nullptr;
119
120 // File info bar
121 QFrame* fileInfoBar = nullptr;
122 QLabel* fileNameLabel = nullptr;
123 QLabel* fileModifiedIndicator = nullptr;
124 QLabel* compileStatusIndicator = nullptr;
125
126 // Central widget
127 CodeEditor* codeEditor = nullptr;
128
129 // Sidebar
130 QFrame* sideBar = nullptr;
131 QToolButton* compileButton = nullptr;
132 QToolButton* runButton = nullptr;
133
134 // Runtime view
135 nsbaci::ui::RuntimeView* runtimeView = nullptr;
136
137 // File actions
138 QAction* actionNew = nullptr;
139 QAction* actionSave = nullptr;
140 QAction* actionSaveAs = nullptr;
141 QAction* actionOpen = nullptr;
142 QAction* actionExit = nullptr;
143
144 // Edit actions
145 QAction* actionUndo = nullptr;
146 QAction* actionRedo = nullptr;
147 QAction* actionCut = nullptr;
148 QAction* actionCopy = nullptr;
149 QAction* actionPaste = nullptr;
150 QAction* actionSelectAll = nullptr;
151
152 // View actions
153 QAction* actionToggleSidebar = nullptr;
154 QAction* actionFullscreen = nullptr;
155
156 // Edit actions (preferences)
157 QAction* actionPreferences = nullptr;
158
159 // Build actions
160 QAction* actionCompile = nullptr;
161 QAction* actionRun = nullptr;
162
163 // Help actions
164 QAction* actionUserGuide = nullptr;
165 QAction* actionAbout = nullptr;
166
167 // State
168 QString currentFileName; // Just the filename for display
169 QString currentFilePath; // Full path for saving
170 bool isModified = false;
171 bool hasName = false;
172 bool isCompiled =
173 false; // True when program is compiled and code hasn't changed
174
175 // Current preferences
177
178 private:
179 void createCentralWidget();
180 void createEditorView();
181 void createRuntimeView();
182 void createMenuBar();
183 void createStatusBar();
184 void setupShortcuts();
185 void applyStyleSheet();
186 void applyPreferences(const nsbaci::ui::Preferences& prefs);
187 QString darkStyleSheet() const;
188 QString lightStyleSheet() const;
189
190 void switchToEditor();
191 void switchToRuntime();
192};
193#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.
Preferences dialog for nsbaci application settings.
RuntimeView widget declaration for nsbaci.
Holds all user-configurable preferences.
Definition preferencesDialog.h:38
UI Error type definitions for nsbaci.
User Guide dialog with integrated code examples for nsbaci.