Revert "style: Check for QColor when setting in ColorDict."
This reverts commit 9b82fae6fb
.
This commit is contained in:
parent
1d5cae3146
commit
a79c139aa4
@ -73,17 +73,6 @@ class ColorDict(collections.UserDict):
|
||||
|
||||
"""A dict aimed at Qt stylesheet colors."""
|
||||
|
||||
def __setitem__(self, key, val):
|
||||
"""Override __setitem__ to make sure no QColors are set.
|
||||
|
||||
This could happen when accidentally declaring something as QtColor
|
||||
instead of Color in the config, and it'd go unnoticed as the CSS is
|
||||
invalid then.
|
||||
"""
|
||||
if isinstance(val, QColor):
|
||||
raise TypeError("QColor passed to ColorDict!")
|
||||
self.data[key] = val
|
||||
|
||||
def __getitem__(self, key):
|
||||
"""Override dict __getitem__.
|
||||
|
||||
@ -104,6 +93,11 @@ class ColorDict(collections.UserDict):
|
||||
except KeyError:
|
||||
log.config.exception("No color defined for {}!".format(key))
|
||||
return ''
|
||||
if isinstance(val, QColor):
|
||||
# This could happen when accidentally declaring something as
|
||||
# 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('.'):
|
||||
|
@ -102,8 +102,9 @@ class TestColorDict:
|
||||
|
||||
def test_qcolor(self):
|
||||
d = style.ColorDict()
|
||||
d['foo'] = QColor()
|
||||
with pytest.raises(TypeError):
|
||||
d['foo'] = QColor()
|
||||
d['foo']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('key, expected', [
|
||||
|
Loading…
Reference in New Issue
Block a user