summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Alpert <aalpert@blackberry.com>2013-08-23 16:05:12 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-10 17:55:10 +0100
commit2fac63c76d1527c2ef0bf77355d944efaa59af3d (patch)
tree484a7ad427d227a9002fb39ae0690361eda25e4e /src
parent16a26931d481a157f6ff09a3db1b0c3e33a7366d (diff)
Add Asset Locations to QStandardPaths::DataLocation
The locations of UI assets are deployed to is being added as a read-only location under DataLocation. As such a path is located differently on certain mobile platforms, such as Android and BlackBerry, having an entry in StandardPaths will make it easier to write cross-platform code. Change-Id: I4533c90ed7157725a8604591595b350c7f616723 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qstandardpaths.cpp9
-rw-r--r--src/corelib/io/qstandardpaths_blackberry.cpp9
-rw-r--r--src/corelib/io/qstandardpaths_mac.cpp25
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp6
4 files changed, 44 insertions, 5 deletions
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/<USER>"
\row \li DataLocation
- \li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>"
- \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>"
+ \li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources"
+ \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data"
\row \li CacheLocation
\li "~/Library/Caches/<APPNAME>", "/Library/Caches/<APPNAME>"
\li "C:/Users/<USER>/AppData/Local/<APPNAME>/cache"
@@ -232,7 +232,7 @@ QT_BEGIN_NAMESPACE
\li "<APPROOT>/data"
\li "~"
\row \li DataLocation
- \li "<APPROOT>/data"
+ \li "<APPROOT>/data", "<APPROOT>/app/native/assets"
\li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>"
\row \li CacheLocation
\li "<APPROOT>/data/Cache"
@@ -260,7 +260,8 @@ QT_BEGIN_NAMESPACE
In the table above, \c <APPNAME> is usually the organization name, the
application name, or both, or a unique name generated at packaging.
Similarly, <APPROOT> is the location where this application is installed
- (often a sandbox).
+ (often a sandbox). <APPDIR> 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 <qcoreapplication.h>
#endif
+#include <CoreFoundation/CoreFoundation.h>
#include <ApplicationServices/ApplicationServices.h>
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: