Merge b12905298e into 7e3df43463
This commit is contained in:
commit
cb6d915345
|
|
@ -633,9 +633,14 @@ class HintManager(QObject):
|
|||
.format(self._context.tab.tab_id, tab.tab_id))
|
||||
return
|
||||
|
||||
strings = self._hint_strings(elems)
|
||||
unique, urls = self._get_unique_url_elems_collection(elems)
|
||||
|
||||
strings = self._hint_strings(unique)
|
||||
log.hints.debug("hints: {}".format(', '.join(strings)))
|
||||
|
||||
#urls = dict(map(lambda e: (e[1][1], e[1]), urls.items()))
|
||||
strings = list(map(lambda e: strings[unique.index(e)] if e in unique else strings[unique.index([item[0] for item in urls.values() if e in item][0])], elems))
|
||||
|
||||
for elem, string in zip(elems, strings):
|
||||
label = HintLabel(elem, self._context)
|
||||
label.update_text('', string)
|
||||
|
|
@ -657,6 +662,24 @@ class HintManager(QObject):
|
|||
# to make auto_follow == 'always' work
|
||||
self._handle_auto_follow()
|
||||
|
||||
def _get_unique_url_elems_collection(self, elems):
|
||||
unique = list()
|
||||
urls = dict()
|
||||
|
||||
for elem in elems:
|
||||
tag = elem.tag_name()
|
||||
if (tag in ('a', 'img')):
|
||||
url = elem['href' if tag == 'a' else 'src']
|
||||
if url in urls.keys():
|
||||
urls[url].append(elem)
|
||||
else:
|
||||
urls[url] = [elem]
|
||||
unique.append(elem)
|
||||
else:
|
||||
unique.append(elem)
|
||||
|
||||
return unique, urls
|
||||
|
||||
@cmdutils.register(instance='hintmanager', scope='window', name='hint',
|
||||
star_args_optional=True, maxsplit=2)
|
||||
def start(self, # pylint: disable=keyword-arg-before-vararg
|
||||
|
|
|
|||
Loading…
Reference in New Issue