From 4510c18ed3ffd2c01d11159fc2d2ec7f0eb48e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 30 Oct 2009 14:49:05 +0100 Subject: Fix QDesktopServices::DataLocation on Mac. DataLocation now behaves as on the other platforms, QCoreApplication::organizationName() and applicationName() is included in the returned path. --- dist/changes-4.6.0 | 4 ++++ src/gui/util/qdesktopservices.cpp | 9 --------- src/gui/util/qdesktopservices_mac.cpp | 9 ++++++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 7f723da..abe4427 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -143,3 +143,7 @@ information about a particular change. function setFloatingPointPrecision(). Set Qt_4_5 as the version of the QDataStream to get the behavior of previous versions. + - On Mac OS X, QDesktopServices::storageLocation(DataLocation) now includes + QCoreApplication::organizationName() and QCoreApplication::applicationName() + if those are set. This matches the behavior on the other platforms. + \ No newline at end of file diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 1690d87..85b539f 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -294,15 +294,6 @@ void QDesktopServices::unsetUrlHandler(const QString &scheme) Rest of the standard locations point to folder on same drive with executable, except that if executable is in ROM the folder from C drive is returned. - \note On Mac OS X, DataLocation does not include QCoreApplication::organizationName. - Use code like this to add it: - - \code - QString location = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - #ifdef Q_WS_MAC - location.insert(location.count() - QCoreApplication::applicationName().count(), - QCoreApplication::organizationName() + "/"); - #endif \endcode */ diff --git a/src/gui/util/qdesktopservices_mac.cpp b/src/gui/util/qdesktopservices_mac.cpp index 0626e0a..23f9e60 100644 --- a/src/gui/util/qdesktopservices_mac.cpp +++ b/src/gui/util/qdesktopservices_mac.cpp @@ -153,9 +153,12 @@ QString QDesktopServices::storageLocation(StandardLocation type) QString path = getFullPath(ref); - QString appName = QCoreApplication::applicationName(); - if (!appName.isEmpty() && (type == DataLocation || type == CacheLocation)) - path += QLatin1Char('/') + appName; + if (type == DataLocation || type == CacheLocation) { + if (QCoreApplication::organizationName().isEmpty() == false) + path += QLatin1Char('/') + QCoreApplication::organizationName(); + if (QCoreApplication::applicationName().isEmpty() == false) + path += QLatin1Char('/') + QCoreApplication::applicationName(); + } return path; } -- cgit v0.12