mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2034757 [[Enhancement] E-book viewer: search pane should have a context menu](https://bugs.launchpad.net/calibre/+bug/2034757)
This commit is contained in:
parent
ad2f746c2c
commit
3b6e829d36
@ -6,8 +6,8 @@ import regex
|
||||
from collections import Counter, OrderedDict
|
||||
from html import escape
|
||||
from qt.core import (
|
||||
QAbstractItemView, QCheckBox, QComboBox, QFont, QHBoxLayout, QIcon, QLabel, Qt,
|
||||
QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal,
|
||||
QAbstractItemView, QCheckBox, QComboBox, QFont, QHBoxLayout, QIcon, QLabel, QMenu,
|
||||
Qt, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal,
|
||||
)
|
||||
from threading import Thread
|
||||
|
||||
@ -542,6 +542,8 @@ class Results(QTreeWidget): # {{{
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QTreeWidget.__init__(self, parent)
|
||||
self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||
self.customContextMenuRequested.connect(self.show_context_menu)
|
||||
self.setHeaderHidden(True)
|
||||
self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
self.delegate = ResultsDelegate(self)
|
||||
@ -558,6 +560,14 @@ class Results(QTreeWidget): # {{{
|
||||
self.gesture_manager = GestureManager(self)
|
||||
self.setVerticalScrollMode(QAbstractItemView.ScrollMode.ScrollPerPixel)
|
||||
|
||||
def show_context_menu(self, point):
|
||||
self.context_menu = m = QMenu(self)
|
||||
m.addAction(QIcon.ic('plus.png'), _('Expand all'), self.expandAll)
|
||||
m.addAction(QIcon.ic('minus.png'), _('Collapse all'), self.collapseAll)
|
||||
self.context_menu.popup(self.mapToGlobal(point))
|
||||
return True
|
||||
|
||||
|
||||
def viewportEvent(self, ev):
|
||||
if hasattr(self, 'gesture_manager'):
|
||||
ret = self.gesture_manager.handle_event(ev)
|
||||
|
Loading…
x
Reference in New Issue
Block a user