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

List:       kde-bugs-dist
Subject:    [Bug 4229] Right click on K menu does not give RMB menu to edit
From:       Stephan Binner <binner () kde ! org>
Date:       2004-09-26 18:47:42
Message-ID: 20040926184742.3966.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
        
http://bugs.kde.org/show_bug.cgi?id=4229        




------- Additional Comments From binner kde org  2004-09-26 20:47 -------
CVS commit by binner: 

Add menu context menus with "Edit Group" respectively "Edit Item" entry
which launch the KDE menu editor and preselect the selected group/item.
CCMAIL: 4229 bugs kde org, bastian kde org


  M +58 -4     service_mnu.cpp   1.77
  M +5 -0      service_mnu.h   1.29


--- kdebase/kicker/ui/service_mnu.cpp  #1.76:1.77
 @ -35,4 +35,5  @ CONNECTION WITH THE SOFTWARE OR THE USE 
 #include <klocale.h>
 #include <kmimetype.h>
+#include <kprocess.h>
 #include <krun.h>
 #include <kservicegroup.h>
 @ -58,5 +59,5  @ static RecentlyLaunchedApps s_RecentApps
 PanelServiceMenu::PanelServiceMenu(const QString & label, const QString & relPath, \
QWidget * parent,  const char * name, bool addmenumode)
-    : KPanelMenu(label, parent, name), relPath_(relPath), \
clearOnClose_(false),addmenumode_(addmenumode) +    : KPanelMenu(label, parent, \
name), relPath_(relPath), clearOnClose_(false),addmenumode_(addmenumode), \
popupMenu_(0)  {
     readConfig();
 @ -503,10 +504,65  @ void PanelServiceMenu::mousePressEvent(Q
 void PanelServiceMenu::mouseReleaseEvent(QMouseEvent * ev)
 {
-    if (ev->button()==RightButton)
+    if (ev->button()==RightButton && kapp->authorizeKAction("menuedit")) {
+        int id = idAt( ev->pos() );
+
+        if (id < idStart)
+            return;
+
+        if (!entryMap_.contains(id)) {
+            kdDebug(1210) << "Cannot find service with menu id " << id << endl;
+      return;
+        }
+
+        contextKSycocaEntry_ = entryMap_[id];
+
+        delete popupMenu_;
+        popupMenu_ = new KPopupMenu(this);
+        connect(popupMenu_, SIGNAL(activated(int)), SLOT(slotContextMenu(int)));
+
+        switch (contextKSycocaEntry_->sycocaType()) {
+            case KST_KService:
+                popupMenu_->insertItem( SmallIconSet("kmenuedit"), i18n("Edit Item") \
); +                break;
+
+            case KST_KServiceGroup:
+                popupMenu_->insertItem( SmallIconSet("kmenuedit"), i18n("Edit Menu") \
); +                break;
+
+            default:
       return;
+               break;
+        }
+      
+        popupMenu_->popup( this->mapToGlobal( ev->pos() ) );
+      
+        return;
+    }
 
     KPanelMenu::mouseReleaseEvent(ev);
 }
 
+void PanelServiceMenu::slotContextMenu(int)
+{
+    KProcess *proc = new KProcess;
+    *proc << KStandardDirs::findExe(QString::fromLatin1("kmenuedit"));
+
+    switch (contextKSycocaEntry_->sycocaType()) {
+        case KST_KService:
+            *proc << "/"+relPath_ << static_cast<KService \
*>(contextKSycocaEntry_)->menuId(); +            break;
+
+        case KST_KServiceGroup:
+            *proc << "/"+static_cast<KServiceGroup \
*>(contextKSycocaEntry_)->relPath(); +            break;
+
+        default:
+            return;
+            break;
+        }
+    
+    proc->start();    
+}
+
 void PanelServiceMenu::mouseMoveEvent(QMouseEvent * ev)
 {
 @ -533,6 +589,4  @ void PanelServiceMenu::mouseMoveEvent(QM
     KSycocaEntry * e = entryMap_[id];
 
-    KService::Ptr service = static_cast<KService *>(e);
-
     QString filePath;
 

--- kdebase/kicker/ui/service_mnu.h  #1.28:1.29
 @ -106,5 +106,10  @ protected:
     PopupMenuList subMenus;
     
+private slots:
+    void slotContextMenu(int);
+    
 private:
+    KPopupMenu* popupMenu_;
+    KSycocaEntry* contextKSycocaEntry_;
     void readConfig();
  };


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

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