Add !important to all hint properties.

This commit is contained in:
Florian Bruhin 2015-01-06 17:10:54 +01:00
parent 9ebf36f26b
commit 77df4c7241

View File

@ -267,6 +267,14 @@ class HintManager(QObject):
display = elem.styleProperty('display', QWebElement.InlineStyle) display = elem.styleProperty('display', QWebElement.InlineStyle)
return display == 'none' return display == 'none'
def _show_elem(self, elem):
"""Show a given element."""
elem.setStyleProperty('display', 'inline !important')
def _hide_elem(self, elem):
"""Hide a given element."""
elem.setStyleProperty('display', 'none !important')
def _set_style_properties(self, elem, label): def _set_style_properties(self, elem, label):
"""Set the hint CSS on the element given. """Set the hint CSS on the element given.
@ -289,9 +297,9 @@ class HintManager(QObject):
# Make text uppercase if set in config # Make text uppercase if set in config
if (config.get('hints', 'uppercase') and if (config.get('hints', 'uppercase') and
config.get('hints', 'mode') == 'letter'): config.get('hints', 'mode') == 'letter'):
attrs.append(('text-transform', 'uppercase')) attrs.append(('text-transform', 'uppercase !important'))
else: else:
attrs.append(('text-transform', 'none')) attrs.append(('text-transform', 'none !important'))
for k, v in attrs: for k, v in attrs:
label.setStyleProperty(k, v) label.setStyleProperty(k, v)
@ -313,8 +321,8 @@ class HintManager(QObject):
top /= zoom top /= zoom
log.hints.vdebug("Drawing label '{!r}' at {}/{} for element '{!r}', " log.hints.vdebug("Drawing label '{!r}' at {}/{} for element '{!r}', "
"zoom level {}".format(label, left, top, elem, zoom)) "zoom level {}".format(label, left, top, elem, zoom))
label.setStyleProperty('left', '{}px'.format(left)) label.setStyleProperty('left', '{}px !important'.format(left))
label.setStyleProperty('top', '{}px'.format(top)) label.setStyleProperty('top', '{}px !important'.format(top))
def _draw_label(self, elem, string): def _draw_label(self, elem, string):
"""Draw a hint label over an element. """Draw a hint label over an element.
@ -717,10 +725,10 @@ class HintManager(QObject):
match_color, matched, rest)) match_color, matched, rest))
if self._is_hidden(elems.label): if self._is_hidden(elems.label):
# hidden element which matches again -> unhide it # hidden element which matches again -> unhide it
elems.label.setStyleProperty('display', 'inline') self._show_elem(elems.label)
else: else:
# element doesn't match anymore -> hide it # element doesn't match anymore -> hide it
elems.label.setStyleProperty('display', 'none') self._hide_elem(elems.label)
except webelem.IsNullError: except webelem.IsNullError:
pass pass
@ -736,10 +744,10 @@ class HintManager(QObject):
str(elems.elem).lower().startswith(filterstr)): str(elems.elem).lower().startswith(filterstr)):
if self._is_hidden(elems.label): if self._is_hidden(elems.label):
# hidden element which matches again -> unhide it # hidden element which matches again -> unhide it
elems.label.setStyleProperty('display', 'inline') self._show_elem(elems.label)
else: else:
# element doesn't match anymore -> hide it # element doesn't match anymore -> hide it
elems.label.setStyleProperty('display', 'none') self._hide_elem(elems.label)
except webelem.IsNullError: except webelem.IsNullError:
pass pass
visible = {} visible = {}