[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    clockapplet: about configChanged() and configAccepted()
From:       Leonardo Giordani <giordani.leonardo () gmail ! com>
Date:       2013-07-07 14:24:34
Message-ID: CAEhE+OmFR0ru6B=pP8augdaDjAjxCBNg7ZgN0V9Mhk68RVQzKw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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>

[Attachment #5 (text/html)]

<div dir="ltr"><div><div>Hi all,<br><br>I started working on Plasma digital-clock, to \
try and implement some changes in layout. Since I&#39;m a complete novice I&#39;m \
reviewing the existing code of the applet to understand it (I can understand C++/Qt, \
but don&#39;t know KDE internals).<br> <br></div>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.<br><br>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.<br> \
<br></div><div>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.<br> </div><div><br></div><div>The ClockApplet behaviour is indeed \
correct, I think. The configChanged() method calls configAccepted() (UI -&gt; \
KConfigGroup) if the user is configuring, then the same values are put in the object \
from the KConfigGroup.<br> <br></div><div>The clockConfigChanged() and \
clockConfigAccepted() methods in the digital-clock applet behave \
differently.<br></div><div><br></div><div>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.<br> <br></div><div>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().<br> <br></div><div>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.<br> <br>Thank you in \
advance<br><br>Leo<br><br></div><div><br><br></div><div><br><br>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().<br> <br></div><br><div><br><br>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()<br> <div><div><br><br clear="all"><div><div \
dir="ltr"><div>Leonardo Giordani<br></div>Author of <a \
href="http://lgiordani.github.com" target="_blank">The Digital Cat</a><br>My profile \
on <a href="http://about.me/leonardo.giordani" target="_blank">About.me</a><br> \
</div></div> </div></div></div></div>



_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic