Question about KSPaths and finding data files

Artem Fedoskin afedoskin3 at gmail.com
Wed Aug 17 21:43:43 UTC 2016


Hi Akarsh,

There was an issue with QStandardPaths::GenericDataLocation (
https://phabricator.kde.org/D1873). That is why we decided to add "kstars"
to paths. If QStandardPaths::AppDataLocation returns the same path but
already with "kstars" on both Windows and Linux than we can change it.

Regards, Artem

2016-08-17 22:25 GMT+02:00 Akarsh Simha <akarshsimha at gmail.com>:

> Hi
>
> In KSPaths, we have the following code (for non-Android case):
>
>     return QStandardPaths::locate(location, "kstars" + QDir::separator() +
>                                   fileName,options);
>
> And we use location = QStandardPaths::GenericDataLocation almost
> everywhere in KStars, which should return something like
> ~/.local/share/ on Linux, whereby our addition of "kstars" seen above
> will result in ~/.local/share/kstars/ and everything is fine.
>
> My question is, why do we prefer QStandardPaths::GenericDataLocation
> over QStandardPaths::AppDataLocation? The latter gives an app-specific
> result, whereby we don't have to prepend "kstars" + QDir::separator()
> to the file name. If there is a reason to prefer one over the other,
> we should document this in a comment.
>
> Secondly, I will probably add the following code to KSPaths (both methods)
>
> ...
> QString _fileName = fileName;
> if( location == QStandardPaths::GenericDataLocation || location ==
> QStandardPaths::GenericConfigLocation ) {
>    _fileName = "kstars" + QDir::separator() + fileName;
> }
> ...
>
> would this be okay? It's not wise to add "kstars" + separator to every
> kind of path location understood by QStandardPaths.
>
> To me, personally, it seems much cleaner to use
> QStandardPaths::AppDataLocation and let Qt do the hard work of
> figuring out where to put the data. But if there's a good reason for
> one over the other, I'll be happy to change my opinion.
>
> Regards
> Akarsh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kstars-devel/attachments/20160817/50d7ae03/attachment.html>


More information about the Kstars-devel mailing list