LibEngsas
emainwindow.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  MA 02110-1301 USA.
18 */
19 
20 #ifndef EMAINWINDOW_H
21 #define EMAINWINDOW_H
22 
23 #include "eglobal.h"
24 #include <QMainWindow>
25 
26 #include "ehelpcentersetup.h"
27 
28 class EWidget;
29 class EAction;
30 class ESettingsModel;
31 class EHelpCenter;
32 class EDependencyModel;
33 class ESetupWizardObject;
34 class EAboutModel;
35 
36 #include <QUrl>
37 
38 class QMenu;
39 class QStatusBar;
40 class QMenuBar;
41 class QSignalMapper;
42 
58 class E_CORE_EXPORT EMainWindow : public QMainWindow
59 {
60  Q_OBJECT
61  public:
62  EMainWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0);
63  virtual ~EMainWindow();
64  void setWindowTitle ( const QString &title );
65 
66  protected slots:
67  virtual void fileNew();
68  virtual void fileOpen();
69  virtual void fileOpen(QString absoluteFilePath);
70  virtual void fileSave();
71  virtual void fileSaveAs();
82  virtual void fileDoSave(QString file);
83  virtual void filePrint();
84  virtual void fileExit();
85  virtual void editCut();
86  virtual void editCopy();
87  virtual void editPaste();
88  virtual void editUndo();
89  virtual void editRedo();
107  virtual inline void editSetupWizard(){ }
115  virtual inline void editSettings(){ showSettings(0); }
116  virtual void viewReload();
122  void helpHelp();
130  virtual void helpHelp(QString file);
137  virtual inline void helpDependencies(){ showDependencies(0); }
144  virtual void helpAbout();
151  virtual inline void reloadSettings(){ emit doReloadSettings(); }
152 
156  void enableActions(EngSaS::AvailableActions enabledActions);
161  void connectESlots(QObject *object);
162 
168  inline void errorByPass(const QString &message){ error(message); }
174  inline void warningByPass(const QString &message){ warning(message); }
180  inline void informationByPass(const QString &message){ information(message); }
186  inline void reloadEnableActionsByPass(){ reloadEnableActions(); }
192  inline void addMenuByPass(QMenu* newMenu, const QString &parent, QString before = QString()){ addMenu(newMenu, parent, before); }
198  inline void addActionByPass(QAction* newAction, const QString &parent, QString before = QString()){ addAction(newAction, parent, before); }
204  inline void addToolBarByPass(QToolBar* newToolBar, Qt::ToolBarArea area = Qt::TopToolBarArea){ addToolBar(newToolBar, area); }
210  inline void addNewDockWidgetByPass(QDockWidget *widget, const Qt::DockWidgetArea &area){ addNewDockWidget(widget, area); }
216  inline void setCentralWidgetByPass(QWidget *centralWidget){ setCentralWidget(centralWidget); }
222  inline void showSettingsByPass(){ showSettings(); }
228  inline void showHelpByPass(const QString &page){ showHelp(page); }
233  inline void showStatusWidgetByPass(QWidget* widget){ showStatusWidget(widget); }
238  inline void reloadSettingsRequestByPass(){ reloadSettings(); }
242  void clearRecentlyUsed();
243 
244  protected:
259  void showSetupWizard(EngSaS::SetupWizardObjects objects,
260  bool msgOnNotNeeded = false,
261  QIcon logo = QIcon(),
262  QString applicationName = QString());
268  void showSettings(ESettingsModel *model);
274  void showDependencies(EDependencyModel *model);
283  void showAbout(QPixmap logo, QString name, QString version, QUrl url, EAboutModel *model);
290  void setupHelpCenter(EHelpCenterSetup setup);
294  void closeEvent(QCloseEvent *event);
301  void restoreWindowState();
302 
309  void error(const QString &message);
316  void warning(const QString &message);
323  void information(const QString &message);
327  void reloadEnableActions();
341  void addMenu(QMenu* newMenu, const QString &parent, QString before = QString());
352  void addAction(QAction* newAction, const QString &parent, QString before = QString());
357  void addToolBar(QToolBar* newToolBar, Qt::ToolBarArea area = Qt::TopToolBarArea);
362  void addNewDockWidget(QDockWidget *widget, const Qt::DockWidgetArea &area);
367  void setCentralWidget(QWidget *centralWidget);
372  inline void showSettings(){ editSettings(); }
377  void showHelp(const QString &page);
382  void showStatusWidget(QWidget* widget);
383 
387  EWidget *getCentralWidget();
388  void controleMenuStati();
389  void controleMenuStati(QMenu *menu);
390  void addToRecentlyUsed(QString absoluteFilePath);
391 
392  QMenuBar *menubar;
393  QStatusBar *statusbar;
394  QMenu *fileMenu, *fileRecentlyUsedMenu, *editMenu, *viewMenu;
395  QMenu *otherMenu, *helpMenu;
415  QList<QAction*> recentlyUsedActions;
417  QSignalMapper *recentlyUsedMapper;
418 
419  private:
424  QAction *findBefore(QObject *parent, QString name);
429  void setupUi();
433  void loadRecentlyUsed();
434 
435  signals:
436  void doReloadSettings();
437 };
438 
439 #endif // EMAINWINDOW_H