LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
shortcutmanager.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <QObject>
12 #include <QHash>
13 #include "shortcutsconfig.h"
16 #include "interfaces/structures.h"
17 
18 class QAction;
19 class QShortcut;
20 class IShortcutProxy;
21 
22 namespace LC
23 {
24  struct Entity;
25 }
26 
27 namespace LC::Util
28 {
55  class UTIL_SHORTCUTS_API ShortcutManager : public QObject
56  {
57  ICoreProxy_ptr CoreProxy_;
58  QObject *ContextObj_ = nullptr;
59 
60  QHash<QString, QList<QAction*>> Actions_;
61 
62  QHash<QString, QList<QShortcut*>> Shortcuts_;
63  QHash<QShortcut*, QList<QShortcut*>> Shortcut2Subs_;
64 
65  QHash<QString, Entity> Globals_;
66 
67  QMap<QString, ActionInfo> ActionInfo_;
68  public:
75  explicit ShortcutManager (const ICoreProxy_ptr& proxy, QObject *parent = nullptr);
76 
84  void SetObject (QObject *pluginObj);
85 
98  void RegisterAction (const QString& id, QAction *action);
99 
100  using IDPair_t = QPair<QString, QAction*>;
101 
102  void RegisterActions (const std::initializer_list<IDPair_t>& actions);
103 
112  void RegisterShortcut (const QString& id,
113  const ActionInfo& info, QShortcut *shortcut);
114 
129  void RegisterActionInfo (const QString& id, const ActionInfo& info);
130 
146  void RegisterGlobalShortcut (const QString& id,
147  QObject *target, const QByteArray& method,
148  const ActionInfo& info);
149 
159  void AnnounceGlobalShorcuts ();
160 
171  void SetShortcut (const QString& id, const QKeySequences_t& sequences);
172 
180  QMap<QString, ActionInfo> GetActionInfo () const;
181 
190  ShortcutManager& operator<< (const QPair<QString, QAction*>& pair);
191  private:
192  bool HasActionInfo (const QString&) const;
193  };
194 }
IShortcutProxy
Proxy for requesting shortcuts from the shortcut manager in the Core.
Definition: ishortcutproxy.h:27
QList< QKeySequence >
icoreproxy.h
LC::Util
Definition: icoreproxy.h:33
shortcutsconfig.h
LC::ActionInfo
Describes an action exposed in shortcut manager.
Definition: ihaveshortcuts.h:31
structures.h
ICoreProxy_ptr
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition: icoreproxy.h:181
LC::Util::ShortcutManager
Aids in providing configurable shortcuts.
Definition: shortcutmanager.h:55
operator<<
QDataStream & operator<<(QDataStream &out, const LC::Util::RegExp &rx)
Definition: regexp.cpp:218
LC
Definition: constants.h:14
LC::Util::ShortcutManager::IDPair_t
QPair< QString, QAction * > IDPair_t
Definition: shortcutmanager.h:100
QMap
Definition: anutil.h:17
UTIL_SHORTCUTS_API
#define UTIL_SHORTCUTS_API
Definition: shortcutsconfig.h:16
ihaveshortcuts.h