forked from M-Labs/artiq
1
0
Fork 0

scanwidget: shortcuts (4a21946)

This commit is contained in:
Robert Jördens 2016-03-16 23:30:50 +01:00
parent fb31782b6f
commit ec5c2b6699
2 changed files with 10 additions and 9 deletions

View File

@ -155,7 +155,7 @@ class _RangeScan(LayoutWidget):
spinbox.setSuffix(" " + procdesc["unit"]) spinbox.setSuffix(" " + procdesc["unit"])
self.scanner = scanner = ScanWidget() self.scanner = scanner = ScanWidget()
scanner.setMinimumSize(150, 0) scanner.setFocusPolicy(QtCore.Qt.StrongFocus)
scanner.setSizePolicy(QtWidgets.QSizePolicy( scanner.setSizePolicy(QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)) QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed))
self.addWidget(scanner, 0, 0, -1, 1) self.addWidget(scanner, 0, 0, -1, 1)

View File

@ -22,13 +22,17 @@ class ScanWidget(QtWidgets.QWidget):
self.ticker = Ticker() self.ticker = Ticker()
self.menu = QtWidgets.QMenu(self) self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
action = QtWidgets.QAction("&View Range", self) action = QtWidgets.QAction("V&iew range", self)
action.setShortcut(QtGui.QKeySequence("CTRL+i"))
action.setShortcutContext(QtCore.Qt.WidgetShortcut)
action.triggered.connect(self.viewRange) action.triggered.connect(self.viewRange)
self.menu.addAction(action) self.addAction(action)
action = QtWidgets.QAction("&Snap Range", self) action = QtWidgets.QAction("Sna&p range", self)
action.setShortcut(QtGui.QKeySequence("CTRL+p"))
action.setShortcutContext(QtCore.Qt.WidgetShortcut)
action.triggered.connect(self.snapRange) action.triggered.connect(self.snapRange)
self.menu.addAction(action) self.addAction(action)
qfm = QtGui.QFontMetrics(self.font()) qfm = QtGui.QFontMetrics(self.font())
self._labelSize = QtCore.QSize( self._labelSize = QtCore.QSize(
@ -39,9 +43,6 @@ class ScanWidget(QtWidgets.QWidget):
self._axisView = None self._axisView = None
self._offset, self._drag = None, None self._offset, self._drag = None, None
def contextMenuEvent(self, ev):
self.menu.popup(ev.globalPos())
def sizeHint(self): def sizeHint(self):
return self.minimumSizeHint() return self.minimumSizeHint()