In appletscripting.h there is a method called showConfigurationInterface():<br><br> /**<br> * Show a configuration dialog.<br> */<br> virtual void showConfigurationInterface();<br><br>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.<br>
<br>An example of using a config dialog from the analog clock:<br><br>void Clock::createConfigurationInterface(KConfigDialog *parent)<br>{<br> //TODO: Make the size settable<br> QWidget *widget = new QWidget();<br> ui.setupUi(widget);<br>
parent->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply );<br> connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));<br> connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));<br>
parent->addPage(widget, parent->windowTitle(), icon());<br><br> ui.timeZones->setSelected(m_timezone, true);<br> ...<br>}<br><br>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:<br>
<br>KConfigDialog *parent = new KConfigDialog;<br>parent->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply );<br>connect(parent, SIGNAL(applyClicked()), this, SLOT(configurationAccepted()));<br>connect(parent, SIGNAL(okClicked()), this, SLOT(configurationAccepted()));<br>
<br>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?<br>
<br>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.<br>
<br>Then the scripting api code can put the widget in the KConfigDialog:<br><br>parent->addPage(widget, parent->windowTitle(), icon());<br><br>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.<br>
<br>-- Richard<br><br>
<br><br><br>