Commit 460acc37 authored by Eike Ziller's avatar Eike Ziller
Browse files

Avoid removing the shortcut settings of older Qt Creator versions



The format has changed in 3.1, but keep the old settings around for a
while, in case that people switch back to 3.0 (or earlier).

Task-number: QTCREATORBUG-11947
Change-Id: I3ad6075c93f614364aae53e8291e937050277140
Reviewed-by: default avatarShawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 46d9b4ee
......@@ -49,6 +49,7 @@ namespace {
}
static const char kKeyboardSettingsKey[] = "KeyboardShortcuts";
static const char kKeyboardSettingsTransferredKey[] = "OldSettingsTransferred";
using namespace Core;
using namespace Core::Internal;
......@@ -603,10 +604,16 @@ static const char oldSequenceKey[] = "Keysequence";
void ActionManagerPrivate::initialize()
{
// TODO remove me after some period after 3.1
// TODO also remove the old settings after some period after 3.1
// settings->remove(QLatin1String(oldSettingsGroup));
// settings->contains(QLatin1String(kKeyboardSettingsKey) + QLatin1Char('/')
// + QLatin1String(kKeyboardSettingsTransferredKey))
// check if settings in old style (pre 3.1) exist
QSettings *settings = Core::ICore::settings();
if (settings->contains(QLatin1String(kKeyboardSettingsKey)))
if (settings->contains(QLatin1String(kKeyboardSettingsKey) + QLatin1Char('/')
+ QLatin1String(kKeyboardSettingsTransferredKey))) {
return;
}
// move old settings style to new settings style
QMap<Id, QKeySequence> shortcutMap;
const int shortcuts = settings->beginReadArray(QLatin1String(oldSettingsGroup));
......@@ -619,14 +626,13 @@ void ActionManagerPrivate::initialize()
settings->endArray();
// write settings in new style
settings->beginGroup(QLatin1String(kKeyboardSettingsKey));
settings->setValue(QLatin1String(kKeyboardSettingsTransferredKey), true);
QMapIterator<Id, QKeySequence> it(shortcutMap);
while (it.hasNext()) {
it.next();
settings->setValue(it.key().toString(), it.value().toString());
}
settings->endGroup();
// remove old settings
settings->remove(QLatin1String(oldSettingsGroup));
}
void ActionManagerPrivate::saveSettings(QSettings *settings)
......
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