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

List:       kde-panel-devel
Subject:    Re: Handling Configuration Dialogs in the Scripting api
From:       Sebastian Kuegler <sebas () kde ! org>
Date:       2008-05-08 10:22:56
Message-ID: 200805081222.56922.sebas () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


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 

["signature.asc" (application/pgp-signature)]

_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel


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

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