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

List:       kde-commits
Subject:    KDE/kdebase/workspace/libs/plasma
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2007-11-18 22:02:01
Message-ID: 1195423321.606868.18347.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 738430 by aseigo:

we do actually still want context menus on applets, even with the hover thing.


 M  +2 -1      applet.cpp  
 M  +36 -6     containment.cpp  


--- trunk/KDE/kdebase/workspace/libs/plasma/applet.cpp #738429:738430
@@ -1189,12 +1189,14 @@
 {
     //kDebug() << "context menu event!";
     if (!scene()) {
+        //kDebug() << "no scene?!";
         return;
     }
 
     Applet* containment = dynamic_cast<Plasma::Applet*>(topLevelItem());
 
     if (!containment) {
+        //kDebug() << "no containment. hm.";
         Widget::contextMenuEvent(event);
         return;
     }
@@ -1202,7 +1204,6 @@
     // we want to pass up the context menu event to the Containment at
     // this point
     containment->contextMenuEvent(event);
-    return;
 }
 
 } // Plasma namespace
--- trunk/KDE/kdebase/workspace/libs/plasma/containment.cpp #738429:738430
@@ -163,7 +163,7 @@
     }
 
     KMenu desktopMenu;
-    //kDebug() << "context menu event " << immutable;
+    //kDebug() << "context menu event " << (QObject*)applet;
     if (!applet) {
         if (!scene() || static_cast<Corona*>(scene())->isImmutable()) {
             //kDebug() << "immutability";
@@ -185,9 +185,40 @@
             desktopMenu.addAction(action);
         }
     } else {
-        //kDebug() << "immutable applet";
-        QGraphicsItem::contextMenuEvent(event);
-        return;
+        bool hasEntries = false;   
+        if (applet->hasConfigurationInterface()) {   
+            QAction* configureApplet = new QAction(i18n("%1 Settings...", \
applet->name()), &desktopMenu);    +            connect(configureApplet, \
SIGNAL(triggered(bool)),    +                    applet, \
SLOT(showConfigurationInterface()));    +            \
desktopMenu.addAction(configureApplet);    +            hasEntries = true;   
+        }   
+    
+        if (scene() && !static_cast<Corona*>(scene())->isImmutable()) {   
+            QAction* closeApplet = new QAction(i18n("Remove this %1", \
applet->name()), &desktopMenu);    +            QVariant appletV;   
+            appletV.setValue((QObject*)applet);   
+            closeApplet->setData(appletV);   
+            connect(closeApplet, SIGNAL(triggered(bool)),   
+                    this, SLOT(destroyApplet()));   
+            desktopMenu.addAction(closeApplet);   
+            hasEntries = true;   
+        }   
+    
+        QList<QAction*> actions = applet->contextActions();   
+        if (!actions.isEmpty()) {   
+            desktopMenu.addSeparator();   
+            foreach(QAction* action, actions) {   
+                desktopMenu.addAction(action);   
+            }   
+            hasEntries = true;   
+        }   
+    
+        if (!hasEntries) {   
+            QGraphicsItem::contextMenuEvent(event);   
+            kDebug() << "no entries";   
+            return;   
+        }
     }
 
     event->accept();
@@ -529,8 +560,7 @@
 
     switch (event->type()) {
     case QEvent::GraphicsSceneHoverEnter:
-        if (!d->immutable && !applet->isImmutable()
-         && !d->handles.contains(applet)) {
+        if (!d->immutable && !applet->isImmutable() && !d->handles.contains(applet)) \
{  AppletHandle *handle = new AppletHandle(this, applet);
             d->handles[applet] = handle;
             connect(handle, SIGNAL(disappearDone(AppletHandle*)),


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

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