Fix key-config usage
This commit is contained in:
parent
aa75262fe4
commit
30f1970850
@ -277,7 +277,7 @@ def _get_cmd_completions(include_hidden, include_aliases, prefix=''):
|
||||
"""
|
||||
assert cmdutils.cmd_dict
|
||||
cmdlist = []
|
||||
cmd_to_keys = objreg.get('key-config').get_reverse_bindings_for('normal')
|
||||
cmd_to_keys = config.key_instance.get_reverse_bindings_for('normal')
|
||||
for obj in set(cmdutils.cmd_dict.values()):
|
||||
hide_debug = obj.debug and not objreg.get('args').debug
|
||||
hide_hidden = obj.hide and not include_hidden
|
||||
|
@ -56,6 +56,7 @@ UNSET = object()
|
||||
# FIXME:conf for new config
|
||||
val = None
|
||||
instance = None
|
||||
key_instance = None
|
||||
|
||||
|
||||
def _init_main_config(parent=None):
|
||||
@ -171,12 +172,13 @@ def init(parent=None):
|
||||
Args:
|
||||
parent: The parent to pass to QObjects which get initialized.
|
||||
"""
|
||||
global val, instance
|
||||
global val, instance, key_instance
|
||||
# _init_main_config(parent)
|
||||
configdata.init()
|
||||
newconfig.init(parent)
|
||||
val = newconfig.val
|
||||
instance = newconfig.instance
|
||||
key_instance = newconfig.key_instance
|
||||
# _init_key_config(parent)
|
||||
_init_misc()
|
||||
|
||||
|
@ -110,6 +110,26 @@ class change_filter: # pylint: disable=invalid-name
|
||||
return wrapper
|
||||
|
||||
|
||||
class NewKeyConfig:
|
||||
|
||||
def get_reverse_bindings_for(self, section):
|
||||
"""Get a dict of commands to a list of bindings for the section."""
|
||||
cmd_to_keys = {}
|
||||
bindings = val.bindings.commands[section]
|
||||
if bindings is None:
|
||||
return cmd_to_keys
|
||||
for key, full_cmd in bindings.items():
|
||||
for cmd in full_cmd.split(';;'):
|
||||
cmd = cmd.strip()
|
||||
cmd_to_keys.setdefault(cmd, [])
|
||||
# put special bindings last
|
||||
if utils.is_special_key(key):
|
||||
cmd_to_keys[cmd].append(key)
|
||||
else:
|
||||
cmd_to_keys[cmd].insert(0, key)
|
||||
return cmd_to_keys
|
||||
|
||||
|
||||
class NewConfigManager(QObject):
|
||||
|
||||
changed = pyqtSignal(str) # FIXME:conf stub...
|
||||
@ -200,9 +220,10 @@ def init(parent):
|
||||
new_config.read_defaults()
|
||||
objreg.register('config', new_config)
|
||||
|
||||
global val, instance
|
||||
global val, instance, key_instance
|
||||
val = ConfigContainer(new_config)
|
||||
instance = new_config
|
||||
key_instance = NewKeyConfig()
|
||||
|
||||
for cf in _change_filters:
|
||||
cf.validate()
|
||||
|
@ -439,17 +439,3 @@ class KeyConfigParser(QObject):
|
||||
bindings = {k: v for k, v in bindings.items()
|
||||
if v != self.UNBOUND_COMMAND}
|
||||
return bindings
|
||||
|
||||
def get_reverse_bindings_for(self, section):
|
||||
"""Get a dict of commands to a list of bindings for the section."""
|
||||
cmd_to_keys = {}
|
||||
for key, full_cmd in self.get_bindings_for(section).items():
|
||||
for cmd in full_cmd.split(';;'):
|
||||
cmd = cmd.strip()
|
||||
cmd_to_keys.setdefault(cmd, [])
|
||||
# put special bindings last
|
||||
if utils.is_special_key(key):
|
||||
cmd_to_keys[cmd].append(key)
|
||||
else:
|
||||
cmd_to_keys[cmd].insert(0, key)
|
||||
return cmd_to_keys
|
||||
|
@ -482,9 +482,8 @@ class _BasePrompt(QWidget):
|
||||
self._key_grid = QGridLayout()
|
||||
self._key_grid.setVerticalSpacing(0)
|
||||
|
||||
key_config = objreg.get('key-config')
|
||||
# The bindings are all in the 'prompt' mode, even for yesno prompts
|
||||
all_bindings = key_config.get_reverse_bindings_for('prompt')
|
||||
all_bindings = config.key_instance.get_reverse_bindings_for('prompt')
|
||||
labels = []
|
||||
|
||||
for cmd, text in self._allowed_commands():
|
||||
|
@ -24,7 +24,8 @@ from PyQt5.QtWidgets import (QLineEdit, QWidget, QHBoxLayout, QLabel,
|
||||
QStyleOption, QStyle, QLayout, QApplication)
|
||||
from PyQt5.QtGui import QValidator, QPainter
|
||||
|
||||
from qutebrowser.utils import utils, objreg, qtutils, log, usertypes
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.utils import utils, qtutils, log, usertypes
|
||||
from qutebrowser.misc import cmdhistory, objects
|
||||
|
||||
|
||||
@ -289,8 +290,7 @@ class FullscreenNotification(QLabel):
|
||||
padding: 30px;
|
||||
""")
|
||||
|
||||
key_config = objreg.get('key-config')
|
||||
all_bindings = key_config.get_reverse_bindings_for('normal')
|
||||
all_bindings = config.key_instance.get_reverse_bindings_for('normal')
|
||||
bindings = all_bindings.get('fullscreen --leave')
|
||||
if bindings:
|
||||
key = bindings[0]
|
||||
|
Loading…
Reference in New Issue
Block a user