From e5000c315dd29ae9356e1b33ed041917c637c85b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 6 May 2014 07:11:20 +0200 Subject: [PATCH] Revert "Use global HintManager" This reverts commit a76d68f564aa7750e96ff1a79f14a6cf528325f1. WTF. I thought I reset --hard-ed that one? --- qutebrowser/app.py | 14 ++++---------- qutebrowser/browser/curcommand.py | 23 +++++++++++++++++++++-- qutebrowser/browser/hints.py | 5 ----- qutebrowser/widgets/_tabbedbrowser.py | 6 ++++++ 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index f6e9008d6..ef35657ac 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -63,7 +63,6 @@ from qutebrowser.commands.managers import CommandManager, SearchManager from qutebrowser.config.iniparsers import ReadWriteConfigParser from qutebrowser.config.lineparser import LineConfigParser from qutebrowser.browser.cookies import CookieJar -from qutebrowser.browser.hints import HintManager from qutebrowser.utils.message import MessageBridge from qutebrowser.utils.misc import dotted_getattr from qutebrowser.utils.debug import set_trace # pylint: disable=unused-import @@ -89,7 +88,6 @@ class QuteBrowser(QApplication): modeman: The global ModeManager instance. networkmanager: The global NetworkManager instance. cookiejar: The global CookieJar instance. - hintmanager: The global HintManager instance. _keyparsers: A mapping from modes to keyparsers. _dirs: AppDirs instance for config/cache directories. _args: ArgumentParser instance. @@ -129,7 +127,6 @@ class QuteBrowser(QApplication): self.networkmanager = NetworkManager(self.cookiejar) self.commandmanager = CommandManager() self.searchmanager = SearchManager() - self.hintmanager = HintManager() self._init_cmds() self.mainwindow = MainWindow() @@ -318,13 +315,10 @@ class QuteBrowser(QApplication): kp['normal'].keystring_updated.connect(status.keystring.setText) # hints - kp['hint'].fire_hint.connect(self.hintmanager.fire) - kp['hint'].filter_hints.connect(self.hintmanager.filter_hints) - kp['hint'].keystring_updated.connect( - self.hintmanager.handle_partial_key) - self.hintmanager.hint_strings_updated.connect( - kp['hint'].on_hint_strings_updated) - self.hintmanager.openurl.connect(tabs.cur.openurl_slot) + kp['hint'].fire_hint.connect(tabs.cur.fire_hint) + kp['hint'].filter_hints.connect(tabs.cur.filter_hints) + kp['hint'].keystring_updated.connect(tabs.cur.handle_hint_key) + tabs.hint_strings_updated.connect(kp['hint'].on_hint_strings_updated) # messages self.messagebridge.error.connect(status.disp_error) diff --git a/qutebrowser/browser/curcommand.py b/qutebrowser/browser/curcommand.py index 01e5ca1bb..0afdb216d 100644 --- a/qutebrowser/browser/curcommand.py +++ b/qutebrowser/browser/curcommand.py @@ -241,8 +241,27 @@ class CurCommandDispatcher(QObject): except AttributeError: message.error("Unknown hinting target {}!".format(targetstr)) return - QApplication.instance().hintmanager.start(frame, widget.url(), group, - target) + widget.hintmanager.start(frame, widget.url(), group, target) + + @cmdutils.register(instance='mainwindow.tabs.cur', hide=True) + def follow_hint(self): + """Follow the currently selected hint.""" + self._tabs.currentWidget().hintmanager.follow_hint() + + @pyqtSlot(str) + def handle_hint_key(self, keystr): + """Handle a new hint keypress.""" + self._tabs.currentWidget().hintmanager.handle_partial_key(keystr) + + @pyqtSlot(str) + def fire_hint(self, keystr): + """Fire a completed hint.""" + self._tabs.currentWidget().hintmanager.fire(keystr) + + @pyqtSlot(str) + def filter_hints(self, filterstr): + """Filter displayed hints.""" + self._tabs.currentWidget().hintmanager.filter_hints(filterstr) @cmdutils.register(instance='mainwindow.tabs.cur') def prevpage(self): diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index d36ac72d2..dde970263 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -30,7 +30,6 @@ import qutebrowser.keyinput.modeman as modeman import qutebrowser.utils.message as message import qutebrowser.utils.url as urlutils import qutebrowser.utils.webelem as webelem -import qutebrowser.commands.utils as cmdutils from qutebrowser.utils.usertypes import enum @@ -381,7 +380,6 @@ class HintManager(QObject): self.hint_strings_updated.emit(strings) modeman.enter('hint') - @pyqtSlot(str) def handle_partial_key(self, keystr): """Handle a new partial keypress.""" delete = [] @@ -397,7 +395,6 @@ class HintManager(QObject): for key in delete: del self._elems[key] - @pyqtSlot(str) def filter_hints(self, filterstr): """Filter displayed hints according to a text.""" delete = [] @@ -414,7 +411,6 @@ class HintManager(QObject): # unpacking gets us the first (and only) key in the dict. self.fire(*self._elems) - @pyqtSlot(str) def fire(self, keystr, force=False): """Fire a completed hint. @@ -455,7 +451,6 @@ class HintManager(QObject): if self._target != Target.rapid: modeman.leave('hint') - @cmdutils.register(instance='hintmanager', hide=True) def follow_hint(self): """Follow the currently selected hint.""" if not self._to_follow: diff --git a/qutebrowser/widgets/_tabbedbrowser.py b/qutebrowser/widgets/_tabbedbrowser.py index 5e3311a4e..6c9ab7cf4 100644 --- a/qutebrowser/widgets/_tabbedbrowser.py +++ b/qutebrowser/widgets/_tabbedbrowser.py @@ -66,6 +66,8 @@ class TabbedBrowser(TabWidget): cur_scroll_perc_changed: Scroll percentage of current tab changed. arg 1: x-position in %. arg 2: y-position in %. + hint_strings_updated: Hint strings were updated. + arg: A list of hint strings. shutdown_complete: The shuttdown is completed. quit: The last tab was closed, quit application. resized: Emitted when the browser window has resized, so the completion @@ -80,6 +82,7 @@ class TabbedBrowser(TabWidget): cur_url_changed = pyqtSignal('QUrl') cur_link_hovered = pyqtSignal(str, str, str) cur_scroll_perc_changed = pyqtSignal(int, int) + hint_strings_updated = pyqtSignal(list) shutdown_complete = pyqtSignal() quit = pyqtSignal() resized = pyqtSignal('QRect') @@ -128,6 +131,9 @@ class TabbedBrowser(TabWidget): tab.scroll_pos_changed.connect( self._filter.create(self.cur_scroll_perc_changed)) tab.urlChanged.connect(self._filter.create(self.cur_url_changed)) + # hintmanager + tab.hintmanager.hint_strings_updated.connect(self.hint_strings_updated) + tab.hintmanager.openurl.connect(self.cur.openurl_slot) # misc tab.titleChanged.connect(self.on_title_changed) tab.open_tab.connect(self.tabopen)