Improve hovering a hint
This commit is contained in:
parent
84759a4928
commit
4d101eea59
@ -115,7 +115,7 @@ class HintManager(QObject):
|
|||||||
Target.yank: "Yank hint to clipboard...",
|
Target.yank: "Yank hint to clipboard...",
|
||||||
Target.yank_primary: "Yank hint to primary selection...",
|
Target.yank_primary: "Yank hint to primary selection...",
|
||||||
Target.fill: "Set hint in commandline...",
|
Target.fill: "Set hint in commandline...",
|
||||||
Target.hover: "Hover over a hint",
|
Target.hover: "Hover over a hint...",
|
||||||
Target.rapid: "Follow hint (rapid mode)...",
|
Target.rapid: "Follow hint (rapid mode)...",
|
||||||
Target.rapid_win: "Follow hint in new window (rapid mode)...",
|
Target.rapid_win: "Follow hint in new window (rapid mode)...",
|
||||||
Target.download: "Download hint...",
|
Target.download: "Download hint...",
|
||||||
@ -336,44 +336,29 @@ class HintManager(QObject):
|
|||||||
target = Target.window
|
target = Target.window
|
||||||
else:
|
else:
|
||||||
target = self._context.target
|
target = self._context.target
|
||||||
self.set_open_target.emit(target.name)
|
|
||||||
# FIXME Instead of clicking the center, we could have nicer heuristics.
|
# FIXME Instead of clicking the center, we could have nicer heuristics.
|
||||||
# e.g. parse (-webkit-)border-radius correctly and click text fields at
|
# e.g. parse (-webkit-)border-radius correctly and click text fields at
|
||||||
# the bottom right, and everything else on the top left or so.
|
# the bottom right, and everything else on the top left or so.
|
||||||
# https://github.com/The-Compiler/qutebrowser/issues/70
|
# https://github.com/The-Compiler/qutebrowser/issues/70
|
||||||
pos = elem.rect_on_view().center()
|
pos = elem.rect_on_view().center()
|
||||||
log.hints.debug("Clicking on '{}' at {}/{}".format(
|
action = "Hovering" if target == Target.hover else "Clicking"
|
||||||
elem, pos.x(), pos.y()))
|
log.hints.debug("{} on '{}' at {}/{}".format(
|
||||||
events = (
|
action, elem, pos.x(), pos.y()))
|
||||||
|
events = [
|
||||||
QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton,
|
QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton,
|
||||||
Qt.NoModifier),
|
Qt.NoModifier),
|
||||||
QMouseEvent(QEvent.MouseButtonPress, pos, Qt.LeftButton,
|
]
|
||||||
Qt.NoButton, Qt.NoModifier),
|
if target != Target.hover:
|
||||||
QMouseEvent(QEvent.MouseButtonRelease, pos, Qt.LeftButton,
|
self.set_open_target.emit(target.name)
|
||||||
Qt.NoButton, Qt.NoModifier),
|
events += [
|
||||||
)
|
QMouseEvent(QEvent.MouseButtonPress, pos, Qt.LeftButton,
|
||||||
|
Qt.NoButton, Qt.NoModifier),
|
||||||
|
QMouseEvent(QEvent.MouseButtonRelease, pos, Qt.LeftButton,
|
||||||
|
Qt.NoButton, Qt.NoModifier),
|
||||||
|
]
|
||||||
for evt in events:
|
for evt in events:
|
||||||
self.mouse_event.emit(evt)
|
self.mouse_event.emit(evt)
|
||||||
|
|
||||||
def _hover(self, elem):
|
|
||||||
"""Hover over an element.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
elem: The QWebElement to hover.
|
|
||||||
"""
|
|
||||||
target = self._context.target
|
|
||||||
self.set_open_target.emit(target.name)
|
|
||||||
# FIXME Instead of clicking the center, we could have nicer heuristics.
|
|
||||||
# e.g. parse (-webkit-)border-radius correctly and click text fields at
|
|
||||||
# the bottom right, and everything else on the top left or so.
|
|
||||||
# https://github.com/The-Compiler/qutebrowser/issues/70
|
|
||||||
pos = elem.rect_on_view().center()
|
|
||||||
log.hints.debug("Hovering on '{}' at {}/{}".format(
|
|
||||||
elem, pos.x(), pos.y()))
|
|
||||||
event = QMouseEvent(
|
|
||||||
QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton, Qt.NoModifier)
|
|
||||||
self.mouse_event.emit(event)
|
|
||||||
|
|
||||||
def _yank(self, url):
|
def _yank(self, url):
|
||||||
"""Yank an element to the clipboard or primary selection.
|
"""Yank an element to the clipboard or primary selection.
|
||||||
|
|
||||||
@ -705,7 +690,7 @@ class HintManager(QObject):
|
|||||||
Target.window: self._click,
|
Target.window: self._click,
|
||||||
Target.rapid: self._click,
|
Target.rapid: self._click,
|
||||||
Target.rapid_win: self._click,
|
Target.rapid_win: self._click,
|
||||||
Target.hover: self._hover,
|
Target.hover: self._click,
|
||||||
# _download needs a QWebElement to get the frame.
|
# _download needs a QWebElement to get the frame.
|
||||||
Target.download: self._download,
|
Target.download: self._download,
|
||||||
}
|
}
|
||||||
|
@ -923,7 +923,7 @@ KEY_DATA = collections.OrderedDict([
|
|||||||
('hint all tab', ['F']),
|
('hint all tab', ['F']),
|
||||||
('hint all window', ['wf']),
|
('hint all window', ['wf']),
|
||||||
('hint all tab-bg', [';b']),
|
('hint all tab-bg', [';b']),
|
||||||
('hint all hover', ['e']),
|
('hint all hover', [';h']),
|
||||||
('hint images', [';i']),
|
('hint images', [';i']),
|
||||||
('hint images tab', [';I']),
|
('hint images tab', [';I']),
|
||||||
('hint images tab-bg', ['.i']),
|
('hint images tab-bg', ['.i']),
|
||||||
|
Loading…
Reference in New Issue
Block a user