about Qt's QStandardPaths

René J.V. Bertin rjvbertin at gmail.com
Tue Sep 29 05:39:24 PDT 2015


Hi,

Sorry, another long mail...

Part of the reason that I keep coming back to the Qt5 port(s) has to do with a new class introduced after Qt4, QStandardPaths (QSP), which has (static) methods to obtain the standard locations where all kinds of (shared or not) information and resources is expected to be found and written.

There are 2 issues with this that need discussion:

1) Can these locations (the ones that are not user-specific) be unmodified from "stock" Qt, i.e. point into /Library/Application\ Support and similar locations, or should they point under ${prefix} as much as possible? The user-specific locations would probably be limited to those relevant for config files and other resources which can be sandboxed. Any resource that has to be shared among applications should (probably) not be installed in a path that has the application name in it.

2) The stock QSP are compliant with Mac and iOS App Store requirements, which puts them at odds with applications that follow Freedesktop/XDG conventions. This is all the more the case if those applications should be able to share resources with others that are not based on Qt5; those would include any KDE application not yet available in a KF5 version (i.e. only as KDE4), and all GTk/Gnome applications. Resources shared between KDE and non-KDE Freedesktop applications would include icon themes but are almost certainly not limited to that.

Point 1 is something that may impose a patch to the "mainstream" qt5-mac port, and I'm currently wrestling with a solution to point 2.
I'd need some feedback to know if I'm pursuing the right solution though.

a- Should "pure Qt5" applications that do not use any KF5 framework use "native" QSP locations just as they would when built against an "official" Qt5 install (and independent of the answer to point 1 above)?

b- Should resources installed by KF5 ports and that can be shared with non-Qt5-based Freedesktop ports also be accessible to those ports (unpatched)?

c- Should KF5 ports (and possible pure Qt5 Freedesktop apps) be able to access relevant shared resources installed by or for other Freedesktop ports?

If the answer to b and c is positive a patch like the one I'm working on should be implemented for QStandardPaths.

If the answer to a) is *not* positive, that patch can be simple and impose what are basically XDG-style locations on all ports that use Qt5, at least for the ones that are not user specific (cf. point 1). Simple and clean, no confusion possible (among libraries and applications in MacPorts).

If the answer to a) is positive and affirmative (= stronger than "preferable"), a more complex approach is required, one that will probably include a QSP convention switch that can be toggled when an application loads (Qt itself uses QSP internally too, so the choice of convention cannot be made at compile-time). 

I'm kind of hoping the consensus will be that it's up to the user to decide if s/he gives priority to a) or to b+c, by choosing to install either port:qt5-mac (which would give it back a reason to be called like that!) or something I currently call port:qt5-kde . Note that variants wouldn't do in this scenario (certain ports will require qt5-kde, others may insist on qt5-mac), and the Portfiles are complex enough already not to use subports.

For reference:

>>> stock QStandardPaths from Qt 5.5.0 on OS X (from qtdiag from my port:qt5-kde; these only have a fix applied to the FontsLocation)
Standard paths [*...* denote writable entry]:
  DesktopLocation: "Desktop" */Users/bertin/Desktop*
  DocumentsLocation: "Documents" */Users/bertin/Documents*
  FontsLocation: "Fonts" */Users/bertin/Library/Fonts* /Library/Fonts /System/Library/Fonts
  ApplicationsLocation: "Applications" */Applications*
  MusicLocation: "Music" */Users/bertin/Music*
  MoviesLocation: "Movies" */Users/bertin/Movies*
  PicturesLocation: "Pictures" */Users/bertin/Pictures*
  TempLocation: "TemporaryItems" */var/folders/j1/1439ppj08xj8h6006s6drbq00000gs/T*
  HomeLocation: "Home" */Users/bertin*
  AppLocalDataLocation: "Application Support" */Users/bertin/Library/Application Support/QtProject/qtdiag* /Library/Application Support/QtProject/qtdiag /opt/local/libexec/qt5/bin/
  CacheLocation: "Caches" */Users/bertin/Library/Caches/QtProject/qtdiag* /Library/Caches/QtProject/qtdiag
  GenericDataLocation: "Application Support" */Users/bertin/Library/Application Support* /Library/Application Support
  RuntimeLocation: "Application Support" */Users/bertin/Library/Application Support*
  ConfigLocation: "Preferences" */Users/bertin/Library/Preferences*
  DownloadLocation: "Desktop" */Users/bertin/Downloads*
  GenericCacheLocation: "Caches" */Users/bertin/Library/Caches* /Library/Caches
  GenericConfigLocation: "Preferences" */Users/bertin/Library/Preferences*
  AppDataLocation: "Application Support" */Users/bertin/Library/Application Support/QtProject/qtdiag* /Library/Application Support/QtProject/qtdiag /opt/local/libexec/qt5/bin/
  AppConfigLocation: "Preferences" */Users/bertin/Library/Preferences/QtProject/qtdiag*
----------------------------------------------------
>>> stock QStandardPaths from Qt 5.5.0 on Linux; also note the xdg-kde-plasma directories
Standard paths [*...* denote writable entry]:
  DesktopLocation: "Desktop" */home/bertin/Desktop*
  DocumentsLocation: "Documents" */home/bertin/Documents*
  FontsLocation: "Fonts" */home/bertin/.fonts*
  ApplicationsLocation: "Applications" */home/bertin/.local/share/applications* /usr/share/applications /usr/share/kde-plasma/applications /usr/local/share/applications
  MusicLocation: "Music" */home/bertin/Music*
  MoviesLocation: "Movies" */home/bertin/Videos*
  PicturesLocation: "Pictures" */home/bertin/Pictures*
  TempLocation: "Temporary Directory" */tmp*
  HomeLocation: "Home" */home/bertin*
  AppLocalDataLocation: "Application Data" */home/bertin/.local/share/QtProject/qtdiag* /usr/share/QtProject/qtdiag /usr/share/kde-plasma/QtProject/qtdiag /usr/local/share/QtProject/qtdiag
  CacheLocation: "Cache" */home/bertin/.cache/QtProject/qtdiag*
  GenericDataLocation: "Shared Data" */home/bertin/.local/share* /usr/share /usr/share/kde-plasma /usr/local/share
  RuntimeLocation: "Runtime" */run/user/505*
  ConfigLocation: "Configuration" */home/bertin/.config* /etc/xdg/xdg-kde-plasma /usr/share/upstart/xdg /etc/xdg
  DownloadLocation: "Download" */home/bertin/Desktop/Downloads*
  GenericCacheLocation: "Shared Cache" */home/bertin/.cache*
  GenericConfigLocation: "Shared Configuration" */home/bertin/.config* /etc/xdg/xdg-kde-plasma /usr/share/upstart/xdg /etc/xdg
  AppDataLocation: "Application Data" */home/bertin/.local/share/QtProject/qtdiag* /usr/share/QtProject/qtdiag /usr/share/kde-plasma/QtProject/qtdiag /usr/local/share/QtProject/qtdiag
  AppConfigLocation: "Application Configuration" */home/bertin/.config/QtProject/qtdiag* /etc/xdg/xdg-kde-plasma/QtProject/qtdiag /usr/share/upstart/xdg/QtProject/qtdiag /etc/xdg/QtProject/qtdiag

(this comes from qtdiag from my qt5-kde build on Linux; I see I'll have to rebuild it once again with an appropriate QSP patch because those paths should point into ${prefix} ...)


Thanks,
René


More information about the macports-dev mailing list