LP-56 - Better txpid option namings, fix tabs-spaces, tooltips. headers, variable...
[librepilot.git] / ground / openpilotgcs / src / plugins / coreplugin / mainwindow.h
blobc19903424a91c40ea7c8ec33473c4a893606e143
1 /**
2 ******************************************************************************
4 * @file mainwindow.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup CorePlugin Core Plugin
10 * @{
11 * @brief The Core GCS plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef MAINWINDOW_H
30 #define MAINWINDOW_H
32 #include "core_global.h"
34 #include "eventfilteringmainwindow.h"
36 #include <QtCore/QMap>
37 #include <QSettings>
39 QT_BEGIN_NAMESPACE
40 class QSettings;
41 class QShortcut;
42 class QToolButton;
43 class MyTabWidget;
44 QT_END_NAMESPACE
46 class AboutDialog;
48 namespace Core {
49 class ActionManager;
50 class BaseMode;
51 class BaseView;
52 class IConfigurablePlugin;
53 class IContext;
54 class IMode;
55 class IWizard;
56 class ConnectionManager;
57 class MessageManager;
58 class MimeDatabase;
59 class ModeManager;
60 class RightPaneWidget;
61 class SettingsDatabase;
62 class UniqueIDManager;
63 class VariableManager;
64 class ThreadManager;
65 class ViewManagerInterface;
66 class UAVGadgetManager;
67 class UAVGadgetInstanceManager;
70 namespace Internal {
71 class ActionManagerPrivate;
72 class CoreImpl;
73 class FancyTabWidget;
74 class GeneralSettings;
75 class ShortcutSettings;
76 class WorkspaceSettings;
78 class CORE_EXPORT MainWindow : public EventFilteringMainWindow {
79 Q_OBJECT
81 public:
82 MainWindow();
83 ~MainWindow();
85 bool init(QString *errorMessage);
86 void extensionsInitialized();
87 void shutdown();
89 IContext *contextObject(QWidget *widget);
90 void addContextObject(IContext *contex);
91 void removeContextObject(IContext *contex);
92 void resetContext();
93 void readSettings(QSettings *qs = 0, bool workspaceDiffOnly = false);
94 void saveSettings(QSettings *qs = 0);
95 void readSettings(IConfigurablePlugin *plugin, QSettings *qs = 0);
96 void saveSettings(IConfigurablePlugin *plugin, QSettings *qs = 0);
97 void deleteSettings();
98 void openFiles(const QStringList &fileNames);
100 Core::ActionManager *actionManager() const;
101 Core::UniqueIDManager *uniqueIDManager() const;
102 Core::MessageManager *messageManager() const;
103 QList<UAVGadgetManager *> uavGadgetManagers() const;
104 UAVGadgetInstanceManager *uavGadgetInstanceManager() const;
105 Core::ConnectionManager *connectionManager() const;
106 Core::VariableManager *variableManager() const;
107 Core::ThreadManager *threadManager() const;
108 Core::ModeManager *modeManager() const;
109 Core::MimeDatabase *mimeDatabase() const;
110 Internal::GeneralSettings *generalSettings() const;
111 QSettings *settings(QSettings::Scope scope) const;
112 inline SettingsDatabase *settingsDatabase() const
114 return m_settingsDatabase;
116 IContext *currentContextObject() const;
117 QStatusBar *statusBar() const;
118 void addAdditionalContext(int context);
119 void removeAdditionalContext(int context);
120 bool hasContext(int context) const;
122 void updateContext();
124 void setSuppressNavigationWidget(bool suppress);
126 signals:
127 void windowActivated();
129 public slots:
130 void newFile();
131 void openFileWith();
132 void exit();
133 void setFullScreen(bool on);
135 bool showOptionsDialog(const QString &category = QString(),
136 const QString &page = QString(),
137 QWidget *parent = 0);
139 bool showWarningWithOptions(const QString &title, const QString &text,
140 const QString &details = QString(),
141 const QString &settingsCategory = QString(),
142 const QString &settingsId = QString(),
143 QWidget *parent = 0);
145 protected:
146 virtual void changeEvent(QEvent *e);
147 virtual void closeEvent(QCloseEvent *event);
148 virtual void dragEnterEvent(QDragEnterEvent *event);
149 virtual void dropEvent(QDropEvent *event);
151 private slots:
152 void openFile();
153 void aboutToShowRecentFiles();
154 void openRecentFile();
155 void setFocusToEditor();
156 void saveAll();
157 void showAboutDialog();
158 void destroyAboutDialog();
159 void aboutPlugins();
160 void updateFocusWidget(QWidget *old, QWidget *now);
161 void modeChanged(Core::IMode *mode);
162 void showUavGadgetMenus(bool show, bool hasSplitter);
163 void applyTabBarSettings(QTabWidget::TabPosition pos, bool movable);
164 void showHelp();
166 private:
167 void updateContextObject(IContext *context);
168 void registerDefaultContainers();
169 void registerDefaultActions();
170 void createWorkspaces(QSettings *qs, bool diffOnly = false);
171 QString loadStyleSheet(QString name);
173 CoreImpl *m_coreImpl;
174 UniqueIDManager *m_uniqueIDManager;
175 QList<int> m_globalContext;
176 QList<int> m_additionalContexts;
177 QSettings *m_settings;
178 QSettings *m_globalSettings;
179 SettingsDatabase *m_settingsDatabase;
180 bool m_dontSaveSettings; // In case of an Error or if we reset the settings, never save them.
181 ActionManagerPrivate *m_actionManager;
182 MessageManager *m_messageManager;
183 VariableManager *m_variableManager;
184 ThreadManager *m_threadManager;
185 ModeManager *m_modeManager;
186 QList<UAVGadgetManager *> m_uavGadgetManagers;
187 UAVGadgetInstanceManager *m_uavGadgetInstanceManager;
188 ConnectionManager *m_connectionManager;
189 MimeDatabase *m_mimeDatabase;
190 MyTabWidget *m_modeStack;
191 Core::BaseView *m_outputView;
192 AboutDialog *m_aboutDialog;
194 IContext *m_activeContext;
196 QMap<QWidget *, IContext *> m_contextWidgets;
198 GeneralSettings *m_generalSettings;
199 ShortcutSettings *m_shortcutSettings;
200 WorkspaceSettings *m_workspaceSettings;
202 // actions
203 QShortcut *m_focusToEditor;
204 QAction *m_newAction;
205 QAction *m_openAction;
206 QAction *m_openWithAction;
207 QAction *m_saveAllAction;
208 QAction *m_exitAction;
209 QAction *m_optionsAction;
210 QAction *m_toggleFullScreenAction;
211 // UavGadgetManager actions
212 QAction *m_showToolbarsAction;
213 QAction *m_splitAction;
214 QAction *m_splitSideBySideAction;
215 QAction *m_removeCurrentSplitAction;
216 QAction *m_removeAllSplitsAction;
217 QAction *m_gotoOtherSplitAction;
219 QString m_config_description;
220 QString m_config_details;
221 QString m_config_stylesheet;
222 #ifdef Q_WS_MAC
223 QAction *m_minimizeAction;
224 QAction *m_zoomAction;
225 #endif
227 } // namespace Internal
228 } // namespace Core
230 #endif // MAINWINDOW_H