diff -r e26fa3b06f4f -r e6e270b705c2 src/eric7/Preferences/ConfigurationPages/EditorStylesPage.py --- a/src/eric7/Preferences/ConfigurationPages/EditorStylesPage.py Thu Nov 02 16:43:22 2023 +0100 +++ b/src/eric7/Preferences/ConfigurationPages/EditorStylesPage.py Fri Nov 03 19:36:14 2023 +0100 @@ -204,6 +204,12 @@ self.editorColours["AnnotationsStyleBackground"] = QColor( Preferences.getEditorColour("AnnotationsStyleBackground") ) + self.editorColours["AnnotationsInfoForeground"] = QColor( + Preferences.getEditorColour("AnnotationsInfoForeground") + ) + self.editorColours["AnnotationsInfoBackground"] = QColor( + Preferences.getEditorColour("AnnotationsInfoBackground") + ) self.eolCheckBox.setChecked(Preferences.getEditor("ShowEOL")) self.wrapModeComboBox.setCurrentIndex( @@ -496,8 +502,8 @@ Preferences.setEditor("ShowMarkerSearch", self.searchMarkerCheckBox.isChecked()) self.saveColours(Preferences.setEditorColour) - for key in list(self.editorColours.keys()): - Preferences.setEditorColour(key, self.editorColours[key]) + for color in self.editorColours: + Preferences.setEditorColour(color, self.editorColours[color]) @pyqtSlot() def on_linenumbersFontButton_clicked(self): @@ -573,93 +579,96 @@ self.editorColours["AnnotationsStyleBackground"], ) + self.__setSampleStyleSheet( + self.annotationsInformationSample, + self.editorColours["AnnotationsInfoForeground"], + self.editorColours["AnnotationsInfoBackground"], + ) + + def __selectAnnotationColor(self, annotationType, isBackground, annotationSample): + """ + Private method to select an annotation color and update the sample. + + @param annotationType type of the annotation + @type str + @param isBackground flag indicating the background color + @type bool + @param annotationSample reference to the annotation sample widget + @type QLineEdit + """ + bgColorStr = f"Annotations{annotationType}Background" + fgColorStr =f"Annotations{annotationType}Foreground" + + color = QColorDialog.getColor( + self.editorColours[bgColorStr] + if isBackground + else self.editorColours[fgColorStr] + ) + if color.isValid(): + self.__setSampleStyleSheet( + annotationSample, + self.editorColours[fgColorStr] if isBackground else color, + color if isBackground else self.editorColours[bgColorStr], + ) + self.editorColours[ + bgColorStr if isBackground else fgColorStr + ] = color + @pyqtSlot() def on_annotationsWarningFgButton_clicked(self): """ Private slot to set the foreground colour of the warning annotations. """ - colour = QColorDialog.getColor( - self.editorColours["AnnotationsWarningForeground"] - ) - if colour.isValid(): - self.__setSampleStyleSheet( - self.annotationsWarningSample, - colour, - self.editorColours["AnnotationsWarningBackground"], - ) - self.editorColours["AnnotationsWarningForeground"] = colour + self.__selectAnnotationColor("Warning", False, self.annotationsWarningSample) @pyqtSlot() def on_annotationsWarningBgButton_clicked(self): """ Private slot to set the background colour of the warning annotations. """ - colour = QColorDialog.getColor( - self.editorColours["AnnotationsWarningBackground"] - ) - if colour.isValid(): - self.__setSampleStyleSheet( - self.annotationsWarningSample, - self.editorColours["AnnotationsWarningForeground"], - colour, - ) - self.editorColours["AnnotationsWarningBackground"] = colour + self.__selectAnnotationColor("Warning", True, self.annotationsWarningSample) @pyqtSlot() def on_annotationsErrorFgButton_clicked(self): """ Private slot to set the foreground colour of the error annotations. """ - colour = QColorDialog.getColor(self.editorColours["AnnotationsErrorForeground"]) - if colour.isValid(): - self.__setSampleStyleSheet( - self.annotationsErrorSample, - colour, - self.editorColours["AnnotationsErrorBackground"], - ) - self.editorColours["AnnotationsErrorForeground"] = colour + self.__selectAnnotationColor("Error", False, self.annotationsErrorSample) @pyqtSlot() def on_annotationsErrorBgButton_clicked(self): """ Private slot to set the background colour of the error annotations. """ - colour = QColorDialog.getColor(self.editorColours["AnnotationsErrorBackground"]) - if colour.isValid(): - self.__setSampleStyleSheet( - self.annotationsErrorSample, - self.editorColours["AnnotationsErrorForeground"], - colour, - ) - self.editorColours["AnnotationsErrorBackground"] = colour + self.__selectAnnotationColor("Error", True, self.annotationsErrorSample) @pyqtSlot() def on_annotationsStyleWarningFgButton_clicked(self): """ Private slot to set the foreground colour of the style annotations. """ - colour = QColorDialog.getColor(self.editorColours["AnnotationsStyleForeground"]) - if colour.isValid(): - self.__setSampleStyleSheet( - self.annotationsStyleWarningSample, - colour, - self.editorColours["AnnotationsStyleBackground"], - ) - self.editorColours["AnnotationsStyleForeground"] = colour + self.__selectAnnotationColor("Style", False, self.annotationsStyleWarningSample) @pyqtSlot() def on_annotationsStyleWarningBgButton_clicked(self): """ Private slot to set the background colour of the style annotations. """ - colour = QColorDialog.getColor(self.editorColours["AnnotationsStyleBackground"]) - if colour.isValid(): - self.__setSampleStyleSheet( - self.annotationsStyleWarningSample, - self.editorColours["AnnotationsStyleForeground"], - colour, - ) - self.editorColours["AnnotationsStyleBackground"] = colour + self.__selectAnnotationColor("Style", True, self.annotationsStyleWarningSample) + + @pyqtSlot() + def on_annotationsInformationFgButton_clicked(self): + """ + Private slot to set the foreground colour of the information annotations. + """ + self.__selectAnnotationColor("Info", False, self.annotationsInformationSample) + + @pyqtSlot() + def on_annotationsInformationBgButton_clicked(self): + """ + Private slot to set the background colour of the information annotations. + """ + self.__selectAnnotationColor("Info", True, self.annotationsInformationSample) def create(dlg): # noqa: U100