mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Workaround for incompatibility between Qt 5.5+ and Ubuntu that caused the context menu for the book list to flicker. Fixes #1534936 [Context menu of the individual books on Ubuntu 15:10 flawed](https://bugs.launchpad.net/calibre/+bug/1534936)
This commit is contained in:
parent
3636e380f3
commit
1c1d8c4f9e
@ -13,6 +13,7 @@ from PyQt5.Qt import (QImage, QSizePolicy, QTimer, QDialog, Qt, QSize, QAction,
|
|||||||
QStackedLayout, QLabel, QByteArray, pyqtSignal, QKeySequence, QFont)
|
QStackedLayout, QLabel, QByteArray, pyqtSignal, QKeySequence, QFont)
|
||||||
|
|
||||||
from calibre import plugins
|
from calibre import plugins
|
||||||
|
from calibre.constants import islinux
|
||||||
from calibre.gui2 import (config, available_height, available_width, gprefs,
|
from calibre.gui2 import (config, available_height, available_width, gprefs,
|
||||||
rating_font)
|
rating_font)
|
||||||
|
|
||||||
@ -170,8 +171,10 @@ if pictureflow is not None:
|
|||||||
|
|
||||||
def contextMenuEvent(self, event):
|
def contextMenuEvent(self, event):
|
||||||
if self.context_menu is not None:
|
if self.context_menu is not None:
|
||||||
|
from calibre.gui2.main_window import clone_menu
|
||||||
self.context_menu_requested.emit()
|
self.context_menu_requested.emit()
|
||||||
self.context_menu.popup(event.globalPos())
|
m = clone_menu(self.context_menu) if islinux else self.context_menu
|
||||||
|
m.popup(event.globalPos())
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
|
@ -15,6 +15,7 @@ from PyQt5.Qt import (
|
|||||||
QIcon, QItemSelection, QMimeData, QDrag, QStyle, QPoint, QUrl, QHeaderView,
|
QIcon, QItemSelection, QMimeData, QDrag, QStyle, QPoint, QUrl, QHeaderView,
|
||||||
QStyleOptionHeader, QItemSelectionModel, QSize, QFontMetrics)
|
QStyleOptionHeader, QItemSelectionModel, QSize, QFontMetrics)
|
||||||
|
|
||||||
|
from calibre.constants import islinux
|
||||||
from calibre.gui2.library.delegates import (RatingDelegate, PubDateDelegate,
|
from calibre.gui2.library.delegates import (RatingDelegate, PubDateDelegate,
|
||||||
TextDelegate, DateDelegate, CompleteDelegate, CcTextDelegate,
|
TextDelegate, DateDelegate, CompleteDelegate, CcTextDelegate,
|
||||||
CcBoolDelegate, CcCommentsDelegate, CcDateDelegate, CcTemplateDelegate,
|
CcBoolDelegate, CcCommentsDelegate, CcDateDelegate, CcTemplateDelegate,
|
||||||
@ -818,11 +819,13 @@ class BooksView(QTableView): # {{{
|
|||||||
self.edit_collections_action = edit_collections_action
|
self.edit_collections_action = edit_collections_action
|
||||||
|
|
||||||
def contextMenuEvent(self, event):
|
def contextMenuEvent(self, event):
|
||||||
|
from calibre.gui2.main_window import clone_menu
|
||||||
sac = self.gui.iactions['Sort By']
|
sac = self.gui.iactions['Sort By']
|
||||||
sort_added = tuple(ac for ac in self.context_menu.actions() if ac is sac.qaction)
|
sort_added = tuple(ac for ac in self.context_menu.actions() if ac is sac.qaction)
|
||||||
if sort_added:
|
if sort_added:
|
||||||
sac.update_menu()
|
sac.update_menu()
|
||||||
self.context_menu.popup(event.globalPos())
|
m = clone_menu(self.context_menu) if islinux else self.context_menu
|
||||||
|
m.popup(event.globalPos())
|
||||||
event.accept()
|
event.accept()
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -162,3 +162,29 @@ class MainWindow(QMainWindow):
|
|||||||
elif etype == ev.WindowUnblocked:
|
elif etype == ev.WindowUnblocked:
|
||||||
self.window_unblocked.emit()
|
self.window_unblocked.emit()
|
||||||
return QMainWindow.event(self, ev)
|
return QMainWindow.event(self, ev)
|
||||||
|
|
||||||
|
def clone_menu(menu):
|
||||||
|
def clone_action(ac, parent):
|
||||||
|
if ac.isSeparator():
|
||||||
|
ans = QAction(parent)
|
||||||
|
ans.setSeparator(True)
|
||||||
|
return ans
|
||||||
|
sc = ac.shortcut()
|
||||||
|
sc = '' if sc.isEmpty() else sc.toString(sc.NativeText)
|
||||||
|
ans = QAction(ac.icon(), ac.text() + '\t' + sc, parent)
|
||||||
|
ans.triggered.connect(ac.trigger)
|
||||||
|
ans.setEnabled(ac.isEnabled())
|
||||||
|
ans.setStatusTip(ac.statusTip())
|
||||||
|
ans.setVisible(ac.isVisible())
|
||||||
|
return ans
|
||||||
|
|
||||||
|
def clone_one_menu(m):
|
||||||
|
ans = QMenu(m.parent())
|
||||||
|
for ac in m.actions():
|
||||||
|
cac = clone_action(ac, ans)
|
||||||
|
ans.addAction(cac)
|
||||||
|
m = ac.menu()
|
||||||
|
if m is not None:
|
||||||
|
cac.setMenu(clone_menu(m))
|
||||||
|
return ans
|
||||||
|
return clone_one_menu(menu)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user