diff options
author | David Faure <faure@kde.org> | 2012-03-24 09:23:25 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-24 19:07:22 +0100 |
commit | 518a4cb5abdca788c4bb59e570e97c01e44587c8 (patch) | |
tree | 96160c719612cd133a0abc2af316a945e12c5289 /src/gui/util | |
parent | ad81f75429f6c5586d667880f90f4a425f1ce968 (diff) |
Restore Qt4 compat in QDesktopServices::DataLocation
"/data/" was appended to the base directory.
Change-Id: I220f2ce74c36b795bc49c7c84106feb0709d1547
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/util')
-rw-r--r-- | src/gui/util/qdesktopservices.cpp | 18 | ||||
-rw-r--r-- | src/gui/util/qdesktopservices.h | 4 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 25fb08f532..1a6661440c 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -54,6 +54,7 @@ #include <qmutex.h> #include <qplatformservices_qpa.h> #include <qplatformintegration_qpa.h> +#include <qdir.h> QT_BEGIN_NAMESPACE @@ -283,6 +284,23 @@ void QDesktopServices::unsetUrlHandler(const QString &scheme) Use QStandardPaths::displayName() */ + +QString QDesktopServices::storageLocationImpl(StandardLocation type) +{ +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) + if (type == DataLocation) { + QString xdgDataHome = QLatin1String(qgetenv("XDG_DATA_HOME")); + if (xdgDataHome.isEmpty()) + xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); + xdgDataHome += QLatin1String("/data/") + + QCoreApplication::organizationName() + QLatin1Char('/') + + QCoreApplication::applicationName(); + return xdgDataHome; + } +#endif + return QStandardPaths::writableLocation(static_cast<QStandardPaths::StandardLocation>(type)); +} + QT_END_NAMESPACE #include "qdesktopservices.moc" diff --git a/src/gui/util/qdesktopservices.h b/src/gui/util/qdesktopservices.h index 04a639437e..280acaf277 100644 --- a/src/gui/util/qdesktopservices.h +++ b/src/gui/util/qdesktopservices.h @@ -79,12 +79,14 @@ public: }; QT_DEPRECATED static QString storageLocation(StandardLocation type) { - return QStandardPaths::writableLocation(static_cast<QStandardPaths::StandardLocation>(type)); + return storageLocationImpl(type); } QT_DEPRECATED static QString displayName(StandardLocation type) { return QStandardPaths::displayName(static_cast<QStandardPaths::StandardLocation>(type)); } #endif +private: + static QString storageLocationImpl(StandardLocation type); }; #endif // QT_NO_DESKTOPSERVICES |