diff --git a/qutebrowser/completion/completiondelegate.py b/qutebrowser/completion/completiondelegate.py index 6688a2dfa..b4f9c5a33 100644 --- a/qutebrowser/completion/completiondelegate.py +++ b/qutebrowser/completion/completiondelegate.py @@ -138,10 +138,10 @@ class CompletionItemDelegate(QStyledItemDelegate): self._painter.translate(text_rect.left(), text_rect.top()) self._get_textdoc(index) - self._draw_textdoc(text_rect) + self._draw_textdoc(text_rect, index.column()) self._painter.restore() - def _draw_textdoc(self, rect): + def _draw_textdoc(self, rect, col): """Draw the QTextDocument of an item. Args: @@ -156,7 +156,9 @@ class CompletionItemDelegate(QStyledItemDelegate): elif not self._opt.state & QStyle.State_Enabled: color = config.val.colors.completion.category.fg else: - color = config.val.colors.completion.fg + colors = config.val.colors.completion.fg + # if multiple colors are set, use different colors per column + color = colors[col % len(colors)] self._painter.setPen(color) ctx = QAbstractTextDocumentLayout.PaintContext() diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 8778cc013..a118a8b59 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1540,9 +1540,15 @@ zoom.text_only: ## colors colors.completion.fg: - default: white - type: QtColor - desc: Text color of the completion widget. + default: ["white", "white", "white"] + type: + name: ListOrValue + valtype: QtColor + desc: >- + Text color of the completion widget. + + May be a single color to use for all columns or a list of three colors, + one for each column. colors.completion.odd.bg: default: '#444444' diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index 32a7a8119..d8bf73700 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -385,7 +385,7 @@ class TestConfig: def test_get(self, conf): """Test conf.get() with a QColor (where get/get_obj is different).""" - assert conf.get('colors.completion.fg') == QColor('white') + assert conf.get('colors.completion.category.fg') == QColor('white') @pytest.mark.parametrize('value', [{}, {'normal': {'a': 'nop'}}]) def test_get_bindings(self, config_stub, conf, value): @@ -400,7 +400,7 @@ class TestConfig: assert not conf._mutables def test_get_obj_simple(self, conf): - assert conf.get_obj('colors.completion.fg') == 'white' + assert conf.get_obj('colors.completion.category.fg') == 'white' @pytest.mark.parametrize('option', ['content.headers.custom', 'keyhint.blacklist',