From 3b2b7845de6ab2b97428a3591a2005409c7828d4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 28 Aug 2014 11:14:12 +0530 Subject: [PATCH] OS X: Workaround for Qt 5 bug that causes the popup menu on the author to author sort button in the edit metadata dialog to not respond if the mouse button if not released once before clicking menu entries. See #1362338 (Copy Author Sort to Author isn't working) https://bugreports.qt-project.org/browse/QTBUG-41017 --- src/calibre/gui2/metadata/single.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/metadata/single.py b/src/calibre/gui2/metadata/single.py index cf457f764f..c2435a1927 100644 --- a/src/calibre/gui2/metadata/single.py +++ b/src/calibre/gui2/metadata/single.py @@ -15,6 +15,7 @@ from PyQt5.Qt import (Qt, QVBoxLayout, QHBoxLayout, QWidget, QPushButton, QTabWidget, QIcon, QToolButton, QSplitter, QGroupBox, QSpacerItem, QSizePolicy, QFrame, QSize, QKeySequence, QMenu, QShortcut) +from calibre.constants import isosx from calibre.ebooks.metadata import authors_to_string, string_to_authors from calibre.gui2 import ResizableDialog, error_dialog, gprefs, pixmap_to_data from calibre.gui2.metadata.basic_widgets import (TitleEdit, AuthorsEdit, @@ -129,7 +130,18 @@ class MetadataSingleDialogBase(ResizableDialog): 'change author sort from red to green. There is a menu of ' 'functions available under this button. Click and hold ' 'on the button to see it.') + '

') - b.m = m = QMenu() + if isosx: + # Workaround for https://bugreports.qt-project.org/browse/QTBUG-41017 + class Menu(QMenu): + + def mouseReleaseEvent(self, ev): + ac = self.actionAt(ev.pos()) + if ac is not None: + ac.trigger() + return QMenu.mouseReleaseEvent(self, ev) + b.m = m = Menu() + else: + b.m = m = QMenu() ac = m.addAction(QIcon(I('forward.png')), _('Set author sort from author')) ac2 = m.addAction(QIcon(I('back.png')), _('Set author from author sort')) ac3 = m.addAction(QIcon(I('user_profile.png')), _('Manage authors'))