mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a toolbar action to toggle the search panel
This commit is contained in:
parent
d54f29bc0e
commit
496e6d57d7
@ -455,6 +455,10 @@ class SearchPanel(QWidget): # {{{
|
||||
self.results.setCurrentRow(0)
|
||||
self.results.item_activated()
|
||||
|
||||
def visibility_changed(self, visible):
|
||||
if visible:
|
||||
self.focus_input()
|
||||
|
||||
def clear_searches(self):
|
||||
self.current_search = None
|
||||
searchable_text_for_name.cache_clear()
|
||||
|
@ -53,6 +53,7 @@ def all_actions():
|
||||
'next_section': Action('arrow-down.png', _('Next section'), 'next_section'),
|
||||
'previous_section': Action('arrow-up.png', _('Previous section'), 'previous_section'),
|
||||
'toc': Action('toc.png', _('Table of Contents'), 'toggle_toc'),
|
||||
'search': Action('search.png', _('Search'), 'toggle_search'),
|
||||
'bookmarks': Action('bookmarks.png', _('Bookmarks'), 'toggle_bookmarks'),
|
||||
'inspector': Action('debug.png', _('Inspector'), 'toggle_inspector'),
|
||||
'reference': Action('reference.png', _('Toggle Reference mode'), 'toggle_reference_mode'),
|
||||
@ -69,7 +70,7 @@ def all_actions():
|
||||
|
||||
DEFAULT_ACTIONS = (
|
||||
'back', 'forward', None, 'open', 'copy', 'increase_font_size', 'decrease_font_size', 'fullscreen', 'color_scheme',
|
||||
None, 'previous', 'next', None, 'toc', 'bookmarks', 'lookup', 'reference', 'chrome', None, 'mode', 'print', 'preferences',
|
||||
None, 'previous', 'next', None, 'toc', 'search', 'bookmarks', 'lookup', 'reference', 'chrome', None, 'mode', 'print', 'preferences',
|
||||
'metadata', 'inspector'
|
||||
)
|
||||
|
||||
@ -121,7 +122,7 @@ class ActionsToolBar(ToolBar):
|
||||
def hide_toolbar(self):
|
||||
self.web_view.trigger_shortcut('toggle_toolbar')
|
||||
|
||||
def initialize(self, web_view):
|
||||
def initialize(self, web_view, toggle_search_action):
|
||||
self.web_view = web_view
|
||||
shortcut_action = self.create_shortcut_action
|
||||
aa = all_actions()
|
||||
@ -157,6 +158,8 @@ class ActionsToolBar(ToolBar):
|
||||
self.next_section_action = shortcut_action('next_section')
|
||||
self.previous_section_action = shortcut_action('previous_section')
|
||||
|
||||
self.search_action = a = toggle_search_action
|
||||
a.setText(aa.search.text), a.setIcon(aa.search.icon)
|
||||
self.toc_action = a = shortcut_action('toc')
|
||||
a.setCheckable(True)
|
||||
self.bookmarks_action = a = shortcut_action('bookmarks')
|
||||
|
@ -139,6 +139,7 @@ class EbookViewer(MainWindow):
|
||||
self.search_widget = w = SearchPanel(self)
|
||||
w.search_requested.connect(self.start_search)
|
||||
self.search_dock.setWidget(w)
|
||||
self.search_dock.visibilityChanged.connect(self.search_widget.visibility_changed)
|
||||
|
||||
self.lookup_widget = w = Lookup(self)
|
||||
self.lookup_dock.visibilityChanged.connect(self.lookup_widget.visibility_changed)
|
||||
@ -176,7 +177,7 @@ class EbookViewer(MainWindow):
|
||||
self.web_view.print_book.connect(self.print_book, type=Qt.QueuedConnection)
|
||||
self.web_view.reset_interface.connect(self.reset_interface, type=Qt.QueuedConnection)
|
||||
self.web_view.shortcuts_changed.connect(self.shortcuts_changed)
|
||||
self.actions_toolbar.initialize(self.web_view)
|
||||
self.actions_toolbar.initialize(self.web_view, self.search_dock.toggleViewAction())
|
||||
self.setCentralWidget(self.web_view)
|
||||
self.loading_overlay = LoadingOverlay(self)
|
||||
self.restore_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user