On Thursday 19 February 2009, Benjamin Kleiner wrote:
> On Thursday, 19. February 2009 16:55:38 Thomas Coopman wrote:
> > I have been running in the same problem and have looked a bit at the code
> > and it looks like createConfigurationInterface is not in AppletScript so
> > there are some changes needed to solve this.
> >
> > But if it is possible to use showConfiguration and get the same dialog I
> > would like to know how too.
>
> Well, the following code emulates the wanted behaviour relatively well:
>
>       def showConfigurationInterface(self):
>               dialog = KPageDialog()
>               dialog.setFaceType(KPageDialog.List)
>               dialog.setButtons( KDialog.ButtonCode(KDialog.Ok | 
> KDialog.Cancel) )
>               #The assignment of actions to the buttons happens in
> createConfigurationInterface(), as proposed.
> self.createConfigurationInterface(dialog)
>               dialog.exec_()
>
> It works nice, but you currently have to rewrite it every time you make a
> new applet, which is kind of annoying.

ah, so this is a shortcoming of the python scriptengine ... which in turn is a 
limitation in AppletScriptEngine in that you can't get the "standard" Plasma 
config dialog from there. som

ething like the attached patch which could then be used by the python engine 
to provide a nice method in the interpreter (e.g. 
createConfigurationInterface)

-- 
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 Qt Software

Index: scripting/appletscript.h
===================================================================
--- scripting/appletscript.h	(revision 928671)
+++ scripting/appletscript.h	(working copy)
@@ -32,6 +32,7 @@
 class QAction;
 class QPainter;
 class QStyleOptionGraphicsItem;
+class KConfigDialog;
 
 namespace Plasma
 {
@@ -165,6 +166,14 @@
      */
     const Package *package() const;
 
+    /**
+     * @return a standard Plasma applet configuration dialog, ready
+     * to have pages added to it.
+     *
+     * Note that the dialog returned is set to delete on close.
+     */
+    KConfigDialog *standardConfigurationDialog();
+
 private:
     AppletScriptPrivate *const d;
 };
Index: scripting/appletscript.cpp
===================================================================
--- scripting/appletscript.cpp	(revision 928671)
+++ scripting/appletscript.cpp	(working copy)
@@ -19,6 +19,8 @@
 
 #include "scripting/appletscript.h"
 
+#include "kconfigdialog.h"
+
 #include "applet.h"
 #include "package.h"
 #include "private/applet_p.h"
@@ -125,10 +127,19 @@
 void AppletScript::showConfigurationInterface()
 {
     if (applet()) {
-        applet()->d->generateGenericConfigDialog();
+        applet()->d->generateGenericConfigDialog()->show();
     }
 }
 
+KConfigDialog *AppletScript::standardConfigurationDialog()
+{
+    if (applet()) {
+        return applet()->d->generateGenericConfigDialog();
+    }
+
+    return 0;
+}
+
 void AppletScript::configChanged()
 {
 }
Index: applet.cpp
===================================================================
--- applet.cpp	(revision 928671)
+++ applet.cpp	(working copy)
@@ -1548,7 +1548,7 @@
     } else if (d->script) {
         d->script->showConfigurationInterface();
     } else {
-        d->generateGenericConfigDialog();
+        d->generateGenericConfigDialog()->show();
     }
 
     emit releaseVisualFocus();
@@ -1564,7 +1564,7 @@
     return i18nc("@title:window", "%1 Settings", q->name());
 }
 
-void AppletPrivate::generateGenericConfigDialog()
+KConfigDialog *AppletPrivate::generateGenericConfigDialog()
 {
     KConfigSkeleton *nullManager = new KConfigSkeleton(0);
     KConfigDialog *dialog = new KConfigDialog(0, configDialogId(), nullManager);
@@ -1579,7 +1579,7 @@
     QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished()));
     QObject::connect(dialog, SIGNAL(finished()), q, SLOT(configDialogFinished()));
     QObject::connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater()));
-    dialog->show();
+    return dialog;
 }
 
 void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog)
Index: private/applet_p.h
===================================================================
--- private/applet_p.h	(revision 928671)
+++ private/applet_p.h	(working copy)
@@ -83,7 +83,7 @@
     void addGlobalShortcutsPage(KConfigDialog *dialog);
     void clearShortcutEditorPtr();
     void configDialogFinished();
-    void generateGenericConfigDialog();
+    KConfigDialog *generateGenericConfigDialog();
     QString configDialogId() const;
     QString configWindowTitle() const;
 

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to