LP-56 - Better txpid option namings, fix tabs-spaces, tooltips. headers, variable...
[librepilot.git] / ground / openpilotgcs / src / plugins / coreplugin / modemanager.h
blob6568f5473a4fd4c992e2c8605bbdfca4ff582f1b
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 FancyTabWidget;
52 class FancyActionBar;
53 class MainWindow;
54 } // namespace Internal
56 class CORE_EXPORT ModeManager : public QObject {
57 Q_OBJECT
59 public:
60 ModeManager(Internal::MainWindow *mainWindow, MyTabWidget *modeStack);
62 void init();
63 static ModeManager *instance()
65 return m_instance;
68 IMode *currentMode() const;
69 IMode *mode(const QString &id) const;
71 void addAction(Command *command, int priority, QMenu *menu = 0);
72 void addWidget(QWidget *widget);
73 void updateModeNameIcon(IMode *mode, const QIcon &icon, const QString &label);
74 QVector<IMode *> modes() const
76 return m_modes;
78 void reorderModes(QMap<QString, int> priorities);
80 signals:
81 void currentModeAboutToChange(Core::IMode *mode);
82 void currentModeChanged(Core::IMode *mode);
83 void newModeOrder(QVector<IMode *> modes);
85 public slots:
86 void activateMode(const QString &id);
87 void activateModeByWorkspaceName(const QString &id);
88 void setFocusToCurrentMode();
89 void triggerAction(const QString &actionId);
91 private slots:
92 void objectAdded(QObject *obj);
93 void aboutToRemoveObject(QObject *obj);
94 void currentTabAboutToChange(int index);
95 void currentTabChanged(int index);
96 void updateModeToolTip();
97 void tabMoved(int from, int to);
99 private:
100 int indexOf(const QString &id) const;
101 void setDefaultKeyshortcuts();
103 static ModeManager *m_instance;
104 Internal::MainWindow *m_mainWindow;
105 MyTabWidget *m_modeStack;
106 QMap<Command *, int> m_actions;
107 QVector<IMode *> m_modes;
108 QVector<Command *> m_modeShortcuts;
109 QSignalMapper *m_signalMapper;
110 QList<int> m_addedContexts;
111 QList<int> m_tabOrder;
112 bool m_isReprioritizing;
114 } // namespace Core
116 #endif // MODEMANAGER_H