Handling Configuration Dialogs in the Scripting api

Sebastian Kuegler sebas at kde.org
Thu May 8 12:22:56 CEST 2008


On Thursday 08 May 2008 12:14:25 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. Similarly the C++ equivalent is called
> createConfigureInterface() and would be better named
> createConfigurationDialog() in my opinion.

That's old API. If you spot it somewhere, cull it in favor of 
createConfigurationInterface() (why it's not ...Dialog(), not sure... maybe 
we won't use a dialog in the future but just flip the applet around and have 
configuration on its backside).

> An example of using a config dialog from the analog clock:
>
> void Clock::createConfigurationInterface(KConfigDialog *parent)
> {
>     //TODO: Make the size settable
>     QWidget *widget = new QWidget();
>     ui.setupUi(widget);
>     parent->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply );
>     connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
>     connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
>     parent->addPage(widget, parent->windowTitle(), icon());
>
>     ui.timeZones->setSelected(m_timezone, true);
>     ...
> }
>
> It is passed a KConfigDialog, whereas the scripting equivalent isn't. So we
> could abstract out quite a bit of that for a scripting api:
>
> KConfigDialog *parent = new KConfigDialog;
> parent->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply );
> connect(parent, SIGNAL(applyClicked()), this,
> SLOT(configurationAccepted()));
> connect(parent, SIGNAL(okClicked()), this, SLOT(configurationAccepted()));
>
> Where 'this' is the scripting applet code - maybe the slot should be called
> 'configurationAccepted()', and my second question is why doesn't the
> scripting api have a method that is called when the user presses ok or
> apply buttons?
>
> 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.
>
> 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.

Can't really comment on that part, so I won't. :)
-- 
sebas

 http://www.kde.org | http://vizZzion.org |  GPG Key ID: 9119 0EF9 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20080508/58a01227/attachment.pgp 


More information about the Panel-devel mailing list