Ignore isNullError while handling label elements.
Fixes #295 (hopefully for real this time!)
This commit is contained in:
parent
99fb516aa3
commit
d94f848c82
@ -672,17 +672,22 @@ class HintManager(QObject):
|
|||||||
"""Handle a new partial keypress."""
|
"""Handle a new partial keypress."""
|
||||||
log.hints.debug("Handling new keystring: '{}'".format(keystr))
|
log.hints.debug("Handling new keystring: '{}'".format(keystr))
|
||||||
for (string, elems) in self._context.elems.items():
|
for (string, elems) in self._context.elems.items():
|
||||||
|
try:
|
||||||
if string.startswith(keystr):
|
if string.startswith(keystr):
|
||||||
matched = string[:len(keystr)]
|
matched = string[:len(keystr)]
|
||||||
rest = string[len(keystr):]
|
rest = string[len(keystr):]
|
||||||
elems.label.setInnerXml('<font color="{}">{}</font>{}'.format(
|
match_color = config.get('colors', 'hints.fg.match')
|
||||||
config.get('colors', 'hints.fg.match'), matched, rest))
|
elems.label.setInnerXml(
|
||||||
|
'<font color="{}">{}</font>{}'.format(
|
||||||
|
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')
|
elems.label.setStyleProperty('display', 'inline')
|
||||||
else:
|
else:
|
||||||
# element doesn't match anymore -> hide it
|
# element doesn't match anymore -> hide it
|
||||||
elems.label.setStyleProperty('display', 'none')
|
elems.label.setStyleProperty('display', 'none')
|
||||||
|
except webelem.IsNullError:
|
||||||
|
pass
|
||||||
|
|
||||||
def filter_hints(self, filterstr):
|
def filter_hints(self, filterstr):
|
||||||
"""Filter displayed hints according to a text.
|
"""Filter displayed hints according to a text.
|
||||||
@ -691,6 +696,7 @@ class HintManager(QObject):
|
|||||||
filterstr: The string to filer with, or None to show all.
|
filterstr: The string to filer with, or None to show all.
|
||||||
"""
|
"""
|
||||||
for elems in self._context.elems.values():
|
for elems in self._context.elems.values():
|
||||||
|
try:
|
||||||
if (filterstr is None or
|
if (filterstr is None or
|
||||||
str(elems.elem).lower().startswith(filterstr)):
|
str(elems.elem).lower().startswith(filterstr)):
|
||||||
if self._is_hidden(elems.label):
|
if self._is_hidden(elems.label):
|
||||||
@ -699,6 +705,8 @@ class HintManager(QObject):
|
|||||||
else:
|
else:
|
||||||
# element doesn't match anymore -> hide it
|
# element doesn't match anymore -> hide it
|
||||||
elems.label.setStyleProperty('display', 'none')
|
elems.label.setStyleProperty('display', 'none')
|
||||||
|
except webelem.IsNullError:
|
||||||
|
pass
|
||||||
visible = {}
|
visible = {}
|
||||||
for k, e in self._context.elems.items():
|
for k, e in self._context.elems.items():
|
||||||
if not self._is_hidden(e.label):
|
if not self._is_hidden(e.label):
|
||||||
@ -779,11 +787,14 @@ class HintManager(QObject):
|
|||||||
"""Reposition hints if contents size changed."""
|
"""Reposition hints if contents size changed."""
|
||||||
log.hints.debug("Contents size changed...!")
|
log.hints.debug("Contents size changed...!")
|
||||||
for elems in self._context.elems.values():
|
for elems in self._context.elems.values():
|
||||||
|
try:
|
||||||
if elems.elem.webFrame() is None:
|
if elems.elem.webFrame() is None:
|
||||||
# This sometimes happens for some reason...
|
# This sometimes happens for some reason...
|
||||||
elems.label.removeFromDocument()
|
elems.label.removeFromDocument()
|
||||||
continue
|
continue
|
||||||
self._set_style_position(elems.elem, elems.label)
|
self._set_style_position(elems.elem, elems.label)
|
||||||
|
except webelem.IsNullError:
|
||||||
|
pass
|
||||||
|
|
||||||
@pyqtSlot(usertypes.KeyMode)
|
@pyqtSlot(usertypes.KeyMode)
|
||||||
def on_mode_left(self, mode):
|
def on_mode_left(self, mode):
|
||||||
|
Loading…
Reference in New Issue
Block a user