mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
8cd60c1a96
commit
88d926143e
@ -61,6 +61,7 @@ class FTSDialog(Dialog):
|
|||||||
self.show_appropriate_panel()
|
self.show_appropriate_panel()
|
||||||
self.update_indexing_label()
|
self.update_indexing_label()
|
||||||
self.scan_status.indexing_progress_changed.connect(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):
|
def show_fat_details(self):
|
||||||
warning_dialog(self, _('Library on a FAT drive'), _(
|
warning_dialog(self, _('Library on a FAT drive'), _(
|
||||||
|
@ -10,9 +10,10 @@ from contextlib import suppress
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from itertools import count
|
from itertools import count
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemModel, QAbstractItemView, QCheckBox, QDialog, QDialogButtonBox, QFont,
|
QAbstractItemModel, QAbstractItemView, QAction, QCheckBox, QDialog,
|
||||||
QHBoxLayout, QIcon, QLabel, QMenu, QModelIndex, QPixmap, QPushButton, QRect, QSize,
|
QDialogButtonBox, QFont, QHBoxLayout, QIcon, QKeySequence, QLabel, QMenu,
|
||||||
QSplitter, QStackedWidget, Qt, QTreeView, QVBoxLayout, QWidget, pyqtSignal,
|
QModelIndex, QPixmap, QPushButton, QRect, QSize, QSplitter, QStackedWidget, Qt,
|
||||||
|
QTreeView, QVBoxLayout, QWidget, pyqtSignal,
|
||||||
)
|
)
|
||||||
from threading import Event, Thread
|
from threading import Event, Thread
|
||||||
|
|
||||||
@ -589,6 +590,9 @@ class ResultDetails(QWidget):
|
|||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
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.key = None
|
||||||
self.pixmap_label = pl = QLabel(self)
|
self.pixmap_label = pl = QLabel(self)
|
||||||
pl.setScaledContents(True)
|
pl.setScaledContents(True)
|
||||||
@ -626,6 +630,10 @@ class ResultDetails(QWidget):
|
|||||||
' to see updated results.'), show=True)
|
' to see updated results.'), show=True)
|
||||||
self.remove_book_from_results.emit(self.current_book_id)
|
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):
|
def results_anchor_clicked(self, url):
|
||||||
if self.current_book_id > 0 and url.scheme() == 'book':
|
if self.current_book_id > 0 and url.scheme() == 'book':
|
||||||
book_id, result_num, fmt = url.path().strip('/').split('/')
|
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>'
|
text += '<p>' + _('{series_index} of {series}').format(series_index=sidx, series=series) + '</p>'
|
||||||
ict = '<img valign="bottom" src="calibre-icon:///{}" width=16 height=16>'
|
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(
|
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(
|
text += '<a href="calibre://mark" title="{1}">{2}\xa0{0}</a></p>'.format(
|
||||||
_('Mark'), '<p>' + _(
|
_('Mark'), '<p>' + _(
|
||||||
'Put a pin on this book in the calibre library, for future reference.'
|
'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:
|
if st is not None:
|
||||||
s.restoreState(st)
|
s.restoreState(st)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def jump_to_current_book_action(self):
|
||||||
|
return self.details.result_details.jump_action
|
||||||
|
|
||||||
def view_current_result(self):
|
def view_current_result(self):
|
||||||
return self.results_view.view_current_result()
|
return self.results_view.view_current_result()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user