Debian Codegraph @

mainwindow.h

raw symbols SCIP
1 /****************************************************************************
2 ** SASM - simple IDE for assembler development
3 ** Copyright (C) 2013 Dmitriy Manushin
4 ** Contact: site: http://dman95.github.io/SASM/
5 ** e-mail: [email protected]
6 **
7 ** This file is part of SASM.
8 **
9 ** SASM is free software: you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation, either version 3 of the License, or
12 ** (at your option) any later version.
13 **
14 ** SASM is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** You should have received a copy of the GNU General Public License
20 ** along with SASM. If not, see <http://www.gnu.org/licenses/>.
21 **
22 ** Этот файл — часть SASM.
23 **
24 ** SASM - свободная программа: вы можете перераспространять ее и/или
25 ** изменять ее на условиях Стандартной общественной лицензии GNU в том виде,
26 ** в каком она была опубликована Фондом свободного программного обеспечения;
27 ** либо версии 3 лицензии, либо (по вашему выбору) любой более поздней
28 ** версии.
29 **
30 ** SASM распространяется в надежде, что она будет полезной,
31 ** но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА
32 ** или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Подробнее см. в Стандартной
33 ** общественной лицензии GNU.
34 **
35 ** Вы должны были получить копию Стандартной общественной лицензии GNU
36 ** вместе с этой программой. Если это не так, см.
37 ** <http://www.gnu.org/licenses/>.)
38 **
39 ****************************************************************************/
40
41 #ifndef MAINWINDOW_H
42 #define MAINWINDOW_H
43
44 #include <QMainWindow>
45 #include <QStackedWidget>
46 #include <QTextBrowser>
47 #include <QTimer>
48 #include <QElapsedTimer>
49 #include <QMenuBar>
50 #include <QMessageBox>
51 #include <QFileDialog>
52 #include <QTime>
53 #include <QPointer>
54 #include <QColorDialog>
55 #include <QSignalMapper>
56 #include <QMap>
57 #include <QSplitter>
58 #include <QToolBar>
59 #include <QMutex>
60 #include <QDragEnterEvent>
61 #include <QMimeData>
62 #include "tab.h"
63 #include "highlighter.h"
64 #include "debugger.h"
65 #include "finddialog.h"
66 #include "ruqtextedit.h"
67 #include "getstartedwidget.h"
68 #include "ui_settings.h"
69 #include "debugtablewidget.h"
70 #include "debuganycommandwidget.h"
71 #include "assembler.h"
72 #include "nasm.h"
73 #include "gas.h"
74 #include "common.h"
75 #include "fasm.h"
76 #include "signallocker.h"
77 #include "masm.h"
78
79 #define SASM_VERSION "3.15.0"
80
81 /**
82 * @file mainwindow.h
83 * Defines the main user interface.
84 */
85
86 /*! \brief The MainWindow class defines the actions and behavior of the main user interface.
87 *
88 */
89
90 class MainWindow : public QMainWindow
91 {
92 Q_OBJECT
93
94 public:
95 MainWindow(const QStringList & args, QWidget *parent = 0);
96 ~MainWindow();
97
98 void initUi();
99 void createMenus();
100 void createActions();
101 void createButtons();
102 void createToolBars();
103 void writeSettings();
104 void setupEditor(int i);
105 bool okToContinue(int index = -1);
106 void setTabPath(const QString &filePath, int index = -1);
107 bool removeDirRecuresively(const QString &dirName);
108
109 private:
110 //ui
111 GetStartedWidget *getStartedWidget;
112 QStackedWidget *mainWidget;
113 QSplitter *splitter;
114 QVBoxLayout *workLayout;
115 QWidget *workWidget;
116 RuQTextEdit *compilerOut;
117 QTabWidget *tabs;
118
119 //! Menus and Actions
120 QMenu *fileMenu;
121 QMenu *editMenu;
122 QMenu *debugMenu;
123 QMenu *buildMenu;
124 QMenu *settingsMenu;
125 QMenu *helpMenu;
126 QAction *newAction;
127 QAction *openAction;
128 QAction *closeAction;
129 QAction *saveAction;
130 QAction *saveAsAction;
131 QAction *saveExeAction;
132 QAction *exitAction;
133 QAction *findAction;
134 QAction *commentAction;
135 QAction *uncommentAction;
136 QAction *undoAction;
137 QAction *redoAction;
138 QAction *cutAction;
139 QAction *copyAction;
140 QAction *pasteAction;
141 QAction *deleteAction;
142 QAction *selectAllAction;
143 QAction *putTabAction;
144 QAction *deleteTabAction;
145 QAction *buildAction;
146 QAction *runAction;
147 QAction *runExeAction;
148 QAction *stopAction;
149 QAction *debugAction;
150 QAction *debugNextAction;
151 QAction *debugNextNiAction;
152 QAction *debugToggleBreakpointAction;
153 QAction *debugShowRegistersAction;
154 QAction *debugShowMemoryAction;
155 QAction *settingsAction;
156 QAction *helpAction;
157 QAction *aboutAction;
158
159 //! Toolbars
160 QToolBar *fileToolBar;
161 QToolBar *editToolBar;
162 QToolBar *buildToolBar;
163 QToolBar *debugToolBar;
164
165 //! Builder and debugger and all that concern to them
166 QProcess *runProcess;
167 CodeEditor *prevCodeEditor;
168 QTimer *timer;
169 QElapsedTimer programExecutionTime;
170 Debugger *debugger;
171 bool programIsBuilded;
172 QPointer<DebugTableWidget> registersWindow;
173 QDockWidget *registersDock;
174 QPointer<DebugTableWidget> memoryWindow;
175 QDockWidget *memoryDock;
176 QList<RuQPlainTextEdit::Watch> watches;
177 DebugAnyCommandWidget *debugAnyCommandWidget;
178 bool programStopped;
179 int outputIndex;
180 Assembler *assembler;
181 bool debuggerWasStarted;
182 QString debugKey;
183
184 //! Highlighters
185 Highlighter *highlighter;
186 Highlighter *settingsHighlighter;
187
188 //! Search
189 QPointer<FindDialog> findDialog;
190 Qt::CaseSensitivity prevCs;
191
192 //! Settings and Help
193 QPointer<QWidget> settingsWindow;
194 Ui::SettingsWindow settingsUi;
195 QString startText;
196 CodeEditor *settingsStartTextEditor;
197 //!save and open
198 QString saveOpenDirectory;
199 QPointer<QTextBrowser> help;
200 QSignalMapper *colorSignalMapper;
201 QSignalMapper *fontsSignalMapper;
202 QList<QPushButton *> colorButtons;
203 //! According to colorButtons
204 QList<QColor> defaultColors;
205 QMap<QString, QColor> colorsMap;
206 QList<QCheckBox *> fontCheckBoxes;
207 QSettings settings;
208 QString backupAssembler;
209 QString backupMode;
210 QString backupAssemblerOptions;
211 QString backupLinkerOptions;
212 QString backupObjectFileName;
213 bool backupDisableLinking;
214 bool backupCurrentDir;
215 QString backupAssemblerPath;
216 QString backupStartText;
217 QString backupLinkerPath;
218
219 //! About close
220 bool closeFromCloseAll;
221 void closeEvent(QCloseEvent *e);
222
223 public slots:
224 //! Actions and Menus
225 void newFile();
226 void openFile();
227 void closeFile();
228 bool saveFile(int index = -1, bool openSaveAs = true);
229 bool saveAsFile(int index = -1);
230 void saveExe();
231 bool closeApp();
232 void refreshEditMenu();
233 void changeCurrentSavedState(bool changed);
234 void openFile(QString path);
235
236 //! Build
237 void buildProgram(bool debugMode = false);
238 void runProgram();
239 void runExeProgram();
240 void stopProgram();
241 void testStopOfProgram();
242 void setProgramBuildedFlagToFalse();
243 void changeCurrentTab(int index);
244 void printLog(const QString & message, const QColor &color);
245 void printLogWithTime(const QString & message, const QColor &color);
246 void startCountProgramTime();
247
248 //! Debug
249 void debug();
250 void enableDebugActions();
251 void disableDebugActions(bool start = false);
252 void debugNext();
253 void debugNextNi();
254 void debugExit();
255 void debugToggleBreakpoint();
256 void debugShowRegisters();
257 void debugShowMemory();
258 void debugRunCommand(QString command, bool print);
259 void saveWatches(DebugTableWidget *table);
260 void setShowRegistersToUnchecked();
261 void setShowMemoryToUnchecked();
262 void setShowMemoryToChecked(const RuQPlainTextEdit::Watch &variable);
263 void showAnyCommandWidget();
264 void closeAnyCommandWidget();
265 void printOutput(QString msg, int index = -1);
266 void getOutput();
267 void changeDebugActionToStart();
268
269 //! Search
270 void find();
271 void findNext(const QString &pattern, Qt::CaseSensitivity cs, bool all, bool replace,
272 const QString &replaceText = 0);
273 void findNextAfterTextChange();
274
275 //! Settings
276 void restorePrevSession(bool notNotify = false);
277 void openSettings();
278 void initColorButtons(bool dark, bool ignoreSettings);
279 void changeColorButtonsLight();
280 void changeColorButtonsDark();
281 void changeMode(bool x86);
282 void changeAssembler();
283 void changeStartText();
284 void saveSettings();
285 void exitSettings();
286 void changeActionsState(int widgetIndex);
287 void resetAllSettings();
288 void pickColor(QWidget *colorButton, bool init = false, bool ignoreSettings = false);
289 void changeHighlightingFont(QWidget *box, bool init = false);
290 void changeHighlightingLineMode(int mode);
291 void recreateHighlighter();
292 void recreateAssembler(bool start = false);
293 void initAssemblerSettings(bool firstOpening);
294 void backupSettings();
295 void restoreSettingsAndExit();
296 void printMasmInfo();
297 void enableOrDisableLinkingEdit(int disableLinkingCheckboxState);
298
299 //! Closing
300 bool deleteTab(int index, bool saveFileName = false);
301 void closeAllChildWindows();
302
303 //! Help and About
304 void openHelp();
305 void openAbout();
306
307 //! Single Application message
308 void onMessageReceived(const QString &message);
309
310 protected:
311 void dragEnterEvent(QDragEnterEvent *event);
312
313 void dropEvent(QDropEvent *event);
314 };
315
316 #endif // MAINWINDOW_H