Bug 81438 - JJ: Kmenu doesn't close after dragging a shortcut to the desktop
Summary: JJ: Kmenu doesn't close after dragging a shortcut to the desktop
Status: RESOLVED FIXED
Alias: None
Product: kicker
Classification: Plasma
Component: Drag 'n Drop (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: John Firebaugh
URL:
Keywords:
: 83318 85382 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-05-12 17:32 UTC by Jukka Hellen
Modified: 2005-01-14 19:15 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
kmenu-close-after-drop.patch (1.09 KB, patch)
2005-01-11 22:34 UTC, Stefan Nikolaus
Details
kmenu-close-after-drop.patch (4.17 KB, patch)
2005-01-13 15:14 UTC, Stefan Nikolaus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jukka Hellen 2004-05-12 17:32:56 UTC
Version:            (using KDE KDE 3.2.2)
Installed from:    Unlisted Binary Package
OS:                Linux

Try to drag a shortcut from the Kmenu to the desktop and that Kmenu wont go down automatically. You have to do it manually afterwards :(
Comment 1 Daniel Roberge 2004-05-27 08:36:59 UTC
This same behavior occurs for me in KDE 3.3alpha1. I'm not sure this is necessarily the wrong behavior, though.
Comment 2 Stephan Binner 2004-06-15 07:55:57 UTC
*** Bug 83318 has been marked as a duplicate of this bug. ***
Comment 3 Stephan Binner 2004-07-18 15:57:48 UTC
*** Bug 85382 has been marked as a duplicate of this bug. ***
Comment 4 Stefan Nikolaus 2005-01-11 22:34:46 UTC
Created attachment 9044 [details]
kmenu-close-after-drop.patch
Comment 5 Stefan Nikolaus 2005-01-13 15:14:22 UTC
Created attachment 9072 [details]
kmenu-close-after-drop.patch

Improved patch. Respects accidental drags. Also solves
http://bugs.kde.org/show_bug.cgi?id=88940.
Comment 6 Stefan Nikolaus 2005-01-14 08:51:22 UTC
Okay, I've polished the patch respecting the coding style. Instead of creating a new attachment and mess this report up you can mail me if you're interested.
Comment 7 Aaron J. Seigo 2005-01-14 19:15:51 UTC
CVS commit by aseigo: 

close menus after dragging items out of them
patch graciously contributed by Stefan Nikolaus

BUG:81438
BUG:88940
CCMAIL: stefan.nikolaus@stuco.uni-oldenburg.de


  M +9 -0      browser_mnu.cpp   1.67
  M +1 -0      browser_mnu.h   1.17
  M +31 -2     service_mnu.cpp   1.90
  M +3 -0      service_mnu.h   1.36


--- kdebase/kicker/ui/browser_mnu.cpp  #1.66:1.67
@@ -399,8 +399,17 @@ void PanelBrowserMenu::mouseMoveEvent(QM
     KURL::List files(url);
     KURLDrag *d = new KURLDrag(files, this);
+    connect(d, SIGNAL(destroyed()), this, SLOT(slotDragObjectDestroyed()));
     d->setPixmap(iconSet(id)->pixmap());
     d->drag();
 }
 
+void PanelBrowserMenu::slotDragObjectDestroyed()
+{
+    if (KURLDrag::target() != this)
+    {
+        close();
+    }
+}
+
 void PanelBrowserMenu::dragEnterEvent( QDragEnterEvent *ev )
 {

--- kdebase/kicker/ui/browser_mnu.h  #1.16:1.17
@@ -51,4 +51,5 @@ protected slots:
     void slotClearIfNeeded(const QString&);
     void slotClear();
+    void slotDragObjectDestroyed();
 
 protected:

--- kdebase/kicker/ui/service_mnu.cpp  #1.89:1.90
@@ -693,8 +693,7 @@ void PanelServiceMenu::mouseMoveEvent(QM
 
     KURLDrag *d = new KURLDrag(KURL::List(url), this);
-
+    connect(d, SIGNAL(destroyed()), this, SLOT(slotDragObjectDestroyed()));
     d->setPixmap(icon);
     d->dragCopy();
-    //close();
 
     // Set the startposition outside the panel, so there is no drag initiated
@@ -704,4 +703,34 @@ void PanelServiceMenu::mouseMoveEvent(QM
 }
 
+void PanelServiceMenu::dragEnterEvent(QDragEnterEvent *event)
+{
+    // Set the DragObject's target to this widget. This is needed because the
+    // widget doesn't accept drops, but we want to determine if the drag object
+    // is dropped on it. This avoids closing on accidental drags. If this
+    // widget accepts drops in the future, these lines can be removed.
+    if (event->source() == this)
+    {
+        KURLDrag::setTarget(this);
+    }
+    event->ignore();
+}
+
+void PanelServiceMenu::dragLeaveEvent(QDragLeaveEvent */*event*/)
+{
+    // see PanelServiceMenu::dragEnterEvent why this is nescessary
+    if (!frameGeometry().contains(QCursor::pos()))
+    {
+        KURLDrag::setTarget(0);
+    }
+}
+
+void PanelServiceMenu::slotDragObjectDestroyed()
+{
+    if (KURLDrag::target() != this)
+    {
+        close();
+    }
+}
+
 PanelServiceMenu *PanelServiceMenu::newSubMenu(const QString & label, const QString & relPath,
                                                QWidget * parent, const char * name)

--- kdebase/kicker/ui/service_mnu.h  #1.35:1.36
@@ -76,4 +76,5 @@ protected slots:
     virtual void configChanged();
     virtual void slotClose();
+    void slotDragObjectDestroyed();
 
 protected:
@@ -84,4 +85,6 @@ protected:
     virtual void mouseReleaseEvent(QMouseEvent *);
     virtual void mouseMoveEvent(QMouseEvent *);
+    virtual void dragEnterEvent(QDragEnterEvent *);
+    virtual void dragLeaveEvent(QDragLeaveEvent *);
 
     void activateParent(const QString &child);