From ec5c2b6699c390ccdf31a9adfd942a654b799d1e Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Wed, 16 Mar 2016 23:30:50 +0100 Subject: [PATCH] scanwidget: shortcuts (4a21946) --- artiq/gui/entries.py | 2 +- artiq/gui/scanwidget.py | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/artiq/gui/entries.py b/artiq/gui/entries.py index b6a467fa3..4cbcdc220 100644 --- a/artiq/gui/entries.py +++ b/artiq/gui/entries.py @@ -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) diff --git a/artiq/gui/scanwidget.py b/artiq/gui/scanwidget.py index 741234764..ac6a20e28 100644 --- a/artiq/gui/scanwidget.py +++ b/artiq/gui/scanwidget.py @@ -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()