forked from M-Labs/artiq
scanwidget: scroll and code simplification (0cca4a3)
This commit is contained in:
parent
ec5c2b6699
commit
a4e916de73
|
@ -155,9 +155,7 @@ class _RangeScan(LayoutWidget):
|
||||||
spinbox.setSuffix(" " + procdesc["unit"])
|
spinbox.setSuffix(" " + procdesc["unit"])
|
||||||
|
|
||||||
self.scanner = scanner = ScanWidget()
|
self.scanner = scanner = ScanWidget()
|
||||||
scanner.setFocusPolicy(QtCore.Qt.StrongFocus)
|
disable_scroll_wheel(scanner)
|
||||||
scanner.setSizePolicy(QtWidgets.QSizePolicy(
|
|
||||||
QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed))
|
|
||||||
self.addWidget(scanner, 0, 0, -1, 1)
|
self.addWidget(scanner, 0, 0, -1, 1)
|
||||||
|
|
||||||
self.min = ScientificSpinBox()
|
self.min = ScientificSpinBox()
|
||||||
|
|
|
@ -156,14 +156,12 @@ class ScanWidget(QtWidgets.QWidget):
|
||||||
|
|
||||||
def wheelEvent(self, ev):
|
def wheelEvent(self, ev):
|
||||||
y = ev.angleDelta().y()/120.
|
y = ev.angleDelta().y()/120.
|
||||||
|
if not y:
|
||||||
|
return
|
||||||
if ev.modifiers() & QtCore.Qt.ShiftModifier:
|
if ev.modifiers() & QtCore.Qt.ShiftModifier:
|
||||||
if y:
|
self.setNum(max(1, self._num + y))
|
||||||
self.setNum(max(1, self._num + y))
|
|
||||||
elif ev.modifiers() & QtCore.Qt.ControlModifier:
|
|
||||||
if y:
|
|
||||||
self._zoom(self.zoomFactor**y, ev.x())
|
|
||||||
else:
|
else:
|
||||||
ev.ignore()
|
self._zoom(self.zoomFactor**y, ev.x())
|
||||||
|
|
||||||
def resizeEvent(self, ev):
|
def resizeEvent(self, ev):
|
||||||
if not ev.oldSize().isValid():
|
if not ev.oldSize().isValid():
|
||||||
|
|
Loading…
Reference in New Issue