[KDE/Mac] Thoughts on standard directories in Qt5 - QStandardPaths

Marko Käning mk-lists at email.de
Sun Dec 7 13:36:57 UTC 2014

Hi Ian,

On 07 Dec 2014, at 07:52 , Ian Wadham <iandw.au at gmail.com> wrote:
> Errrmmm, yes, I think so… :-) but no harm done… :-)  In fact, you may have given
> René and me some good ideas… :-)

and so have YOU with this (private) email, which I am bringing herewith to the list!

> XDG_* is really intended for Unix and Linux systems.  I think the Qt 5 source code
> implements it fully only in two places, but refers to it in passing in a few other places.


> The two places are qsettings.cpp and qstandardpaths_unix.cpp.  QSettings is not
> used in KF5 as far as I can see.  David's slideshow says it is "suboptimal and
> deprecated", but that was in 2012, see:
>    https://devdays.kdab.com/wp-content/uploads/2012/Qt_Addons_KDE_Frameworks.pdf
> That leaves qstandardpaths_unix.cpp, which is where Qt 5 implements the XDG_*
> standard (see http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
> for Unix and Linux platforms.
> I think what you have been doing is taking bits of qstandardpaths_unix.cpp and
> patching them into qstandardpaths_mac.cpp, thus becoming reliant on XDG.

Yes, exactly.

> File qstandardpaths_unix.cpp implements the defaults for XDG directories if the $XDG_*
> environment variables are not defined, but qstandardpaths_mac.cpp does NOT
> implement those defaults.  I would say that is why you can only succeed by defining
> $XDG_* variables, implementing them in your patch and thus bending OS X and
> Qt 5 to your will… ;-)

Absolutely! :)

> Another (more radical) approach is to install qstandardpaths_unix.cpp in your copy
> of Qt 5, as I have been discussing with René on this thread, and thus bypass
> qstandardpaths_mac.cpp altogether.  Then you should install all non-code files in
> the same locations as for Linux, but taking care to install the code, bundle and icons
> into the /Applications structure, as is required in an OS X desktop.

I decided to simply add the missing bits to my current patched version of
qstandardpaths_mac.cpp! This is the cleaner approach, as it takes into account OSX’
specifics [1].

> Then your KDE apps should find their files at run-time, without having to use $XDG_*
> variables.  The only problems I foresee are:

We’ll see…
I’ll report back once the newly patched qt5 build has finished. :)

>    - The methods and location types relating to executables in QSP might have to be patched.

All done in [1], but perhaps I still might need to do something about this here:
+//    case ApplicationsLocation:
+//        path = writableLocation(GenericDataLocation) + QLatin1String("/applications");
+//        break;
which is currently commented out...

>    - It would be advisable, eventually, to change the $XDG_* defaults away from /usr/local, /usr
>      and /etc, because these are deprecated in MacPorts… or maybe you could make them go
>      into /opt/local somewhere right away.

One could do it, but since I am not working with a MacPorts-ish qt5 anyways, but with
a qt5 only for the OSX/CI system, I don’t need to touch this.

>    - I don't know how pure-Qt apps, such as Qt Assistant and Qt Designer would react to this
>      approach, but we have to walk before we can run… :-)  Hopefully they would work just as
>      well as they do in Linux.

Well, these work without my old patch and I don’t expect them to fail with the new patch in

> Hope some of this works for you.

I am very hopeful it will.

As I said, I will report back once the builds are done, which will still take about 2 hrs for

	Ian, A BIG THANKS for the pointer in the right direction!!!!


[1] http://commits.kde.org/clones/websites/build-kde-org/kaning/mp-osx-ci/01769a403fd56914f9271ae3fd5ab239d7ca8f40

More information about the kde-mac mailing list