Add zooming with Ctrl-mousewheel.

Closes #51.
This commit is contained in:
Florian Bruhin 2015-03-30 15:26:07 +02:00
parent fab6bc285c
commit 70ccdd86b2
3 changed files with 32 additions and 0 deletions

View File

@ -83,6 +83,7 @@
|<<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-rocker-gestures,rocker-gestures>>|Whether to enable Opera-like mouse rocker gestures. This disables the context menu.
|<<input-mouse-zoom-divider,mouse-zoom-divider>>|How much to divide the mouse wheel movements to translate them into zoom increments.
|==============
.Quick reference for section ``tabs''
@ -785,6 +786,12 @@ Valid values:
Default: +pass:[false]+
[[input-mouse-zoom-divider]]
=== mouse-zoom-divider
How much to divide the mouse wheel movements to translate them into zoom increments.
Default: +pass:[512]+
== tabs
Configuration of the tab bar.

View File

@ -527,3 +527,23 @@ class WebView(QWebView):
menu = self.page().createStandardContextMenu()
self.shutting_down.connect(menu.close)
menu.exec_(e.globalPos())
def wheelEvent(self, e):
"""Zoom on Ctrl-Mousewheel.
Args:
e: The QWheelEvent.
"""
if e.modifiers() & Qt.ControlModifier:
e.accept()
divider = config.get('input', 'mouse-zoom-divider')
factor = self.zoomFactor() + e.angleDelta().y() / divider
if factor < 0:
return
perc = int(100 * factor)
message.info(self.win_id, "Zoom level: {}%".format(perc))
self._zoom.fuzzyval = perc
self.setZoomFactor(factor)
self._default_zoom_changed = True
else:
super().wheelEvent(e)

View File

@ -392,6 +392,11 @@ DATA = collections.OrderedDict([
SettingValue(typ.Bool(), 'false'),
"Whether to enable Opera-like mouse rocker gestures. This disables "
"the context menu."),
('mouse-zoom-divider',
SettingValue(typ.Int(minval=1), '512'),
"How much to divide the mouse wheel movements to translate them "
"into zoom increments."),
)),
('tabs', sect.KeyValue(