clockapplet: about configChanged() and configAccepted()

Leonardo Giordani giordani.leonardo at gmail.com
Sun Jul 7 14:24:34 UTC 2013


Hi all,

I started working on Plasma digital-clock, to try and implement some
changes in layout. Since I'm a complete novice I'm reviewing the existing
code of the applet to understand it (I can understand C++/Qt, but don't
know KDE internals).

I am now looking at configChanged() and configAccepted() and I have a
question. Sorry, it is a long explanation but I want to be sure to
understand how things work.

If I correctly understood, the parent ClockApplet object
(libs/plasmaclock/clockapplet.cpp) implements configChanged() and
configAccepted(), calling the relative methods clockConfigChanged() and
clockConfigAccepted() implemented by the actual applet.

There are three actors here: the KConfigGroup, the object, and (optionally)
the config UI. When configChanged() is called the object values shall be
initialized with the KConfigGroup values. When the user accepts the
configuration from the UI, UI values shall be put in the KConfigGroup, then
the object shall be initialized.

The ClockApplet behaviour is indeed correct, I think. The configChanged()
method calls configAccepted() (UI -> KConfigGroup) if the user is
configuring, then the same values are put in the object from the
KConfigGroup.

The clockConfigChanged() and clockConfigAccepted() methods in the
digital-clock applet behave differently.

While the clockConfigChanged() method (plasma/applets/digital-clock) puts
values in the object from the KConfigGroup (which is correct), the
clockConfigAccepted() method takes values from the UI and fills the object,
then puts the object values into the KConfigGroup.

In my opinion this results in the clock configuration be written twice when
the user is configuring the applet. The first time from the conditional
clockConfigAccepted() and the second one from clockConfigChanged().

Can someone please tell me if I correctly understood the mechanism and if
the issue I pointed out is real? I know the this would be a very small
issue, nevertheless it can help me understanding the code.

Thank you in advance

Leo





The method configChanged() of ClockApplet
(libs/plasmaclock/clockapplet.cpp:438) is automatically called from
external scripts or whatever changes the applet configuration, and
explicitely by init().




Inside it configAccepted() is called if the config interface is being shown
(through isUserConfiguring()) and that stores UI values in the
KConfigGroup, then calls clockConfigAccepted(). The same values are loaded
from the KConfigGroup immediately after, then clockConfigChanged()


Leonardo Giordani
Author of The Digital Cat <http://lgiordani.github.com>
My profile on About.me <http://about.me/leonardo.giordani>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20130707/dcf8a9f0/attachment.html>


More information about the Plasma-devel mailing list