Ejemplo n.º 1
0
class HotkeyDialog(QDialog):
    shortcuts = None

    def __init__(self, shortcuts):
        super(HotkeyDialog, self).__init__()

        # shortcuts is a reference to the real shortcuts dict so modify it only if the user presses ok!
        self.shortcuts = shortcuts

        # Set up the user interface from Designer.
        self.ui = Ui_HotkeyDialog()
        self.ui.setupUi(self)

        self.setAttribute(Qt.WA_DeleteOnClose)

        # add hotkey edits
        for key in sorted(shortcuts.keys()):
            shortcut = self.shortcuts[key]
            edit = HotkeyLineEdit()
            edit.setKeySequence(shortcut.key())
            self.ui.formLayout.addRow(key, edit)

        # save if the user accepts the dialog (presses ok)
        self.accepted.connect(self.save)

    # save shortcuts in container when the dialog is closed
    def save(self):
      log.info("Saving Hotkey stuff in Hotkeydialog")
      
      for i in range(0, self.ui.formLayout.rowCount()):
        key  = self.ui.formLayout.itemAt(i, QFormLayout.LabelRole).widget().text()
        edit = self.ui.formLayout.itemAt(i, QFormLayout.FieldRole).widget()

        if key not in self.shortcuts: raise RuntimeError
        self.shortcuts[key].setKey(edit.key_sequence)
Ejemplo n.º 2
0
    def __init__(self, shortcuts):
        super(HotkeyDialog, self).__init__()

        # shortcuts is a reference to the real shortcuts dict so modify it only if the user presses ok!
        self.shortcuts = shortcuts

        # Set up the user interface from Designer.
        self.ui = Ui_HotkeyDialog()
        self.ui.setupUi(self)

        self.setAttribute(Qt.WA_DeleteOnClose)

        # add hotkey edits
        for key in sorted(shortcuts.keys()):
            shortcut = self.shortcuts[key]
            edit = HotkeyLineEdit()
            edit.setKeySequence(shortcut.key())
            self.ui.formLayout.addRow(key, edit)

        # save if the user accepts the dialog (presses ok)
        self.accepted.connect(self.save)