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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/containmentactions/switchactivity
From:       Chani Armitage <chanika () gmail ! com>
Date:       2009-08-28 22:23:09
Message-ID: 1251498189.728338.28008.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1016791 by chani:

contextualActions for switchactivity

 M  +25 -7     switch.cpp  
 M  +2 -0      switch.h  


--- trunk/KDE/kdebase/workspace/plasma/containmentactions/switchactivity/switch.cpp \
#1016790:1016791 @@ -49,7 +49,7 @@
     }
 }
 
-void SwitchActivity::contextEvent(QGraphicsSceneMouseEvent *event)
+void SwitchActivity::makeMenu(QMenu *menu)
 {
     Plasma::Containment *myCtmt = containment();
     if (!myCtmt) {
@@ -60,10 +60,6 @@
         return;
     }
 
-    KMenu desktopMenu;
-
-    desktopMenu.addTitle(i18n("Activities"));
-
     QList<Plasma::Containment*> containments = c->containments();
     foreach (Plasma::Containment *ctmt, containments) {
         if (ctmt->containmentType() == Plasma::Containment::PanelContainment ||
@@ -76,7 +72,7 @@
         if (name.isEmpty()) {
             name = ctmt->name();
         }
-        QAction *action = desktopMenu.addAction(name);
+        QAction *action = menu->addAction(name);
         action->setData(QVariant::fromValue<QPointer<Plasma::Containment> \
>(QPointer<Plasma::Containment>(ctmt)));  
         //WARNING this assumes the plugin will only ever be set on activities, not \
panels! @@ -84,11 +80,33 @@
             action->setEnabled(false);
         }
     }
+    connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(switchTo(QAction*)));
+}
 
-    connect(&desktopMenu, SIGNAL(triggered(QAction*)), this, \
SLOT(switchTo(QAction*))); +void \
SwitchActivity::contextEvent(QGraphicsSceneMouseEvent *event) +{
+    KMenu desktopMenu;
+
+    desktopMenu.addTitle(i18n("Activities"));
+    makeMenu(&desktopMenu);
+
     desktopMenu.exec(event->screenPos());
 }
 
+QList<QAction*> SwitchActivity::contextualActions()
+{
+    QList<QAction*> list;
+    QMenu *menu = new QMenu();
+
+    makeMenu(menu);
+    QAction *action = new QAction(this); //FIXME I hope this doesn't leak
+    action->setMenu(menu);
+    menu->setTitle(i18n("Activities"));
+
+    list << action;
+    return list;
+}
+
 void SwitchActivity::switchTo(QAction *action)
 {
     QPointer<Plasma::Containment> ctmt = \
                action->data().value<QPointer<Plasma::Containment> >();
--- trunk/KDE/kdebase/workspace/plasma/containmentactions/switchactivity/switch.h \
#1016790:1016791 @@ -33,6 +33,8 @@
         void contextEvent(QEvent *event);
         void contextEvent(QGraphicsSceneMouseEvent *event);
         void wheelEvent(QGraphicsSceneWheelEvent *event);
+        QList<QAction*> contextualActions();
+        void makeMenu(QMenu *menu);
 
     public slots:
         void switchTo(QAction *action);


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

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