Move input -> rocker-gestures to MouseEventFilter

This commit is contained in:
Florian Bruhin 2016-08-11 18:48:14 +02:00
parent e8980d01e6
commit fb07655e56
2 changed files with 7 additions and 14 deletions

View File

@ -74,6 +74,7 @@ class MouseEventFilter(QObject):
self._handlers = {
QEvent.MouseButtonPress: self._handle_mouse_press,
QEvent.Wheel: self._handle_wheel,
QEvent.ContextMenu: self._handle_context_menu,
}
self._ignore_wheel_event = False
@ -113,6 +114,10 @@ class MouseEventFilter(QObject):
return False
def _handle_context_menu(self, _e):
"""Suppress context menus if rocker gestures are turned on."""
return config.get('input', 'rocker-gestures')
def _mousepress_backforward(self, e):
"""Handle back/forward mouse button presses.

View File

@ -78,9 +78,7 @@ class WebView(QWebView):
window=win_id)
mode_manager.entered.connect(self.on_mode_entered)
mode_manager.left.connect(self.on_mode_left)
if config.get('input', 'rocker-gestures'):
self.setContextMenuPolicy(Qt.PreventContextMenu)
objreg.get('config').changed.connect(self.on_config_changed)
objreg.get('config').changed.connect(self._set_bg_color)
def _init_page(self, tabdata):
"""Initialize the QWebPage used by this view.
@ -110,6 +108,7 @@ class WebView(QWebView):
# deleted
pass
@config.change_filter('colors', 'webpage.bg')
def _set_bg_color(self):
"""Set the webpage background color as configured."""
col = config.get('colors', 'webpage.bg')
@ -119,17 +118,6 @@ class WebView(QWebView):
palette.setColor(QPalette.Base, col)
self.setPalette(palette)
@pyqtSlot(str, str)
def on_config_changed(self, section, option):
"""Update rocker gestures/background color."""
if section == 'input' and option == 'rocker-gestures':
if config.get('input', 'rocker-gestures'):
self.setContextMenuPolicy(Qt.PreventContextMenu)
else:
self.setContextMenuPolicy(Qt.DefaultContextMenu)
elif section == 'colors' and option == 'webpage.bg':
self._set_bg_color()
def _mousepress_insertmode(self, e):
"""Switch to insert mode when an editable element was clicked.