dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
modemanager.h
Go to the documentation of this file.
1 
13 /*
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.
18  *
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.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #ifndef MODEMANAGER_H
29 #define MODEMANAGER_H
30 
31 #include <QObject>
32 #include <QList>
33 #include <QMap>
34 #include <QVector>
35 
36 #include <coreplugin/core_global.h>
37 
38 QT_BEGIN_NAMESPACE
39 class QSignalMapper;
40 class QMenu;
41 class QIcon;
42 class MyTabWidget;
43 QT_END_NAMESPACE
44 
45 namespace Core {
46 
47 class Command;
48 class IMode;
49 
50 namespace Internal {
51  class MainWindow;
52 } // namespace Internal
53 
54 class CORE_EXPORT ModeManager : public QObject
55 {
56  Q_OBJECT
57 
58 public:
59  ModeManager(Internal::MainWindow *mainWindow, MyTabWidget *modeStack);
60 
61  void init();
62  static ModeManager *instance() { return m_instance; }
63 
64  IMode *currentMode() const;
65  IMode *mode(const QString &id) const;
66 
67  void addAction(Command *command, int priority, QMenu *menu = nullptr);
68  void addWidget(QWidget *widget);
69  void updateModeNameIcon(IMode *mode, const QIcon &icon, const QString &label);
70  QVector<IMode *> modes() const { return m_modes; }
71  void reorderModes(QMap<QString, int> priorities);
72 
73 signals:
74  void currentModeAboutToChange(Core::IMode *mode);
75  void currentModeChanged(Core::IMode *mode);
76  void newModeOrder(QVector<IMode *> modes);
77  void modesChanged();
78 
79 public slots:
80  void activateMode(const QString &id);
81  void activateModeByWorkspaceName(const QString &id);
82  void setFocusToCurrentMode();
83  void triggerAction(const QString &actionId);
84 
85 private slots:
86  void objectAdded(QObject *obj);
87  void aboutToRemoveObject(QObject *obj);
88  void currentTabAboutToChange(int index);
89  void currentTabChanged(int index);
90  void updateModeToolTip();
91  void tabMoved(int from, int to);
92 
93 private:
94  int indexOf(const QString &id) const;
95  void setDefaultKeyshortcuts();
96 
97  static ModeManager *m_instance;
98  Internal::MainWindow *m_mainWindow;
99  MyTabWidget *m_modeStack;
100  QMap<Command *, int> m_actions;
101  QVector<IMode *> m_modes;
102  QVector<Command *> m_modeShortcuts;
103  QSignalMapper *m_signalMapper;
104  QList<int> m_addedContexts;
105  QList<int> m_tabOrder;
106  bool m_isReprioritizing;
107 };
108 
109 } // namespace Core
110 
111 #endif // MODEMANAGER_H
static ModeManager * instance()
Definition: modemanager.h:62
QVector< IMode * > modes() const
Definition: modemanager.h:70
The class Command represents an action like a menu item, tool button, or shortcut. You don't create Command objects directly, instead use {ActionManager::registerAction()} to register an action and retrieve a Command. The Command object represents the user visible action and its properties. If multiple actions are registered with the same ID (but different contexts) the returned Command is the shared one between these actions.
Definition: command.h:43