def __init__(self, parent=None):
     super(ShortcutEditDialog, self).__init__(parent)
     self.setMinimumWidth(400)
     # create gui
     
     layout = QVBoxLayout()
     layout.setSpacing(10)
     self.setLayout(layout)
     
     top = QHBoxLayout()
     top.setSpacing(4)
     p = self.toppixmap = QLabel()
     l = self.toplabel = QLabel()
     l.setWordWrap(True)
     top.addWidget(p)
     top.addWidget(l, 1)
     layout.addLayout(top)
     
     grid = QGridLayout()
     grid.setSpacing(4)
     grid.setColumnStretch(1, 2)
     layout.addLayout(grid)
     
     self.buttonDefault = QRadioButton(self)
     self.buttonNone = QRadioButton(self)
     self.buttonCustom = QRadioButton(self)
     grid.addWidget(self.buttonDefault, 0, 0, 1, 2)
     grid.addWidget(self.buttonNone, 1, 0, 1, 2)
     grid.addWidget(self.buttonCustom, 2, 0, 1, 2)
     
     self.keybuttons = []
     self.keylabels = []
     for num in range(4):
         l = QLabel(self)
         l.setStyleSheet("margin-left: 2em;")
         l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
         b = KeySequenceWidget(self)
         b.keySequenceChanged.connect(self.slotKeySequenceChanged)
         l.setBuddy(b)
         self.keylabels.append(l)
         self.keybuttons.append(b)
         grid.addWidget(l, num+3, 0)
         grid.addWidget(b, num+3, 1)
     
     layout.addWidget(Separator(self))
     
     b = QDialogButtonBox(self)
     b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     layout.addWidget(b)
     b.accepted.connect(self.accept)
     b.rejected.connect(self.reject)
     app.translateUI(self)
 def __init__(self, parent=None, conflictCallback=None, *cbArgs):
     """conflictCallback is a optional method called when a shortcut is changed.
     
     cbArgs is optional arguments of the conflictCallback method.
     it should return the name of the potential conflict or a null value """
     
     super(ShortcutEditDialog, self).__init__(parent)
     self.conflictCallback = conflictCallback
     self.cbArgs = cbArgs
     self.setMinimumWidth(400)
     # create gui
     
     layout = QVBoxLayout()
     layout.setSpacing(10)
     self.setLayout(layout)
     
     top = QHBoxLayout()
     top.setSpacing(4)
     p = self.toppixmap = QLabel()
     l = self.toplabel = QLabel()
     top.addWidget(p)
     top.addWidget(l, 1)
     layout.addLayout(top)
     grid = QGridLayout()
     grid.setSpacing(4)
     grid.setColumnStretch(1, 2)
     layout.addLayout(grid)
     
     self.buttonDefault = QRadioButton(self, toggled=self.slotButtonDefaultToggled)
     self.buttonNone = QRadioButton(self)
     self.lconflictDefault = QLabel('test')
     self.lconflictDefault.setStyleSheet("color : red;")
     self.lconflictDefault.setVisible(False)
     self.buttonCustom = QRadioButton(self)
     grid.addWidget(self.buttonDefault, 0, 0, 1, 2)
     grid.addWidget(self.lconflictDefault, 1, 0, 1, 2)
     grid.addWidget(self.buttonNone, 2, 0, 1, 2)
     grid.addWidget(self.buttonCustom, 3, 0, 1, 2)
     
     self.keybuttons = []
     self.keylabels = []
     self.conflictlabels = []
     for num in range(4):
         l = QLabel(self)
         l.setStyleSheet("margin-left: 2em;")
         l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
         b = KeySequenceWidget(self, num)
         b.keySequenceChanged.connect(self.slotKeySequenceChanged)
         l.setBuddy(b)
         self.keylabels.append(l)
         self.keybuttons.append(b)
         grid.addWidget(l, num+4+num, 0)
         grid.addWidget(b, num+4+num, 1)
         lconflict = QLabel()
         lconflict.setStyleSheet("color : red;")
         self.conflictlabels.append(lconflict)
         lconflict.setVisible(False)
         grid.addWidget(lconflict, num+5+num, 0, 1, 2, Qt.AlignHCenter)
     
     layout.addWidget(Separator(self))
     
     b = QDialogButtonBox(self)
     b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     layout.addWidget(b)
     b.accepted.connect(self.accept)
     b.rejected.connect(self.reject)
     app.translateUI(self)
Exemple #3
0
    def __init__(self, parent=None, conflictCallback=None, *cbArgs):
        """conflictCallback is a optional method called when a shortcut is changed.
        
        cbArgs is optional arguments of the conflictCallback method.
        it should return the name of the potential conflict or a null value """

        super(ShortcutEditDialog, self).__init__(parent)
        self.conflictCallback = conflictCallback
        self.cbArgs = cbArgs
        self.setMinimumWidth(400)
        # create gui

        layout = QVBoxLayout()
        layout.setSpacing(10)
        self.setLayout(layout)

        top = QHBoxLayout()
        top.setSpacing(4)
        p = self.toppixmap = QLabel()
        l = self.toplabel = QLabel()
        top.addWidget(p)
        top.addWidget(l, 1)
        layout.addLayout(top)
        grid = QGridLayout()
        grid.setSpacing(4)
        grid.setColumnStretch(1, 2)
        layout.addLayout(grid)

        self.buttonDefault = QRadioButton(
            self, toggled=self.slotButtonDefaultToggled)
        self.buttonNone = QRadioButton(self)
        self.lconflictDefault = QLabel('test')
        self.lconflictDefault.setStyleSheet("color : red;")
        self.lconflictDefault.setVisible(False)
        self.buttonCustom = QRadioButton(self)
        grid.addWidget(self.buttonDefault, 0, 0, 1, 2)
        grid.addWidget(self.lconflictDefault, 1, 0, 1, 2)
        grid.addWidget(self.buttonNone, 2, 0, 1, 2)
        grid.addWidget(self.buttonCustom, 3, 0, 1, 2)

        self.keybuttons = []
        self.keylabels = []
        self.conflictlabels = []
        for num in range(4):
            l = QLabel(self)
            l.setStyleSheet("margin-left: 2em;")
            l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
            b = KeySequenceWidget(self, num)
            b.keySequenceChanged.connect(self.slotKeySequenceChanged)
            l.setBuddy(b)
            self.keylabels.append(l)
            self.keybuttons.append(b)
            grid.addWidget(l, num + 4 + num, 0)
            grid.addWidget(b, num + 4 + num, 1)
            lconflict = QLabel()
            lconflict.setStyleSheet("color : red;")
            self.conflictlabels.append(lconflict)
            lconflict.setVisible(False)
            grid.addWidget(lconflict, num + 5 + num, 0, 1, 2, Qt.AlignHCenter)

        layout.addWidget(Separator(self))

        b = QDialogButtonBox(self)
        b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        layout.addWidget(b)
        b.accepted.connect(self.accept)
        b.rejected.connect(self.reject)
        app.translateUI(self)