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"])
self.scanner = scanner = ScanWidget()
scanner.setMinimumSize(150, 0)
scanner.setFocusPolicy(QtCore.Qt.StrongFocus)
scanner.setSizePolicy(QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed))
self.addWidget(scanner, 0, 0, -1, 1)

View File

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