Commit f3d7bbff authored by Nicolas Arnaud-Cormos's avatar Nicolas Arnaud-Cormos Committed by Tobias Hunger
Browse files

Add removeShortcut method to the actionManager.



Almost working as the removeAction, but we don't need to check if the command is empty here.

Merge-request: 236
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent c41d9412
......@@ -377,7 +377,7 @@ void ActionManagerPrivate::unregisterAction(QAction *action, const Id &id)
QTC_ASSERT(c, return);
a = qobject_cast<Action *>(c);
if (!a) {
qWarning() << "registerAction: id" << id << "is registered with a different command type.";
qWarning() << "unregisterAction: id" << id << "is registered with a different command type.";
return;
}
a->removeOverrideAction(action);
......@@ -517,3 +517,20 @@ void ActionManagerPrivate::saveSettings(QSettings *settings)
settings->endArray();
}
void ActionManagerPrivate::unregisterShortcut(const Core::Id &id)
{
Shortcut *sc = 0;
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
CommandPrivate *c = m_idCmdMap.value(uid, 0);
QTC_ASSERT(c, return);
sc = qobject_cast<Shortcut *>(c);
if (!sc) {
qWarning() << "unregisterShortcut: id" << id << "is registered with a different command type.";
return;
}
delete sc->shortcut();
m_idCmdMap.remove(uid);
delete sc;
emit commandListChanged();
}
......@@ -71,6 +71,7 @@ public:
virtual QList<Command *> commands() const = 0;
virtual void unregisterAction(QAction *action, const Id &id) = 0;
virtual void unregisterShortcut(const Id &id) = 0;
signals:
void commandListChanged();
......
......@@ -91,6 +91,7 @@ public:
Core::Command *command(const Id &id) const;
Core::ActionContainer *actionContainer(const Id &id) const;
void unregisterAction(QAction *action, const Id &id);
void unregisterShortcut(const Id &id);
private:
bool hasContext(const Context &context) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment