Question about KSPaths and finding data files

Akarsh Simha akarshsimha at gmail.com
Wed Aug 17 20:25:28 UTC 2016


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


More information about the Kstars-devel mailing list