Skip to content

Commit

Permalink
scanwidget: shortcuts (4a21946)
Browse files Browse the repository at this point in the history
jordens committed Mar 16, 2016
1 parent fb31782 commit ec5c2b6
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion artiq/gui/entries.py
Original file line number Diff line number Diff line change
@@ -155,7 +155,7 @@ def apply_properties(spinbox):
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)
17 changes: 9 additions & 8 deletions artiq/gui/scanwidget.py
Original file line number Diff line number Diff line change
@@ -22,13 +22,17 @@ def __init__(self, zoomFactor=1.05, zoomMargin=.1, dynamicRange=1e9):

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 @@ def __init__(self, zoomFactor=1.05, zoomMargin=.1, dynamicRange=1e9):
self._axisView = None
self._offset, self._drag = None, None

def contextMenuEvent(self, ev):
self.menu.popup(ev.globalPos())

def sizeHint(self):
return self.minimumSizeHint()

0 comments on commit ec5c2b6

Please sign in to comment.