2021-04-06 23:10:57 +08:00
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
2021-08-31 14:40:41 +08:00
|
|
|
#include <QFileSystemWatcher>
|
2021-04-06 23:10:57 +08:00
|
|
|
#include <QMainWindow>
|
2021-08-30 22:05:45 +08:00
|
|
|
#include <QTimer>
|
2021-04-24 15:57:45 +08:00
|
|
|
#include "common.h"
|
2021-08-05 12:31:53 +08:00
|
|
|
#include "widgets/searchresultview.h"
|
2021-08-23 17:27:17 +08:00
|
|
|
#include "widgets/classbrowser.h"
|
2021-08-29 10:29:56 +08:00
|
|
|
#include "widgets/codecompletionpopup.h"
|
|
|
|
#include "widgets/headercompletionpopup.h"
|
2021-09-02 12:14:02 +08:00
|
|
|
#include "caretlist.h"
|
2021-04-06 23:10:57 +08:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
namespace Ui { class MainWindow; }
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2021-07-20 15:16:52 +08:00
|
|
|
|
|
|
|
enum class CompileTarget {
|
|
|
|
Invalid, None, File, Project, SyntaxCheck
|
|
|
|
};
|
|
|
|
|
2021-04-07 21:13:15 +08:00
|
|
|
class EditorList;
|
2021-04-08 10:29:21 +08:00
|
|
|
class QLabel;
|
2021-04-18 11:41:41 +08:00
|
|
|
class QComboBox;
|
2021-04-20 22:24:33 +08:00
|
|
|
class CompilerManager;
|
2021-06-24 20:43:09 +08:00
|
|
|
class Editor;
|
2021-07-23 13:22:05 +08:00
|
|
|
class Debugger;
|
2021-07-26 11:47:54 +08:00
|
|
|
class CPUDialog;
|
2021-08-01 10:00:27 +08:00
|
|
|
class QPlainTextEdit;
|
2021-08-03 23:55:57 +08:00
|
|
|
class SearchDialog;
|
2021-09-11 11:42:20 +08:00
|
|
|
class Project;
|
2021-04-07 21:13:15 +08:00
|
|
|
|
2021-04-06 23:10:57 +08:00
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2021-06-25 12:40:11 +08:00
|
|
|
enum class CompileSuccessionTaskType {
|
|
|
|
None,
|
|
|
|
Run,
|
|
|
|
Debug,
|
|
|
|
Profile
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CompileSuccessionTask {
|
|
|
|
CompileSuccessionTaskType type;
|
|
|
|
QString filename;
|
|
|
|
};
|
|
|
|
|
|
|
|
using PCompileSuccessionTask = std::shared_ptr<CompileSuccessionTask>;
|
|
|
|
|
2021-04-06 23:10:57 +08:00
|
|
|
public:
|
|
|
|
MainWindow(QWidget *parent = nullptr);
|
|
|
|
~MainWindow();
|
|
|
|
|
2021-06-12 22:36:23 +08:00
|
|
|
void updateForEncodingInfo();
|
|
|
|
void updateStatusbarForLineCol();
|
|
|
|
void updateForStatusbarModeInfo();
|
2021-08-30 22:05:45 +08:00
|
|
|
void updateStatusbarMessage(const QString& s);
|
2021-06-07 11:02:03 +08:00
|
|
|
void updateEditorSettings();
|
2021-06-12 22:36:23 +08:00
|
|
|
void updateEditorActions();
|
2021-07-01 19:44:38 +08:00
|
|
|
void updateCompileActions();
|
2021-06-20 14:30:47 +08:00
|
|
|
void updateEditorColorSchemes();
|
2021-06-24 20:43:09 +08:00
|
|
|
void updateCompilerSet();
|
2021-08-01 23:24:37 +08:00
|
|
|
void updateDebuggerSettings();
|
2021-06-24 20:43:09 +08:00
|
|
|
void checkSyntaxInBack(Editor* e);
|
2021-06-25 12:40:11 +08:00
|
|
|
bool compile(bool rebuild=false);
|
|
|
|
void runExecutable(const QString& exeName, const QString& filename=QString());
|
|
|
|
void runExecutable();
|
2021-07-23 13:22:05 +08:00
|
|
|
void debug();
|
2021-08-05 19:58:32 +08:00
|
|
|
void showSearchPanel();
|
2021-04-08 10:29:21 +08:00
|
|
|
|
2021-06-18 21:48:40 +08:00
|
|
|
void applySettings();
|
2021-09-02 16:35:28 +08:00
|
|
|
void applyUISettings();
|
2021-08-31 14:40:41 +08:00
|
|
|
QFileSystemWatcher* fileSystemWatcher();
|
2021-06-18 21:48:40 +08:00
|
|
|
|
2021-07-26 00:22:08 +08:00
|
|
|
void removeActiveBreakpoints();
|
2021-07-26 18:22:09 +08:00
|
|
|
void setActiveBreakpoint(QString FileName, int Line, bool setFocus=true);
|
2021-07-26 00:22:08 +08:00
|
|
|
void updateAppTitle();
|
2021-07-26 11:47:54 +08:00
|
|
|
void addDebugOutput(const QString& text);
|
2021-07-30 23:28:58 +08:00
|
|
|
void changeDebugOutputLastline(const QString& text);
|
2021-08-01 23:24:37 +08:00
|
|
|
void updateDebugEval(const QString& value);
|
2021-07-26 11:47:54 +08:00
|
|
|
|
2021-08-02 10:08:25 +08:00
|
|
|
void rebuildOpenedFileHisotryMenu();
|
|
|
|
|
2021-08-23 17:27:17 +08:00
|
|
|
void updateClassBrowserForEditor(Editor* editor);
|
|
|
|
|
2021-08-30 22:05:45 +08:00
|
|
|
void resetAutoSaveTimer();
|
|
|
|
|
2021-08-01 10:00:27 +08:00
|
|
|
QPlainTextEdit* txtLocals();
|
|
|
|
|
2021-07-26 18:22:09 +08:00
|
|
|
CPUDialog *cpuDialog() const;
|
2021-07-26 00:22:08 +08:00
|
|
|
|
2021-08-01 09:13:38 +08:00
|
|
|
Debugger *debugger() const;
|
|
|
|
|
2021-08-03 23:55:57 +08:00
|
|
|
EditorList *editorList() const;
|
|
|
|
|
|
|
|
SearchDialog *searchDialog() const;
|
|
|
|
|
2021-08-05 12:31:53 +08:00
|
|
|
SearchResultModel* searchResultModel();
|
|
|
|
|
2021-08-29 10:29:56 +08:00
|
|
|
const std::shared_ptr<CodeCompletionPopup> &completionPopup() const;
|
|
|
|
|
|
|
|
const std::shared_ptr<HeaderCompletionPopup> &headerCompletionPopup() const;
|
2021-09-02 12:14:02 +08:00
|
|
|
CaretList &caretList();
|
|
|
|
void updateCaretActions();
|
|
|
|
|
2021-09-11 18:42:49 +08:00
|
|
|
std::shared_ptr<Project> project();
|
|
|
|
|
2021-08-30 22:05:45 +08:00
|
|
|
public slots:
|
|
|
|
void onCompileLog(const QString& msg);
|
|
|
|
void onCompileIssue(PCompileIssue issue);
|
|
|
|
void onCompileFinished();
|
|
|
|
void onCompileErrorOccured(const QString& reason);
|
|
|
|
void onRunErrorOccured(const QString& reason);
|
|
|
|
void onRunFinished();
|
|
|
|
void cleanUpCPUDialog();
|
|
|
|
void onDebugCommandInput(const QString& command);
|
|
|
|
void onDebugEvaluateInput();
|
|
|
|
void onParserProgress(const QString& fileName, int total, int current);
|
|
|
|
void onStartParsing();
|
|
|
|
void onEndParsing(int total, int updateView);
|
|
|
|
void onEvalValueReady(const QString& value);
|
2021-09-03 00:26:49 +08:00
|
|
|
void onEditorContextMenu(const QPoint& pos);
|
2021-09-04 22:15:02 +08:00
|
|
|
void onEditorTabContextMenu(const QPoint& pos);
|
2021-08-29 10:29:56 +08:00
|
|
|
|
2021-09-02 20:12:16 +08:00
|
|
|
private:
|
2021-09-11 18:42:49 +08:00
|
|
|
void closeProject(bool refreshEditor);
|
2021-04-11 21:33:08 +08:00
|
|
|
void openFiles(const QStringList& files);
|
|
|
|
void openFile(const QString& filename);
|
2021-09-11 11:42:20 +08:00
|
|
|
void openProject(const QString& filename);
|
2021-08-30 22:05:45 +08:00
|
|
|
CompileTarget getCompileTarget();
|
|
|
|
bool debugInferiorhasBreakpoint();
|
|
|
|
void setupActions();
|
2021-09-02 19:36:16 +08:00
|
|
|
void openCloseBottomPanel(bool open);
|
|
|
|
void openCloseLeftPanel(bool open);
|
2021-08-30 22:05:45 +08:00
|
|
|
void prepareDebugger();
|
|
|
|
void doAutoSave(Editor *e);
|
2021-08-31 11:13:12 +08:00
|
|
|
void buildContextMenus();
|
2021-09-02 20:12:16 +08:00
|
|
|
void maximizeEditor();
|
2021-09-03 16:39:20 +08:00
|
|
|
void openShell(const QString& folder, const QString& shellCommand);
|
2021-09-05 13:51:07 +08:00
|
|
|
QAction* createActionFor(const QString& text,
|
|
|
|
QWidget* parent,
|
|
|
|
QKeySequence shortcut=QKeySequence());
|
2021-09-11 18:42:49 +08:00
|
|
|
void scanActiveProject(bool parse=false);
|
2021-08-30 22:05:45 +08:00
|
|
|
|
2021-04-07 21:13:15 +08:00
|
|
|
private slots:
|
2021-08-30 22:05:45 +08:00
|
|
|
void onAutoSaveTimeout();
|
2021-08-31 14:40:41 +08:00
|
|
|
void onFileChanged(const QString& path);
|
2021-08-30 22:05:45 +08:00
|
|
|
|
2021-09-05 13:51:07 +08:00
|
|
|
void onWatchViewContextMenu(const QPoint& pos);
|
|
|
|
void onTableIssuesContextMenu(const QPoint& pos);
|
2021-09-05 21:05:38 +08:00
|
|
|
void onSearchViewContextMenu(const QPoint& pos);
|
2021-09-05 22:16:54 +08:00
|
|
|
void onBreakpointsViewContextMenu(const QPoint& pos);
|
2021-09-05 13:51:07 +08:00
|
|
|
|
2021-04-07 21:13:15 +08:00
|
|
|
void on_actionNew_triggered();
|
|
|
|
|
2021-04-07 22:44:08 +08:00
|
|
|
void on_EditorTabsLeft_tabCloseRequested(int index);
|
|
|
|
|
2021-04-08 10:29:21 +08:00
|
|
|
void on_actionOpen_triggered();
|
|
|
|
|
2021-04-11 12:39:22 +08:00
|
|
|
void on_actionSave_triggered();
|
|
|
|
|
|
|
|
void on_actionSaveAs_triggered();
|
|
|
|
|
2021-04-16 22:04:48 +08:00
|
|
|
void on_actionOptions_triggered();
|
|
|
|
|
2021-04-18 11:41:41 +08:00
|
|
|
// qt will auto bind slots with the prefix "on_"
|
|
|
|
void onCompilerSetChanged(int index);
|
|
|
|
|
2021-04-20 22:24:33 +08:00
|
|
|
void on_actionCompile_triggered();
|
|
|
|
|
2021-04-21 18:58:35 +08:00
|
|
|
void on_actionRun_triggered();
|
|
|
|
|
2021-04-21 23:06:55 +08:00
|
|
|
void on_actionUndo_triggered();
|
|
|
|
|
|
|
|
void on_actionRedo_triggered();
|
|
|
|
|
|
|
|
void on_actionCut_triggered();
|
|
|
|
|
|
|
|
void on_actionSelectAll_triggered();
|
|
|
|
|
|
|
|
void on_actionCopy_triggered();
|
|
|
|
|
|
|
|
void on_actionPaste_triggered();
|
|
|
|
|
|
|
|
void on_actionIndent_triggered();
|
|
|
|
|
|
|
|
void on_actionUnIndent_triggered();
|
|
|
|
|
2021-04-24 15:57:45 +08:00
|
|
|
void on_actionToggleComment_triggered();
|
|
|
|
|
|
|
|
void on_actionUnfoldAll_triggered();
|
|
|
|
|
|
|
|
void on_actionFoldAll_triggered();
|
|
|
|
|
2021-04-29 20:54:44 +08:00
|
|
|
void on_tableIssues_doubleClicked(const QModelIndex &index);
|
|
|
|
|
2021-06-12 22:36:23 +08:00
|
|
|
void on_actionEncode_in_ANSI_triggered();
|
|
|
|
|
|
|
|
void on_actionEncode_in_UTF_8_triggered();
|
|
|
|
|
|
|
|
void on_actionAuto_Detect_triggered();
|
|
|
|
|
|
|
|
void on_actionConvert_to_ANSI_triggered();
|
|
|
|
|
|
|
|
void on_actionConvert_to_UTF_8_triggered();
|
|
|
|
|
2021-06-23 22:38:02 +08:00
|
|
|
void on_tabMessages_tabBarClicked(int index);
|
|
|
|
|
2021-06-24 16:05:19 +08:00
|
|
|
void on_tabMessages_currentChanged(int index);
|
|
|
|
|
|
|
|
void on_tabMessages_tabBarDoubleClicked(int index);
|
|
|
|
|
2021-06-25 12:40:11 +08:00
|
|
|
void on_actionCompile_Run_triggered();
|
|
|
|
|
|
|
|
void on_actionRebuild_triggered();
|
|
|
|
|
|
|
|
void on_actionStop_Execution_triggered();
|
|
|
|
|
2021-07-20 15:16:52 +08:00
|
|
|
void on_actionDebug_triggered();
|
|
|
|
|
2021-07-31 14:04:43 +08:00
|
|
|
void on_actionStep_Over_triggered();
|
|
|
|
|
|
|
|
void on_actionStep_Into_triggered();
|
|
|
|
|
|
|
|
void on_actionStep_Out_triggered();
|
|
|
|
|
|
|
|
void on_actionRun_To_Cursor_triggered();
|
|
|
|
|
|
|
|
void on_actionContinue_triggered();
|
|
|
|
|
2021-08-01 01:06:43 +08:00
|
|
|
void on_actionAdd_Watch_triggered();
|
|
|
|
|
2021-08-01 23:24:37 +08:00
|
|
|
void on_actionView_CPU_Window_triggered();
|
|
|
|
|
2021-08-02 10:08:25 +08:00
|
|
|
void on_actionExit_triggered();
|
|
|
|
|
2021-08-03 23:55:57 +08:00
|
|
|
void on_actionFind_triggered();
|
|
|
|
|
|
|
|
void on_actionFind_in_files_triggered();
|
|
|
|
|
|
|
|
void on_actionReplace_triggered();
|
|
|
|
|
|
|
|
void on_actionFind_Next_triggered();
|
|
|
|
|
|
|
|
void on_actionFind_Previous_triggered();
|
|
|
|
|
2021-08-05 19:58:32 +08:00
|
|
|
void on_cbSearchHistory_currentIndexChanged(int index);
|
|
|
|
|
|
|
|
void on_btnSearchAgin_clicked();
|
2021-08-31 11:13:12 +08:00
|
|
|
void on_actionRemove_Watch_triggered();
|
|
|
|
|
|
|
|
void on_actionRemove_All_Watches_triggered();
|
|
|
|
|
|
|
|
void on_actionModify_Watch_triggered();
|
|
|
|
|
2021-09-02 12:14:02 +08:00
|
|
|
void on_actionReformat_Code_triggered();
|
|
|
|
|
|
|
|
void on_actionBack_triggered();
|
|
|
|
|
|
|
|
void on_actionForward_triggered();
|
|
|
|
|
2021-09-02 19:36:16 +08:00
|
|
|
void on_tabInfos_tabBarClicked(int index);
|
|
|
|
|
|
|
|
void on_splitterInfos_splitterMoved(int pos, int index);
|
|
|
|
|
|
|
|
void on_splitterMessages_splitterMoved(int pos, int index);
|
|
|
|
|
|
|
|
void on_EditorTabsLeft_tabBarDoubleClicked(int index);
|
|
|
|
|
|
|
|
void on_actionClose_triggered();
|
|
|
|
|
2021-09-02 20:12:16 +08:00
|
|
|
void on_actionClose_All_triggered();
|
|
|
|
|
|
|
|
void on_actionMaximize_Editor_triggered();
|
|
|
|
|
2021-09-03 00:26:49 +08:00
|
|
|
void on_actionNext_Editor_triggered();
|
|
|
|
|
|
|
|
void on_actionPrevious_Editor_triggered();
|
|
|
|
|
2021-09-03 10:30:08 +08:00
|
|
|
void on_actionToggle_Breakpoint_triggered();
|
|
|
|
|
|
|
|
void on_actionClear_all_breakpoints_triggered();
|
|
|
|
|
|
|
|
void on_actionBreakpoint_property_triggered();
|
|
|
|
|
2021-09-03 11:50:04 +08:00
|
|
|
void on_actionGoto_Declaration_triggered();
|
|
|
|
|
|
|
|
void on_actionGoto_Definition_triggered();
|
|
|
|
|
2021-09-03 16:39:20 +08:00
|
|
|
void on_actionFind_references_triggered();
|
|
|
|
|
|
|
|
void on_actionOpen_Containing_Folder_triggered();
|
|
|
|
|
|
|
|
void on_actionOpen_Terminal_triggered();
|
|
|
|
|
2021-09-04 00:13:42 +08:00
|
|
|
void on_actionFile_Properties_triggered();
|
|
|
|
|
2021-09-05 21:05:38 +08:00
|
|
|
void on_searchView_doubleClicked(const QModelIndex &index);
|
|
|
|
|
|
|
|
void on_tblStackTrace_doubleClicked(const QModelIndex &index);
|
|
|
|
|
|
|
|
void on_tblBreakpoints_doubleClicked(const QModelIndex &index);
|
|
|
|
|
2021-04-06 23:10:57 +08:00
|
|
|
private:
|
|
|
|
Ui::MainWindow *ui;
|
2021-08-01 09:13:38 +08:00
|
|
|
EditorList *mEditorList;
|
|
|
|
QLabel *mFileInfoStatus;
|
|
|
|
QLabel *mFileEncodingStatus;
|
|
|
|
QLabel *mFileModeStatus;
|
|
|
|
QMenu *mMenuEncoding;
|
|
|
|
QMenu *mMenuEncodingList;
|
2021-08-02 10:08:25 +08:00
|
|
|
QMenu *mMenuRecentFiles;
|
2021-08-01 09:13:38 +08:00
|
|
|
QComboBox *mCompilerSet;
|
|
|
|
CompilerManager *mCompilerManager;
|
|
|
|
Debugger *mDebugger;
|
|
|
|
CPUDialog *mCPUDialog;
|
2021-08-03 23:55:57 +08:00
|
|
|
SearchDialog *mSearchDialog;
|
2021-08-02 10:08:25 +08:00
|
|
|
QList<QAction *> mRecentFileActions;
|
2021-08-23 17:27:17 +08:00
|
|
|
bool mQuitting;
|
2021-08-27 16:38:55 +08:00
|
|
|
QElapsedTimer mParserTimer;
|
2021-08-31 14:40:41 +08:00
|
|
|
QFileSystemWatcher mFileSystemWatcher;
|
2021-09-11 18:42:49 +08:00
|
|
|
std::shared_ptr<Project> mProject;
|
2021-07-23 13:22:05 +08:00
|
|
|
|
2021-08-29 10:29:56 +08:00
|
|
|
std::shared_ptr<CodeCompletionPopup> mCompletionPopup;
|
|
|
|
std::shared_ptr<HeaderCompletionPopup> mHeaderCompletionPopup;
|
|
|
|
|
2021-08-05 12:31:53 +08:00
|
|
|
SearchResultModel mSearchResultModel;
|
|
|
|
PSearchResultListModel mSearchResultListModel;
|
|
|
|
PSearchResultTreeModel mSearchResultTreeModel;
|
|
|
|
PSearchResultTreeViewDelegate mSearchViewDelegate;
|
2021-08-23 17:27:17 +08:00
|
|
|
ClassBrowserModel mClassBrowserModel;
|
2021-08-05 12:31:53 +08:00
|
|
|
|
2021-06-23 22:38:02 +08:00
|
|
|
bool mCheckSyntaxInBack;
|
2021-09-02 19:36:16 +08:00
|
|
|
bool mOpenClosingBottomPanel;
|
|
|
|
int mBottomPanelHeight;
|
|
|
|
bool mBottomPanelOpenned;
|
|
|
|
bool mOpenClosingLeftPanel;
|
|
|
|
int mLeftPanelWidth;
|
|
|
|
bool mLeftPanelOpenned;
|
2021-06-25 12:40:11 +08:00
|
|
|
PCompileSuccessionTask mCompileSuccessionTask;
|
2021-04-20 22:24:33 +08:00
|
|
|
|
2021-08-30 22:05:45 +08:00
|
|
|
QTimer mAutoSaveTimer;
|
|
|
|
|
2021-09-02 12:14:02 +08:00
|
|
|
CaretList mCaretList;
|
|
|
|
|
2021-09-02 20:12:16 +08:00
|
|
|
bool mClosing;
|
|
|
|
bool mSystemTurnedOff;
|
2021-09-05 05:01:31 +08:00
|
|
|
QPoint mEditorContextMenuPos;
|
2021-08-29 10:29:56 +08:00
|
|
|
|
2021-09-05 19:10:54 +08:00
|
|
|
//actions for compile issue table
|
2021-09-05 13:51:07 +08:00
|
|
|
QAction * mTableIssuesCopyAction;
|
|
|
|
QAction * mTableIssuesCopyAllAction;
|
|
|
|
QAction * mTableIssuesClearAction;
|
|
|
|
|
2021-09-05 21:05:38 +08:00
|
|
|
//actions for search result view
|
|
|
|
QAction * mSearchViewClearAction;
|
|
|
|
QAction * mSearchViewClearAllAction;
|
|
|
|
|
2021-09-05 22:16:54 +08:00
|
|
|
//actions for breakpoint view
|
|
|
|
QAction * mBreakpointViewPropertyAction;
|
|
|
|
QAction * mBreakpointViewRemoveAllAction;
|
|
|
|
|
2021-04-09 17:48:25 +08:00
|
|
|
// QWidget interface
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *event) override;
|
2021-09-02 19:36:16 +08:00
|
|
|
void showEvent(QShowEvent* event) override;
|
2021-09-05 21:17:33 +08:00
|
|
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
|
|
|
void dropEvent(QDropEvent *event) override;
|
2021-04-06 23:10:57 +08:00
|
|
|
};
|
2021-04-08 10:29:21 +08:00
|
|
|
|
|
|
|
extern MainWindow* pMainWindow;
|
2021-04-06 23:10:57 +08:00
|
|
|
#endif // MAINWINDOW_H
|