Function to add shortcuts via code

I plan on adding a few more.
master
Salvo 'LtWorf' Tomaselli 2015-12-31 14:29:12 +07:00
parent 950a2273c3
commit 76cdfe7d06
1 changed files with 17 additions and 0 deletions

@ -67,6 +67,23 @@ class relForm(QtWidgets.QMainWindow):
self._restore_settings() 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): def checkVersion(self):
from relational import maintenance from relational import maintenance
online = maintenance.check_latest_version() online = maintenance.check_latest_version()