gui: don't scroll experiment editor on modified wheel (closes #303)

If you try to target e.g. spinbox with a ctrl- or shift-wheel to change the value
and you don't aim well, the tree widget will scroll. We already have tree
scroll on unmodified wheel. Let's have the modified wheel events exclusively
target the smaller widgets.
This commit is contained in:
Robert Jördens 2016-03-08 16:12:38 +01:00
parent 41ca223c45
commit c08881de5d

View File

@ -18,6 +18,15 @@ logger = logging.getLogger(__name__)
# 2. file:<class name>@<file name>
class _WheelFilter(QtCore.QObject):
def eventFilter(self, obj, event):
if (event.type() == QtCore.QEvent.Wheel and
event.modifiers() != QtCore.Qt.NoModifier):
event.ignore()
return True
return False
class _ArgumentEditor(QtWidgets.QTreeWidget):
def __init__(self, manager, dock, expurl):
self.manager = manager
@ -38,6 +47,8 @@ class _ArgumentEditor(QtWidgets.QTreeWidget):
self.setHorizontalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)
self.setVerticalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)
self.viewport().installEventFilter(_WheelFilter(self.viewport()))
self._groups = dict()
self._arg_to_entry_widgetitem = dict()