Handling Configuration Dialogs in the Scripting api

Aaron J. Seigo aseigo at kde.org
Thu May 8 19:04:27 CEST 2008


On Thursday 08 May 2008, Richard Dale wrote:
>   In appletscripting.h there is a method called
> showConfigurationInterface():
>
>   /**
>      * Show a configuration dialog.
>      */
>     virtual void showConfigurationInterface();
>
> Note that the comment describes it as a 'dialog', and so the first question
> is why isn't it named 'showConfigurationDialog()' - interface seems pretty
> meaningless to me.

because it's not guaranteed to be a dialog. right now the C++ API puts an 
assumption in there about a dialog, but it's actually not universal.

> Similarly the C++ equivalent is called 
> createConfigureInterface() and would be better named
> createConfigurationDialog() in my opinion.

hm. actually, that was purposeful to leave it like that in the scripting API. 

showConfigurationInterface in Applet automatically creates a config based on 
ui files and configXML if that is available in the package, otherwise it 
calls showConfigurationInterface in the script, which is supposed to do the 
analog of showConfigurationInterface in Applet: decide how best to create and 
display a config interface for the given API.

so given that pattern, i figured to keep the naming in line with Applet 
itself, rather than what plasmoids implement.

there are two small flaws in the existing "automatically generate a config 
dialog from config xml and a ui file":

* KConfigSkeleton is completely unaware of KConfigGroup; it's KConfig centric 
and so fails us here. i will fix this in KDE 4.2

* the dialog that gets created isn't connected to any slot to signal that the 
configuration has changed. having some way to signal such updates such that 
the loaded widget updates itself needs to be taken into consideration. i see 
you've already noticed this, however ;)

> why doesn't the 
> scripting api have a method that is called when the user presses ok or
> apply buttons?

nobody was using this yet, and i had other things to take cafe of. now that 
there are scripts circling the tank, it needs to be addressed.

perhaps a SLOT in AppletScript that notifies of configuration changes?

> So after the above preamable we can call showConfigurationIterface(), and
> it does its stuff and creates a widget with the dialog. And then what? The
> method is a void, and I think it should return the created widget instead.

no, this is completely up to the scripting API. consider HTML/CSS for a really 
bizarro possibility: that stuff probably knows nothing about controls and 
code outside of html forms and javascript. building assumptions into the 
ScriptEngine API such as "knows about Qt/KDE dialogs" is going to fail us.

> Then the scripting api code can put the widget in the KConfigDialog:
>
> parent->addPage(widget, parent->windowTitle(), icon());
>
> When the slot configurationAccepted() is invoked the scripting api would
> then call back into the scripting code, which would get the config details
> from the dialog.

that's certainly a pattern that more powerful scripting APIs will likely 
follow.

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Trolltech
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20080508/03a1c14b/attachment.pgp 


More information about the Panel-devel mailing list