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>
This commit is contained in:
parent
ffcf4f4001
commit
68c4669ce4
@ -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();
|
||||
|
@ -72,7 +72,9 @@ public:
|
||||
GenericCacheLocation,
|
||||
GenericConfigLocation,
|
||||
AppDataLocation,
|
||||
AppConfigLocation
|
||||
AppConfigLocation,
|
||||
PublicShareLocation,
|
||||
TemplatesLocation
|
||||
};
|
||||
Q_ENUM(StandardLocation)
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user