--- a/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Mon Mar 18 19:07:10 2019 +0100 +++ b/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Mon Mar 18 19:15:57 2019 +0100 @@ -54,6 +54,7 @@ self.setupUi(self) self.setObjectName("EditorHighlightingStylesPage") + self.defaultSubstylesButton.setIcon(UI.PixmapCache.getIcon("editUndo")) self.addSubstyleButton.setIcon(UI.PixmapCache.getIcon("plus")) self.deleteSubstyleButton.setIcon(UI.PixmapCache.getIcon("minus")) self.editSubstyleButton.setIcon(UI.PixmapCache.getIcon("edit")) @@ -239,6 +240,8 @@ self.eolfillCheckBox.setChecked(eolfill) selectedOne = len(self.styleElementList.selectedItems()) == 1 + self.defaultSubstylesButton.setEnabled( + selectedOne and substyle < 0 and self.lexer.isBaseStyle(style)) self.addSubstyleButton.setEnabled( selectedOne and substyle < 0 and self.lexer.isBaseStyle(style)) self.deleteSubstyleButton.setEnabled(selectedOne and substyle >= 0) @@ -742,6 +745,35 @@ itm.setData(0, self.StyleRole, style) itm.setData(0, self.SubstyleRole, newSubstyle) self.__styleOneItem(itm, style, newSubstyle) + + @pyqtSlot() + def on_defaultSubstylesButton_clicked(self): + """ + Private slot to reset all substyles to default values. + """ + style, substyle = self.__currentStyles() + ok = E5MessageBox.yesNo( + self, + self.tr("Reset Sub-Styles to Default"), + self.tr("<p>Do you really want to reset all defined sub-styles of" + " <b>{0}</b> to the default values?</p>""").format( + self.lexer.description(style, substyle))) + if ok: + # 1. reset sub-styles + self.lexer.loadDefaultSubStyles(style) + + # 2. delete all existing sub-style items + parent = self.styleElementList.currentItem() + while parent.childCount() > 0: + itm = parent.takeChild(0) # __IGNORE_WARNING__ + del itm + + # 3. create the new list of sub-style items + for description, _, substyle in self.lexer.getSubStyles(style): + itm = QTreeWidgetItem(parent, [description]) + itm.setData(0, self.StyleRole, style) + itm.setData(0, self.SubstyleRole, substyle) + self.__styleOneItem(itm, style, substyle) def create(dlg):