mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add search for the preview panel
This commit is contained in:
parent
a35f25a122
commit
4af671be80
@ -13,6 +13,7 @@ from future_builtins import map
|
||||
from threading import Thread
|
||||
from Queue import Queue, Empty
|
||||
from collections import namedtuple
|
||||
from functools import partial
|
||||
|
||||
from PyQt4.Qt import (
|
||||
QWidget, QVBoxLayout, QApplication, QSize, QNetworkAccessManager, QMenu, QIcon,
|
||||
@ -30,6 +31,7 @@ from calibre.gui2 import error_dialog
|
||||
from calibre.gui2.tweak_book import current_container, editors, tprefs, actions
|
||||
from calibre.gui2.viewer.documentview import apply_settings
|
||||
from calibre.gui2.viewer.config import config
|
||||
from calibre.gui2.widgets2 import HistoryLineEdit2
|
||||
from calibre.utils.ipc.simple_worker import offload_worker
|
||||
|
||||
shutdown = object()
|
||||
@ -463,6 +465,22 @@ class Preview(QWidget):
|
||||
parse_worker.start()
|
||||
self.current_sync_request = None
|
||||
|
||||
self.search = HistoryLineEdit2(self)
|
||||
self.search.initialize('tweak_book_preview_search')
|
||||
self.search.setPlaceholderText(_('Search in preview'))
|
||||
self.search.returnPressed.connect(partial(self.find, 'next'))
|
||||
self.bar.addSeparator()
|
||||
self.bar.addWidget(self.search)
|
||||
for d in ('next', 'prev'):
|
||||
ac = actions['find-%s-preview' % d]
|
||||
ac.triggered.connect(partial(self.find, d))
|
||||
self.bar.addAction(ac)
|
||||
|
||||
def find(self, direction):
|
||||
text = unicode(self.search.text())
|
||||
self.view.findText(text, QWebPage.FindWrapsAroundDocument | (
|
||||
QWebPage.FindBackward if direction == 'prev' else QWebPage.FindFlags(0)))
|
||||
|
||||
def request_sync(self, lnum):
|
||||
if self.current_name:
|
||||
self.sync_requested.emit(self.current_name, lnum)
|
||||
|
@ -239,6 +239,8 @@ class Main(MainWindow):
|
||||
self.action_reload_preview = reg('view-refresh.png', _('Refresh preview'), None, 'reload-preview', ('F5',), _('Refresh preview'))
|
||||
self.action_split_in_preview = reg('auto_author_sort.png', _('Split this file'), None, 'split-in-preview', (), _(
|
||||
'Split file in the preview panel'))
|
||||
self.action_find_next_preview = reg('arrow-down.png', _('Find Next'), None, 'find-next-preview', (), _('Find next in preview'))
|
||||
self.action_find_prev_preview = reg('arrow-up.png', _('Find Previous'), None, 'find-prev-preview', (), _('Find previous in preview'))
|
||||
|
||||
# Search actions
|
||||
group = _('Search')
|
||||
|
Loading…
x
Reference in New Issue
Block a user