itom  4.1.0
mainWindow.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef MAINWINDOW_H
24 #define MAINWINDOW_H
25 
26 #include "workspaceDockWidget.h"
27 #include "callStackDockWidget.h"
28 #include "consoleWidget.h"
29 #include "AIManagerWidget.h"
30 #include "fileSystemDockWidget.h"
31 #include "breakPointDockWidget.h"
32 #include "bookmarkDockWidget.h"
33 #include "helpDockWidget.h"
34 #include "lastCommandDockWidget.h"
35 //#include "pythonMessageDockWidget.h"
36 #include "userManagement.h"
37 
38 #include <qtableview.h>
39 #include <qprocess.h>
40 #include <qsplitter.h>
41 
42 #include <qsignalmapper.h>
43 
44 #include "../organizer/helpSystem.h"
45 
46 #include <qsharedpointer.h>
47 
48 class QSignalMapper; //forward declaration
49 
50 namespace ito {
51 
52 class WidgetInfoBox; //forward declaration
53 
54 #ifdef ITOM_USEHELPVIEWER
55 class HelpViewer; //forward declaration
56 #endif
57 
58 class MainWindow : public QMainWindow
59 {
60  Q_OBJECT
61 
62 public:
63  MainWindow();
64  ~MainWindow();
65 
66  ito::RetVal addCentralWidget(QWidget *widget);
67 
69 
70 protected:
71  void closeEvent(QCloseEvent *event);
72  void resizeEvent(QResizeEvent * event);
73  void moveEvent (QMoveEvent * event);
74 
75  inline bool pythonBusy() const { return m_pythonBusy; }
76  inline bool pythonDebugMode() const { return m_pythonDebugMode; }
77  inline bool pythonInWaitingMode() const { return m_pythonInWaitingMode; }
79 private:
80  void createActions();
81  void createMenus();
82  void createToolBars();
83  void createStatusBar();
84  void updateMenus();
85  void updatePythonActions();
86 
87  void getMenuHandlesRecursively(const QMenu *parent, QSharedPointer<QVector<size_t> > menuHandles);
88  QAction* searchActionRecursively(const size_t menuHandle, const QMenu *parent);
89 
90  ConsoleWidget *m_console;
91 
92  QVBoxLayout *m_contentLayout;
93  QSplitter *m_contentSplitter;
94 
95  BreakPointDockWidget *m_breakPointDock;
96  BookmarkDockWidget *m_bookmarkDock;
97  LastCommandDockWidget *m_lastCommandDock;
98 // PythonMessageDockWidget *m_pythonMessageDock;
99  HelpDockWidget *m_helpDock;
100  WorkspaceDockWidget *m_globalWorkspaceDock;
101  WorkspaceDockWidget *m_localWorkspaceDock;
102  CallStackDockWidget *m_callStackDock;
103  FileSystemDockWidget *m_fileSystemDock;
104 
105  AIManagerWidget* m_pAIManagerWidget;
106 
107  QSignalMapper *m_lastFilesMapper;
108  QSignalMapper *m_openScriptsMapper;
109  QSignalMapper *m_openFigureMapper;
111  QMap<QString, QToolBar*> m_userDefinedToolBars;
112  QMap<QString, QMenu* > m_userDefinedRootMenus;
113  QSignalMapper *m_userDefinedSignalMapper;
114  unsigned int m_userDefinedActionCounter;
115 
116  QAction *m_appFileNew;
117  QAction *m_appFileOpen;
118  QAction *m_aboutQt;
119  QAction *m_aboutQitom;
120 
121  QMap<QString, QAction*> m_actions;
122 
123  QMenu *m_pMenuFigure;
124  QMenu *m_pShowOpenFigure;
125  QMenu *m_pMenuHelp;
126  QMenu *m_pMenuFile;
127  QMenu *m_plastFilesMenu;
128  QMenu *m_pMenuPython;
129  QMenu *m_pMenuReloadModule;
130  QMenu *m_pMenuView;
131 
132  HelpSystem *m_pHelpSystem;
133 
134  QLabel *m_pStatusLblCurrentDir; //label for showing current directory
135  QLabel *m_pStatusLblPythonBusy; //label for showing the busy status of python (hidden, if python is currently not working)
136 
137 #ifdef ITOM_USEHELPVIEWER
138  QPointer<HelpViewer> m_helpViewer;
139 #endif
140 
141  QRect m_geometryNormalState;
142 
146  bool m_isFullscreen;
147 
148  QMap<QString, QPointer<WidgetInfoBox> > m_infoBoxWidgets;
149 
150 signals:
151  void mainWindowCloseRequest();
152  void pythonDebugCommand(tPythonDbgCmd cmd);
153  void pythonSetAutoReloadSettings(bool enabled, bool checkFile, bool checkCmd, bool checkFct);
154 
155 public slots:
156  void addAbstractDock(AbstractDockWidget* dockWidget, Qt::DockWidgetArea area = Qt::TopDockWidgetArea);
157  void removeAbstractDock(AbstractDockWidget* dockWidget);
158  void connectPythonMessageBox(QListWidget* pythonMessageBox);
159 
160  void pythonStateChanged(tPythonTransitions pyTransition);
161 
162  void setStatusText(QString message, int timeout);
163 
164  ito::RetVal addToolbarButton(const QString &toolbarName, const QString &buttonName, const QString &buttonIconFilename, const QString &pythonCode, QSharedPointer<size_t> buttonHandle, ItomSharedSemaphore *waitCond = NULL);
165  ito::RetVal removeToolbarButton(const QString &toolbarName, const QString &buttonName, QSharedPointer<QVector<size_t> > buttonHandles, bool showMessage = true, ItomSharedSemaphore *waitCond = nullptr);
166  ito::RetVal removeToolbarButton(const size_t buttonHandle, bool showMessage = true, ItomSharedSemaphore *waitCond = nullptr);
167 
168  ito::RetVal addMenuElement(int typeID, const QString &key, const QString &name, const QString &code, const QString &buttonIconFilename, QSharedPointer<size_t> menuHandle, bool showMessage = true, ItomSharedSemaphore *waitCond = NULL);
169  ito::RetVal removeMenuElement(const QString &key, QSharedPointer<QVector<size_t> > removedMenuHandles, bool showMessage = true, ItomSharedSemaphore *waitCond = NULL);
170  ito::RetVal removeMenuElement(const size_t menuHandle, QSharedPointer<QVector<size_t> > removedMenuHandles, bool showMessage = true, ItomSharedSemaphore *waitCond = NULL);
171 
172  ito::RetVal dumpToolbarsAndButtons(QSharedPointer<QString> pythonCodeString, ItomSharedSemaphore *waitCond = NULL);
173 
174  void pythonRunSelection(QString selectionText);
175 
176  void setCursor(const Qt::CursorShape cursor);
177  void resetCursor();
178 
179  void currentDirectoryChanged();
180 
181  void showInfoMessageLine( QString text, QString winKey = "" );
182 
183  void showAssistant(const QString &collectionFile = "");
184 
185  void setCentralWidgetsSizes(const QVector<int> &sizes);
186 
187 private slots:
188  void mnuAboutQitom();
189  void mnuExitApplication();
190 
191  void mnuNewScript();
192  void mnuOpenFile();
193  void mnuShowAssistant();
194  void mnuShowScriptReference();
195  void mnuShowDesigner();
196  void mnuShowProperties();
197  void mnuShowUserManagement();
198  void mnuToggleExecPyCodeByDebugger(bool checked);
199  void mnuCloseAllPlots();
200  void mnuShowAllPlots();
201  void mnuMinimizeAllPlots();
202 
203  void mnuScriptStop();
204  void mnuScriptContinue();
205  void mnuScriptStep();
206  void mnuScriptStepOver();
207  void mnuScriptStepOut();
208  void mnuPyReloadModules();
209  void mnuShowLoadedPlugins();
210  void mnuPyPipManager();
211  void mnuPyTimerManager();
212 
213  void mnuPyAutoReloadTriggered(bool checked);
214 
215  void helpAssistantError ( QProcess::ProcessError error );
216  void designerError ( QProcess::ProcessError error );
217 
218  void userDefinedActionTriggered(const QString &pythonCode);
219 
220  void pythonAutoReloadChanged(bool enabled, bool checkFile, bool checkCmd, bool checkFct);
221 
222  void menuLastFilesAboutToShow();
223  void lastFileOpen(const QString &path);
224  void openScript(const QString &filename);
225 
226  void mnuViewAboutToShow();
227  void mnuFigureAboutToShow();
228  void raiseFigureByHandle(int handle);
229 
230 };
231 
232 } //end namespace ito
233 
234 #endif
Definition: helpSystem.h:36
void createStatusBar()
initializes status bar
Definition: mainWindow.cpp:1117
QSignalMapper * m_openFigureMapper
Definition: mainWindow.h:109
bool pythonBusy() const
Definition: mainWindow.h:75
bool m_pythonBusy
Definition: mainWindow.h:143
void createActions()
creates actions for menu and toolbar
Definition: mainWindow.cpp:645
void addAbstractDock(AbstractDockWidget *dockWidget, Qt::DockWidgetArea area=Qt::TopDockWidgetArea)
slot invoked by ScriptEditorOrganizer, if any ScriptDockWidget should be added to main window's dock ...
Definition: mainWindow.cpp:555
Definition: lastCommandDockWidget.h:50
Definition: AIManagerWidget.h:41
void mnuScriptStepOut()
slot invoked to execute a python debugging step out
Definition: mainWindow.cpp:2305
QSignalMapper * m_openScriptsMapper
Definition: mainWindow.h:108
void mnuScriptStep()
slot invoked to execute a python debugging step
Definition: mainWindow.cpp:2291
Class for managing status values (like errors or warning)
Definition: retVal.h:54
void pythonStateChanged(tPythonTransitions pyTransition)
slot connected to signal pythonStateChanged in PythonEngine which is invoked by every change of the p...
Definition: mainWindow.cpp:1144
bool m_pythonInWaitingMode
Definition: mainWindow.h:145
Definition: helpDockWidget.h:39
Definition: fileSystemDockWidget.h:52
docking
Definition: callStackDockWidget.h:37
Definition: consoleWidget.h:57
Definition: mainWindow.h:58
Definition: apiFunctionsGraph.cpp:39
Provides the bookmark toolbox which is mainly a view of the BookmarkModel.
Definition: bookmarkDockWidget.h:43
void pythonDebugCommand(tPythonDbgCmd cmd)
void mnuOpenFile()
slot invoked by action to open any known file format
Definition: mainWindow.cpp:1264
semaphore which can be used for asychronous thread communication. By using this class it is possible ...
Definition: sharedStructuresQt.h:57
void removeAbstractDock(AbstractDockWidget *dockWidget)
slot invoked by ScriptEditorOrganizer, if any ScriptDockWidget should be removed from docking area ...
Definition: mainWindow.cpp:595
void updatePythonActions()
updates actions which deal with python commands
Definition: mainWindow.cpp:1223
bool pythonInWaitingMode() const
Definition: mainWindow.h:77
void createToolBars()
creates toolbar
Definition: mainWindow.cpp:767
void scriptEditorOrganizerAvailable()
slot called by startupApplication if script editor organizer is loaded.
Definition: mainWindow.cpp:534
Definition: breakPointDockWidget.h:38
bool m_pythonDebugMode
Definition: mainWindow.h:144
docking widget for contents of type workspace widget
Definition: workspaceDockWidget.h:38
QSignalMapper * m_lastFilesMapper
Definition: mainWindow.h:107
abstract dock widget class which inherits QDockWidget. The content of QDockWidget consists of an inst...
Definition: abstractDockWidget.h:54
void mnuScriptStepOver()
slot invoked to execute a python debugging step over
Definition: mainWindow.cpp:2298
bool pythonDebugMode() const
Definition: mainWindow.h:76
void mnuNewScript()
slot invoked by action to open a new python script
Definition: mainWindow.cpp:1247
void closeEvent(QCloseEvent *event)
close event invoked if main window should be closed (and therefore the whole application too) ...
Definition: mainWindow.cpp:619
~MainWindow()
destructor
Definition: mainWindow.cpp:395
void mainWindowCloseRequest()
void mnuScriptContinue()
slot invoked to continue debugging process if actually waiting at breakpoint
Definition: mainWindow.cpp:2284
MainWindow()
constructor
Definition: mainWindow.cpp:68