Ubuntu – Configuration files in a KDE application

application-developmentkde

I'm writing an open source application using KDE to sell in the Software Center. According to the requirements for uploading an application to the Software Center,

Write all configuration settings to ~/.config/ (This can be one file or a directory containing multiple configuration files)

By default, it appears that KDE applications store configuration files in ~/.kde/share/config/<name>rc. Is this not allowed? If so, how do I change where the file is stored? I'm using KConfig XT. The tutorial says

Start that file by opening the tag which controls which KConfig file the data will be stored in. There are three possibilities:

  1. If the <kcfgfile> tag has no attributes the generated code will use the application's default KConfig file (normally $HOME/.kde/config/<appname>rc).
  2. The "name" attribute is used to manually specify a file name. If the value assigned to "name" is not an absolute file path, the file will be created in the default KDE config directory (normally $HOME/.kde/config).
  3. If you would like to be able to specify the config file at construction time, use <kcfgfile arg="true">. This causes the constructor of the generated class to take a KSharedConfig::Ptr as an argument, allowing you to construct multiple instances pointing to different files.

I've tried setting the name attribute to be ~/.config/<appname>, but there is no file at that location, although settings are still being saved. Also, when I set the name attribute, other settings are still saved to ~/.kde/share/config/<appname>rc, such as window size.

How to I change where configuration data is stored for a KDE app so it will meet upload requirements for the Software Center?

Best Answer

If you are using the KConfig API, your application should be fine for uploading to MyApps and inclusion in the store.

You could also instead use the Qt bindings for dconf, dconf-qt, which would allow you to store your settings in dconf, which would be under the ~/.config/ directory.

Also note that the ~/.config/ requirement is perhaps not well specified in those requirements, as it should be $XDG_CONFIG_HOME instead, for which ~/.config/ is simply the default, and which users may decide to change to another location, so that the files underneath it, may be more easily accessible to them.