forked from qt-creator/qt-creator
ActionManager: Avoid losing shortcuts when actions are unregistered
Since the action for this ID might be unregistered temporarily, and re- registered under different circumstances. Change-Id: I6c4ef3ddf814487cc9b63ff979ebb1539cdf7c81 Task-number: QTCREATORBUG-8108 Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -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)
|
||||
{
|
||||
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();
|
||||
const QString settingsKey = QLatin1String(kKeyboardSettingsKey) + QLatin1Char('/')
|
||||
+ cmd->id().toString();
|
||||
QKeySequence key = cmd->keySequence();
|
||||
if (key != cmd->defaultKeySequence())
|
||||
settings->setValue(id.toString(), key.toString());
|
||||
ICore::settings()->setValue(settingsKey, key.toString());
|
||||
else
|
||||
settings->remove(id.toString());
|
||||
}
|
||||
settings->endGroup();
|
||||
ICore::settings()->remove(settingsKey);
|
||||
}
|
||||
|
||||
void ActionManagerPrivate::saveSettings()
|
||||
{
|
||||
const IdCmdMap::const_iterator cmdcend = m_idCmdMap.constEnd();
|
||||
for (IdCmdMap::const_iterator j = m_idCmdMap.constBegin(); j != cmdcend; ++j) {
|
||||
saveSettings(j.value());
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -985,7 +985,7 @@ void MainWindow::writeSettings()
|
||||
settings->endGroup();
|
||||
|
||||
DocumentManager::saveSettings();
|
||||
ActionManager::saveSettings(settings);
|
||||
ActionManager::saveSettings();
|
||||
EditorManagerPrivate::saveSettings();
|
||||
m_navigationWidget->saveSettings(settings);
|
||||
}
|
||||
|
Reference in New Issue
Block a user