Add Opera-like mouse rocker gestures.
This commit is contained in:
parent
f19eba3b40
commit
c8c095d499
@ -150,6 +150,7 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* Matthias Lisin
|
* Matthias Lisin
|
||||||
* Helen Sherwood-Taylor
|
* Helen Sherwood-Taylor
|
||||||
* HalosGhost
|
* HalosGhost
|
||||||
|
* Gregor Pohl
|
||||||
* Eivind Uggedal
|
* Eivind Uggedal
|
||||||
* Andreas Fischer
|
* Andreas Fischer
|
||||||
// QUTE_AUTHORS_END
|
// QUTE_AUTHORS_END
|
||||||
|
@ -78,6 +78,7 @@
|
|||||||
|<<input-forward-unbound-keys,forward-unbound-keys>>|Whether to forward unbound keys to the webview in normal mode.
|
|<<input-forward-unbound-keys,forward-unbound-keys>>|Whether to forward unbound keys to the webview in normal mode.
|
||||||
|<<input-spatial-navigation,spatial-navigation>>|Enables or disables the Spatial Navigation feature
|
|<<input-spatial-navigation,spatial-navigation>>|Enables or disables the Spatial Navigation feature
|
||||||
|<<input-links-included-in-focus-chain,links-included-in-focus-chain>>|Whether hyperlinks should be included in the keyboard focus chain.
|
|<<input-links-included-in-focus-chain,links-included-in-focus-chain>>|Whether hyperlinks should be included in the keyboard focus chain.
|
||||||
|
|<<input-rocker-gestures,rocker-gestures>>|Whether to enable Opera-like mouse rocker gestures. This disables the context menu.
|
||||||
|==============
|
|==============
|
||||||
|
|
||||||
.Quick reference for section ``tabs''
|
.Quick reference for section ``tabs''
|
||||||
@ -731,6 +732,17 @@ Valid values:
|
|||||||
|
|
||||||
Default: +pass:[true]+
|
Default: +pass:[true]+
|
||||||
|
|
||||||
|
[[input-rocker-gestures]]
|
||||||
|
=== rocker-gestures
|
||||||
|
Whether to enable Opera-like mouse rocker gestures. This disables the context menu.
|
||||||
|
|
||||||
|
Valid values:
|
||||||
|
|
||||||
|
* +true+
|
||||||
|
* +false+
|
||||||
|
|
||||||
|
Default: +pass:[false]+
|
||||||
|
|
||||||
== tabs
|
== tabs
|
||||||
Configuration of the tab bar.
|
Configuration of the tab bar.
|
||||||
|
|
||||||
|
@ -143,6 +143,8 @@ class WebView(QWebView):
|
|||||||
self.setZoomFactor(float(config.get('ui', 'default-zoom')) / 100)
|
self.setZoomFactor(float(config.get('ui', 'default-zoom')) / 100)
|
||||||
self._default_zoom_changed = False
|
self._default_zoom_changed = False
|
||||||
objreg.get('config').changed.connect(self.on_config_changed)
|
objreg.get('config').changed.connect(self.on_config_changed)
|
||||||
|
if config.get('input', 'rocker-gestures'):
|
||||||
|
self.setContextMenuPolicy(Qt.PreventContextMenu)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
url = utils.elide(self.url().toDisplayString(), 50)
|
url = utils.elide(self.url().toDisplayString(), 50)
|
||||||
@ -178,6 +180,11 @@ class WebView(QWebView):
|
|||||||
100)
|
100)
|
||||||
self._default_zoom_changed = False
|
self._default_zoom_changed = False
|
||||||
self.init_neighborlist()
|
self.init_neighborlist()
|
||||||
|
elif section == 'input' and option == 'rocker-gestures':
|
||||||
|
if config.get('input', 'rocker-gestures'):
|
||||||
|
self.setContextMenuPolicy(Qt.PreventContextMenu)
|
||||||
|
else:
|
||||||
|
self.setContextMenuPolicy(Qt.DefaultContextMenu)
|
||||||
|
|
||||||
def init_neighborlist(self):
|
def init_neighborlist(self):
|
||||||
"""Initialize the _zoom neighborlist."""
|
"""Initialize the _zoom neighborlist."""
|
||||||
@ -192,15 +199,15 @@ class WebView(QWebView):
|
|||||||
Args:
|
Args:
|
||||||
e: The QMouseEvent.
|
e: The QMouseEvent.
|
||||||
"""
|
"""
|
||||||
if e.button() == Qt.XButton1:
|
if e.button() in (Qt.XButton1, Qt.LeftButton):
|
||||||
# Back button on mice which have it.
|
# Back button on mice which have it, or rocker gesture
|
||||||
if self.page().history().canGoBack():
|
if self.page().history().canGoBack():
|
||||||
self.back()
|
self.back()
|
||||||
else:
|
else:
|
||||||
message.error(self._win_id, "At beginning of history.",
|
message.error(self._win_id, "At beginning of history.",
|
||||||
immediately=True)
|
immediately=True)
|
||||||
elif e.button() == Qt.XButton2:
|
elif e.button() in (Qt.XButton2, Qt.RightButton):
|
||||||
# Forward button on mice which have it.
|
# Forward button on mice which have it, or rocker gesture
|
||||||
if self.page().history().canGoForward():
|
if self.page().history().canGoForward():
|
||||||
self.forward()
|
self.forward()
|
||||||
else:
|
else:
|
||||||
@ -497,7 +504,10 @@ class WebView(QWebView):
|
|||||||
Return:
|
Return:
|
||||||
The superclass return value.
|
The superclass return value.
|
||||||
"""
|
"""
|
||||||
if e.button() in (Qt.XButton1, Qt.XButton2):
|
is_rocker_gesture = (config.get('input', 'rocker-gestures') and
|
||||||
|
e.buttons() == Qt.LeftButton | Qt.RightButton)
|
||||||
|
|
||||||
|
if e.button() in (Qt.XButton1, Qt.XButton2) or is_rocker_gesture:
|
||||||
self._mousepress_backforward(e)
|
self._mousepress_backforward(e)
|
||||||
super().mousePressEvent(e)
|
super().mousePressEvent(e)
|
||||||
return
|
return
|
||||||
|
@ -370,6 +370,11 @@ DATA = collections.OrderedDict([
|
|||||||
('links-included-in-focus-chain',
|
('links-included-in-focus-chain',
|
||||||
SettingValue(typ.Bool(), 'true'),
|
SettingValue(typ.Bool(), 'true'),
|
||||||
"Whether hyperlinks should be included in the keyboard focus chain."),
|
"Whether hyperlinks should be included in the keyboard focus chain."),
|
||||||
|
|
||||||
|
('rocker-gestures',
|
||||||
|
SettingValue(typ.Bool(), 'false'),
|
||||||
|
"Whether to enable Opera-like mouse rocker gestures. This disables "
|
||||||
|
"the context menu."),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
('tabs', sect.KeyValue(
|
('tabs', sect.KeyValue(
|
||||||
|
Loading…
Reference in New Issue
Block a user