diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/Preferences/ToolGroupConfigurationDialog.py --- a/src/eric7/Preferences/ToolGroupConfigurationDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Preferences/ToolGroupConfigurationDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -21,59 +21,62 @@ """ Class implementing a configuration dialog for the tool groups. """ + def __init__(self, toolGroups, currentGroup, parent=None): """ Constructor - + @param toolGroups list of configured tool groups @param currentGroup number of the active group (integer) @param parent parent widget (QWidget) """ super().__init__(parent) self.setupUi(self) - + self.currentGroup = currentGroup self.toolGroups = copy.deepcopy(toolGroups) for group in toolGroups: self.groupsList.addItem(group[0]) - + if len(toolGroups): self.groupsList.setCurrentRow(0) self.on_groupsList_currentRowChanged(0) - + @pyqtSlot() def on_newButton_clicked(self): """ Private slot to clear all entry fields. """ self.nameEdit.clear() - + @pyqtSlot() def on_addButton_clicked(self): """ Private slot to add a new entry. """ groupName = self.nameEdit.text() - + if not groupName: EricMessageBox.critical( self, self.tr("Add tool group entry"), - self.tr("You have to give a name for the group to add.")) + self.tr("You have to give a name for the group to add."), + ) return - - if len(self.groupsList.findItems( - groupName, Qt.MatchFlag.MatchExactly)): + + if len(self.groupsList.findItems(groupName, Qt.MatchFlag.MatchExactly)): EricMessageBox.critical( self, self.tr("Add tool group entry"), - self.tr("An entry for the group name {0} already exists.") - .format(groupName)) + self.tr("An entry for the group name {0} already exists.").format( + groupName + ), + ) return - + self.groupsList.addItem(groupName) self.toolGroups.append([groupName, []]) - + @pyqtSlot() def on_changeButton_clicked(self): """ @@ -82,28 +85,30 @@ row = self.groupsList.currentRow() if row < 0: return - + groupName = self.nameEdit.text() - + if not groupName: EricMessageBox.critical( self, self.tr("Add tool group entry"), - self.tr("You have to give a name for the group to add.")) + self.tr("You have to give a name for the group to add."), + ) return - - if len(self.groupsList.findItems( - groupName, Qt.MatchFlag.MatchExactly)): + + if len(self.groupsList.findItems(groupName, Qt.MatchFlag.MatchExactly)): EricMessageBox.critical( self, self.tr("Add tool group entry"), - self.tr("An entry for the group name {0} already exists.") - .format(groupName)) + self.tr("An entry for the group name {0} already exists.").format( + groupName + ), + ) return - + self.toolGroups[row][0] = groupName self.groupsList.currentItem().setText(groupName) - + @pyqtSlot() def on_deleteButton_clicked(self): """ @@ -112,21 +117,23 @@ row = self.groupsList.currentRow() if row < 0: return - + res = EricMessageBox.yesNo( self, self.tr("Delete tool group entry"), - self.tr("""<p>Do you really want to delete the tool group""" - """ <b>"{0}"</b>?</p>""") - .format(self.groupsList.currentItem().text()), - icon=EricMessageBox.Warning) + self.tr( + """<p>Do you really want to delete the tool group""" + """ <b>"{0}"</b>?</p>""" + ).format(self.groupsList.currentItem().text()), + icon=EricMessageBox.Warning, + ) if not res: return - + if row == self.currentGroup: # set to default group if current group gets deleted self.currentGroup = -1 - + del self.toolGroups[row] itm = self.groupsList.takeItem(row) del itm @@ -134,7 +141,7 @@ row -= 1 self.groupsList.setCurrentRow(row) self.on_groupsList_currentRowChanged(row) - + @pyqtSlot() def on_downButton_clicked(self): """ @@ -149,7 +156,7 @@ if curr + 1 == len(self.toolGroups): self.downButton.setEnabled(False) self.upButton.setEnabled(True) - + @pyqtSlot() def on_upButton_clicked(self): """ @@ -164,25 +171,25 @@ if curr - 1 == 0: self.upButton.setEnabled(False) self.downButton.setEnabled(True) - + def on_groupsList_currentRowChanged(self, row): """ Private slot to set the lineedits depending on the selected entry. - + @param row the row of the selected entry (integer) """ if row >= 0 and row < len(self.toolGroups): group = self.toolGroups[row] self.nameEdit.setText(group[0]) - + self.deleteButton.setEnabled(True) self.changeButton.setEnabled(True) - + if row != 0: self.upButton.setEnabled(True) else: self.upButton.setEnabled(False) - + if row + 1 != len(self.toolGroups): self.downButton.setEnabled(True) else: @@ -193,20 +200,20 @@ self.upButton.setEnabled(False) self.deleteButton.setEnabled(False) self.changeButton.setEnabled(False) - + def getToolGroups(self): """ Public method to retrieve the tool groups. - + @return a list of lists containing the group name and the tool group entries """ return self.toolGroups[:], self.currentGroup - + def __swap(self, itm1, itm2): """ Private method used two swap two list entries given by their index. - + @param itm1 index of first entry (int) @param itm2 index of second entry (int) """