Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / coreplugin / modemanager.h
blobfc2cf44528c5aacd8decb5da80736fda8abe3772
1 /**
2 ******************************************************************************
4 * @file modemanager.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 MODEMANAGER_H
30 #define MODEMANAGER_H
32 #include <QtCore/QObject>
33 #include <QtCore/QList>
34 #include <QtCore/QMap>
35 #include <QtCore/QVector>
37 #include <coreplugin/core_global.h>
39 QT_BEGIN_NAMESPACE
40 class QSignalMapper;
41 class QMenu;
42 class QIcon;
43 class MyTabWidget;
44 QT_END_NAMESPACE
46 namespace Core {
47 class Command;
48 class IMode;
50 namespace Internal {
51 class MainWindow;
52 } // namespace Internal
54 class CORE_EXPORT ModeManager : public QObject {
55 Q_OBJECT
57 public:
58 ModeManager(Internal::MainWindow *mainWindow, MyTabWidget *modeStack);
60 void init();
61 static ModeManager *instance()
63 return m_instance;
66 IMode *currentMode() const;
67 IMode *mode(const QString &id) const;
69 void addAction(Command *command, int priority, QMenu *menu = 0);
70 void addWidget(QWidget *widget);
71 void updateModeNameIcon(IMode *mode, const QIcon &icon, const QString &label);
72 QVector<IMode *> modes() const
74 return m_modes;
76 void reorderModes(QMap<QString, int> priorities);
78 signals:
79 void currentModeAboutToChange(Core::IMode *mode);
80 void currentModeChanged(Core::IMode *mode);
81 void newModeOrder(QVector<IMode *> modes);
83 public slots:
84 void activateMode(const QString &id);
85 void activateModeByWorkspaceName(const QString &id);
86 void setFocusToCurrentMode();
87 void triggerAction(const QString &actionId);
89 private slots:
90 void objectAdded(QObject *obj);
91 void aboutToRemoveObject(QObject *obj);
92 void currentTabAboutToChange(int index);
93 void currentTabChanged(int index);
94 void updateModeToolTip();
95 void tabMoved(int from, int to);
97 private:
98 int indexOf(const QString &id) const;
99 void setDefaultKeyshortcuts();
101 static ModeManager *m_instance;
102 Internal::MainWindow *m_mainWindow;
103 MyTabWidget *m_modeStack;
104 QMap<Command *, int> m_actions;
105 QVector<IMode *> m_modes;
106 QVector<Command *> m_modeShortcuts;
107 QSignalMapper *m_signalMapper;
108 QList<int> m_addedContexts;
109 QList<int> m_tabOrder;
110 bool m_isReprioritizing;
112 } // namespace Core
114 #endif // MODEMANAGER_H