Add support to hover mouse over a hint
This commit is contained in:
parent
904d84db7e
commit
84759a4928
@ -145,6 +145,7 @@ Start hinting.
|
||||
- `tab`: Open the link in a new tab.
|
||||
- `tab-bg`: Open the link in a new background tab.
|
||||
- `window`: Open the link in a new window.
|
||||
- `hover` : Hover over the link.
|
||||
- `yank`: Yank the link to the clipboard.
|
||||
- `yank-primary`: Yank the link to the primary selection.
|
||||
- `fill`: Fill the commandline with the command given as
|
||||
|
@ -40,7 +40,7 @@ ElemTuple = collections.namedtuple('ElemTuple', ['elem', 'label'])
|
||||
|
||||
|
||||
Target = usertypes.enum('Target', ['normal', 'tab', 'tab_bg', 'window', 'yank',
|
||||
'yank_primary', 'fill', 'rapid',
|
||||
'yank_primary', 'fill', 'hover', 'rapid',
|
||||
'rapid_win', 'download', 'userscript',
|
||||
'spawn'])
|
||||
|
||||
@ -115,6 +115,7 @@ class HintManager(QObject):
|
||||
Target.yank: "Yank hint to clipboard...",
|
||||
Target.yank_primary: "Yank hint to primary selection...",
|
||||
Target.fill: "Set hint in commandline...",
|
||||
Target.hover: "Hover over a hint",
|
||||
Target.rapid: "Follow hint (rapid mode)...",
|
||||
Target.rapid_win: "Follow hint in new window (rapid mode)...",
|
||||
Target.download: "Download hint...",
|
||||
@ -354,6 +355,25 @@ class HintManager(QObject):
|
||||
for evt in events:
|
||||
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):
|
||||
"""Yank an element to the clipboard or primary selection.
|
||||
|
||||
@ -685,6 +705,7 @@ class HintManager(QObject):
|
||||
Target.window: self._click,
|
||||
Target.rapid: self._click,
|
||||
Target.rapid_win: self._click,
|
||||
Target.hover: self._hover,
|
||||
# _download needs a QWebElement to get the frame.
|
||||
Target.download: self._download,
|
||||
}
|
||||
|
@ -923,6 +923,7 @@ KEY_DATA = collections.OrderedDict([
|
||||
('hint all tab', ['F']),
|
||||
('hint all window', ['wf']),
|
||||
('hint all tab-bg', [';b']),
|
||||
('hint all hover', ['e']),
|
||||
('hint images', [';i']),
|
||||
('hint images tab', [';I']),
|
||||
('hint images tab-bg', ['.i']),
|
||||
|
@ -220,7 +220,8 @@ PromptMode = enum('PromptMode', ['yesno', 'text', 'user_pwd', 'alert'])
|
||||
|
||||
|
||||
# Where to open a clicked link.
|
||||
ClickTarget = enum('ClickTarget', ['normal', 'tab', 'tab_bg', 'window'])
|
||||
ClickTarget = enum('ClickTarget', ['normal', 'tab', 'tab_bg', 'window',
|
||||
'hover'])
|
||||
|
||||
|
||||
# Key input modes
|
||||
|
Loading…
Reference in New Issue
Block a user