Add KSharedConfig::openStateConfig for storing state information
ClosedPublic

Authored by nicolasfella on Jan 5 2020, 5:52 PM.

Details

Summary

A common complaint is that our apps store 'state' information such as recent files or window sizes in their configuration files, making it ugly to store them in version control systems.

Therefore we should not store such information in XDG_CONFIG_DIR but instead use XDG_DATA_DIR for this.

This patch adds a utility method that creates a KSharedConfig backed by a file in such a suitable location.

For e.g. dolphin the file .local/share/dolphin/dolphinstaterc would be created.

See T12246 for some context

Diff Detail

Repository
R237 KConfig
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nicolasfella created this revision.Jan 5 2020, 5:52 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJan 5 2020, 5:52 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
nicolasfella requested review of this revision.Jan 5 2020, 5:52 PM
nicolasfella edited the summary of this revision. (Show Details)Jan 5 2020, 5:52 PM
dfaure added a comment.Jan 5 2020, 5:57 PM

For e.g. dolphin the file .config/dolphin/dolphinstate would be created.

You mean ~/.local/share/dolphin/dolphinstate, right?

src/core/ksharedconfig.cpp
124

My idea was to add const QString &fileName = QString() to this method so that complex apps can use multiple state files. Or for parts and plugins to use a fixed name whatever app they're in.
(one example: kmail-standalone vs kmail-in-kontact).

126

I think SimpleConfig would be enough. We don't need cascading (I think) and we don't need kdeglobals (for sure).

nicolasfella edited the summary of this revision. (Show Details)Jan 5 2020, 6:03 PM

For e.g. dolphin the file .config/dolphin/dolphinstate would be created.

You mean ~/.local/share/dolphin/dolphinstate, right?

Of course

nicolasfella marked an inline comment as done.
  • Add filename arg and use simpleconfig
nicolasfella added inline comments.Jan 5 2020, 6:18 PM
src/core/ksharedconfig.cpp
124

I didn't see a use case for it, but your's makes sense

dfaure accepted this revision.Jan 5 2020, 6:29 PM

Looks good. I'm just going back and forth in my mind between dolphinstate and dolphinstaterc. The latter would have the benefit of telling experienced developers that it uses the KConfig file format (not e.g. some binary format). This is minor though, surely we'll get used to it whichever way.

Maybe mention the method name in the first line of the commit log, so that the future release changelog is more informative.

Thanks!

This revision is now accepted and ready to land.Jan 5 2020, 6:29 PM
nicolasfella retitled this revision from Add utility method for opening a KSharedConfig suitable to store state information to Add KSharedConfig::openStateConfig for storing state information.Jan 5 2020, 8:00 PM
  • Change to staterc
nicolasfella edited the summary of this revision. (Show Details)Jan 5 2020, 8:01 PM
dfaure accepted this revision.Jan 5 2020, 8:07 PM

Thanks!

This revision was automatically updated to reflect the committed changes.
broulik added a subscriber: broulik.Jan 7 2020, 9:34 AM

Nice one. Once that XDG_STATE_HOME discussion comes to a conclusion [1] we could then easily swap the location over, I suppose.

[1] https://lists.freedesktop.org/archives/xdg/2016-December/013803.html