LeechCraft 0.6.70-17335-ge406ffdcaf
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<QByteArray, QList<QAction*>> Actions_;
61
62 QHash<QByteArray, QList<QShortcut*>> Shortcuts_;
63 QHash<QShortcut*, QList<QShortcut*>> Shortcut2Subs_;
64
65 QHash<QByteArray, Entity> Globals_;
66
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
152
163 void SetShortcut (const QByteArray& id, const QKeySequences_t& sequences);
164
173
182 ShortcutManager& operator<< (const QPair<QByteArray, QAction*>& pair);
183 private:
184 bool HasActionInfo (const QByteArray&) const;
185 };
186}
Proxy for requesting shortcuts from the shortcut manager in the Core.
void AnnounceGlobalShorcuts()
Announces the global shortcuts.
QPair< QByteArray, QAction * > IDPair_t
ShortcutManager(const ICoreProxy_ptr &proxy, QObject *parent)
Creates the shortcut manager.
void RegisterAction(const QByteArray &id, QAction *action)
Registers the given QAction by the given id.
void SetShortcut(const QByteArray &id, const QKeySequences_t &sequences)
Sets the key sequence for the given action.
void RegisterGlobalShortcut(const QByteArray &id, QObject *target, const QByteArray &method, const ActionInfo &info)
Registers the given global shortcut with the given id.
void RegisterActionInfo(const QByteArray &id, const ActionInfo &info)
Registers the given action info with the given id.
QMap< QByteArray, ActionInfo > GetActionInfo() const
Returns the map with information about actions.
void RegisterActions(const std::initializer_list< IDPair_t > &actions)
void RegisterShortcut(const QByteArray &id, const ActionInfo &info, QShortcut *shortcut)
Registers the given QShortcut with the given id.
Definition anutil.h:15
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition icoreproxy.h:181
QList< QKeySequence > QKeySequences_t
Definition constants.h:15
QDataStream & operator<<(QDataStream &out, const LC::Util::RegExp &rx)
Definition regexp.cpp:61
#define UTIL_SHORTCUTS_API
Describes an action exposed in shortcut manager.
A message used for inter-plugin communication.
Definition structures.h:96