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);
|
a->removeOverrideAction(action);
|
||||||
if (a->isEmpty()) {
|
if (a->isEmpty()) {
|
||||||
// clean up
|
// clean up
|
||||||
|
d->saveSettings(a);
|
||||||
ICore::mainWindow()->removeAction(a->action());
|
ICore::mainWindow()->removeAction(a->action());
|
||||||
// ActionContainers listen to the commands' destroyed signals
|
// ActionContainers listen to the commands' destroyed signals
|
||||||
delete a->action();
|
delete a->action();
|
||||||
@@ -363,9 +364,9 @@ bool ActionManager::isPresentationModeEnabled()
|
|||||||
return d->m_presentationModeEnabled;
|
return d->m_presentationModeEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionManager::saveSettings(QSettings *settings)
|
void ActionManager::saveSettings()
|
||||||
{
|
{
|
||||||
d->saveSettings(settings);
|
d->saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionManager::setContext(const Context &context)
|
void ActionManager::setContext(const Context &context)
|
||||||
@@ -481,18 +482,21 @@ void ActionManagerPrivate::readUserSettings(Id id, Action *cmd)
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionManagerPrivate::saveSettings(QSettings *settings)
|
void ActionManagerPrivate::saveSettings(Action *cmd)
|
||||||
{
|
{
|
||||||
settings->beginGroup(QLatin1String(kKeyboardSettingsKey));
|
const QString settingsKey = QLatin1String(kKeyboardSettingsKey) + QLatin1Char('/')
|
||||||
const IdCmdMap::const_iterator cmdcend = m_idCmdMap.constEnd();
|
+ cmd->id().toString();
|
||||||
for (IdCmdMap::const_iterator j = m_idCmdMap.constBegin(); j != cmdcend; ++j) {
|
|
||||||
const Id id = j.key();
|
|
||||||
Action *cmd = j.value();
|
|
||||||
QKeySequence key = cmd->keySequence();
|
QKeySequence key = cmd->keySequence();
|
||||||
if (key != cmd->defaultKeySequence())
|
if (key != cmd->defaultKeySequence())
|
||||||
settings->setValue(id.toString(), key.toString());
|
ICore::settings()->setValue(settingsKey, key.toString());
|
||||||
else
|
else
|
||||||
settings->remove(id.toString());
|
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());
|
||||||
}
|
}
|
||||||
settings->endGroup();
|
|
||||||
}
|
}
|
||||||
|
@@ -86,7 +86,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
ActionManager(QObject *parent = 0);
|
ActionManager(QObject *parent = 0);
|
||||||
~ActionManager();
|
~ActionManager();
|
||||||
static void saveSettings(QSettings *settings);
|
static void saveSettings();
|
||||||
static void setContext(const Context &context);
|
static void setContext(const Context &context);
|
||||||
|
|
||||||
friend class Core::Internal::CorePlugin; // initialization
|
friend class Core::Internal::CorePlugin; // initialization
|
||||||
|
@@ -67,7 +67,8 @@ public:
|
|||||||
void setContext(const Context &context);
|
void setContext(const Context &context);
|
||||||
bool hasContext(int context) const;
|
bool hasContext(int context) const;
|
||||||
|
|
||||||
void saveSettings(QSettings *settings);
|
void saveSettings();
|
||||||
|
void saveSettings(Action *cmd);
|
||||||
|
|
||||||
void showShortcutPopup(const QString &shortcut);
|
void showShortcutPopup(const QString &shortcut);
|
||||||
bool hasContext(const Context &context) const;
|
bool hasContext(const Context &context) const;
|
||||||
|
@@ -985,7 +985,7 @@ void MainWindow::writeSettings()
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
DocumentManager::saveSettings();
|
DocumentManager::saveSettings();
|
||||||
ActionManager::saveSettings(settings);
|
ActionManager::saveSettings();
|
||||||
EditorManagerPrivate::saveSettings();
|
EditorManagerPrivate::saveSettings();
|
||||||
m_navigationWidget->saveSettings(settings);
|
m_navigationWidget->saveSettings(settings);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user