Using custom controls in KConfigXT

14 views
Skip to first unread message

Christian Taubenheim

unread,
Mar 19, 2012, 4:19:19 AM3/19/12
to kde-...@kde.org
Hi all,
i use the KConfigXT concept for managing settings of my app.
I also managed to implement a QButton that holds a user specified color
(by opening a QColorDialog), which is transferred into the settings
manually.

I called 'enableButtonApply(true) on my dialog if the user changed the
color, but when the user clicks 'Apply' no other signal gets emitted
from KConfigDialog.

What signal should i emit if the data in this KConfigDialog has changed?
I tried to emit 'settingsChanged(QString)' but that applies the settings
directly without giving the user a chance to click 'cancel' and dismiss
the settings.

Many thanks in advance for any help on that.
Greetings, -chris-

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

David Edmundson

unread,
Mar 19, 2012, 6:45:35 AM3/19/12
to kde-...@kde.org
On Mon, Mar 19, 2012 at 8:19 AM, Christian Taubenheim
<c.taub...@q-bus.de> wrote:
> Hi all,
> i use the KConfigXT concept for managing settings of my app.
> I also managed to implement a QButton that holds a user specified color (by
> opening a QColorDialog), which is transferred into the settings manually.
>
> I called 'enableButtonApply(true) on my dialog if the user changed the
> color, but when the user clicks 'Apply' no other signal gets emitted from
> KConfigDialog.
>
> What signal should i emit if the data in this KConfigDialog has changed?
> I tried to emit 'settingsChanged(QString)' but that applies the settings
> directly without giving the user a chance to click 'cancel' and dismiss the
> settings.
>
> Many thanks in advance for any help on that.
> Greetings, -chris-
>

If you're using KConfigXT the most correct solution is to let
KConfigXT know how to use your new class, rather than loading/saving
manually.

I'm assuming you have a class for your button.
in MyButtonClass add a Q_PROPERTY to set/write this colour. Specify
this property as "USER".
http://qt-project.org/doc/qt-4.8/properties.html

I'm guessing KConfigXT was written before the NOTIFY part of a
q_property, so it has a manually stored map of signals to know when a
setting has changed.
You can add to this at runtime. (do this before the UI has loaded)
KConfigDialogManager::changedMap()->insert("MyButtonClass",
SIGNAL(somethingUpdated(QColor)));

http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKConfigDialogManager.html

In theory now KConfigXT will handle everything for you.

(btw, have you checked that KColorButton isn't what you want)

Stefan Majewsky

unread,
Mar 20, 2012, 7:26:22 PM3/20/12
to kde-...@kde.org
On Mon, Mar 19, 2012 at 9:19 AM, Christian Taubenheim
<c.taub...@q-bus.de> wrote:
> Hi all,
> i use the KConfigXT concept for managing settings of my app.
> I also managed to implement a QButton that holds a user specified color (by
> opening a QColorDialog), which is transferred into the settings manually.

For a working code sample, look in SVN at
trunk/KDE/kdegames/palapeli/src/config. In the config dialog, one can
select a background pattern for the game area, and selecting "Plain
color" enables a KColorButton where the color can be chosen.

I don't remember at the moment if I use KConfigXT, but the pattern
presented there can definitely be applied to KConfigXT.

Greetings
Stefan

Reply all
Reply to author
Forward
0 new messages