diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp index f6e4c9900c5..2a6c517f61a 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp +++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp @@ -326,6 +326,7 @@ void ActionManager::unregisterAction(QAction *action, Id id) a->removeOverrideAction(action); if (a->isEmpty()) { // clean up + d->saveSettings(a); ICore::mainWindow()->removeAction(a->action()); // ActionContainers listen to the commands' destroyed signals delete a->action(); @@ -363,9 +364,9 @@ bool ActionManager::isPresentationModeEnabled() return d->m_presentationModeEnabled; } -void ActionManager::saveSettings(QSettings *settings) +void ActionManager::saveSettings() { - d->saveSettings(settings); + d->saveSettings(); } void ActionManager::setContext(const Context &context) @@ -481,18 +482,21 @@ void ActionManagerPrivate::readUserSettings(Id id, Action *cmd) settings->endGroup(); } -void ActionManagerPrivate::saveSettings(QSettings *settings) +void ActionManagerPrivate::saveSettings(Action *cmd) +{ + const QString settingsKey = QLatin1String(kKeyboardSettingsKey) + QLatin1Char('/') + + cmd->id().toString(); + QKeySequence key = cmd->keySequence(); + if (key != cmd->defaultKeySequence()) + ICore::settings()->setValue(settingsKey, key.toString()); + else + ICore::settings()->remove(settingsKey); +} + +void ActionManagerPrivate::saveSettings() { - settings->beginGroup(QLatin1String(kKeyboardSettingsKey)); const IdCmdMap::const_iterator cmdcend = m_idCmdMap.constEnd(); for (IdCmdMap::const_iterator j = m_idCmdMap.constBegin(); j != cmdcend; ++j) { - const Id id = j.key(); - Action *cmd = j.value(); - QKeySequence key = cmd->keySequence(); - if (key != cmd->defaultKeySequence()) - settings->setValue(id.toString(), key.toString()); - else - settings->remove(id.toString()); + saveSettings(j.value()); } - settings->endGroup(); } diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.h b/src/plugins/coreplugin/actionmanager/actionmanager.h index e65ef5fe73e..a25f7beb349 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.h +++ b/src/plugins/coreplugin/actionmanager/actionmanager.h @@ -86,7 +86,7 @@ signals: private: ActionManager(QObject *parent = 0); ~ActionManager(); - static void saveSettings(QSettings *settings); + static void saveSettings(); static void setContext(const Context &context); friend class Core::Internal::CorePlugin; // initialization diff --git a/src/plugins/coreplugin/actionmanager/actionmanager_p.h b/src/plugins/coreplugin/actionmanager/actionmanager_p.h index 8718108693c..3792dc7b2ef 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager_p.h +++ b/src/plugins/coreplugin/actionmanager/actionmanager_p.h @@ -67,7 +67,8 @@ public: void setContext(const Context &context); bool hasContext(int context) const; - void saveSettings(QSettings *settings); + void saveSettings(); + void saveSettings(Action *cmd); void showShortcutPopup(const QString &shortcut); bool hasContext(const Context &context) const; diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index e7423ae3d03..aa3ee201fea 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -985,7 +985,7 @@ void MainWindow::writeSettings() settings->endGroup(); DocumentManager::saveSettings(); - ActionManager::saveSettings(settings); + ActionManager::saveSettings(); EditorManagerPrivate::saveSettings(); m_navigationWidget->saveSettings(settings); }