Call on_mode_entered only once for hints.

This commit is contained in:
Florian Bruhin 2014-09-25 19:06:38 +02:00
parent 0494bc3763
commit c188c6986d
2 changed files with 9 additions and 8 deletions

View File

@ -40,7 +40,7 @@ from qutebrowser.commands import userscripts, runners, cmdutils
from qutebrowser.config import (style, config, websettings, iniparsers, from qutebrowser.config import (style, config, websettings, iniparsers,
lineparser, configtypes, keyconfparser) lineparser, configtypes, keyconfparser)
from qutebrowser.network import qutescheme, proxy from qutebrowser.network import qutescheme, proxy
from qutebrowser.browser import quickmarks, cookies, downloads, cache from qutebrowser.browser import quickmarks, cookies, downloads, cache, hints
from qutebrowser.widgets import mainwindow, console, crash from qutebrowser.widgets import mainwindow, console, crash
from qutebrowser.keyinput import modeparsers, keyparser, modeman from qutebrowser.keyinput import modeparsers, keyparser, modeman
from qutebrowser.utils import (log, version, message, utilcmds, readline, from qutebrowser.utils import (log, version, message, utilcmds, readline,
@ -387,6 +387,7 @@ class Application(QApplication):
# misc # misc
self.lastWindowClosed.connect(self.shutdown) self.lastWindowClosed.connect(self.shutdown)
tabs.quit.connect(self.shutdown) tabs.quit.connect(self.shutdown)
mode_manager.entered.connect(hints.on_mode_entered)
# status bar # status bar
mode_manager.entered.connect(status.on_mode_entered) mode_manager.entered.connect(status.on_mode_entered)

View File

@ -42,6 +42,13 @@ Target = usertypes.enum('Target', 'normal', 'tab', 'tab_bg', 'yank',
'userscript', 'spawn') 'userscript', 'spawn')
@pyqtSlot(usertypes.KeyMode)
def on_mode_entered(mode):
"""Stop hinting when insert mode was entered."""
if mode == usertypes.KeyMode.insert:
modeman.maybe_leave(usertypes.KeyMode.hint, 'insert mode')
class HintContext: class HintContext:
"""Context namespace used for hinting. """Context namespace used for hinting.
@ -139,7 +146,6 @@ class HintManager(QObject):
super().__init__(parent) super().__init__(parent)
self._context = None self._context = None
objreg.get('mode-manager').left.connect(self.on_mode_left) objreg.get('mode-manager').left.connect(self.on_mode_left)
objreg.get('mode-manager').entered.connect(self.on_mode_entered)
def _cleanup(self): def _cleanup(self):
"""Clean up after hinting.""" """Clean up after hinting."""
@ -676,12 +682,6 @@ class HintManager(QObject):
css = self._get_hint_css(elems.elem, elems.label) css = self._get_hint_css(elems.elem, elems.label)
elems.label['style'] = css elems.label['style'] = css
@pyqtSlot(usertypes.KeyMode)
def on_mode_entered(self, mode):
"""Stop hinting when insert mode was entered."""
if mode == usertypes.KeyMode.insert:
modeman.maybe_leave(usertypes.KeyMode.hint, 'insert mode')
@pyqtSlot(usertypes.KeyMode) @pyqtSlot(usertypes.KeyMode)
def on_mode_left(self, mode): def on_mode_left(self, mode):
"""Stop hinting when hinting mode was left.""" """Stop hinting when hinting mode was left."""