Make keyhint delay configurable.
ui.keyhint-delay controls the time from starting a keychain to showing the keyhint dialog. Resolves #2462.
This commit is contained in:
parent
0c7d012420
commit
a68f997d95
@ -406,6 +406,10 @@ def data(readonly=False):
|
|||||||
"Globs are supported, so ';*' will blacklist all keychains"
|
"Globs are supported, so ';*' will blacklist all keychains"
|
||||||
"starting with ';'. Use '*' to disable keyhints"),
|
"starting with ';'. Use '*' to disable keyhints"),
|
||||||
|
|
||||||
|
('keyhint-delay',
|
||||||
|
SettingValue(typ.Int(minval=0), '500'),
|
||||||
|
"Time from pressing a key to seeing the keyhint dialog (ms)"),
|
||||||
|
|
||||||
('prompt-radius',
|
('prompt-radius',
|
||||||
SettingValue(typ.Int(minval=0), '8'),
|
SettingValue(typ.Int(minval=0), '8'),
|
||||||
"The rounding radius for the edges of prompts."),
|
"The rounding radius for the edges of prompts."),
|
||||||
|
@ -67,7 +67,6 @@ class KeyHintView(QLabel):
|
|||||||
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum)
|
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum)
|
||||||
self.hide()
|
self.hide()
|
||||||
self._show_timer = usertypes.Timer(self, 'keyhint_show')
|
self._show_timer = usertypes.Timer(self, 'keyhint_show')
|
||||||
self._show_timer.setInterval(500)
|
|
||||||
self._show_timer.timeout.connect(self.show)
|
self._show_timer.timeout.connect(self.show)
|
||||||
style.set_register_stylesheet(self)
|
style.set_register_stylesheet(self)
|
||||||
|
|
||||||
@ -108,6 +107,7 @@ class KeyHintView(QLabel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# delay so a quickly typed keychain doesn't display hints
|
# delay so a quickly typed keychain doesn't display hints
|
||||||
|
self._show_timer.setInterval(config.get('ui', 'keyhint-delay'))
|
||||||
self._show_timer.start()
|
self._show_timer.start()
|
||||||
suffix_color = html.escape(config.get('colors', 'keyhint.fg.suffix'))
|
suffix_color = html.escape(config.get('colors', 'keyhint.fg.suffix'))
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ def expected_text(*args):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def keyhint(qtbot, config_stub, key_config_stub):
|
def keyhint_config(config_stub):
|
||||||
"""Fixture to initialize a KeyHintView."""
|
"""Fixture providing the necessary config settings for the KeyHintView."""
|
||||||
config_stub.data = {
|
config_stub.data = {
|
||||||
'colors': {
|
'colors': {
|
||||||
'keyhint.fg': 'white',
|
'keyhint.fg': 'white',
|
||||||
@ -55,9 +55,16 @@ def keyhint(qtbot, config_stub, key_config_stub):
|
|||||||
'fonts': {'keyhint': 'Comic Sans'},
|
'fonts': {'keyhint': 'Comic Sans'},
|
||||||
'ui': {
|
'ui': {
|
||||||
'keyhint-blacklist': '',
|
'keyhint-blacklist': '',
|
||||||
|
'keyhint-delay': 500,
|
||||||
'status-position': 'bottom',
|
'status-position': 'bottom',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
return config_stub
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def keyhint(qtbot, keyhint_config, key_config_stub):
|
||||||
|
"""Fixture to initialize a KeyHintView."""
|
||||||
keyhint = KeyHintView(0, None)
|
keyhint = KeyHintView(0, None)
|
||||||
qtbot.add_widget(keyhint)
|
qtbot.add_widget(keyhint)
|
||||||
assert keyhint.text() == ''
|
assert keyhint.text() == ''
|
||||||
@ -161,3 +168,16 @@ def test_blacklist_all(keyhint, config_stub, key_config_stub):
|
|||||||
|
|
||||||
keyhint.update_keyhint('normal', 'a')
|
keyhint.update_keyhint('normal', 'a')
|
||||||
assert not keyhint.text()
|
assert not keyhint.text()
|
||||||
|
|
||||||
|
|
||||||
|
def test_delay(qtbot, stubs, monkeypatch, keyhint_config, key_config_stub):
|
||||||
|
timer = stubs.FakeTimer()
|
||||||
|
monkeypatch.setattr(
|
||||||
|
'qutebrowser.misc.keyhintwidget.usertypes.Timer',
|
||||||
|
lambda *_: timer)
|
||||||
|
interval = 200
|
||||||
|
keyhint_config.set('ui', 'keyhint-delay', interval)
|
||||||
|
key_config_stub.set_bindings_for('normal', OrderedDict([('aa', 'cmd-aa')]))
|
||||||
|
keyhint = KeyHintView(0, None)
|
||||||
|
keyhint.update_keyhint('normal', 'a')
|
||||||
|
assert timer.interval() == interval
|
||||||
|
Loading…
Reference in New Issue
Block a user