52 """ |
52 """ |
53 super(EditorHighlightingStylesPage, self).__init__() |
53 super(EditorHighlightingStylesPage, self).__init__() |
54 self.setupUi(self) |
54 self.setupUi(self) |
55 self.setObjectName("EditorHighlightingStylesPage") |
55 self.setObjectName("EditorHighlightingStylesPage") |
56 |
56 |
|
57 self.defaultSubstylesButton.setIcon(UI.PixmapCache.getIcon("editUndo")) |
57 self.addSubstyleButton.setIcon(UI.PixmapCache.getIcon("plus")) |
58 self.addSubstyleButton.setIcon(UI.PixmapCache.getIcon("plus")) |
58 self.deleteSubstyleButton.setIcon(UI.PixmapCache.getIcon("minus")) |
59 self.deleteSubstyleButton.setIcon(UI.PixmapCache.getIcon("minus")) |
59 self.editSubstyleButton.setIcon(UI.PixmapCache.getIcon("edit")) |
60 self.editSubstyleButton.setIcon(UI.PixmapCache.getIcon("edit")) |
60 self.copySubstyleButton.setIcon(UI.PixmapCache.getIcon("editCopy")) |
61 self.copySubstyleButton.setIcon(UI.PixmapCache.getIcon("editCopy")) |
61 |
62 |
237 self.sampleText.setPalette(pl) |
238 self.sampleText.setPalette(pl) |
238 self.sampleText.repaint() |
239 self.sampleText.repaint() |
239 self.eolfillCheckBox.setChecked(eolfill) |
240 self.eolfillCheckBox.setChecked(eolfill) |
240 |
241 |
241 selectedOne = len(self.styleElementList.selectedItems()) == 1 |
242 selectedOne = len(self.styleElementList.selectedItems()) == 1 |
|
243 self.defaultSubstylesButton.setEnabled( |
|
244 selectedOne and substyle < 0 and self.lexer.isBaseStyle(style)) |
242 self.addSubstyleButton.setEnabled( |
245 self.addSubstyleButton.setEnabled( |
243 selectedOne and substyle < 0 and self.lexer.isBaseStyle(style)) |
246 selectedOne and substyle < 0 and self.lexer.isBaseStyle(style)) |
244 self.deleteSubstyleButton.setEnabled(selectedOne and substyle >= 0) |
247 self.deleteSubstyleButton.setEnabled(selectedOne and substyle >= 0) |
245 self.editSubstyleButton.setEnabled(selectedOne and substyle >= 0) |
248 self.editSubstyleButton.setEnabled(selectedOne and substyle >= 0) |
246 self.copySubstyleButton.setEnabled(selectedOne and substyle >= 0) |
249 self.copySubstyleButton.setEnabled(selectedOne and substyle >= 0) |
740 parent.setExpanded(True) |
743 parent.setExpanded(True) |
741 itm = QTreeWidgetItem(parent, [description]) |
744 itm = QTreeWidgetItem(parent, [description]) |
742 itm.setData(0, self.StyleRole, style) |
745 itm.setData(0, self.StyleRole, style) |
743 itm.setData(0, self.SubstyleRole, newSubstyle) |
746 itm.setData(0, self.SubstyleRole, newSubstyle) |
744 self.__styleOneItem(itm, style, newSubstyle) |
747 self.__styleOneItem(itm, style, newSubstyle) |
|
748 |
|
749 @pyqtSlot() |
|
750 def on_defaultSubstylesButton_clicked(self): |
|
751 """ |
|
752 Private slot to reset all substyles to default values. |
|
753 """ |
|
754 style, substyle = self.__currentStyles() |
|
755 ok = E5MessageBox.yesNo( |
|
756 self, |
|
757 self.tr("Reset Sub-Styles to Default"), |
|
758 self.tr("<p>Do you really want to reset all defined sub-styles of" |
|
759 " <b>{0}</b> to the default values?</p>""").format( |
|
760 self.lexer.description(style, substyle))) |
|
761 if ok: |
|
762 # 1. reset sub-styles |
|
763 self.lexer.loadDefaultSubStyles(style) |
|
764 |
|
765 # 2. delete all existing sub-style items |
|
766 parent = self.styleElementList.currentItem() |
|
767 while parent.childCount() > 0: |
|
768 itm = parent.takeChild(0) # __IGNORE_WARNING__ |
|
769 del itm |
|
770 |
|
771 # 3. create the new list of sub-style items |
|
772 for description, _, substyle in self.lexer.getSubStyles(style): |
|
773 itm = QTreeWidgetItem(parent, [description]) |
|
774 itm.setData(0, self.StyleRole, style) |
|
775 itm.setData(0, self.SubstyleRole, substyle) |
|
776 self.__styleOneItem(itm, style, substyle) |
745 |
777 |
746 |
778 |
747 def create(dlg): |
779 def create(dlg): |
748 """ |
780 """ |
749 Module function to create the configuration page. |
781 Module function to create the configuration page. |