mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Show shortcut for add highlight button in tooltip
This commit is contained in:
parent
1905a8e750
commit
ba99cb7971
@ -7,13 +7,14 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
from itertools import chain
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QHBoxLayout, QIcon, QItemSelectionModel, QLabel, QListWidget, QListWidgetItem,
|
||||
QPushButton, Qt, QTextBrowser, QVBoxLayout, QWidget, pyqtSignal
|
||||
QHBoxLayout, QIcon, QItemSelectionModel, QKeySequence, QLabel, QListWidget,
|
||||
QListWidgetItem, QPushButton, Qt, QTextBrowser, QVBoxLayout, QWidget, pyqtSignal
|
||||
)
|
||||
|
||||
from calibre.constants import plugins
|
||||
from calibre.gui2 import error_dialog, question_dialog
|
||||
from calibre.gui2.viewer.search import SearchInput
|
||||
from calibre.gui2.viewer.shortcuts import index_to_key_sequence
|
||||
from polyglot.builtins import range
|
||||
|
||||
|
||||
@ -128,6 +129,18 @@ class HighlightsPanel(QWidget):
|
||||
l.addWidget(nd)
|
||||
nd.setVisible(False)
|
||||
|
||||
def set_tooltips(self, rmap):
|
||||
a = rmap.get('create_annotation')
|
||||
if a:
|
||||
|
||||
def as_text(idx):
|
||||
return index_to_key_sequence(idx).toString(QKeySequence.NativeText)
|
||||
|
||||
tt = self.add_button.toolTip().partition('[')[0].strip()
|
||||
keys = sorted(filter(None, map(as_text, a)))
|
||||
if keys:
|
||||
self.add_button.setToolTip('{} [{}]'.format(tt, ', '.join(keys)))
|
||||
|
||||
def search_requested(self, query):
|
||||
if not self.highlights.find_query(query):
|
||||
error_dialog(self, _('No matches'), _(
|
||||
|
@ -203,6 +203,7 @@ class EbookViewer(MainWindow):
|
||||
for k, v in iteritems(smap):
|
||||
rmap[v].append(k)
|
||||
self.actions_toolbar.set_tooltips(rmap)
|
||||
self.highlights_widget.set_tooltips(rmap)
|
||||
|
||||
def resizeEvent(self, ev):
|
||||
self.loading_overlay.resize(self.size())
|
||||
|
Loading…
x
Reference in New Issue
Block a user