From 8e38735982107ec76e62705f5f3d7cf3af37ad53 Mon Sep 17 00:00:00 2001 From: Hugo Slepicka Date: Wed, 29 Apr 2020 10:07:49 -0700 Subject: [PATCH] FIX: Adding missing file that was not under version control. --- pydm/utilities/shortcuts.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pydm/utilities/shortcuts.py diff --git a/pydm/utilities/shortcuts.py b/pydm/utilities/shortcuts.py new file mode 100644 index 000000000..3ed06b2bf --- /dev/null +++ b/pydm/utilities/shortcuts.py @@ -0,0 +1,29 @@ +from qtpy import QtWidgets, QtGui, QtCore + + +def install_connection_inspector(parent, keys=None): + """ + Install a QShortcut at the application which opens the PyDM Connection + Inspector + + Parameters + ---------- + parent : QWidget + A shortcut is "listened for" by Qt's event loop when the shortcut's + parent widget is receiving events. + keys : QKeySequence, optional + Default value is `Alt+C` + """ + from pydm.connection_inspector import ConnectionInspector + + def show_inspector(): + c = ConnectionInspector(parent=parent) + c.show() + + parent = parent or QtWidgets.QApplication.desktop() + + if keys is None: + keys = QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_C) + shortcut = QtWidgets.QShortcut(keys, parent); + shortcut.setContext(QtCore.Qt.ApplicationShortcut) + shortcut.activated.connect(show_inspector)