diff --git a/patches/qtbase/config-standardpaths.patch b/patches/qtbase/config-standardpaths.patch index c1483e69..55d66104 100755 --- a/patches/qtbase/config-standardpaths.patch +++ b/patches/qtbase/config-standardpaths.patch @@ -1,139 +1,139 @@ i#! /bin/sh patch -p1 -f -l $* < $0 exit $? diff -Nru qtbase-5.6.1.orig/src/corelib/io/qstandardpaths.cpp qtbase-5.6.1/src/corelib/io/qstandardpaths.cpp --- qtbase-5.6.1.orig/src/corelib/io/qstandardpaths.cpp 2016-07-22 15:11:23.307466618 +0200 +++ qtbase-5.6.1/src/corelib/io/qstandardpaths.cpp 2016-07-22 15:12:52.629403686 +0200 @@ -56,6 +56,14 @@ #include #endif +#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) +#include +#include +#endif +#ifdef Q_OS_WIN +#include +#endif + #ifndef QT_NO_STANDARDPATHS QT_BEGIN_NAMESPACE @@ -671,6 +679,90 @@ return qsp_testMode; } +static const char standardPathsSection[] = "StandardPaths"; + +static QSettings *findConfiguration() +{ +#ifdef QT_BUILD_QMAKE + QString qtconfig = qmake_libraryInfoFile(); + if (QFile::exists(qtconfig)) + return new QSettings(qtconfig, QSettings::IniFormat); +#else + QString qtconfig = QStringLiteral(":/qt/etc/qt.conf"); + if (QFile::exists(qtconfig)) + return new QSettings(qtconfig, QSettings::IniFormat); +#ifdef Q_OS_DARWIN + CFBundleRef bundleRef = CFBundleGetMainBundle(); + if (bundleRef) { + QCFType urlRef = CFBundleCopyResourceURL(bundleRef, + QCFString(QLatin1String("qt.conf")), + 0, + 0); + if (urlRef) { + QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle); + qtconfig = QDir::cleanPath(path); + if (QFile::exists(qtconfig)) + return new QSettings(qtconfig, QSettings::IniFormat); + } + } +#endif + if (QCoreApplication::instance()) { + QDir pwd(QCoreApplication::applicationDirPath()); + qtconfig = pwd.filePath(QLatin1String("qt.conf")); + if (QFile::exists(qtconfig)) + return new QSettings(qtconfig, QSettings::IniFormat); + } +#endif + return 0; //no luck +} + +QString QStandardPaths::presetLocation(StandardLocation type) +{ +#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) && !defined(QT_BOOTSTRAPPED) + QStringList locations = QStringList() << QStringLiteral("DesktopLocation") + << QStringLiteral("DocumentsLocation") + << QStringLiteral("FontsLocation") + << QStringLiteral("ApplicationsLocation") + << QStringLiteral("MusicLocation") + << QStringLiteral("MoviesLocation") + << QStringLiteral("PicturesLocation") + << QStringLiteral("TempLocation") + << QStringLiteral("HomeLocation") + << QStringLiteral("DataLocation") + << QStringLiteral("CacheLocation") + << QStringLiteral("GenericDataLocation") + << QStringLiteral("RuntimeLocation") + << QStringLiteral("ConfigLocation") + << QStringLiteral("DownloadLocation") + << QStringLiteral("GenericCacheLocation") + << QStringLiteral("GenericConfigLocation") + << QStringLiteral("AppDataLocation") + << QStringLiteral("AppConfigLocation") + << QStringLiteral("AppLocalDataLocation"); + + QScopedPointer settings(findConfiguration()); + if (!settings.isNull()) { + QString key = QLatin1String(standardPathsSection); + key += QLatin1Char('/'); + key += locations[type]; + const QString value = settings->value(key).toString(); +#ifdef Q_OS_WIN + if (value.isEmpty()) +#endif + return value; +#ifdef Q_OS_WIN + wchar_t expandedPath[MAX_PATH] = {0}; + if (ExpandEnvironmentStrings((wchar_t*)value.utf16(), expandedPath, MAX_PATH)) { -+ return QString::fromWCharArray(expandedPath).replace("\\", "//"); ++ return QString::fromWCharArray(expandedPath).replace("\\", "/"); + } + return value; +#endif + } +#endif // !QT_BUILD_QMAKE && !QT_NO_SETTINGS + + return QString(); +} + QT_END_NAMESPACE :diff -Nru qtbase-5.6.1.orig/src/corelib/io/qstandardpaths.h qtbase-5.6.1/src/corelib/io/qstandardpaths.h --- qtbase-5.6.1.orig/src/corelib/io/qstandardpaths.h 2016-07-22 15:11:23.307466618 +0200 +++ qtbase-5.6.1/src/corelib/io/qstandardpaths.h 2016-07-22 15:11:49.940044214 +0200 @@ -92,6 +92,8 @@ static bool isTestModeEnabled(); private: + static QString presetLocation(StandardLocation type); + // prevent construction QStandardPaths(); ~QStandardPaths(); diff -Nru qtbase-5.6.1.orig/src/corelib/io/qstandardpaths_win.cpp qtbase-5.6.1/src/corelib/io/qstandardpaths_win.cpp --- qtbase-5.6.1.orig/src/corelib/io/qstandardpaths_win.cpp 2016-07-22 15:11:23.307466618 +0200 +++ qtbase-5.6.1/src/corelib/io/qstandardpaths_win.cpp 2016-07-22 15:13:41.682467339 +0200 @@ -203,7 +203,9 @@ QString QStandardPaths::writableLocation(StandardLocation type) { - QString result; + QString result = QStandardPaths::presetLocation(type); + if (!result.isEmpty()) + return result; switch (type) { case DownloadLocation: result = sHGetKnownFolderPath(qCLSID_FOLDERID_Downloads, type);