58 SIGNAL (destroyed ()),
60 SLOT (handleActionDestroyed ()));
62 const QIcon& icon = act->icon ().isNull () ?
63 CoreProxy_->GetIconThemeManager ()->GetIcon (act->property (
"ActionIcon").toString ()) :
66 { act->text (), act->shortcuts (), icon });
68 if (CoreProxy_->GetShortcutProxy ()->HasObject (ContextObj_))
70 CoreProxy_->GetShortcutProxy ()->GetShortcuts (ContextObj_,
id));
75 Shortcuts_ [id] << shortcut;
77 SIGNAL (destroyed ()),
79 SLOT (handleShortcutDestroyed ()));
83 if (CoreProxy_->GetShortcutProxy ()->HasObject (ContextObj_))
85 CoreProxy_->GetShortcutProxy ()->GetShortcuts (ContextObj_,
id));
90 if (!ActionInfo_.contains (
id) ||
91 ActionInfo_ [id].UserVisibleText_.isEmpty ())
92 ActionInfo_ [
id] = info;
96 QObject *target,
const QByteArray& method,
const ActionInfo& info)
99 "x-leechcraft/global-action-register");
100 e.
Additional_ [
"Receiver"] = QVariant::fromValue (target);
106 ActionInfo_ [id] = info;
111 for (
const auto& entity : Globals_)
112 CoreProxy_->GetEntityManager ()->HandleEntity (entity);
117 for (
auto act : Actions_ [
id])
118 act->setShortcuts (seqs);
120 for (
auto sc : Shortcuts_ [
id])
121 sc->setKey (seqs.value (0));
123 if (Globals_.contains (
id))
125 auto& e = Globals_ [id];
126 e.Additional_ [
"Shortcut"] = QVariant::fromValue (seqs.value (0));
127 CoreProxy_->GetEntityManager ()->HandleEntity (e);
138 RegisterAction (pair.first, pair.second);
142 void ShortcutManager::handleActionDestroyed ()
144 auto act =
static_cast<QAction*
> (sender ());
145 for (
const auto&
id : Actions_.keys ())
146 Actions_ [
id].removeAll (act);
149 void ShortcutManager::handleShortcutDestroyed()
151 auto sc =
static_cast<QShortcut*
> (sender ());
152 for (
const auto&
id : Shortcuts_.keys ())
153 Shortcuts_ [
id].removeAll (sc);
Entity MakeEntity(const QVariant &entity, const QString &location, TaskParameters tp, const QString &mime)
QMap< QString, ActionInfo > GetActionInfo() const
Returns the map with information about actions.
void RegisterShortcut(const QString &id, const ActionInfo &info, QShortcut *shortcut)
Registers the given QShortcut with the given id.
ShortcutManager(ICoreProxy_ptr proxy, QObject *parent=0)
Creates the shortcut manager.
void SetObject(QObject *pluginObj)
Sets the plugin instance object of this manager.
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
void AnnounceGlobalShorcuts()
Announces the global shortcuts.
void RegisterGlobalShortcut(const QString &id, QObject *target, const QByteArray &method, const ActionInfo &info)
Registers the given global shortcut with the given id.
void RegisterAction(const QString &id, QAction *action)
Registers the given QAction by the given id.
Describes an action exposed in shortcut manager.
QKeySequences_t Seqs_
List of key sequences for this action.
Aids in providing configurable shortcuts.
QMap< QString, QVariant > Additional_
Additional parameters.
void SetShortcut(const QString &id, const QKeySequences_t &sequences)
Sets the key sequence for the given action.
Describes parameters of an entity.
void RegisterActionInfo(const QString &id, const ActionInfo &info)
Registers the given action info with the given id.