--- a/src/eric7/Preferences/ConfigurationPages/EditorHighlightingStylesSelectionDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Preferences/ConfigurationPages/EditorHighlightingStylesSelectionDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -8,12 +8,10 @@ """ from PyQt6.QtCore import pyqtSlot, Qt -from PyQt6.QtWidgets import ( - QDialog, QDialogButtonBox, QListWidgetItem, QAbstractButton -) +from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QListWidgetItem, QAbstractButton from .Ui_EditorHighlightingStylesSelectionDialog import ( - Ui_EditorHighlightingStylesSelectionDialog + Ui_EditorHighlightingStylesSelectionDialog, ) @@ -23,10 +21,11 @@ """ Class implementing a dialog to select the styles to be imported/exported. """ + def __init__(self, lexerNames, forImport, preselect=None, parent=None): """ Constructor - + @param lexerNames list of lexer names to select from @type list of str @param forImport flag indicating a dialog for importing styles @@ -38,33 +37,35 @@ """ super().__init__(parent) self.setupUi(self) - + self.__selectAllButton = self.buttonBox.addButton( - self.tr("Select All"), QDialogButtonBox.ButtonRole.ActionRole) - + self.tr("Select All"), QDialogButtonBox.ButtonRole.ActionRole + ) + if forImport: self.setWindowTitle(self.tr("Import Highlighting Styles")) - self.infoLabel.setText(self.tr( - "Select the highlighting styles to be imported")) + self.infoLabel.setText( + self.tr("Select the highlighting styles to be imported") + ) else: self.setWindowTitle(self.tr("Export Highlighting Styles")) - self.infoLabel.setText(self.tr( - "Select the highlighting styles to be exported")) - + self.infoLabel.setText( + self.tr("Select the highlighting styles to be exported") + ) + if preselect is None: preselect = [] - + for name in lexerNames: itm = QListWidgetItem(name, self.lexersList) - itm.setFlags( - Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsEnabled) + itm.setFlags(Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsEnabled) if name in preselect: itm.setCheckState(Qt.CheckState.Checked) else: itm.setCheckState(Qt.CheckState.Unchecked) - + self.__updateOkButton() - + @pyqtSlot() def __updateOkButton(self): """ @@ -77,24 +78,23 @@ break else: enable = False - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled(enable) - + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable) + @pyqtSlot(QListWidgetItem) def on_lexersList_itemChanged(self, item): """ Private slot to react on changes in check state. - + @param item reference to the changed item @type QListWidgetItem """ self.__updateOkButton() - + @pyqtSlot(QAbstractButton) def on_buttonBox_clicked(self, button): """ Private slot to handle the user pressing a button. - + @param button reference to the button pressed @type QAbstractButton """ @@ -102,11 +102,11 @@ for row in range(self.lexersList.count()): itm = self.lexersList.item(row) itm.setCheckState(Qt.CheckState.Checked) - + def getLexerNames(self): """ Public method to get the selected lexer names. - + @return list of selected lexer names @rtype list of str """ @@ -115,5 +115,5 @@ itm = self.lexersList.item(row) if itm.checkState() == Qt.CheckState.Checked: lexerNames.append(itm.text()) - + return lexerNames