diff options
Diffstat (limited to 'src/corelib/io/qstandardpaths.cpp')
-rw-r--r-- | src/corelib/io/qstandardpaths.cpp | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index ec8e6899e4..792721f50d 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -126,6 +126,12 @@ using namespace Qt::StringLiterals; template files can be stored. This is a generic value. Note that the returned path may be empty if the system has no concept of a templates location. This enum value was added in Qt 6.4. + \value [since 6.7] StateLocation Returns a directory location where user-specific application + state data files should be written. This is an application-specific directory, + and the returned path is never empty. + \value [since 6.7] GenericStateLocation Returns a directory location where shared state data files + across applications should be written. This value might be generic or application-specific, + but the returned path is never empty. The following table gives examples of paths on different operating systems. The first path is the writable path (unless noted). Other, additional @@ -166,6 +172,9 @@ using namespace Qt::StringLiterals; \row \li CacheLocation \li "~/Library/Caches/<APPNAME>", "/Library/Caches/<APPNAME>" \li "C:/Users/<USER>/AppData/Local/<APPNAME>/cache" + \row \li StateLocation + \li "~/Library/Preferences/<APPNAME>/State" + \li "C:/Users/<USER>/AppData/Local/<APPNAME>/State", "C:/ProgramData/<APPNAME>/State" \row \li GenericDataLocation \li "~/Library/Application Support", "/Library/Application Support" \li "C:/Users/<USER>/AppData/Local", "C:/ProgramData", "<APPDIR>", "<APPDIR>/data" @@ -184,6 +193,9 @@ using namespace Qt::StringLiterals; \row \li GenericCacheLocation \li "~/Library/Caches", "/Library/Caches" \li "C:/Users/<USER>/AppData/Local/cache" + \row \li GenericStateLocation + \li "~/Library/Preferences/State" + \li "C:/Users/<USER>/AppData/Local/State", "C:/ProgramData/State" \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", "<APPDIR>/data/<APPNAME>" @@ -222,6 +234,8 @@ using namespace Qt::StringLiterals; \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>" \row \li CacheLocation \li "~/.cache/<APPNAME>" + \row \li StateLocation + \li "~/.local/state/<APPNAME>" \row \li GenericDataLocation \li "~/.local/share", "/usr/local/share", "/usr/share" \row \li RuntimeLocation @@ -234,6 +248,8 @@ using namespace Qt::StringLiterals; \li "~/Downloads" \row \li GenericCacheLocation \li "~/.cache" + \row \li GenericStateLocation + \li "~/.local/state" \row \li AppDataLocation \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>" \row \li AppConfigLocation @@ -250,7 +266,7 @@ using namespace Qt::StringLiterals; \li "<APPROOT>/files" \li "<APPROOT>/Documents/Desktop" \row \li DocumentsLocation - \li "<USER>/Documents", "<USER>/<APPNAME>/Documents" + \li "<USER>/Documents" [*], "<USER>/<APPNAME>/Documents" \li "<APPROOT>/Documents" \row \li FontsLocation \li "/system/fonts" (not writable) @@ -259,13 +275,13 @@ using namespace Qt::StringLiterals; \li not supported (directory not readable) \li not supported \row \li MusicLocation - \li "<USER>/Music", "<USER>/<APPNAME>/Music" + \li "<USER>/Music" [*], "<USER>/<APPNAME>/Music" \li "<APPROOT>/Documents/Music" \row \li MoviesLocation - \li "<USER>/Movies", "<USER>/<APPNAME>/Movies" + \li "<USER>/Movies" [*], "<USER>/<APPNAME>/Movies" \li "<APPROOT>/Documents/Movies" \row \li PicturesLocation - \li "<USER>/Pictures", "<USER>/<APPNAME>/Pictures" + \li "<USER>/Pictures" [*], "<USER>/<APPNAME>/Pictures" \li "<APPROOT>/Documents/Pictures", "assets-library://" \row \li TempLocation \li "<APPROOT>/cache" @@ -279,8 +295,12 @@ using namespace Qt::StringLiterals; \row \li CacheLocation \li "<APPROOT>/cache", "<USER>/<APPNAME>/cache" \li "<APPROOT>/Library/Caches" + \row \li StateLocation + \li "<APPROOT>/files/state" + \row \li GenericStateLocation (there is shared state) + \li "<APPROOT>/files/state" \row \li GenericDataLocation - \li "<USER>" + \li "<USER>" [*] or "<USER>/<APPNAME>/files" \li "<APPROOT>/Library/Application Support" \row \li RuntimeLocation \li "<APPROOT>/cache" @@ -292,7 +312,7 @@ using namespace Qt::StringLiterals; \li "<APPROOT>/files/settings" (there is no shared settings) \li "<APPROOT>/Library/Preferences" \row \li DownloadLocation - \li "<USER>/Downloads", "<USER>/<APPNAME>/Downloads" + \li "<USER>/Downloads" [*], "<USER>/<APPNAME>/Downloads" \li "<APPROOT>/Documents/Downloads" \row \li GenericCacheLocation \li "<APPROOT>/cache" (there is no shared cache) @@ -328,6 +348,11 @@ using namespace Qt::StringLiterals; \note On Android, reading/writing to GenericDataLocation needs the READ_EXTERNAL_STORAGE/WRITE_EXTERNAL_STORAGE permission granted. + \note [*] On Android 11 and above, public directories are no longer directly accessible + in scoped storage mode. Thus, paths of the form \c "<USER>/DirName" are not returned. + Instead, you can use \l QFileDialog which uses the Storage Access Framework (SAF) + to access such directories. + \note On iOS, if you do pass \c {QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()} as argument to \l{QFileDialog::setDirectory()}, a native image picker dialog will be used for accessing the user's photo album. @@ -515,10 +540,12 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr } /*! + \fn QString QStandardPaths::displayName(StandardLocation type) + \include standardpath/functiondocs.qdocinc displayName */ -#if !defined(Q_OS_MAC) && !defined(QT_BOOTSTRAPPED) +#if !defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED) QString QStandardPaths::displayName(StandardLocation type) { switch (type) { @@ -544,6 +571,8 @@ QString QStandardPaths::displayName(StandardLocation type) return QCoreApplication::translate("QStandardPaths", "Application Data"); case CacheLocation: return QCoreApplication::translate("QStandardPaths", "Cache"); + case StateLocation: + return QCoreApplication::translate("QStandardPaths", "State"); case GenericDataLocation: return QCoreApplication::translate("QStandardPaths", "Shared Data"); case RuntimeLocation: @@ -554,6 +583,8 @@ QString QStandardPaths::displayName(StandardLocation type) return QCoreApplication::translate("QStandardPaths", "Shared Configuration"); case GenericCacheLocation: return QCoreApplication::translate("QStandardPaths", "Shared Cache"); + case GenericStateLocation: + return QCoreApplication::translate("QStandardPaths", "Shared State"); case DownloadLocation: return QCoreApplication::translate("QStandardPaths", "Download"); case AppDataLocation: |