From b7555d7424c70916e53d4b5fc307f5fe2a63961a Mon Sep 17 00:00:00 2001 From: GRiker Date: Sat, 2 Mar 2013 05:16:16 -0700 Subject: [PATCH] Proposed changes to calibre.gui2.bars - incomplete implementation, need to discriminate which menu item received the drop. For KG review. --- src/calibre/gui2/bars.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/calibre/gui2/bars.py b/src/calibre/gui2/bars.py index 50b3f3e7f5..38643fb40f 100644 --- a/src/calibre/gui2/bars.py +++ b/src/calibre/gui2/bars.py @@ -123,6 +123,15 @@ class ToolBar(QToolBar): # {{{ md.hasFormat("application/calibre+from_device"): event.setDropAction(Qt.CopyAction) event.accept() + + elif self.added_actions: + # Give added_actions an opportunity to process the drag&drop event + # This calls the first QMenu object that accepts drops, rather than the + # specific one that was dropped on + for aa in self.added_actions: + if aa.menu() is not None and aa.menu().acceptDrops(): + aa.menu().dragEnterEvent(event) + break else: event.ignore() @@ -141,6 +150,15 @@ class ToolBar(QToolBar): # {{{ break if allowed: event.acceptProposedAction() + + elif self.added_actions: + # Give added_actions an opportunity to process the drag&drop event + # This calls the first QMenu object that accepts drops, rather than the + # specific one that was dropped on + for aa in self.added_actions: + if aa.menu() is not None and aa.menu().acceptDrops(): + aa.menu().dragMoveEvent(event) + break else: event.ignore() @@ -169,6 +187,15 @@ class ToolBar(QToolBar): # {{{ self.gui.current_view(), paths=paths) event.accept() + # Give added_actions an opportunity to process the drag&drop event + # This calls the first QMenu object that accepts drops, rather than the + # specific one that was dropped on + if self.added_actions: + for aa in self.added_actions: + if aa.menu() is not None and aa.menu().acceptDrops(): + aa.menu().dropEvent(event) + break + # }}} class MenuAction(QAction): # {{{