Save search parameters in tabbed_browser.

This commit is contained in:
Florian Bruhin 2015-09-18 07:01:51 +02:00
parent f62bf099a0
commit 841e8fbbd1
3 changed files with 14 additions and 18 deletions

View File

@ -1308,10 +1308,8 @@ class CommandDispatcher:
view.search(text, flags | QWebPage.HighlightAllOccurrences)
view.search_text = text
view.search_flags = flags
main_window = objreg.get('main-window', scope='window',
window=self._win_id)
main_window.search_text = text
main_window.search_flags = flags
self._tabbed_browser.search_text = text
self._tabbed_browser.search_flags = flags
@cmdutils.register(instance='command-dispatcher', hide=True,
scope='window', count='count')
@ -1322,14 +1320,12 @@ class CommandDispatcher:
count: How many elements to ignore.
"""
view = self._current_widget()
main_window = objreg.get('main-window', scope='window',
window=self._win_id)
self._clear_search(view, main_window.search_text)
self._clear_search(view, self._tabbed_browser.search_text)
if main_window.search_text is not None:
view.search_text = main_window.search_text
view.search_flags = main_window.search_flags
if self._tabbed_browser.search_text is not None:
view.search_text = self._tabbed_browser.search_text
view.search_flags = self._tabbed_browser.search_flags
view.search(view.search_text,
view.search_flags | QWebPage.HighlightAllOccurrences)
for _ in range(count):
@ -1344,13 +1340,11 @@ class CommandDispatcher:
count: How many elements to ignore.
"""
view = self._current_widget()
main_window = objreg.get('main-window', scope='window',
window=self._win_id)
self._clear_search(view, main_window.search_text)
self._clear_search(view, self._tabbed_browser.search_text)
if main_window.search_text is not None:
view.search_text = main_window.search_text
view.search_flags = main_window.search_flags
if self._tabbed_browser.search_text is not None:
view.search_text = self._tabbed_browser.search_text
view.search_flags = self._tabbed_browser.search_flags
view.search(view.search_text,
view.search_flags | QWebPage.HighlightAllOccurrences)
# The int() here serves as a QFlags constructor to create a copy of the

View File

@ -109,8 +109,6 @@ class MainWindow(QWidget):
self._commandrunner = None
self.win_id = next(win_id_gen)
self.registry = objreg.ObjectRegistry()
self.search_text = None
self.search_flags = 0
objreg.window_registry[self.win_id] = self
objreg.register('main-window', self, scope='window',
window=self.win_id)

View File

@ -54,6 +54,8 @@ class TabbedBrowser(tabwidget.TabWidget):
emitted if the signal occurred in the current tab.
Attributes:
search_text/search_flags: Search parameters which are shared between
all tabs.
_win_id: The window ID this tabbedbrowser is associated with.
_filter: A SignalFilter instance.
_now_focused: The tab which is focused now.
@ -108,6 +110,8 @@ class TabbedBrowser(tabwidget.TabWidget):
self._undo_stack = []
self._filter = signalfilter.SignalFilter(win_id, self)
self._now_focused = None
self.search_text = None
self.search_flags = 0
objreg.get('config').changed.connect(self.update_favicons)
objreg.get('config').changed.connect(self.update_window_title)
objreg.get('config').changed.connect(self.update_tab_titles)