<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'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).<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 -> 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>