summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Feber <bfeber@protonmail.com>2021-07-22 22:29:01 +0200
committerBjörn Feber <bfeber@protonmail.com>2022-01-01 18:34:30 +0200
commit68c4669ce49aad21beff0e8ef0122a86d53b12e2 (patch)
tree01991f4393bf8cf2b12a0f6e28e28565906fd575
parentffcf4f400102aa3626bcf1dda6f8a703553f59f7 (diff)
Add PublicShare and Templates QStandardPaths
These directories are common on desktop operating systems. "Public" is used for sharing files with other users and "Templates" lets you add new files to the file creation desktop menu (for example in a file manager). An example use in a Qt application would be KDE's KIO having default icons for both directories. This is where they point to: Windows: C:/Users/Public, C:/Users/<USER>/AppData/Roaming/Microsoft/Windows/Templates macOS: ~/Public, ~/Templates Unix: ~/Public, ~/Templates Task-number: QTBUG-86106 Task-number: QTBUG-78092 Change-Id: Ifca60c7d2a6dc2109ec290e8fb109ee2d5ca4d38 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/io/qstandardpaths.cpp28
-rw-r--r--src/corelib/io/qstandardpaths.h4
-rw-r--r--src/corelib/io/qstandardpaths_android.cpp2
-rw-r--r--src/corelib/io/qstandardpaths_haiku.cpp4
-rw-r--r--src/corelib/io/qstandardpaths_mac.mm9
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp12
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp6
7 files changed, 63 insertions, 2 deletions
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index b76eafcb89..e07cea451b 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -153,6 +153,14 @@ QT_BEGIN_NAMESPACE
configuration files should be written. This is an application-specific directory,
and the returned path is never empty.
This enum value was added in Qt 5.5.
+ \value PublicShareLocation Returns a directory location where user-specific publicly shared files
+ and directories can be stored. This is a generic value. Note that the returned path may be
+ empty if the system has no concept of a publicly shared location.
+ This enum value was added in Qt 6.3.
+ \value TemplatesLocation Returns a directory location where user-specific
+ 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.3.
The following table gives examples of paths on different operating systems.
The first path is the writable path (unless noted). Other, additional
@@ -217,6 +225,12 @@ QT_BEGIN_NAMESPACE
\row \li AppConfigLocation
\li "~/Library/Preferences/<APPNAME>"
\li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>"
+ \row \li PublicShareLocation
+ \li "~/Public"
+ \li "C:/Users/Public"
+ \row \li TemplatesLocation
+ \li "~/Templates"
+ \li "C:/Users/<USER>/AppData/Roaming/Microsoft/Windows/Templates"
\endtable
\table
@@ -259,6 +273,10 @@ QT_BEGIN_NAMESPACE
\li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>"
\row \li AppConfigLocation
\li "~/.config/<APPNAME>", "/etc/xdg/<APPNAME>"
+ \row \li PublicShareLocation
+ \li "~/Public"
+ \row \li TemplatesLocation
+ \li "~/Templates"
\endtable
\table
@@ -320,6 +338,12 @@ QT_BEGIN_NAMESPACE
\row \li AppConfigLocation
\li "<APPROOT>/files/settings"
\li "<APPROOT>/Library/Preferences/<APPNAME>"
+ \row \li PublicShareLocation
+ \li not supported
+ \li not supported
+ \row \li TemplatesLocation
+ \li not supported
+ \li not supported
\endtable
In the table above, \c <APPNAME> is usually the organization name, the
@@ -572,6 +596,10 @@ QString QStandardPaths::displayName(StandardLocation type)
case AppDataLocation:
case AppConfigLocation:
return QCoreApplication::translate("QStandardPaths", "Application Configuration");
+ case PublicShareLocation:
+ return QCoreApplication::translate("QStandardPaths", "Public");
+ case TemplatesLocation:
+ return QCoreApplication::translate("QStandardPaths", "Templates");
}
// not reached
return QString();
diff --git a/src/corelib/io/qstandardpaths.h b/src/corelib/io/qstandardpaths.h
index 2ee228beec..145591f58d 100644
--- a/src/corelib/io/qstandardpaths.h
+++ b/src/corelib/io/qstandardpaths.h
@@ -72,7 +72,9 @@ public:
GenericCacheLocation,
GenericConfigLocation,
AppDataLocation,
- AppConfigLocation
+ AppConfigLocation,
+ PublicShareLocation,
+ TemplatesLocation
};
Q_ENUM(StandardLocation)
diff --git a/src/corelib/io/qstandardpaths_android.cpp b/src/corelib/io/qstandardpaths_android.cpp
index d5ece85818..28993a16dc 100644
--- a/src/corelib/io/qstandardpaths_android.cpp
+++ b/src/corelib/io/qstandardpaths_android.cpp
@@ -200,6 +200,8 @@ QString QStandardPaths::writableLocation(StandardLocation type)
return getFilesDir();
case QStandardPaths::ApplicationsLocation:
case QStandardPaths::FontsLocation:
+ case QStandardPaths::PublicShareLocation:
+ case QStandardPaths::TemplatesLocation:
default:
break;
}
diff --git a/src/corelib/io/qstandardpaths_haiku.cpp b/src/corelib/io/qstandardpaths_haiku.cpp
index 044d69fe45..cac7767e6b 100644
--- a/src/corelib/io/qstandardpaths_haiku.cpp
+++ b/src/corelib/io/qstandardpaths_haiku.cpp
@@ -137,6 +137,8 @@ QString QStandardPaths::writableLocation(StandardLocation type)
case MusicLocation:
case MoviesLocation:
case DownloadLocation:
+ case PublicShareLocation:
+ case TemplatesLocation:
case HomeLocation:
return haikuStandardPath(B_USER_DIRECTORY);
case FontsLocation:
@@ -178,6 +180,8 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
case MusicLocation:
case MoviesLocation:
case DownloadLocation:
+ case PublicShareLocation:
+ case TemplatesLocation:
case HomeLocation:
paths += haikuStandardPath(B_USER_NONPACKAGED_DIRECTORY);
break;
diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm
index a95e6a3bb1..8c102d6928 100644
--- a/src/corelib/io/qstandardpaths_mac.mm
+++ b/src/corelib/io/qstandardpaths_mac.mm
@@ -85,6 +85,9 @@ static NSSearchPathDirectory searchPathDirectory(QStandardPaths::StandardLocatio
return NSCachesDirectory;
case QStandardPaths::DownloadLocation:
return NSDownloadsDirectory;
+ case QStandardPaths::PublicShareLocation:
+ return NSSharedPublicDirectory;
+ case QStandardPaths::TemplatesLocation:
default:
return (NSSearchPathDirectory)0;
}
@@ -136,6 +139,12 @@ static QString baseWritableLocation(QStandardPaths::StandardLocation type,
break;
case QStandardPaths::ApplicationsLocation:
break;
+ case QStandardPaths::PublicShareLocation:
+ path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Public");
+ break;
+ case QStandardPaths::TemplatesLocation:
+ path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Templates");
+ break;
#endif
case QStandardPaths::FontsLocation:
path = pathForDirectory(NSLibraryDirectory, mask) + QLatin1String("/Fonts");
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index fa35265257..6acec9c034 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -88,6 +88,10 @@ static QLatin1String xdg_key_name(QStandardPaths::StandardLocation type)
return QLatin1String("VIDEOS");
case QStandardPaths::DownloadLocation:
return QLatin1String("DOWNLOAD");
+ case QStandardPaths::PublicShareLocation:
+ return QLatin1String("PUBLICSHARE");
+ case QStandardPaths::TemplatesLocation:
+ return QLatin1String("TEMPLATES");
default:
return QLatin1String();
}
@@ -338,6 +342,14 @@ QString QStandardPaths::writableLocation(StandardLocation type)
path = writableLocation(GenericDataLocation) + QLatin1String("/applications");
break;
+ case PublicShareLocation:
+ path = QDir::homePath() + QLatin1String("/Public");
+ break;
+
+ case TemplatesLocation:
+ path = QDir::homePath() + QLatin1String("/Templates");
+ break;
+
default:
break;
}
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 36541a4f81..93034dd9b0 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -144,8 +144,10 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type)
FOLDERID_LocalAppData, // GenericConfigLocation ("Local" path)
FOLDERID_RoamingAppData,// AppDataLocation ("Roaming" path)
FOLDERID_LocalAppData, // AppConfigLocation ("Local" path)
+ FOLDERID_Public, // PublicShareLocation
+ FOLDERID_Templates, // TemplatesLocation
};
- static_assert(sizeof(folderIds) / sizeof(folderIds[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
+ static_assert(sizeof(folderIds) / sizeof(folderIds[0]) == size_t(QStandardPaths::TemplatesLocation + 1));
// folders for low integrity processes
static const GUID folderIds_li[] = {
@@ -166,6 +168,8 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type)
FOLDERID_LocalAppDataLow,// GenericConfigLocation ("Local" path)
FOLDERID_RoamingAppData, // AppDataLocation ("Roaming" path)
FOLDERID_LocalAppDataLow,// AppConfigLocation ("Local" path)
+ FOLDERID_Public, // PublicShareLocation
+ FOLDERID_Templates, // TemplatesLocation
};
static_assert(sizeof(folderIds_li) == sizeof(folderIds));