Proposed changes to calibre.gui2.bars - incomplete implementation, need to discriminate which menu item received the drop. For KG review.

This commit is contained in:
GRiker 2013-03-02 05:16:16 -07:00
parent 4fe4ab84ee
commit b7555d7424

View File

@ -123,6 +123,15 @@ class ToolBar(QToolBar): # {{{
md.hasFormat("application/calibre+from_device"): md.hasFormat("application/calibre+from_device"):
event.setDropAction(Qt.CopyAction) event.setDropAction(Qt.CopyAction)
event.accept() 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: else:
event.ignore() event.ignore()
@ -141,6 +150,15 @@ class ToolBar(QToolBar): # {{{
break break
if allowed: if allowed:
event.acceptProposedAction() 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: else:
event.ignore() event.ignore()
@ -169,6 +187,15 @@ class ToolBar(QToolBar): # {{{
self.gui.current_view(), paths=paths) self.gui.current_view(), paths=paths)
event.accept() 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): # {{{ class MenuAction(QAction): # {{{