diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 1181d1b980..c145ec4bad 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -177,8 +177,8 @@ QT_BEGIN_NAMESPACE \li "~" \li "C:/Users/" \row \li DataLocation - \li "~/Library/Application Support/", "/Library/Application Support/" - \li "C:/Users//AppData/Local/", "C:/ProgramData/" + \li "~/Library/Application Support/", "/Library/Application Support/". "/../Resources" + \li "C:/Users//AppData/Local/", "C:/ProgramData/", "", "/data" \row \li CacheLocation \li "~/Library/Caches/", "/Library/Caches/" \li "C:/Users//AppData/Local//cache" @@ -232,7 +232,7 @@ QT_BEGIN_NAMESPACE \li "/data" \li "~" \row \li DataLocation - \li "/data" + \li "/data", "/app/native/assets" \li "~/.local/share/", "/usr/local/share/", "/usr/share/" \row \li CacheLocation \li "/data/Cache" @@ -260,7 +260,8 @@ QT_BEGIN_NAMESPACE In the table above, \c is usually the organization name, the application name, or both, or a unique name generated at packaging. Similarly, is the location where this application is installed - (often a sandbox). + (often a sandbox). is the directory containing the application + executable. The paths above should not be relied upon, as they may change according to OS configuration, locale, or they may change in future Qt versions. diff --git a/src/corelib/io/qstandardpaths_blackberry.cpp b/src/corelib/io/qstandardpaths_blackberry.cpp index 815756ff9a..ec2e61bd15 100644 --- a/src/corelib/io/qstandardpaths_blackberry.cpp +++ b/src/corelib/io/qstandardpaths_blackberry.cpp @@ -103,10 +103,17 @@ QString QStandardPaths::writableLocation(StandardLocation type) QStringList QStandardPaths::standardLocations(StandardLocation type) { + QStringList dirs; + if (type == FontsLocation) return QStringList(QLatin1String("/base/usr/fonts")); - return QStringList(writableLocation(type)); + if (type == DataLocation) + dirs.append(QDir::homePath() + testModeInsert() + QLatin1String("native/assets")); + + const QString localDir = writableLocation(type); + dirs.prepend(localDir); + return dirs; } QT_END_NAMESPACE diff --git a/src/corelib/io/qstandardpaths_mac.cpp b/src/corelib/io/qstandardpaths_mac.cpp index 0efdfae253..aff9112fb7 100644 --- a/src/corelib/io/qstandardpaths_mac.cpp +++ b/src/corelib/io/qstandardpaths_mac.cpp @@ -47,6 +47,7 @@ #include #endif +#include #include QT_BEGIN_NAMESPACE @@ -184,6 +185,30 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) dirs.append(path); } + if (type == DataLocation) { + CFBundleRef mainBundle = CFBundleGetMainBundle(); + if (mainBundle) { + CFURLRef bundleUrl = CFBundleCopyBundleURL(mainBundle); + CFStringRef cfBundlePath = CFURLCopyPath(bundleUrl); + QString bundlePath = QCFString::toQString(cfBundlePath); + CFRelease(cfBundlePath); + CFRelease(bundleUrl); + + CFURLRef resourcesUrl = CFBundleCopyResourcesDirectoryURL(mainBundle); + CFStringRef cfResourcesPath = CFURLCopyPath(bundleUrl); + QString resourcesPath = QCFString::toQString(cfResourcesPath); + CFRelease(cfResourcesPath); + CFRelease(resourcesUrl); + + // Handle bundled vs unbundled executables. CFBundleGetMainBundle() returns + // a valid bundle in both cases. CFBundleCopyResourcesDirectoryURL() returns + // an absolute path for unbundled executables. + if (resourcesPath.startsWith(QLatin1Char('/'))) + dirs.append(resourcesPath); + else + dirs.append(bundlePath + resourcesPath); + } + } const QString localDir = writableLocation(type); dirs.prepend(localDir); return dirs; diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index 6a79c7c00b..200cf4c1b5 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -204,6 +204,12 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) #endif } dirs.append(result); +#ifndef QT_BOOTSTRAPPED + if (type != GenericDataLocation) { + dirs.append(QCoreApplication::applicationDirPath()); + dirs.append(QCoreApplication::applicationDirPath() + QLatin1String("/data")); + } +#endif } break; default: