forked from qt-creator/qt-creator
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: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user