KConfigXT generated class gets value from kdeglobals config file

Carl Schwan carl at carlschwan.eu
Sun Aug 8 22:25:40 BST 2021


Le dimanche 8 août 2021 à 11:15 PM, George Florea Banus <georgefb899 at gmail.com> a écrit :

> In my app I'm using KConfigXT for my settings.
> I have a general group and in it I have a ColorScheme entry.
> Now when there is no ColorScheme set by the user and I try to access
> this entry, instead of getting its default value it gets the value
> stored in `~/.config/kdeglobals` (which also has a ColorScheme entry
> under the General group).
> https://invent.kde.org/multimedia/haruna/-/blob/master/src/settings/generalsettings.kcfg#L46
> https://invent.kde.org/multimedia/haruna/-/blob/master/src/settings/generalsettings.kcfgc
> Any ideas how to prevent this? I'd rather not change the name of the
> entry or the group.

Hi,
when creating a KSharedConfig, you can specify if kdeglobals will be
read and then you can tell KConfigXT that you want to read from an
existing KSharedPtr: https://api.kde.org/frameworks/kconfig/html/kconfig_compiler.html

On another note, for color scheme handling in a QML app, this is how
I did it in NeoChat: https://invent.kde.org/network/neochat/-/blob/master/imports/NeoChat/Settings/ColorScheme.qml
and https://invent.kde.org/network/neochat/-/blob/master/src/colorschemer.h

This allows the user to override the color scheme while using by default
the system theme.

Cheers,
Carl





More information about the kde-devel mailing list