From 557623cc4f22295e5e89462dfdff20d78b3b9cdc Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 4 Sep 2020 09:45:26 +0200 Subject: Rename QLibraryInfo::location() to path() As per ### Qt6 comment. Also rename the LibraryLocation enum to LibraryPath. Change-Id: I556025a19c5bcdf2ff52598eaba32269522d4128 Reviewed-by: Thiago Macieira --- src/corelib/global/qlibraryinfo.cpp | 21 ++++++++++++++------- src/corelib/global/qlibraryinfo.h | 12 +++++++++--- src/corelib/io/qloggingregistry.cpp | 2 +- src/corelib/io/qsettings.cpp | 4 ++-- src/corelib/kernel/qcoreapplication.cpp | 2 +- src/gui/text/qplatformfontdatabase.cpp | 2 +- .../platforms/windows/qwindowsopengltester.cpp | 2 +- src/testlib/qtestcase.cpp | 2 +- 8 files changed, 30 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 1380b08372..f2601babfc 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -356,7 +356,7 @@ QVersionNumber QLibraryInfo::version() noexcept #endif // QT_BUILD_QMAKE /* - * To add a new entry in QLibrary::LibraryLocation, add it to the enum above the bootstrapped values and: + * To add a new entry in QLibrary::LibraryPath, add it to the enum above the bootstrapped values and: * - add its relative path in the qtConfEntries[] array below * (the key is what appears in a qt.conf file) * - add a property name in qmake/property.cpp propList[] array @@ -636,12 +636,19 @@ static QString getPrefix( } #endif // QT_BUILD_QMAKE_BOOTSTRAP +/*! \fn QString QLibraryInfo::path(LibraryPath loc) + \obsolete Use path() instead. + + Returns the path specified by \a loc. + \sa path() +*/ + /*! - Returns the location specified by \a loc. + Returns the path specified by \a p. */ -QString -QLibraryInfo::location(LibraryLocation loc) +QString QLibraryInfo::path(LibraryPath p) { + const LibraryPath loc = p; #ifdef QT_BUILD_QMAKE // ends inside rawLocation ! QString ret = rawLocation(loc, FinalPaths); @@ -653,7 +660,7 @@ QLibraryInfo::location(LibraryLocation loc) } QString -QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) +QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group) { #endif // QT_BUILD_QMAKE, started inside location ! QString ret; @@ -803,7 +810,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) baseDir = prefixFromAppDirHelper(); } else { // we make any other path absolute to the prefix directory - baseDir = location(PrefixPath); + baseDir = path(PrefixPath); } #endif // QT_BUILD_QMAKE ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret); @@ -842,7 +849,7 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) } /*! - \enum QLibraryInfo::LibraryLocation + \enum QLibraryInfo::LibraryPath \keyword library location diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 4a14a9728a..3ceb20336b 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -59,7 +59,7 @@ public: static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION; #endif - enum LibraryLocation + enum LibraryPath { PrefixPath = 0, DocumentationPath, @@ -90,10 +90,16 @@ public: #endif SettingsPath = 100 }; - static QString location(LibraryLocation); // ### Qt 6: consider renaming it to path() + static QString path(LibraryPath p); +#if QT_DEPRECATED_SINCE(6, 0) + using LibraryLocation = LibraryPath; + QT_DEPRECATED_VERSION_X_6_0("Use path()") + static QString location(LibraryLocation location) + { return path(location); } +#endif #ifdef QT_BUILD_QMAKE enum PathGroup { FinalPaths, EffectivePaths, EffectiveSourcePaths, DevicePaths }; - static QString rawLocation(LibraryLocation, PathGroup); + static QString rawLocation(LibraryPath, PathGroup); static void reload(); static void sysrootify(QString *path); #endif diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 91d3e5a73c..e1e35a07ed 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -324,7 +324,7 @@ void QLoggingRegistry::initializeRules() #if !defined(QT_BOOTSTRAPPED) // get rules from Qt data configuration path const QString qtConfigPath - = QDir(QLibraryInfo::location(QLibraryInfo::DataPath)).absoluteFilePath(configFileName); + = QDir(QLibraryInfo::path(QLibraryInfo::DataPath)).absoluteFilePath(configFileName); qr = loadRulesFromFile(qtConfigPath); #endif diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 0a62ffb2be..42a0f38be3 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -992,11 +992,11 @@ static std::unique_lock initDefaultPaths(std::unique_lockisEmpty()) { diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index c89197e219..dd52242c6f 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2706,7 +2706,7 @@ QStringList QCoreApplication::libraryPathsLocked() } #endif // Q_OS_DARWIN - QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath); + QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath); if (QFile::exists(installPathPlugins)) { // Make sure we convert from backslashes to slashes. installPathPlugins = QDir(installPathPlugins).canonicalPath(); diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index d54bda4941..21d43a249f 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -357,7 +357,7 @@ QString QPlatformFontDatabase::fontDir() const { QString fontpath = QString::fromLocal8Bit(qgetenv("QT_QPA_FONTDIR")); if (fontpath.isEmpty()) - fontpath = QLibraryInfo::location(QLibraryInfo::LibrariesPath) + QLatin1String("/fonts"); + fontpath = QLibraryInfo::path(QLibraryInfo::LibrariesPath) + QLatin1String("/fonts"); return fontpath; } diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index 00ac7fa2b7..0c348a9b71 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -263,7 +263,7 @@ static inline QString resolveBugListFile(const QString &fileName) return fileName; // Try QLibraryInfo::SettingsPath which is typically empty unless specified in qt.conf, // then resolve via QStandardPaths::ConfigLocation. - const QString settingsPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); + const QString settingsPath = QLibraryInfo::path(QLibraryInfo::SettingsPath); if (!settingsPath.isEmpty()) { // SettingsPath is empty unless specified in qt.conf. const QFileInfo fi(settingsPath + u'/' + fileName); if (fi.isFile()) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 0202915e67..ac8eeb6c27 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2193,7 +2193,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co if (found.isEmpty()) { const char *testObjectName = QTestResult::currentTestObjectName(); if (testObjectName) { - const QString testsPath = QLibraryInfo::location(QLibraryInfo::TestsPath); + const QString testsPath = QLibraryInfo::path(QLibraryInfo::TestsPath); const QString candidate = QString::fromLatin1("%1/%2/%3") .arg(testsPath, QFile::decodeName(testObjectName).toLower(), base); if (QFileInfo::exists(candidate)) { -- cgit v1.2.3