Handling Configuration Dialogs in the Scripting api

Richard Dale richard.j.dale at gmail.com
Thu May 8 12:14:25 CEST 2008


  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.

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.

-- Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/panel-devel/attachments/20080508/f90e9f99/attachment.html 


More information about the Panel-devel mailing list