diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qstandardpaths.cpp | 35 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths.h | 4 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_android.cpp | 5 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_blackberry.cpp | 5 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_ios.mm | 3 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_mac.cpp | 16 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_unix.cpp | 8 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_win.cpp | 34 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_winrt.cpp | 7 | ||||
-rw-r--r-- | src/gui/util/qdesktopservices.cpp | 2 |
10 files changed, 81 insertions, 38 deletions
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index bd9fa68d93..8c47ad1391 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -117,10 +117,9 @@ QT_BEGIN_NAMESPACE \value HomeLocation Returns the user's home directory (the same as QDir::homePath()). On Unix systems, this is equal to the HOME environment variable. This value might be generic or application-specific, but the returned path is never empty. - \value DataLocation Returns a directory location where persistent - application data can be stored. This is an application-specific directory. To obtain a - path to store data to be shared with other applications, use - QStandardPaths::GenericDataLocation. The returned path is never empty. + \value DataLocation Returns the same value as AppLocalDataLocation. This enumeration value + is deprecated. Using AppDataLocation is preferable since on Windows, the roaming path is + recommended. \value CacheLocation Returns a directory location where user-specific non-essential (cached) data should be written. This is an application-specific directory. The returned path is never empty. @@ -142,6 +141,15 @@ QT_BEGIN_NAMESPACE \value GenericConfigLocation Returns a directory location where user-specific configuration files shared between multiple applications should be written. This is a generic value and the returned path is never empty. + \value AppDataLocation Returns a directory location where persistent + application data can be stored. This is an application-specific directory. + To obtain a path to store data to be shared with other applications, use + QStandardPaths::GenericDataLocation. The returned path is never empty. + On the Windows operating system, this returns the roaming path. + This enum value was added in Qt 5.4. + \value AppLocalDataLocation Returns the local settings path on the Windows operating + system. On all other platforms, it returns the same value as AppDataLocation. + This enum value was added in Qt 5.4. The following table gives examples of paths on different operating systems. The first path is the writable path (unless noted). Other, additional @@ -200,6 +208,12 @@ QT_BEGIN_NAMESPACE \row \li GenericCacheLocation \li "~/Library/Caches", "/Library/Caches" \li "C:/Users/<USER>/AppData/Local/cache" + \row \li AppDataLocation + \li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources" + \li "C:/Users/<USER>/AppData/Roaming/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data" + \row \li AppLocalDataLocation + \li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources" + \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data" \endtable \table @@ -255,6 +269,12 @@ QT_BEGIN_NAMESPACE \row \li GenericCacheLocation \li "<APPROOT>/data/Cache" (there is no shared cache) \li "~/.cache" + \row \li AppDataLocation + \li "<APPROOT>/data", "<APPROOT>/app/native/assets" + \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>" + \row \li AppLocalDataLocation + \li "<APPROOT>/data", "<APPROOT>/app/native/assets" + \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>" \endtable \table @@ -293,6 +313,8 @@ QT_BEGIN_NAMESPACE \li "<USER>/Downloads", "<USER>/<APPNAME>/Downloads" \row \li GenericCacheLocation \li "<APPROOT>/cache" (there is no shared cache) + \row \li AppDataLocation + \li "<APPROOT>/files", "<USER>/<APPNAME>/files" \endtable In the table above, \c <APPNAME> is usually the organization name, the @@ -534,8 +556,6 @@ QString QStandardPaths::displayName(StandardLocation type) return QCoreApplication::translate("QStandardPaths", "Temporary Directory"); case HomeLocation: return QCoreApplication::translate("QStandardPaths", "Home"); - case DataLocation: - return QCoreApplication::translate("QStandardPaths", "Application Data"); case CacheLocation: return QCoreApplication::translate("QStandardPaths", "Cache"); case GenericDataLocation: @@ -550,6 +570,9 @@ QString QStandardPaths::displayName(StandardLocation type) return QCoreApplication::translate("QStandardPaths", "Shared Cache"); case DownloadLocation: return QCoreApplication::translate("QStandardPaths", "Download"); + case AppDataLocation: + case AppLocalDataLocation: + return QCoreApplication::translate("QStandardPaths", "Application Data"); } // not reached return QString(); diff --git a/src/corelib/io/qstandardpaths.h b/src/corelib/io/qstandardpaths.h index 08d6d7b50c..b93adbf156 100644 --- a/src/corelib/io/qstandardpaths.h +++ b/src/corelib/io/qstandardpaths.h @@ -70,7 +70,9 @@ public: ConfigLocation, DownloadLocation, GenericCacheLocation, - GenericConfigLocation + GenericConfigLocation, + AppDataLocation, + AppLocalDataLocation = DataLocation }; static QString writableLocation(StandardLocation type); diff --git a/src/corelib/io/qstandardpaths_android.cpp b/src/corelib/io/qstandardpaths_android.cpp index 60b285a3d6..9bd4b4b428 100644 --- a/src/corelib/io/qstandardpaths_android.cpp +++ b/src/corelib/io/qstandardpaths_android.cpp @@ -244,7 +244,8 @@ QString QStandardPaths::writableLocation(StandardLocation type) return getFilesDir() + testDir() + QLatin1String("/settings"); case QStandardPaths::GenericDataLocation: return getExternalStorageDirectory() + testDir(); - case QStandardPaths::DataLocation: + case QStandardPaths::AppDataLocation: + case QStandardPaths::AppLocalDataLocation: return getFilesDir() + testDir(); case QStandardPaths::GenericCacheLocation: case QStandardPaths::RuntimeLocation: @@ -301,7 +302,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) << getExternalFilesDir("DIRECTORY_DOWNLOADS"); } - if (type == DataLocation) { + if (type == AppDataLocation || type == AppLocalDataLocation) { return QStringList() << writableLocation(type) << getExternalFilesDir(); } diff --git a/src/corelib/io/qstandardpaths_blackberry.cpp b/src/corelib/io/qstandardpaths_blackberry.cpp index ec2e61bd15..2e9d62cd05 100644 --- a/src/corelib/io/qstandardpaths_blackberry.cpp +++ b/src/corelib/io/qstandardpaths_blackberry.cpp @@ -63,7 +63,8 @@ QString QStandardPaths::writableLocation(StandardLocation type) const QString sharedRoot = sharedDir.absolutePath(); switch (type) { - case DataLocation: + case AppDataLocation: + case AppLocalDataLocation: return QDir::homePath() + testModeInsert(); case DesktopLocation: case HomeLocation: @@ -108,7 +109,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) if (type == FontsLocation) return QStringList(QLatin1String("/base/usr/fonts")); - if (type == DataLocation) + if (type == AppDataLocation || type == AppLocalDataLocation) dirs.append(QDir::homePath() + testModeInsert() + QLatin1String("native/assets")); const QString localDir = writableLocation(type); diff --git a/src/corelib/io/qstandardpaths_ios.mm b/src/corelib/io/qstandardpaths_ios.mm index e2100045a6..cdca28b8b5 100644 --- a/src/corelib/io/qstandardpaths_ios.mm +++ b/src/corelib/io/qstandardpaths_ios.mm @@ -90,7 +90,8 @@ QString QStandardPaths::writableLocation(StandardLocation type) case HomeLocation: location = bundlePath(); break; - case DataLocation: + case AppDataLocation: + case AppLocalDataLocation: case GenericDataLocation: location = pathForDirectory(NSDocumentDirectory); break; diff --git a/src/corelib/io/qstandardpaths_mac.cpp b/src/corelib/io/qstandardpaths_mac.cpp index aff9112fb7..a27920899c 100644 --- a/src/corelib/io/qstandardpaths_mac.cpp +++ b/src/corelib/io/qstandardpaths_mac.cpp @@ -83,7 +83,8 @@ OSType translateLocation(QStandardPaths::StandardLocation type) return kTemporaryFolderType; case QStandardPaths::GenericDataLocation: case QStandardPaths::RuntimeLocation: - case QStandardPaths::DataLocation: + case QStandardPaths::AppDataLocation: + case QStandardPaths::AppLocalDataLocation: return kApplicationSupportFolderType; case QStandardPaths::GenericCacheLocation: case QStandardPaths::CacheLocation: @@ -128,7 +129,7 @@ static QString macLocation(QStandardPaths::StandardLocation type, short domain) QString path = getFullPath(ref); - if (type == QStandardPaths::DataLocation || type == QStandardPaths::CacheLocation) + if (type == QStandardPaths::AppDataLocation || type == QStandardPaths::AppLocalDataLocation || type == QStandardPaths::CacheLocation) appendOrganizationAndApp(path); return path; } @@ -140,9 +141,10 @@ QString QStandardPaths::writableLocation(StandardLocation type) QString path; switch (type) { case GenericDataLocation: - case DataLocation: + case AppDataLocation: + case AppLocalDataLocation: path = qttestDir + QLatin1String("/Application Support"); - if (type == DataLocation) + if (type != GenericDataLocation) appendOrganizationAndApp(path); return path; case GenericCacheLocation: @@ -165,7 +167,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) case TempLocation: return QDir::tempPath(); case GenericDataLocation: - case DataLocation: + case AppLocalDataLocation: case GenericCacheLocation: case CacheLocation: case RuntimeLocation: @@ -179,13 +181,13 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) { QStringList dirs; - if (type == GenericDataLocation || type == DataLocation || type == GenericCacheLocation || type == CacheLocation) { + if (type == GenericDataLocation || type == AppDataLocation || type == AppLocalDataLocation || type == GenericCacheLocation || type == CacheLocation) { const QString path = macLocation(type, kOnAppropriateDisk); if (!path.isEmpty()) dirs.append(path); } - if (type == DataLocation) { + if (type == AppDataLocation || type == AppLocalDataLocation) { CFBundleRef mainBundle = CFBundleGetMainBundle(); if (mainBundle) { CFURLRef bundleUrl = CFBundleCopyBundleURL(mainBundle); diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index e2ed7c3766..cde1e4bc72 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -90,7 +90,8 @@ QString QStandardPaths::writableLocation(StandardLocation type) appendOrganizationAndApp(xdgCacheHome); return xdgCacheHome; } - case DataLocation: + case AppDataLocation: + case AppLocalDataLocation: case GenericDataLocation: { QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME")); @@ -98,7 +99,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) xdgDataHome = QDir::homePath() + QLatin1String("/.qttest/share"); if (xdgDataHome.isEmpty()) xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); - if (type == QStandardPaths::DataLocation) + if (type == AppDataLocation || type == AppLocalDataLocation) appendOrganizationAndApp(xdgDataHome); return xdgDataHome; } @@ -305,7 +306,8 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) for (int i = 0; i < dirs.count(); ++i) dirs[i].append(QLatin1String("/applications")); break; - case DataLocation: + case AppDataLocation: + case AppLocalDataLocation: dirs = xdgDataDirs(); for (int i = 0; i < dirs.count(); ++i) appendOrganizationAndApp(dirs[i]); diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index 062ab49207..aaa390ac34 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -81,6 +81,18 @@ static QString convertCharArray(const wchar_t *path) return QDir::fromNativeSeparators(QString::fromWCharArray(path)); } +static inline int clsidForAppDataLocation(QStandardPaths::StandardLocation type) +{ +#ifndef Q_OS_WINCE + return type == QStandardPaths::AppDataLocation ? + CSIDL_APPDATA : // "Roaming" path + CSIDL_LOCAL_APPDATA; // Local path +#else + Q_UNUSED(type) + return CSIDL_APPDATA; +#endif +} + QString QStandardPaths::writableLocation(StandardLocation type) { QString result; @@ -92,15 +104,12 @@ QString QStandardPaths::writableLocation(StandardLocation type) wchar_t path[MAX_PATH]; switch (type) { - case ConfigLocation: // same as DataLocation, on Windows (oversight, but too late to fix it) - case GenericConfigLocation: // same as GenericDataLocation, on Windows - case DataLocation: + case ConfigLocation: // same as AppLocalDataLocation, on Windows + case GenericConfigLocation: // same as GenericDataLocation on Windows + case AppDataLocation: + case AppLocalDataLocation: case GenericDataLocation: -#if defined Q_OS_WINCE - if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE)) -#else - if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE)) -#endif + if (SHGetSpecialFolderPath(0, path, clsidForAppDataLocation(type), FALSE)) result = convertCharArray(path); if (isTestModeEnabled()) result += QLatin1String("/qttest"); @@ -165,7 +174,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) // Although Microsoft has a Cache key it is a pointer to IE's cache, not a cache // location for everyone. Most applications seem to be using a // cache directory located in their AppData directory - return writableLocation(DataLocation) + QLatin1String("/cache"); + return writableLocation(AppLocalDataLocation) + QLatin1String("/cache"); case GenericCacheLocation: return writableLocation(GenericDataLocation) + QLatin1String("/cache"); @@ -192,11 +201,12 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) { wchar_t path[MAX_PATH]; switch (type) { - case ConfigLocation: // same as DataLocation, on Windows (oversight, but too late to fix it) + case ConfigLocation: // same as AppLocalDataLocation, on Windows (oversight, but too late to fix it) case GenericConfigLocation: // same as GenericDataLocation, on Windows - case DataLocation: + case AppDataLocation: + case AppLocalDataLocation: case GenericDataLocation: - if (SHGetSpecialFolderPath(0, path, CSIDL_COMMON_APPDATA, FALSE)) { + if (SHGetSpecialFolderPath(0, path, clsidForAppDataLocation(type), FALSE)) { QString result = convertCharArray(path); if (type != GenericDataLocation && type != GenericConfigLocation) { #ifndef QT_BOOTSTRAPPED diff --git a/src/corelib/io/qstandardpaths_winrt.cpp b/src/corelib/io/qstandardpaths_winrt.cpp index bd72de11bb..172ea3fc3d 100644 --- a/src/corelib/io/qstandardpaths_winrt.cpp +++ b/src/corelib/io/qstandardpaths_winrt.cpp @@ -73,9 +73,10 @@ QString QStandardPaths::writableLocation(StandardLocation type) QString result; switch (type) { - case ConfigLocation: // same as DataLocation, on Windows + case ConfigLocation: // same as AppLocalDataLocation, on Windows case GenericConfigLocation: // same as GenericDataLocation, on Windows - case DataLocation: + case AppDataLocation: + case AppLocalDataLocation: case GenericDataLocation: { ComPtr<IApplicationDataStatics> applicationDataStatics; if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), &applicationDataStatics))) @@ -98,7 +99,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) break; } case CacheLocation: - return writableLocation(DataLocation) + QLatin1String("/cache"); + return writableLocation(AppLocalDataLocation) + QLatin1String("/cache"); case GenericCacheLocation: return writableLocation(GenericDataLocation) + QLatin1String("/cache"); diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 87146118db..460646324f 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -314,7 +314,7 @@ extern Q_CORE_EXPORT QString qt_applicationName_noFallback(); QString QDesktopServices::storageLocationImpl(QStandardPaths::StandardLocation type) { - if (type == QStandardPaths::DataLocation) { + if (type == QStandardPaths::AppLocalDataLocation) { // Preserve Qt 4 compatibility: // * QCoreApplication::applicationName() must default to empty // * Unix data location is under the "data/" subdirectory |