itom  3.0.0
mainWindow.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, 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 "helpDockWidget.h"
33 #include "lastCommandDockWidget.h"
34 #include "userManagement.h"
35 
36 #include <qtableview.h>
37 #include <qprocess.h>
38 
39 #include <qsignalmapper.h>
40 
41 #include "../organizer/helpSystem.h"
42 
43 #include <qsharedpointer.h>
44 
45 class QSignalMapper; //forward declaration
46 
47 namespace ito {
48 
49 class WidgetInfoBox; //forward declaration
50 
51 #ifdef ITOM_USEHELPVIEWER
52 class HelpViewer; //forward declaration
53 #endif
54 
55 class MainWindow : public QMainWindow
56 {
57  Q_OBJECT
58 
59 public:
60  MainWindow();
61  ~MainWindow();
62 
63 
64 
65 protected:
66  void closeEvent(QCloseEvent *event);
67  void resizeEvent(QResizeEvent * event);
68  void moveEvent (QMoveEvent * event);
69 
70  inline bool pythonBusy() const { return m_pythonBusy; }
71  inline bool pythonDebugMode() const { return m_pythonDebugMode; }
72  inline bool pythonInWaitingMode() const { return m_pythonInWaitingMode; }
74 private:
75  void createActions();
76  void createMenus();
77  void createToolBars();
78  void createStatusBar();
79  void updateMenus();
80  void updatePythonActions();
81 
82  void getMenuHandlesRecursively(const QMenu *parent, QSharedPointer<QVector<size_t> > menuHandles);
83  QAction* searchActionRecursively(const size_t menuHandle, const QMenu *parent);
84 
85  ConsoleWidget *m_console;
86 
87  QVBoxLayout *m_contentLayout;
88 
89  BreakPointDockWidget *m_breakPointDock;
90  LastCommandDockWidget *m_lastCommandDock;
91  HelpDockWidget *m_helpDock;
92  WorkspaceDockWidget *m_globalWorkspaceDock;
93  WorkspaceDockWidget *m_localWorkspaceDock;
94  CallStackDockWidget *m_callStackDock;
95  FileSystemDockWidget *m_fileSystemDock;
96 
97  AIManagerWidget* m_pAIManagerWidget;
98 
99  QSignalMapper *m_lastFilesMapper;
100  QSignalMapper *m_openScriptsMapper;
102  QToolBar* m_aboutToolBar;
103  QToolBar* m_appToolBar;
104  QToolBar* m_toolToolBar;
105  QToolBar* m_pythonToolBar;
106 
107  QMap<QString, QToolBar*> m_userDefinedToolBars;
108  QMap<QString, QMenu* > m_userDefinedRootMenus;
109  QSignalMapper *m_userDefinedSignalMapper;
110  unsigned int m_userDefinedActionCounter;
111 
112  QAction *m_appFileNew;
113  QAction *m_appFileOpen;
114  QAction *m_aboutQt;
115  QAction *m_aboutQitom;
116 
117  QMap<QString, QAction*> m_actions;
118 
119  QMenu *m_pMenuHelp;
120  QMenu *m_pMenuFile;
121  QMenu *m_plastFilesMenu;
122  QMenu *m_pMenuPython;
123  QMenu *m_pMenuReloadModule;
124  QMenu *m_pMenuView;
125 
126  HelpSystem *m_pHelpSystem;
127 
128  QLabel *m_statusLblCurrentDir; //label for showing current directory
129 
130 #ifdef ITOM_USEHELPVIEWER
131  QPointer<HelpViewer> m_helpViewer;
132 #endif
133 
134  QRect m_geometryNormalState;
135 
139  bool m_isFullscreen;
140 
141  QMap<QString, QPointer<WidgetInfoBox> > m_infoBoxWidgets;
142 
143 signals:
144  void mainWindowCloseRequest();
145  void pythonDebugCommand(tPythonDbgCmd cmd);
146  void pythonSetAutoReloadSettings(bool enabled, bool checkFile, bool checkCmd, bool checkFct);
147 
148 public slots:
149  void addAbstractDock(AbstractDockWidget* dockWidget, Qt::DockWidgetArea area = Qt::TopDockWidgetArea);
150  void removeAbstractDock(AbstractDockWidget* dockWidget);
151 
152  void pythonStateChanged(tPythonTransitions pyTransition);
153 
154  void setStatusText(QString message, int timeout);
155 
156  ito::RetVal addToolbarButton(const QString &toolbarName, const QString &buttonName, const QString &buttonIconFilename, const QString &pythonCode, QSharedPointer<size_t> buttonHandle, ItomSharedSemaphore *waitCond = NULL);
157  ito::RetVal removeToolbarButton(const QString &toolbarName, const QString &buttonName, QSharedPointer<size_t> buttonHandle, bool showMessage = true, ItomSharedSemaphore *waitCond = NULL);
158  ito::RetVal removeToolbarButton(const size_t buttonHandle, bool showMessage = true, ItomSharedSemaphore *waitCond = NULL);
159 
160  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);
161  ito::RetVal removeMenuElement(const QString &key, QSharedPointer<QVector<size_t> > removedMenuHandles, bool showMessage = true, ItomSharedSemaphore *waitCond = NULL);
162  ito::RetVal removeMenuElement(const size_t menuHandle, QSharedPointer<QVector<size_t> > removedMenuHandles, bool showMessage = true, ItomSharedSemaphore *waitCond = NULL);
163  void pythonRunSelection(QString selectionText);
164 
165  void setCursor(const Qt::CursorShape cursor);
166  void resetCursor();
167 
168  void currentDirectoryChanged();
169 
170  void showInfoMessageLine( QString text, QString winKey = "" );
171 
172  void showAssistant(const QString &collectionFile = "");
173 
174 private slots:
175  void mnuAboutQitom();
176  void mnuExitApplication();
177 
178  void mnuNewScript();
179  void mnuOpenFile();
180  void mnuShowAssistant();
181  void mnuShowScriptReference();
182  void mnuShowDesigner();
183  void mnuShowProperties();
184  void mnuShowUserManagement();
185  void mnuToggleExecPyCodeByDebugger(bool checked);
186 
187  void mnuScriptStop();
188  void mnuScriptContinue();
189  void mnuScriptStep();
190  void mnuScriptStepOver();
191  void mnuScriptStepOut();
192  void mnuPyReloadModules();
193  void mnuShowLoadedPlugins();
194  void mnuPyPipManager();
195  void mnuPyTimerManager();
196 
197  void mnuPyAutoReloadTriggered(bool checked);
198 
199  void helpAssistantError ( QProcess::ProcessError error );
200  void designerError ( QProcess::ProcessError error );
201 
202  void userDefinedActionTriggered(const QString &pythonCode);
203 
204  void pythonAutoReloadChanged(bool enabled, bool checkFile, bool checkCmd, bool checkFct);
205 
206  void menuLastFilesAboutToShow();
207  void lastFileOpen(const QString &path);
208  void openScript(const QString &filename);
209 
210  void mnuViewAboutToShow();
211 
212 };
213 
214 } //end namespace ito
215 
216 #endif
Definition: helpSystem.h:36
void createStatusBar()
initializes status bar
Definition: mainWindow.cpp:912
bool pythonBusy() const
Definition: mainWindow.h:70
bool m_pythonBusy
Definition: mainWindow.h:136
void createActions()
creates actions for menu and toolbar
Definition: mainWindow.cpp:572
void addAbstractDock(AbstractDockWidget *dockWidget, Qt::DockWidgetArea area=Qt::TopDockWidgetArea)
slot invoked by ScriptEditorOrganizer, if any ScriptDockWidget should be added to main window&#39;s dock ...
Definition: mainWindow.cpp:488
Definition: lastCommandDockWidget.h:50
Definition: AIManagerWidget.h:38
void mnuScriptStepOut()
slot invoked to execute a python debugging step out
Definition: mainWindow.cpp:1946
QSignalMapper * m_openScriptsMapper
Definition: mainWindow.h:100
void mnuScriptStep()
slot invoked to execute a python debugging step
Definition: mainWindow.cpp:1932
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:930
bool m_pythonInWaitingMode
Definition: mainWindow.h:138
Definition: helpDockWidget.h:39
Definition: fileSystemDockWidget.h:52
docking
Definition: callStackDockWidget.h:37
Definition: consoleWidget.h:52
Definition: mainWindow.h:55
Definition: apiFunctionsGraph.cpp:39
void pythonDebugCommand(tPythonDbgCmd cmd)
void mnuOpenFile()
slot invoked by action to open any known file format
Definition: mainWindow.cpp:1051
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:528
void updatePythonActions()
updates actions which deal with python commands
Definition: mainWindow.cpp:1010
bool pythonInWaitingMode() const
Definition: mainWindow.h:72
void createToolBars()
creates toolbar
Definition: mainWindow.cpp:690
Definition: breakPointDockWidget.h:38
bool m_pythonDebugMode
Definition: mainWindow.h:137
docking widget for contents of type workspace widget
Definition: workspaceDockWidget.h:38
QSignalMapper * m_lastFilesMapper
Definition: mainWindow.h:99
abstract dock widget class which inherits QDockWidget. The content of QDockWidget consists of an inst...
Definition: abstractDockWidget.h:45
void mnuScriptStepOver()
slot invoked to execute a python debugging step over
Definition: mainWindow.cpp:1939
bool pythonDebugMode() const
Definition: mainWindow.h:71
void mnuNewScript()
slot invoked by action to open a new python script
Definition: mainWindow.cpp:1034
void closeEvent(QCloseEvent *event)
close event invoked if main window should be closed (and therefore the whole application too) ...
Definition: mainWindow.cpp:546
~MainWindow()
destructor
Definition: mainWindow.cpp:356
void mainWindowCloseRequest()
void mnuScriptContinue()
slot invoked to continue debugging process if actually waiting at breakpoint
Definition: mainWindow.cpp:1925
MainWindow()
constructor
Definition: mainWindow.cpp:66