From 0e186487f5b76b175da1f7126cbaaf86d7cd4be3 Mon Sep 17 00:00:00 2001 From: Nathan Isom Date: Thu, 15 Oct 2015 12:36:24 -0500 Subject: [PATCH 1/8] Revert "Don't pass config to stylesheets." This reverts commit dc0e8b4626bfe1fd47a4c77e8b580cd9211a45a2. --- qutebrowser/config/style.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qutebrowser/config/style.py b/qutebrowser/config/style.py index 2b109e72b..6efd3e8fd 100644 --- a/qutebrowser/config/style.py +++ b/qutebrowser/config/style.py @@ -43,7 +43,8 @@ def get_stylesheet(template_str): 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=fontdict, + config=objreg.get('config')) def set_register_stylesheet(obj): From 19c27a04e5e8563f0b4d694c451bb7a5d70dec36 Mon Sep 17 00:00:00 2001 From: Nathan Isom Date: Thu, 15 Oct 2015 13:18:32 -0500 Subject: [PATCH 2/8] Add completion scrollbar settings. --- qutebrowser/completion/completionwidget.py | 24 +++++++++++++++++++--- qutebrowser/config/configdata.py | 16 +++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index 9281a053a..b1c8ec902 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -81,10 +81,28 @@ class CompletionView(QTreeView): QTreeView:item::hover { border: 0px; } - """ - # FIXME style scrollbar - # https://github.com/The-Compiler/qutebrowser/issues/117 + QTreeView QScrollBar { + width: 12px; + {{ color['completion.scrollbar.bg'] }}; + } + + QTreeView QScrollBar::handle{ + /** + This is done this way to evade 'magic' + ref: http://git.io/vCMqZ + Will need to be changed when we utilize jinja better. + **/ + background: {{ config.get('colors', 'completion.scrollbar.fg') }}; + border: 2px solid + {{ config.get('colors', 'completion.scrollbar.bg') }}; + } + + QTreeView QScrollBar::sub-line, QScrollBar::add-line { + border: none; + background:none; + } + """ resize_completion = pyqtSignal() diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 1517280a8..627357478 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -414,6 +414,14 @@ def data(readonly=False): "Whether to shrink the completion to be smaller than the " "configured size if there are no scrollbars."), + ('scrollbar.width', + SettingValue(typ.Int(minval=0), '12'), + "Width of the scrollbar in the completion window (in px)."), + + ('scrollbar.padding', + SettingValue(typ.Int(minval=0), '2'), + "Padding of scrollbar handle in completion window (in px)."), + readonly=readonly )), @@ -872,6 +880,14 @@ def data(readonly=False): SettingValue(typ.QssColor(), '#ff4444'), "Foreground color of the matched text in the completion."), + ('completion.scrollbar.fg', + SettingValue(typ.QssColor(), '${completion.fg}'), + "Color of the scrollbar handle in completion view."), + + ('completion.scrollbar.bg', + SettingValue(typ.QssColor(), '${completion.bg}'), + "Color of the scrollbar in completion view"), + ('statusbar.fg', SettingValue(typ.QssColor(), 'white'), "Foreground color of the statusbar."), From 57d8ebfb83e1118078b07f3bb459fa37f2c2f1c2 Mon Sep 17 00:00:00 2001 From: Nathan Isom Date: Thu, 15 Oct 2015 14:06:16 -0500 Subject: [PATCH 3/8] not hardcode width/padding values. --- qutebrowser/completion/completionwidget.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index b1c8ec902..50f31d8a3 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -83,24 +83,24 @@ class CompletionView(QTreeView): } QTreeView QScrollBar { - width: 12px; - {{ color['completion.scrollbar.bg'] }}; + width: {{ config.get('completion', 'scrollbar.width') }}px; + {{ color['completion.scrollbar.bg'] }} } - QTreeView QScrollBar::handle{ - /** + QTreeView QScrollBar::handle { + /* This is done this way to evade 'magic' ref: http://git.io/vCMqZ Will need to be changed when we utilize jinja better. - **/ + */ background: {{ config.get('colors', 'completion.scrollbar.fg') }}; - border: 2px solid + border: {{ config.get('completion', 'scrollbar.padding') }}px solid {{ config.get('colors', 'completion.scrollbar.bg') }}; } QTreeView QScrollBar::sub-line, QScrollBar::add-line { border: none; - background:none; + background: none; } """ From 27db1ad8916f8509673ff118028efe106c10a626 Mon Sep 17 00:00:00 2001 From: Nathan Isom Date: Fri, 16 Oct 2015 09:56:31 -0500 Subject: [PATCH 4/8] fix scrollbar not showing up error, change test_get_stylesheet a bit. --- qutebrowser/completion/completionwidget.py | 1 + tests/unit/config/test_style.py | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index 50f31d8a3..e10b9cfdd 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -84,6 +84,7 @@ class CompletionView(QTreeView): QTreeView QScrollBar { width: {{ config.get('completion', 'scrollbar.width') }}px; + min-height: 10px; {{ color['completion.scrollbar.bg'] }} } diff --git a/tests/unit/config/test_style.py b/tests/unit/config/test_style.py index 53cce823a..ae8ca1833 100644 --- a/tests/unit/config/test_style.py +++ b/tests/unit/config/test_style.py @@ -27,15 +27,25 @@ from PyQt5.QtGui import QColor from qutebrowser.config import style -def test_get_stylesheet(config_stub): +@pytest.mark.parametrize('template, expected', [ + ("{{ color['completion.bg'] }}", "background-color: black;"), + ("{{ color['completion.fg'] }}", "color: red;"), + ("{{ font['completion'] }}", "font: foo;"), + ("{{ config.get('foo', 'bar') }}", "baz"), +]) +def test_get_stylesheet(config_stub, template, expected): config_stub.data = { - 'colors': {'completion.bg': 'black'}, - 'fonts': {'completion': 'foo'}, + 'colors': { + 'completion.bg': 'black', + 'completion.fg': 'red', + }, + 'fonts': { + 'completion': 'foo', + }, 'foo': {'bar': 'baz'}, } - template = "{{ color['completion.bg'] }}\n{{ font['completion'] }}" rendered = style.get_stylesheet(template) - assert rendered == 'background-color: black;\nfont: foo;' + assert rendered == expected class Obj(QObject): @@ -106,7 +116,6 @@ class TestColorDict: with pytest.raises(TypeError): d['foo'] # pylint: disable=pointless-statement - @pytest.mark.parametrize('key, expected', [ ('foo', 'font: one;'), ('bar', ''), From 9b5c0075b96a2b9452009cd57248e9a16e288ca3 Mon Sep 17 00:00:00 2001 From: Nathan Isom Date: Sat, 17 Oct 2015 19:31:47 -0500 Subject: [PATCH 5/8] Move min-height to correctly fix bug, edit colors to match https://github.com/The-Compiler/qutebrowser/pull/1021. --- qutebrowser/completion/completionwidget.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index e10b9cfdd..67fe09f42 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -84,19 +84,14 @@ class CompletionView(QTreeView): QTreeView QScrollBar { width: {{ config.get('completion', 'scrollbar.width') }}px; - min-height: 10px; - {{ color['completion.scrollbar.bg'] }} + background: {{ color['completion.scrollbar.bg'] }}; } QTreeView QScrollBar::handle { - /* - This is done this way to evade 'magic' - ref: http://git.io/vCMqZ - Will need to be changed when we utilize jinja better. - */ - background: {{ config.get('colors', 'completion.scrollbar.fg') }}; + background: {{ color[completion.scrollbar.fg] }}; border: {{ config.get('completion', 'scrollbar.padding') }}px solid - {{ config.get('colors', 'completion.scrollbar.bg') }}; + {{ color['completion.scrollbar.bg'] }}; + min-height: 10px; } QTreeView QScrollBar::sub-line, QScrollBar::add-line { From d326cc050e810413ec5b821c58cfbe6bcef897e7 Mon Sep 17 00:00:00 2001 From: Nathan Isom Date: Sun, 18 Oct 2015 14:11:22 -0500 Subject: [PATCH 6/8] correct style string, file modeline. --- qutebrowser/completion/completionwidget.py | 2 +- qutebrowser/config/style.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index 26151ebfc..3a1bf367a 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -88,7 +88,7 @@ class CompletionView(QTreeView): } QTreeView QScrollBar::handle { - background: {{ color[completion.scrollbar.fg] }}; + background: {{ color['completion.scrollbar.fg'] }}; border: {{ config.get('completion', 'scrollbar.padding') }}px solid {{ color['completion.scrollbar.bg'] }}; min-height: 10px; diff --git a/qutebrowser/config/style.py b/qutebrowser/config/style.py index 42eea2615..c176c4b8a 100644 --- a/qutebrowser/config/style.py +++ b/qutebrowser/config/style.py @@ -1,4 +1,4 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:D +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2014-2015 Florian Bruhin (The Compiler) # From 9f11990efc3069ffd5069dfc5f907a03f1975e04 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 19 Oct 2015 05:15:52 +0200 Subject: [PATCH 7/8] Rename scrollbar.padding/scrollbar.width. --- qutebrowser/completion/completionwidget.py | 4 ++-- qutebrowser/config/configdata.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index 3a1bf367a..2acd2333d 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -83,13 +83,13 @@ class CompletionView(QTreeView): } QTreeView QScrollBar { - width: {{ config.get('completion', 'scrollbar.width') }}px; + width: {{ config.get('completion', 'scrollbar-width') }}px; background: {{ color['completion.scrollbar.bg'] }}; } QTreeView QScrollBar::handle { background: {{ color['completion.scrollbar.fg'] }}; - border: {{ config.get('completion', 'scrollbar.padding') }}px solid + border: {{ config.get('completion', 'scrollbar-padding') }}px solid {{ color['completion.scrollbar.bg'] }}; min-height: 10px; } diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index f69f69dd1..46cdb91eb 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -414,11 +414,11 @@ def data(readonly=False): "Whether to shrink the completion to be smaller than the " "configured size if there are no scrollbars."), - ('scrollbar.width', + ('scrollbar-width', SettingValue(typ.Int(minval=0), '12'), "Width of the scrollbar in the completion window (in px)."), - ('scrollbar.padding', + ('scrollbar-padding', SettingValue(typ.Int(minval=0), '2'), "Padding of scrollbar handle in completion window (in px)."), From de4ee92b56159404ae22d857f2bf8ec776fcdec8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 19 Oct 2015 05:18:30 +0200 Subject: [PATCH 8/8] Update docs. --- CHANGELOG.asciidoc | 6 ++++++ README.asciidoc | 2 +- doc/help/settings.asciidoc | 28 ++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 1d6e98597..dacc2a06c 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -35,6 +35,12 @@ Added instance. - New setting `statusbar.url.fg.success.https` to set the foreground color for the URL when a page was loaded via HTTPS. +- The scrollbar in the completion is now styled, and the following new options + got added: + * `completion -> scrollbar-width` + * `completion -> scrollbar-padding` + * `colors -> completion.scrollbar.fg` + * `colors -> completion.scrollbar.bg` Changed ~~~~~~~ diff --git a/README.asciidoc b/README.asciidoc index 9ee584709..7f1941703 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -144,10 +144,10 @@ Contributors, sorted by the number of commits in descending order: * Claude * Lamar Pavel * Daniel +* Nathan Isom * Austin Anderson * Artur Shaik * Thorsten Wißmann -* Nathan Isom * Alexey "Averrin" Nabrodov * meles5 * ZDarian diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 2a8502bdd..bd0d9c35e 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -78,6 +78,8 @@ |<>|How many URLs to show in the web history. |<>|Whether to move on to the next part when there's only one possible completion left. |<>|Whether to shrink the completion to be smaller than the configured size if there are no scrollbars. +|<>|Width of the scrollbar in the completion window (in px). +|<>|Padding of scrollbar handle in completion window (in px). |============== .Quick reference for section ``input'' @@ -196,6 +198,8 @@ |<>|Top border color of the completion widget category headers. |<>|Bottom border color of the selected completion item. |<>|Foreground color of the matched text in the completion. +|<>|Color of the scrollbar handle in completion view. +|<>|Color of the scrollbar in completion view |<>|Foreground color of the statusbar. |<>|Background color of the statusbar. |<>|Foreground color of the statusbar if there was an error. @@ -833,6 +837,18 @@ Valid values: Default: +pass:[false]+ +[[completion-scrollbar-width]] +=== scrollbar-width +Width of the scrollbar in the completion window (in px). + +Default: +pass:[12]+ + +[[completion-scrollbar-padding]] +=== scrollbar-padding +Padding of scrollbar handle in completion window (in px). + +Default: +pass:[2]+ + == input Options related to input modes. @@ -1655,6 +1671,18 @@ Foreground color of the matched text in the completion. Default: +pass:[#ff4444]+ +[[colors-completion.scrollbar.fg]] +=== completion.scrollbar.fg +Color of the scrollbar handle in completion view. + +Default: +pass:[${completion.fg}]+ + +[[colors-completion.scrollbar.bg]] +=== completion.scrollbar.bg +Color of the scrollbar in completion view + +Default: +pass:[${completion.bg}]+ + [[colors-statusbar.fg]] === statusbar.fg Foreground color of the statusbar.