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

List:       kde-panel-devel
Subject:    Re: plasma application policies
From:       Richard Dale <richard.j.dale () gmail ! com>
Date:       2009-08-05 13:10:40
Message-ID: 491684420908050610n49e34df6nf14d728cdc5e35f1 () mail ! gmail ! com
[Download RAW message or body]

On Tue, Jul 28, 2009 at 10:07 PM, Aaron J. Seigo<aseigo@kde.org> wrote:
> On Tuesday 28 July 2009, Richard Dale wrote:
>> On Tue, Jul 28, 2009 at 2:32 AM, Aaron J. Seigo<aseigo@kde.org> wrote:
>> > the script engine situation is probably the easiest of the bunch: just
>> > add a method to the script engine that states what it does with
>> > configuration (e.g. setProvidesCustomizedConfiguration(bool)) and quer=
y
>> > that when deciding what to do with the configuration action.
>>
>> I would like something like this so that Google Gadgets etc can return
>> 'yes' and scripts engines like Ruby or Python that want KDE dialogs
>> can return 'no'.
>
> that would be the idea indeed.
>
>> I noticed that a global shortcuts page is now in the standard dialog,
>> and have translated the code for that to Ruby but not commited it yet.
>> I can't use the C++ implementation because the methods are private.
>
> there is this in AppletScriptEngine:
>
> =A0KConfigDialog *standardConfigurationDialog();
>
> so you can get the standard dialog and then pass that on to the Ruby scri=
pt to
> add their own pages to.
The problem with this is that there is no
createConfigurationInterface() callback/virtual method override in the
script engine. This means that the custom pages for a scripted
plasmoid don't get added until the dialog has been created with a
keyboard shortcut page already added. So instead of the keyboard
shortcut page being last, it will be first. The attached patch adds
another method to appletscript.h, addGlobalShortcutsPage() which
allows the script engine code to call back into the scripting code in
between creating the dialog with standardConfigurationDialog() and
adding the shortcut page.

It also moves a few things around in applet.cpp, so that the code for
shortcuts is all in Applet::addGlobalShortcutsPage() including the
connect() calls to the configDialogFinished() slot to handle
completing the dialog.

-- Richard

> --
> Aaron J. Seigo
> humru othro a kohnu se
> GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA =A0EE75 D6B7 2EB1 A7F1 DB43
>
> KDE core developer sponsored by Qt Software
>
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel@kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
>

["plasma_scripting_dialog.patch" (text/x-diff)]

Index: scripting/appletscript.h
===================================================================
--- scripting/appletscript.h	(revision 1007235)
+++ scripting/appletscript.h	(working copy)
@@ -180,6 +180,12 @@
      */
     KConfigDialog *standardConfigurationDialog();
 
+    /**
+     * This method should be called after a scripting applet has added
+     * its own pages to a configuration dialog
+     */
+    void addGlobalShortcutsPage(KConfigDialog *dialog);
+
 private:
     AppletScriptPrivate *const d;
 };
Index: scripting/appletscript.cpp
===================================================================
--- scripting/appletscript.cpp	(revision 1007235)
+++ scripting/appletscript.cpp	(working copy)
@@ -140,6 +140,15 @@
     return 0;
 }
 
+void AppletScript::addGlobalShortcutsPage(KConfigDialog *dialog)
+{
+    if (applet()) {
+        return applet()->d->addGlobalShortcutsPage(dialog);
+    }
+
+    return;
+}
+
 void AppletScript::configChanged()
 {
 }
Index: applet.cpp
===================================================================
--- applet.cpp	(revision 1007235)
+++ applet.cpp	(working copy)
@@ -1584,13 +1584,14 @@
         }
 
         d->addGlobalShortcutsPage(dialog);
-        connect(dialog, SIGNAL(applyClicked()), this, SLOT(configDialogFinished()));
-        connect(dialog, SIGNAL(okClicked()), this, SLOT(configDialogFinished()));
         dialog->show();
     } else if (d->script) {
         d->script->showConfigurationInterface();
     } else {
-        d->generateGenericConfigDialog()->show();
+        KConfigDialog *dialog = d->generateGenericConfigDialog();
+        createConfigurationInterface(dialog);
+        d->addGlobalShortcutsPage(dialog);
+        dialog->show();
     }
 
     emit releaseVisualFocus();
@@ -1640,12 +1641,6 @@
     dialog->setFaceType(KPageDialog::Auto);
     dialog->setWindowTitle(configWindowTitle());
     dialog->setAttribute(Qt::WA_DeleteOnClose, true);
-    q->createConfigurationInterface(dialog);
-    addGlobalShortcutsPage(dialog);
-    //TODO: Apply button does not correctly work for now, so do not show it
-    dialog->showButton(KDialog::Apply, false);
-    QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()));
-    QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished()));
     QObject::connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater()));
     return dialog;
 }
@@ -1668,6 +1663,11 @@
     layout->addWidget(shortcutEditor);
     layout->addStretch();
     dialog->addPage(page, i18n("Keyboard Shortcut"), "preferences-desktop-keyboard");
+
+    //TODO: Apply button does not correctly work for now, so do not show it
+    dialog->showButton(KDialog::Apply, false);
+    QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()));
+    QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished()));
 }
 
 void AppletPrivate::clearShortcutEditorPtr()


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


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

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