summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-11-16 13:06:28 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-11-19 16:44:32 +0100
commit04ec14105ec41a67fe4d53a1962c9d68c5fd8715 (patch)
treeef07120df96a9ab93ffbebb7ef93081068b71f8e /src/corelib/global
parenta3303aceeb49c6c7a5fc21e083715ddbb989a9b0 (diff)
Change qt.conf key Qml2Imports to QmlImports
[ChangeLog][qt.conf] The key Paths/Qml2Imports has been renamed to Paths/QmlImports. For backwards-compatibility, Paths/Qml2Imports is still accepted and acts as default value for when Paths/QmlImports is not present. Fixes: QTBUG-98335 Change-Id: If7ffedd281eb8a87e8ab1a2b69a823e615c33541 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qlibraryinfo.cpp40
-rw-r--r--src/corelib/global/qlibraryinfo_p.h11
2 files changed, 32 insertions, 19 deletions
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 97232d8120..c31e1fdecf 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -490,8 +490,7 @@ static QString getPrefix()
#endif
}
-void QLibraryInfoPrivate::keyAndDefault(QLibraryInfo::LibraryPath loc, QString *key,
- QString *value)
+QLibraryInfoPrivate::LocationInfo QLibraryInfoPrivate::locationInfo(QLibraryInfo::LibraryPath loc)
{
/*
* To add a new entry in QLibraryInfo::LibraryPath, add it to the enum
@@ -512,9 +511,7 @@ void QLibraryInfoPrivate::keyAndDefault(QLibraryInfo::LibraryPath loc, QString *
"Binaries", "bin",
"Plugins", "plugins", // should be ${ArchData}/plugins
- // TODO: Find a way to rename this to QmlImports
- // without breaking compatibility with old qt.conf files.
- "Qml2Imports", "qml", // should be ${ArchData}/qml
+ "QmlImports", "qml", // should be ${ArchData}/qml
"ArchData", ".",
"Data", ".",
@@ -526,18 +523,21 @@ void QLibraryInfoPrivate::keyAndDefault(QLibraryInfo::LibraryPath loc, QString *
static_assert(dot.size() == 1);
static_assert(dot[0] == '.');
+ LocationInfo result;
+
if (int(loc) < qtConfEntries.count()) {
- *key = QLatin1String(qtConfEntries.viewAt(loc * 2));
- *value = QLatin1String(qtConfEntries.viewAt(loc * 2 + 1));
+ result.key = QLatin1String(qtConfEntries.viewAt(loc * 2));
+ result.defaultValue = QLatin1String(qtConfEntries.viewAt(loc * 2 + 1));
+ if (result.key == u"QmlImports")
+ result.fallbackKey = u"Qml2Imports"_qs;
#ifndef Q_OS_WIN // On Windows we use the registry
} else if (loc == QLibraryInfo::SettingsPath) {
- *key = QLatin1String("Settings");
- *value = QLatin1String(dot);
+ result.key = QLatin1String("Settings");
+ result.defaultValue = QLatin1String(dot);
#endif
- } else {
- key->clear();
- value->clear();
}
+
+ return result;
}
/*! \fn QString QLibraryInfo::location(LibraryLocation loc)
@@ -559,15 +559,21 @@ QString QLibraryInfo::path(LibraryPath p)
if (havePaths()) {
fromConf = true;
- QString key;
- QString defaultValue;
- QLibraryInfoPrivate::keyAndDefault(loc, &key, &defaultValue);
- if (!key.isNull()) {
+ auto li = QLibraryInfoPrivate::locationInfo(loc);
+ if (!li.key.isNull()) {
QSettings *config = QLibraryInfoPrivate::configuration();
Q_ASSERT(config != nullptr);
config->beginGroup(QLatin1String("Paths"));
- ret = config->value(key, defaultValue).toString();
+ if (li.fallbackKey.isNull()) {
+ ret = config->value(li.key, li.defaultValue).toString();
+ } else {
+ QVariant v = config->value(li.key);
+ if (!v.isValid())
+ v = config->value(li.fallbackKey, li.defaultValue);
+ ret = v.toString();
+ }
+
int startIndex = 0;
forever {
startIndex = ret.indexOf(QLatin1Char('$'), startIndex);
diff --git a/src/corelib/global/qlibraryinfo_p.h b/src/corelib/global/qlibraryinfo_p.h
index a0900f010b..caed0feb84 100644
--- a/src/corelib/global/qlibraryinfo_p.h
+++ b/src/corelib/global/qlibraryinfo_p.h
@@ -69,8 +69,15 @@ public:
static void reload();
static QString qtconfManualPath;
#endif
- static void keyAndDefault(QLibraryInfo::LibraryPath loc, QString *key,
- QString *value);
+
+ struct LocationInfo
+ {
+ QString key;
+ QString defaultValue;
+ QString fallbackKey;
+ };
+
+ static LocationInfo locationInfo(QLibraryInfo::LibraryPath loc);
};
QT_END_NAMESPACE