Merge branch 'master' of https://github.com/neeasade/qutebrowser into neeasade-master

This commit is contained in:
Florian Bruhin 2015-10-18 23:08:05 +02:00
commit 4f10e553a8
4 changed files with 50 additions and 11 deletions

View File

@ -81,10 +81,24 @@ class CompletionView(QTreeView):
QTreeView:item::hover {
border: 0px;
}
"""
# FIXME style scrollbar
# https://github.com/The-Compiler/qutebrowser/issues/117
QTreeView QScrollBar {
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
{{ color['completion.scrollbar.bg'] }};
min-height: 10px;
}
QTreeView QScrollBar::sub-line, QScrollBar::add-line {
border: none;
background: none;
}
"""
resize_completion = pyqtSignal()

View File

@ -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."),

View File

@ -42,7 +42,8 @@ def get_stylesheet(template_str):
"""
colordict = ColorDict(config.section('colors'))
template = jinja2.Template(template_str)
return template.render(color=colordict, font=config.section('fonts'))
return template.render(color=colordict, font=config.section('fonts'),
config=objreg.get('config'))
def set_register_stylesheet(obj):

View File

@ -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'] }}", "black"),
("{{ color['completion.fg'] }}", "red"),
("{{ font['completion'] }}", "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 == 'black\nfoo'
assert rendered == expected
class Obj(QObject):
@ -105,5 +115,3 @@ class TestColorDict:
d['foo'] = QColor()
with pytest.raises(TypeError):
d['foo'] # pylint: disable=pointless-statement