Preferences/ConfigurationPages/EditorStylesPage.py

changeset 729
090203934c19
parent 564
b3d966393ba9
child 791
9ec2ac20e54e
--- a/Preferences/ConfigurationPages/EditorStylesPage.py	Thu Nov 18 20:53:30 2010 +0100
+++ b/Preferences/ConfigurationPages/EditorStylesPage.py	Fri Nov 19 08:52:51 2010 +0100
@@ -8,6 +8,7 @@
 """
 
 from PyQt4.QtCore import pyqtSlot
+from PyQt4.QtGui import QColor, QPalette, QColorDialog
 from PyQt4.Qsci import QsciScintilla
 
 from QScintilla.QsciScintillaCompat import QsciScintillaCompat
@@ -115,6 +116,15 @@
             self.initColour("FoldMarkersBackground", self.foldmarkersBackgroundButton, 
                 Preferences.getEditorColour)
         
+        self.editorColours["AnnotationsWarningForeground"] = \
+            QColor(Preferences.getEditorColour("AnnotationsWarningForeground"))
+        self.editorColours["AnnotationsWarningBackground"] = \
+            QColor(Preferences.getEditorColour("AnnotationsWarningBackground"))
+        self.editorColours["AnnotationsErrorForeground"] = \
+            QColor(Preferences.getEditorColour("AnnotationsErrorForeground"))
+        self.editorColours["AnnotationsErrorBackground"] = \
+            QColor(Preferences.getEditorColour("AnnotationsErrorBackground"))
+        
         self.eolCheckBox.setChecked(Preferences.getEditor("ShowEOL"))
         self.wrapLongLinesCheckBox.setChecked(
             Preferences.getEditor("WrapLongLines"))
@@ -150,6 +160,9 @@
         self.miniMenuCheckBox.setChecked(
             Preferences.getEditor("MiniContextMenu"))
         
+        self.enableAnnotationsCheckBox.setChecked(
+            Preferences.getEditor("AnnotationsEnabled"))
+        
     def save(self):
         """
         Public slot to save the Editor Styles configuration.
@@ -203,6 +216,9 @@
         Preferences.setEditor("MiniContextMenu",
             self.miniMenuCheckBox.isChecked())
         
+        Preferences.setEditor("AnnotationsEnabled", 
+            self.enableAnnotationsCheckBox.isChecked())
+        
         for key in list(self.editorColours.keys()):
             Preferences.setEditorColour(key, self.editorColours[key])
         
@@ -378,6 +394,70 @@
         self.marginsFontSample.setFont(self.marginsFont)
         self.defaultFontSample.setFont(self.defaultFont)
         self.monospacedFontSample.setFont(self.monospacedFont)
+        
+        pl = self.annotationsWarningSample.palette()
+        pl.setColor(QPalette.Text, self.editorColours["AnnotationsWarningForeground"])
+        pl.setColor(QPalette.Base, self.editorColours["AnnotationsWarningBackground"])
+        self.annotationsWarningSample.setPalette(pl)
+        self.annotationsWarningSample.repaint()
+        
+        pl = self.annotationsErrorSample.palette()
+        pl.setColor(QPalette.Text, self.editorColours["AnnotationsErrorForeground"])
+        pl.setColor(QPalette.Base, self.editorColours["AnnotationsErrorBackground"])
+        self.annotationsErrorSample.setPalette(pl)
+        self.annotationsErrorSample.repaint()
+    
+    @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():
+            pl = self.annotationsWarningSample.palette()
+            pl.setColor(QPalette.Text, colour)
+            self.annotationsWarningSample.setPalette(pl)
+            self.annotationsWarningSample.repaint()
+            self.editorColours["AnnotationsWarningForeground"] = colour
+    
+    @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():
+            pl = self.annotationsWarningSample.palette()
+            pl.setColor(QPalette.Base, colour)
+            self.annotationsWarningSample.setPalette(pl)
+            self.annotationsWarningSample.repaint()
+            self.editorColours["AnnotationsWarningBackground"] = colour
+    
+    @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():
+            pl = self.annotationsErrorSample.palette()
+            pl.setColor(QPalette.Text, colour)
+            self.annotationsErrorSample.setPalette(pl)
+            self.annotationsErrorSample.repaint()
+            self.editorColours["AnnotationsErrorForeground"] = colour
+    
+    @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():
+            pl = self.annotationsErrorSample.palette()
+            pl.setColor(QPalette.Base, colour)
+            self.annotationsErrorSample.setPalette(pl)
+            self.annotationsErrorSample.repaint()
+            self.editorColours["AnnotationsErrorBackground"] = colour
 
 def create(dlg):
     """
@@ -386,4 +466,4 @@
     @param dlg reference to the configuration dialog
     """
     page = EditorStylesPage()
-    return page
\ No newline at end of file
+    return page

eric ide

mercurial