Allow to use short names for Windows Registry root keys
Change-Id: I58b7681bb49e93b7577bc559d754c81d3c6f007b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
parent
cf092abdfc
commit
ac5f4a8e76
@ -442,15 +442,27 @@ QWinSettingsPrivate::QWinSettingsPrivate(QString rPath)
|
||||
if (rPath.startsWith(QLatin1String("HKEY_CURRENT_USER"))) {
|
||||
keyLength = 17;
|
||||
keyName = HKEY_CURRENT_USER;
|
||||
} else if (rPath.startsWith(QLatin1String("HKCU"))) {
|
||||
keyLength = 4;
|
||||
keyName = HKEY_CURRENT_USER;
|
||||
} else if (rPath.startsWith(QLatin1String("HKEY_LOCAL_MACHINE"))) {
|
||||
keyLength = 18;
|
||||
keyName = HKEY_LOCAL_MACHINE;
|
||||
} else if (rPath.startsWith(QLatin1String("HKLM"))) {
|
||||
keyLength = 4;
|
||||
keyName = HKEY_LOCAL_MACHINE;
|
||||
} else if (rPath.startsWith(QLatin1String("HKEY_CLASSES_ROOT"))) {
|
||||
keyLength = 17;
|
||||
keyName = HKEY_CLASSES_ROOT;
|
||||
} else if (rPath.startsWith(QLatin1String("HKCR"))) {
|
||||
keyLength = 4;
|
||||
keyName = HKEY_CLASSES_ROOT;
|
||||
} else if (rPath.startsWith(QLatin1String("HKEY_USERS"))) {
|
||||
keyLength = 10;
|
||||
keyName = HKEY_USERS;
|
||||
} else if (rPath.startsWith(QLatin1String("HKU"))) {
|
||||
keyLength = 3;
|
||||
keyName = HKEY_USERS;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -106,6 +106,7 @@ private slots:
|
||||
void testThreadSafety();
|
||||
void testEmptyData();
|
||||
void testResourceFiles();
|
||||
void testRegistryShortRootNames();
|
||||
#ifdef Q_OS_MAC
|
||||
void fileName();
|
||||
#endif
|
||||
@ -1949,6 +1950,18 @@ void tst_QSettings::testResourceFiles()
|
||||
QCOMPARE(settings.value("Field 1/Bottom").toInt(), 90);
|
||||
}
|
||||
|
||||
void tst_QSettings::testRegistryShortRootNames()
|
||||
{
|
||||
#ifndef Q_OS_WIN
|
||||
QSKIP("This test is specific to the Windows registry only.");
|
||||
#else
|
||||
QVERIFY(QSettings("HKEY_CURRENT_USER", QSettings::NativeFormat).childGroups() == QSettings("HKCU", QSettings::NativeFormat).childGroups());
|
||||
QVERIFY(QSettings("HKEY_LOCAL_MACHINE", QSettings::NativeFormat).childGroups() == QSettings("HKLM", QSettings::NativeFormat).childGroups());
|
||||
QVERIFY(QSettings("HKEY_CLASSES_ROOT", QSettings::NativeFormat).childGroups() == QSettings("HKCR", QSettings::NativeFormat).childGroups());
|
||||
QVERIFY(QSettings("HKEY_USERS", QSettings::NativeFormat).childGroups() == QSettings("HKU", QSettings::NativeFormat).childGroups());
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSettings::fromFile_data()
|
||||
{
|
||||
populateWithFormats();
|
||||
|
Loading…
Reference in New Issue
Block a user