diff -r 27f636beebad -r 2c730d5fd177 eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py --- a/eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Mon Mar 01 17:48:43 2021 +0100 +++ b/eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Tue Mar 02 17:17:09 2021 +0100 @@ -24,7 +24,7 @@ import UI.PixmapCache try: - MonospacedFontsOption = QFontDialog.MonospacedFonts + MonospacedFontsOption = QFontDialog.FontDialogOption.MonospacedFonts except AttributeError: MonospacedFontsOption = QFontDialog.FontDialogOptions(0x10) NoFontsOption = QFontDialog.FontDialogOptions(0) @@ -40,8 +40,8 @@ FAMILYANDSIZE = 2 FONT = 99 - StyleRole = Qt.UserRole + 1 - SubstyleRole = Qt.UserRole + 2 + StyleRole = Qt.ItemDataRole.UserRole + 1 + SubstyleRole = Qt.ItemDataRole.UserRole + 2 def __init__(self, lexers): """ @@ -130,7 +130,8 @@ for description, styleNo, subStyleNo in self.lexer.getStyles(): if subStyleNo >= 0: parent = self.styleElementList.findItems( - self.lexer.description(styleNo), Qt.MatchExactly)[0] + self.lexer.description(styleNo), + Qt.MatchFlag.MatchExactly)[0] parent.setExpanded(True) else: parent = self.styleElementList @@ -190,9 +191,9 @@ item.setBackground(0, paper) item.setForeground(0, colour) if eolfill: - item.setCheckState(0, Qt.Checked) + item.setCheckState(0, Qt.CheckState.Checked) else: - item.setCheckState(0, Qt.Unchecked) + item.setCheckState(0, Qt.CheckState.Unchecked) def __styleAllItems(self): """ @@ -225,8 +226,8 @@ self.sampleText.setFont(font) pl = self.sampleText.palette() - pl.setColor(QPalette.Text, colour) - pl.setColor(QPalette.Base, paper) + pl.setColor(QPalette.ColorRole.Text, colour) + pl.setColor(QPalette.ColorRole.Base, paper) self.sampleText.setPalette(pl) self.sampleText.repaint() self.eolfillCheckBox.setChecked(eolfill) @@ -250,7 +251,7 @@ colour = QColorDialog.getColor(self.lexer.color(style, substyle)) if colour.isValid(): pl = self.sampleText.palette() - pl.setColor(QPalette.Text, colour) + pl.setColor(QPalette.ColorRole.Text, colour) self.sampleText.setPalette(pl) self.sampleText.repaint() for selItem in self.styleElementList.selectedItems(): @@ -268,7 +269,7 @@ colour = QColorDialog.getColor(self.lexer.paper(style, substyle)) if colour.isValid(): pl = self.sampleText.palette() - pl.setColor(QPalette.Base, colour) + pl.setColor(QPalette.ColorRole.Base, colour) self.sampleText.setPalette(pl) self.sampleText.repaint() for selItem in self.styleElementList.selectedItems(): @@ -286,7 +287,7 @@ colour = QColorDialog.getColor(self.lexer.paper(style, substyle)) if colour.isValid(): pl = self.sampleText.palette() - pl.setColor(QPalette.Base, colour) + pl.setColor(QPalette.ColorRole.Base, colour) self.sampleText.setPalette(pl) self.sampleText.repaint() @@ -409,7 +410,7 @@ @param on flag indicating enabled or disabled state (boolean) """ style, substyle = self.__currentStyles() - checkState = Qt.Checked if on else Qt.Unchecked + checkState = Qt.CheckState.Checked if on else Qt.CheckState.Unchecked for selItem in self.styleElementList.selectedItems(): style, substyle = self.__stylesForItem(selItem) self.lexer.setEolFill(on, style, substyle) @@ -537,7 +538,7 @@ EditorHighlightingStylesSelectionDialog) dlg = EditorHighlightingStylesSelectionDialog( lexerNames, forImport=False, preselect=preselect) - if dlg.exec() == QDialog.Accepted: + if dlg.exec() == QDialog.DialogCode.Accepted: lexerNames = dlg.getLexerNames() else: # Cancelled by user @@ -581,7 +582,7 @@ highlightingStylesFile.writeFile(fn, lexers) else: f = QFile(fn) - if f.open(QIODevice.WriteOnly): + if f.open(QIODevice.OpenModeFlag.WriteOnly): from E5XML.HighlightingStylesWriter import ( HighlightingStylesWriter ) @@ -629,7 +630,7 @@ else: # old XML based file f = QFile(fn) - if f.open(QIODevice.ReadOnly): + if f.open(QIODevice.OpenModeFlag.ReadOnly): from E5XML.HighlightingStylesReader import ( HighlightingStylesReader ) @@ -672,7 +673,7 @@ EditorHighlightingStylesSelectionDialog) dlg = EditorHighlightingStylesSelectionDialog( lexerNames, forImport=True) - if dlg.exec() == QDialog.Accepted: + if dlg.exec() == QDialog.DialogCode.Accepted: lexerNames = dlg.getLexerNames() else: # Cancelled by user @@ -760,14 +761,14 @@ style, substyle = self.__currentStyles() dlg = SubstyleDefinitionDialog( self.lexer, style, substyle, parent=self) - if dlg.exec() == QDialog.Accepted: + if dlg.exec() == QDialog.DialogCode.Accepted: description, words = dlg.getData() substyle = self.lexer.addSubstyle(style) self.lexer.setDescription(description, style, substyle) self.lexer.setWords(words, style, substyle) parent = self.styleElementList.findItems( - self.lexer.description(style), Qt.MatchExactly)[0] + self.lexer.description(style), Qt.MatchFlag.MatchExactly)[0] parent.setExpanded(True) itm = QTreeWidgetItem(parent, [description]) itm.setData(0, self.StyleRole, style) @@ -804,7 +805,7 @@ style, substyle = self.__currentStyles() dlg = SubstyleDefinitionDialog( self.lexer, style, substyle, parent=self) - if dlg.exec() == QDialog.Accepted: + if dlg.exec() == QDialog.DialogCode.Accepted: description, words = dlg.getData() self.lexer.setDescription(description, style, substyle) self.lexer.setWords(words, style, substyle) @@ -835,7 +836,7 @@ style, newSubstyle) parent = self.styleElementList.findItems( - self.lexer.description(style), Qt.MatchExactly)[0] + self.lexer.description(style), Qt.MatchFlag.MatchExactly)[0] parent.setExpanded(True) itm = QTreeWidgetItem(parent, [description]) itm.setData(0, self.StyleRole, style)