LeechCraft  0.6.70-16373-g319c272718
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<QByteArray, QList<QAction*>> Actions_;
61 
62  QHash<QByteArray, QList<QShortcut*>> Shortcuts_;
63  QHash<QShortcut*, QList<QShortcut*>> Shortcut2Subs_;
64 
65  QHash<QByteArray, Entity> Globals_;
66 
67  QMap<QByteArray, ActionInfo> ActionInfo_;
68  public:
76  explicit ShortcutManager (const ICoreProxy_ptr& proxy, QObject *parent);
77 
90  void RegisterAction (const QByteArray& id, QAction *action);
91 
92  using IDPair_t = QPair<QByteArray, QAction*>;
93 
94  void RegisterActions (const std::initializer_list<IDPair_t>& actions);
95 
104  void RegisterShortcut (const QByteArray& id,
105  const ActionInfo& info, QShortcut *shortcut);
106 
121  void RegisterActionInfo (const QByteArray& id, const ActionInfo& info);
122 
138  void RegisterGlobalShortcut (const QByteArray& id,
139  QObject *target, const QByteArray& method,
140  const ActionInfo& info);
141 
151  void AnnounceGlobalShorcuts ();
152 
163  void SetShortcut (const QByteArray& id, const QKeySequences_t& sequences);
164 
172  QMap<QByteArray, ActionInfo> GetActionInfo () const;
173 
182  ShortcutManager& operator<< (const QPair<QByteArray, QAction*>& pair);
183  private:
184  bool HasActionInfo (const QByteArray&) const;
185  };
186 }
Describes an action exposed in shortcut manager.
#define UTIL_SHORTCUTS_API
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition: icoreproxy.h:181
Proxy for requesting shortcuts from the shortcut manager in the Core.
Aids in providing configurable shortcuts.
QPair< QByteArray, QAction * > IDPair_t
Definition: anutil.h:17