Merge auto-open option into show

This commit is contained in:
Marshall Lochbaum 2016-08-08 17:24:23 -04:00
parent d98c81c9d6
commit 8da8441623
5 changed files with 15 additions and 13 deletions

View File

@ -200,7 +200,7 @@ class CompletionView(QTreeView):
selmodel.setCurrentIndex( selmodel.setCurrentIndex(
idx, QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows) idx, QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows)
if config.get('completion', 'show'): if config.get('completion', 'show') == 'auto':
self.show() self.show()
def set_model(self, model): def set_model(self, model):
@ -227,8 +227,7 @@ class CompletionView(QTreeView):
if old_model is not None: if old_model is not None:
old_model.deleteLater() old_model.deleteLater()
if (config.get('completion', 'auto-open') and if config.get('completion', 'show') == 'always':
config.get('completion', 'show')):
self.show() self.show()
else: else:
self.hide() self.hide()

View File

@ -351,6 +351,7 @@ class ConfigManager(QObject):
('tabs', 'hide-always'), ('tabs', 'hide-always'),
('ui', 'display-statusbar-messages'), ('ui', 'display-statusbar-messages'),
('general', 'wrap-search'), ('general', 'wrap-search'),
('completion', 'auto-open'),
] ]
CHANGED_OPTIONS = { CHANGED_OPTIONS = {
('content', 'cookies-accept'): ('content', 'cookies-accept'):
@ -363,6 +364,8 @@ class ConfigManager(QObject):
_get_value_transformer({'false': 'none', 'true': 'debug'}), _get_value_transformer({'false': 'none', 'true': 'debug'}),
('ui', 'keyhint-blacklist'): ('ui', 'keyhint-blacklist'):
_get_value_transformer({'false': '*', 'true': ''}), _get_value_transformer({'false': '*', 'true': ''}),
('completion', 'show'):
_get_value_transformer({'false': 'never', 'true': 'always'}),
} }
changed = pyqtSignal(str, str) changed = pyqtSignal(str, str)

View File

@ -427,9 +427,14 @@ def data(readonly=False):
)), )),
('completion', sect.KeyValue( ('completion', sect.KeyValue(
('auto-open', ('show',
SettingValue(typ.Bool(), 'true'), SettingValue(typ.String(
"Automatically open completion when typing."), valid_values=typ.ValidValues(
('always', "Whenever a completion is available."),
('auto', "Whenever a completion is requested."),
('never', "Never.")
)), 'always'),
"When to show the autocompletion window."),
('download-path-suggestion', ('download-path-suggestion',
SettingValue( SettingValue(
@ -444,10 +449,6 @@ def data(readonly=False):
SettingValue(typ.TimestampTemplate(none_ok=True), '%Y-%m-%d'), SettingValue(typ.TimestampTemplate(none_ok=True), '%Y-%m-%d'),
"How to format timestamps (e.g. for history)"), "How to format timestamps (e.g. for history)"),
('show',
SettingValue(typ.Bool(), 'true'),
"Whether to show the autocompletion window."),
('height', ('height',
SettingValue(typ.PercOrInt(minperc=0, maxperc=100, minint=1), SettingValue(typ.PercOrInt(minperc=0, maxperc=100, minint=1),
'50%'), '50%'),

View File

@ -66,7 +66,7 @@ def completer_obj(qtbot, status_command_stub, config_stub, monkeypatch, stubs,
"""Create the completer used for testing.""" """Create the completer used for testing."""
monkeypatch.setattr('qutebrowser.completion.completer.QTimer', monkeypatch.setattr('qutebrowser.completion.completer.QTimer',
stubs.InstaTimer) stubs.InstaTimer)
config_stub.data = {'completion': {'auto-open': False}} config_stub.data = {'completion': {'show': 'auto'}}
return completer.Completer(status_command_stub, 0, completion_widget_stub) return completer.Completer(status_command_stub, 0, completion_widget_stub)

View File

@ -34,8 +34,7 @@ def completionview(qtbot, status_command_stub, config_stub, win_registry,
"""Create the CompletionView used for testing.""" """Create the CompletionView used for testing."""
config_stub.data = { config_stub.data = {
'completion': { 'completion': {
'show': True, 'show': 'always',
'auto-open': True,
'scrollbar-width': 12, 'scrollbar-width': 12,
'scrollbar-padding': 2, 'scrollbar-padding': 2,
'shrink': False, 'shrink': False,