From 76cdfe7d0689e242f5b9ddb0e909f4871c6bdae0 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Thu, 31 Dec 2015 14:29:12 +0100 Subject: [PATCH] Function to add shortcuts via code I plan on adding a few more. --- relational_gui/guihandler.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/relational_gui/guihandler.py b/relational_gui/guihandler.py index ec9eb13..6785640 100644 --- a/relational_gui/guihandler.py +++ b/relational_gui/guihandler.py @@ -67,6 +67,23 @@ class relForm(QtWidgets.QMainWindow): self._restore_settings() + # Shortcuts + shortcuts = ( + (self.ui.lstRelations, QtGui.QKeySequence.Delete, self.unloadRelation), + ) + + self.add_shortcuts(shortcuts) + + def add_shortcuts(self, shortcuts): + for widget,shortcut,slot in shortcuts: + action = QtWidgets.QAction(self) + action.triggered.connect(slot) + action.setShortcut(QtGui.QKeySequence(shortcut)) + # I couldn't find the constant + action.setShortcutContext(0) + widget.addAction(action) + + def checkVersion(self): from relational import maintenance online = maintenance.check_latest_version()