From a4e916de73b9c14b05ce56e1d790775c3f487f3a Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Wed, 16 Mar 2016 23:47:28 +0100 Subject: [PATCH] scanwidget: scroll and code simplification (0cca4a3) --- artiq/gui/entries.py | 4 +--- artiq/gui/scanwidget.py | 10 ++++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/artiq/gui/entries.py b/artiq/gui/entries.py index 4cbcdc220..383d0d701 100644 --- a/artiq/gui/entries.py +++ b/artiq/gui/entries.py @@ -155,9 +155,7 @@ class _RangeScan(LayoutWidget): spinbox.setSuffix(" " + procdesc["unit"]) self.scanner = scanner = ScanWidget() - scanner.setFocusPolicy(QtCore.Qt.StrongFocus) - scanner.setSizePolicy(QtWidgets.QSizePolicy( - QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)) + disable_scroll_wheel(scanner) self.addWidget(scanner, 0, 0, -1, 1) self.min = ScientificSpinBox() diff --git a/artiq/gui/scanwidget.py b/artiq/gui/scanwidget.py index ac6a20e28..57141a1f2 100644 --- a/artiq/gui/scanwidget.py +++ b/artiq/gui/scanwidget.py @@ -156,14 +156,12 @@ class ScanWidget(QtWidgets.QWidget): def wheelEvent(self, ev): y = ev.angleDelta().y()/120. + if not y: + return if ev.modifiers() & QtCore.Qt.ShiftModifier: - if y: - self.setNum(max(1, self._num + y)) - elif ev.modifiers() & QtCore.Qt.ControlModifier: - if y: - self._zoom(self.zoomFactor**y, ev.x()) + self.setNum(max(1, self._num + y)) else: - ev.ignore() + self._zoom(self.zoomFactor**y, ev.x()) def resizeEvent(self, ev): if not ev.oldSize().isValid():