LeechCraft 0.6.70-14794-g33744ae6ce
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
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"
17
18class QAction;
19class QShortcut;
20class IShortcutProxy;
21
22namespace LC
23{
24 struct Entity;
25}
26
27namespace 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}
Proxy for requesting shortcuts from the shortcut manager in the Core.
Aids in providing configurable shortcuts.
QPair< QString, QAction * > IDPair_t
Definition: anutil.h:17
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition: icoreproxy.h:181
Definition: constants.h:15
QDataStream & operator<<(QDataStream &out, const LC::Util::RegExp &rx)
Definition: regexp.cpp:218
#define UTIL_SHORTCUTS_API
Describes an action exposed in shortcut manager.