diff --git a/README.asciidoc b/README.asciidoc index 8aee2e880..9ee584709 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -147,6 +147,7 @@ Contributors, sorted by the number of commits in descending order: * Austin Anderson * Artur Shaik * Thorsten Wißmann +* Nathan Isom * Alexey "Averrin" Nabrodov * meles5 * ZDarian @@ -156,7 +157,6 @@ Contributors, sorted by the number of commits in descending order: * Zach-Button * rikn00 * Patric Schmitz -* Nathan Isom * Martin Zimmermann * Error 800 * Brian Jackson diff --git a/qutebrowser/browser/downloadview.py b/qutebrowser/browser/downloadview.py index 0e21d1fb4..a701a5dc2 100644 --- a/qutebrowser/browser/downloadview.py +++ b/qutebrowser/browser/downloadview.py @@ -64,8 +64,8 @@ class DownloadView(QListView): STYLESHEET = """ QListView { - {{ color['downloads.bg.bar'] }} - {{ font['downloads'] }} + background-color: {{ color['downloads.bg.bar'] }}; + font: {{ font['downloads'] }}; } QListView::item { diff --git a/qutebrowser/completion/completiondelegate.py b/qutebrowser/completion/completiondelegate.py index f2f256a40..d07e7da16 100644 --- a/qutebrowser/completion/completiondelegate.py +++ b/qutebrowser/completion/completiondelegate.py @@ -188,7 +188,7 @@ class CompletionItemDelegate(QStyledItemDelegate): self._doc.setDefaultTextOption(text_option) self._doc.setDefaultStyleSheet(style.get_stylesheet(""" .highlight { - {{ color['completion.match.fg'] }} + color: {{ color['completion.match.fg'] }}; } """)) self._doc.setDocumentMargin(2) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index 9281a053a..6701413ef 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -55,15 +55,15 @@ class CompletionView(QTreeView): # don't define that in this stylesheet. STYLESHEET = """ QTreeView { - {{ font['completion'] }} - {{ color['completion.bg'] }} + font: {{ font['completion'] }}; + background-color: {{ color['completion.bg'] }}; alternate-background-color: {{ color['completion.alternate-bg'] }}; outline: 0; border: 0px; } QTreeView::item:disabled { - {{ color['completion.category.bg'] }} + background-color: {{ color['completion.category.bg'] }}; border-top: 1px solid {{ color['completion.category.border.top'] }}; border-bottom: 1px solid @@ -75,7 +75,7 @@ class CompletionView(QTreeView): {{ color['completion.item.selected.border.top'] }}; border-bottom: 1px solid {{ color['completion.item.selected.border.bottom'] }}; - {{ color['completion.item.selected.bg'] }} + background-color: {{ color['completion.item.selected.bg'] }}; } QTreeView:item::hover { diff --git a/qutebrowser/config/style.py b/qutebrowser/config/style.py index 2b109e72b..55d63e923 100644 --- a/qutebrowser/config/style.py +++ b/qutebrowser/config/style.py @@ -41,9 +41,8 @@ def get_stylesheet(template_str): The formatted template as string. """ colordict = ColorDict(config.section('colors')) - fontdict = FontDict(config.section('fonts')) template = jinja2.Template(template_str) - return template.render(color=colordict, font=fontdict) + return template.render(color=colordict, font=config.section('fonts')) def set_register_stylesheet(obj): @@ -83,10 +82,7 @@ class ColorDict(collections.UserDict): If a value wasn't found, return an empty string. (Color not defined, so no output in the stylesheet) - If the key has a .fg. element in it, return color: X;. - If the key has a .bg. element in it, return background-color: X;. - - In all other cases, return the plain value. + else, return the plain value. """ try: val = self.data[key] @@ -98,33 +94,5 @@ class ColorDict(collections.UserDict): # QtColor instead of Color in the config, and it'd go unnoticed as # the CSS is invalid then. raise TypeError("QColor passed to ColorDict!") - if 'fg' in key.split('.'): - return 'color: {};'.format(val) - elif 'bg' in key.split('.'): - return 'background-color: {};'.format(val) else: return val - - -class FontDict(collections.UserDict): - - """A dict aimed at Qt stylesheet fonts.""" - - def __getitem__(self, key): - """Override dict __getitem__. - - Args: - key: The key to get from the dict. - - Return: - If a value wasn't found, return an empty string. - (Color not defined, so no output in the stylesheet) - - In all other cases, return font: . - """ - try: - val = self.data[key] - except KeyError: - return '' - else: - return 'font: {};'.format(val) diff --git a/qutebrowser/mainwindow/statusbar/bar.py b/qutebrowser/mainwindow/statusbar/bar.py index b4066060d..900871c97 100644 --- a/qutebrowser/mainwindow/statusbar/bar.py +++ b/qutebrowser/mainwindow/statusbar/bar.py @@ -110,58 +110,58 @@ class StatusBar(QWidget): QWidget#StatusBar, QWidget#StatusBar QLabel, QWidget#StatusBar QLineEdit { - {{ font['statusbar'] }} - {{ color['statusbar.bg'] }} - {{ color['statusbar.fg'] }} + font: {{ font['statusbar'] }}; + background-color: {{ color['statusbar.bg'] }}; + color: {{ color['statusbar.fg'] }}; } QWidget#StatusBar[caret_mode="on"], QWidget#StatusBar[caret_mode="on"] QLabel, QWidget#StatusBar[caret_mode="on"] QLineEdit { - {{ color['statusbar.fg.caret'] }} - {{ color['statusbar.bg.caret'] }} + color: {{ color['statusbar.fg.caret'] }}; + background-color: {{ color['statusbar.bg.caret'] }}; } QWidget#StatusBar[caret_mode="selection"], QWidget#StatusBar[caret_mode="selection"] QLabel, QWidget#StatusBar[caret_mode="selection"] QLineEdit { - {{ color['statusbar.fg.caret-selection'] }} - {{ color['statusbar.bg.caret-selection'] }} + color: {{ color['statusbar.fg.caret-selection'] }}; + background-color: {{ color['statusbar.bg.caret-selection'] }}; } QWidget#StatusBar[severity="error"], QWidget#StatusBar[severity="error"] QLabel, QWidget#StatusBar[severity="error"] QLineEdit { - {{ color['statusbar.fg.error'] }} - {{ color['statusbar.bg.error'] }} + color: {{ color['statusbar.fg.error'] }}; + background-color: {{ color['statusbar.bg.error'] }}; } QWidget#StatusBar[severity="warning"], QWidget#StatusBar[severity="warning"] QLabel, QWidget#StatusBar[severity="warning"] QLineEdit { - {{ color['statusbar.fg.warning'] }} - {{ color['statusbar.bg.warning'] }} + color: {{ color['statusbar.fg.warning'] }}; + background-color: {{ color['statusbar.bg.warning'] }}; } QWidget#StatusBar[prompt_active="true"], QWidget#StatusBar[prompt_active="true"] QLabel, QWidget#StatusBar[prompt_active="true"] QLineEdit { - {{ color['statusbar.fg.prompt'] }} - {{ color['statusbar.bg.prompt'] }} + color: {{ color['statusbar.fg.prompt'] }}; + background-color: {{ color['statusbar.bg.prompt'] }}; } QWidget#StatusBar[insert_active="true"], QWidget#StatusBar[insert_active="true"] QLabel, QWidget#StatusBar[insert_active="true"] QLineEdit { - {{ color['statusbar.fg.insert'] }} - {{ color['statusbar.bg.insert'] }} + color: {{ color['statusbar.fg.insert'] }}; + background-color: {{ color['statusbar.bg.insert'] }}; } QWidget#StatusBar[command_active="true"], QWidget#StatusBar[command_active="true"] QLabel, QWidget#StatusBar[command_active="true"] QLineEdit { - {{ color['statusbar.fg.command'] }} - {{ color['statusbar.bg.command'] }} + color: {{ color['statusbar.fg.command'] }}; + background-color: {{ color['statusbar.bg.command'] }}; } """ diff --git a/qutebrowser/mainwindow/statusbar/progress.py b/qutebrowser/mainwindow/statusbar/progress.py index 2d2747431..3f8f0b1c3 100644 --- a/qutebrowser/mainwindow/statusbar/progress.py +++ b/qutebrowser/mainwindow/statusbar/progress.py @@ -39,7 +39,7 @@ class Progress(QProgressBar): } QProgressBar::chunk { - {{ color['statusbar.progress.bg'] }} + background-color: {{ color['statusbar.progress.bg'] }}; } """ diff --git a/qutebrowser/mainwindow/statusbar/url.py b/qutebrowser/mainwindow/statusbar/url.py index b368be54f..f3b829f68 100644 --- a/qutebrowser/mainwindow/statusbar/url.py +++ b/qutebrowser/mainwindow/statusbar/url.py @@ -54,27 +54,27 @@ class UrlText(textbase.TextBase): STYLESHEET = """ QLabel#UrlText[urltype="normal"] { - {{ color['statusbar.url.fg'] }} + color: {{ color['statusbar.url.fg'] }}; } QLabel#UrlText[urltype="success"] { - {{ color['statusbar.url.fg.success'] }} + color: {{ color['statusbar.url.fg.success'] }}; } QLabel#UrlText[urltype="success_https"] { - {{ color['statusbar.url.fg.success.https'] }} + color: {{ color['statusbar.url.fg.success.https'] }}; } QLabel#UrlText[urltype="error"] { - {{ color['statusbar.url.fg.error'] }} + color: {{ color['statusbar.url.fg.error'] }}; } QLabel#UrlText[urltype="warn"] { - {{ color['statusbar.url.fg.warn'] }} + color: {{ color['statusbar.url.fg.warn'] }}; } QLabel#UrlText[urltype="hover"] { - {{ color['statusbar.url.fg.hover'] }} + color: {{ color['statusbar.url.fg.hover'] }}; } """ diff --git a/tests/unit/config/test_style.py b/tests/unit/config/test_style.py index 53cce823a..c113a7716 100644 --- a/tests/unit/config/test_style.py +++ b/tests/unit/config/test_style.py @@ -35,7 +35,7 @@ def test_get_stylesheet(config_stub): } template = "{{ color['completion.bg'] }}\n{{ font['completion'] }}" rendered = style.get_stylesheet(template) - assert rendered == 'background-color: black;\nfont: foo;' + assert rendered == 'black\nfoo' class Obj(QObject): @@ -59,9 +59,9 @@ def test_set_register_stylesheet(delete, qtbot, config_stub, caplog): records = caplog.records() assert len(records) == 1 - assert records[0].message == 'stylesheet for Obj: font: bar;' + assert records[0].message == 'stylesheet for Obj: bar' - assert obj.rendered_stylesheet == 'font: bar;' + assert obj.rendered_stylesheet == 'bar' if delete: with qtbot.waitSignal(obj.destroyed): @@ -72,9 +72,9 @@ def test_set_register_stylesheet(delete, qtbot, config_stub, caplog): config_stub.changed.emit('fonts', 'foo') if delete: - expected = 'font: bar;' + expected = 'bar' else: - expected = 'font: baz;' + expected = 'baz' assert obj.rendered_stylesheet == expected @@ -82,8 +82,8 @@ class TestColorDict: @pytest.mark.parametrize('key, expected', [ ('foo', 'one'), - ('foo.fg', 'color: two;'), - ('foo.bg', 'background-color: three;'), + ('foo.fg', 'two'), + ('foo.bg', 'three'), ]) def test_values(self, key, expected): d = style.ColorDict() @@ -107,11 +107,3 @@ class TestColorDict: d['foo'] # pylint: disable=pointless-statement -@pytest.mark.parametrize('key, expected', [ - ('foo', 'font: one;'), - ('bar', ''), -]) -def test_font_dict(key, expected): - d = style.FontDict() - d['foo'] = 'one' - assert d[key] == expected