Full text search: Allow pressing Ctrl+S to select the current book in the calibre book list. Fixes #2056664 [[Enhancement] Shortcut in the Full search window to jump/select book in calibre library](https://bugs.launchpad.net/calibre/+bug/2056664)

This commit is contained in:
Kovid Goyal 2024-03-10 19:29:24 +05:30
parent 8cd60c1a96
commit 88d926143e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 18 additions and 4 deletions

View File

@ -61,6 +61,7 @@ class FTSDialog(Dialog):
self.show_appropriate_panel()
self.update_indexing_label()
self.scan_status.indexing_progress_changed.connect(self.update_indexing_label)
self.addAction(self.results_panel.jump_to_current_book_action)
def show_fat_details(self):
warning_dialog(self, _('Library on a FAT drive'), _(

View File

@ -10,9 +10,10 @@ from contextlib import suppress
from functools import partial
from itertools import count
from qt.core import (
QAbstractItemModel, QAbstractItemView, QCheckBox, QDialog, QDialogButtonBox, QFont,
QHBoxLayout, QIcon, QLabel, QMenu, QModelIndex, QPixmap, QPushButton, QRect, QSize,
QSplitter, QStackedWidget, Qt, QTreeView, QVBoxLayout, QWidget, pyqtSignal,
QAbstractItemModel, QAbstractItemView, QAction, QCheckBox, QDialog,
QDialogButtonBox, QFont, QHBoxLayout, QIcon, QKeySequence, QLabel, QMenu,
QModelIndex, QPixmap, QPushButton, QRect, QSize, QSplitter, QStackedWidget, Qt,
QTreeView, QVBoxLayout, QWidget, pyqtSignal,
)
from threading import Event, Thread
@ -589,6 +590,9 @@ class ResultDetails(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.jump_action = ac = QAction(self)
ac.triggered.connect(self.jump_to_current_book)
ac.setShortcut(QKeySequence('Ctrl+S', QKeySequence.SequenceFormat.PortableText))
self.key = None
self.pixmap_label = pl = QLabel(self)
pl.setScaledContents(True)
@ -626,6 +630,10 @@ class ResultDetails(QWidget):
' to see updated results.'), show=True)
self.remove_book_from_results.emit(self.current_book_id)
def jump_to_current_book(self):
if self.current_book_id > -1:
jump_to_book(self.current_book_id)
def results_anchor_clicked(self, url):
if self.current_book_id > 0 and url.scheme() == 'book':
book_id, result_num, fmt = url.path().strip('/').split('/')
@ -686,7 +694,8 @@ class ResultDetails(QWidget):
text += '<p>' + _('{series_index} of {series}').format(series_index=sidx, series=series) + '</p>'
ict = '<img valign="bottom" src="calibre-icon:///{}" width=16 height=16>'
text += '<p><a href="calibre://jump" title="{1}">{2}\xa0{0}</a>\xa0\xa0\xa0 '.format(
_('Select'), '<p>' + _('Scroll to this book in the calibre library book list and select it.'), ict.format('lt.png'))
_('Select'), '<p>' + _('Scroll to this book in the calibre library book list and select it [{}]').format(
self.jump_action.shortcut().toString(QKeySequence.SequenceFormat.NativeText)), ict.format('lt.png'))
text += '<a href="calibre://mark" title="{1}">{2}\xa0{0}</a></p>'.format(
_('Mark'), '<p>' + _(
'Put a pin on this book in the calibre library, for future reference.'
@ -856,6 +865,10 @@ class ResultsPanel(QWidget):
if st is not None:
s.restoreState(st)
@property
def jump_to_current_book_action(self):
return self.details.result_details.jump_action
def view_current_result(self):
return self.results_view.view_current_result()