23 , CoreProxy_ { proxy }
40 for (
auto& list : Actions_)
44 if (HasActionInfo (
id))
46 const auto& info = ActionInfo_ [id];
47 if (act->text ().isEmpty ())
48 act->setText (info.UserVisibleText_);
49 if (act->icon ().isNull () &&
50 act->property (
"ActionIcon").isNull ())
51 act->setIcon (info.Icon_);
55 const auto& icon = act->icon ().isNull () ?
56 CoreProxy_->GetIconThemeManager ()->GetIcon (act->property (
"ActionIcon").toString ()) :
66 if (CoreProxy_->GetShortcutProxy ()->HasObject (ContextObj_))
68 CoreProxy_->GetShortcutProxy ()->GetShortcuts (ContextObj_,
id));
73 for (
const auto& [
id, act] : pairs)
79 Shortcuts_ [id] << shortcut;
85 for (
auto& list : Shortcuts_)
86 list.removeAll (shortcut);
88 qDeleteAll (Shortcut2Subs_.take (shortcut));
93 if (CoreProxy_->GetShortcutProxy ()->HasObject (ContextObj_))
95 CoreProxy_->GetShortcutProxy ()->GetShortcuts (ContextObj_,
id));
100 if (!HasActionInfo (
id))
101 ActionInfo_ [id] = info;
105 QObject *target,
const QByteArray& method,
const ActionInfo& info)
108 QStringLiteral (
"x-leechcraft/global-action-register"));
109 e.
Additional_ [QStringLiteral (
"Receiver")] = QVariant::fromValue (target);
111 e.
Additional_ [QStringLiteral (
"Method")] = method;
112 e.
Additional_ [QStringLiteral (
"Shortcut")] = QVariant::fromValue (info.
Seqs_.value (0));
116 ActionInfo_ [id] = info;
121 for (
const auto& entity : Globals_)
122 CoreProxy_->GetEntityManager ()->HandleEntity (entity);
127 for (
auto act : Actions_ [
id])
128 act->setShortcuts (seqs);
130 for (
auto sc : Shortcuts_ [
id])
132 sc->setKey (seqs.value (0));
133 qDeleteAll (Shortcut2Subs_.take (sc));
135 const int seqsSize = seqs.size ();
136 for (
int i = 1; i < seqsSize; ++i)
138 auto subsc =
new QShortcut { sc->parentWidget () };
139 subsc->setContext (sc->context ());
140 subsc->setKey (seqs.value (i));
142 &QShortcut::activated,
144 &QShortcut::activated);
145 Shortcut2Subs_ [sc] << subsc;
149 if (Globals_.contains (
id))
151 auto& e = Globals_ [id];
152 e.Additional_ [QStringLiteral (
"Shortcut")] = QVariant::fromValue (seqs.value (0));
153 e.Additional_ [QStringLiteral (
"AltShortcuts")] =
Util::Map (seqs.mid (1),
154 &QVariant::fromValue<QKeySequence>);
155 CoreProxy_->GetEntityManager ()->HandleEntity (e);
170 bool ShortcutManager::HasActionInfo (
const QString&
id)
const
172 return ActionInfo_.contains (
id) &&
173 !ActionInfo_ [id].UserVisibleText_.isEmpty ();