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

List:       kde-panel-devel
Subject:    Re: [Panel-devel] KDE/kdebase/workspace
From:       Sebastian Sauer <mail () dipe ! org>
Date:       2007-07-30 23:32:26
Message-ID: 200707310132.26942.mail () dipe ! org
[Download RAW message or body]

Aaron J. Seigo wrote:

> On Monday 30 July 2007, Sebastian Sauer wrote:
>> plasma1.patch goes the most easy way to just allow an applet to change
>> the menu. Probably it would be also an idea to just pass a
>> KActionCollection/KAction's and add them to the menu cause that way we
>> arn't limited to a kmenu for the context-stuff
> 
> yes, i like the idea of retrieving QActions. a lot. QList<QAction*>
> contextMenuActions() would be ok, except that "contextMenu" implies a menu
> and you are right that this might be used in non-menu UI, but .. i think
> that's ok. there should probably also be a contextMenuComplete() signal so
> that applets that care to can do a cleanup of their actions...

Patch attached :)

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

Index: libs/plasma/applet.h
===================================================================
--- libs/plasma/applet.h	(revision 694479)
+++ libs/plasma/applet.h	(working copy)
@@ -404,6 +404,15 @@
          **/
         QRectF boundingRect () const;
 
+        /**
+         * Returns a list of context-related QAction instances.
+         *
+         * This is used e.g. within the \a DesktopView to display a contextmenu.
+         * @return A list of actions. The default implementation returns an
+         *         empty list.
+         **/
+        virtual QList<QAction*> contextActions() const;
+
     Q_SIGNALS:
         /**
          * Emitted when the applet needs to take (or lose) keyboard focus.
Index: libs/plasma/applet.cpp
===================================================================
--- libs/plasma/applet.cpp	(revision 694479)
+++ libs/plasma/applet.cpp	(working copy)
@@ -531,6 +531,11 @@
 
 }
 
+QList<QAction*> Applet::contextActions() const
+{
+    return QList<QAction*>();
+}
+
 QColor Applet::color() const
 {
     // TODO: add more colors for more categories and
Index: plasma/plasma/desktopview.cpp
===================================================================
--- plasma/plasma/desktopview.cpp	(revision 694479)
+++ plasma/plasma/desktopview.cpp	(working copy)
@@ -22,6 +22,7 @@
 #include <QAction>
 #include <QFile>
 #include <QWheelEvent>
+#include <QCoreApplication>
 
 #include <KAuthorized>
 #include <KMenu>
@@ -242,7 +243,6 @@
         QGraphicsView::contextMenuEvent(event);
         return;
     } else {
-        //desktopMenu.addSeparator();
         bool hasEntries = false;
         if (applet->hasConfigurationInterface()) {
             QAction* configureApplet = new QAction(i18n("%1 Settings...", applet->name()), this);
@@ -260,6 +260,12 @@
             hasEntries = true;
         }
 
+        desktopMenu.addSeparator();
+        foreach(QAction* action, applet->contextActions()) {
+            desktopMenu.addAction(action);
+            hasEntries = true;
+        }
+
         if (!hasEntries) {
             QGraphicsView::contextMenuEvent(event);
             return;


_______________________________________________
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