Added capability to configure the alpha channel for some colors (as of QScintilla 2.5).

Thu, 10 Mar 2011 19:07:05 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 10 Mar 2011 19:07:05 +0100
changeset 942
1d2a6b8509c6
parent 940
0f5461fe69d4
child 943
1246bd8280a6

Added capability to configure the alpha channel for some colors (as of QScintilla 2.5).

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Preferences.ConfigurationPages.ConfigurationPageBase.html file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/ConfigurationPageBase.py file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/EditorSearchPage.py file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/EditorSpellCheckingPage.py file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/EditorStylesPage.py file | annotate | diff | comparison | revisions
Preferences/__init__.py file | annotate | diff | comparison | revisions
QScintilla/QsciScintillaCompat.py file | annotate | diff | comparison | revisions
changelog file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Thu Mar 10 17:40:11 2011 +0100
+++ b/APIs/Python3/eric5.api	Thu Mar 10 19:07:05 2011 +0100
@@ -4071,7 +4071,7 @@
 eric5.Preferences.ConfigurationPages.ConfigurationPageBase.ConfigurationPageBase.initColour?4(colourstr, button, prefMethod)
 eric5.Preferences.ConfigurationPages.ConfigurationPageBase.ConfigurationPageBase.polishPage?4()
 eric5.Preferences.ConfigurationPages.ConfigurationPageBase.ConfigurationPageBase.saveState?4()
-eric5.Preferences.ConfigurationPages.ConfigurationPageBase.ConfigurationPageBase.selectColour?4(button, colourVar)
+eric5.Preferences.ConfigurationPages.ConfigurationPageBase.ConfigurationPageBase.selectColour?4(button, colourVar, showAlpha = False)
 eric5.Preferences.ConfigurationPages.ConfigurationPageBase.ConfigurationPageBase.selectFont?4(fontSample, fontVar, showFontInfo = False)
 eric5.Preferences.ConfigurationPages.ConfigurationPageBase.ConfigurationPageBase.setState?4(state)
 eric5.Preferences.ConfigurationPages.ConfigurationPageBase.ConfigurationPageBase?1()
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Source/eric5.Preferences.ConfigurationPages.ConfigurationPageBase.html	Thu Mar 10 17:40:11 2011 +0100
+++ b/Documentation/Source/eric5.Preferences.ConfigurationPages.ConfigurationPageBase.html	Thu Mar 10 19:07:05 2011 +0100
@@ -114,7 +114,7 @@
         Public method to save the current state of the widget.
 </p><a NAME="ConfigurationPageBase.selectColour" ID="ConfigurationPageBase.selectColour"></a>
 <h4>ConfigurationPageBase.selectColour</h4>
-<b>selectColour</b>(<i>button, colourVar</i>)
+<b>selectColour</b>(<i>button, colourVar, showAlpha = False</i>)
 <p>
         Public method used by the colour selection buttons.
 </p><dl>
@@ -124,6 +124,10 @@
 </dd><dt><i>colourVar</i></dt>
 <dd>
 reference to the variable containing the colour (QColor)
+</dd><dt><i>showAlpha</i></dt>
+<dd>
+flag indicating to show a selection for the alpha
+            channel (boolean)
 </dd>
 </dl><dl>
 <dt>Returns:</dt>
--- a/Preferences/ConfigurationPages/ConfigurationPageBase.py	Thu Mar 10 17:40:11 2011 +0100
+++ b/Preferences/ConfigurationPages/ConfigurationPageBase.py	Thu Mar 10 19:07:05 2011 +0100
@@ -56,15 +56,21 @@
         button.setIcon(QIcon(pm))
         return colour
         
-    def selectColour(self, button, colourVar):
+    def selectColour(self, button, colourVar, showAlpha = False):
         """
         Public method used by the colour selection buttons.
         
         @param button reference to a button to show the colour on (QPushButton)
         @param colourVar reference to the variable containing the colour (QColor)
+        @param showAlpha flag indicating to show a selection for the alpha
+            channel (boolean)
         @return selected colour (QColor)
         """
-        colour = QColorDialog.getColor(colourVar)
+        if showAlpha:
+            colour = QColorDialog.getColor(colourVar, None, "", 
+                QColorDialog.ShowAlphaChannel)
+        else:
+            colour = QColorDialog.getColor(colourVar)
         if colour.isValid():
             size = button.iconSize()
             pm = QPixmap(size.width(), size.height())
--- a/Preferences/ConfigurationPages/EditorSearchPage.py	Thu Mar 10 17:40:11 2011 +0100
+++ b/Preferences/ConfigurationPages/EditorSearchPage.py	Thu Mar 10 19:07:05 2011 +0100
@@ -67,7 +67,7 @@
         """
         self.editorColours["SearchMarkers"] = \
             self.selectColour(self.searchMarkerButton, 
-                self.editorColours["SearchMarkers"])
+                self.editorColours["SearchMarkers"], True)
 
 def create(dlg):
     """
@@ -76,4 +76,4 @@
     @param dlg reference to the configuration dialog
     """
     page = EditorSearchPage()
-    return page
\ No newline at end of file
+    return page
--- a/Preferences/ConfigurationPages/EditorSpellCheckingPage.py	Thu Mar 10 17:40:11 2011 +0100
+++ b/Preferences/ConfigurationPages/EditorSpellCheckingPage.py	Thu Mar 10 19:07:05 2011 +0100
@@ -103,7 +103,7 @@
         """
         self.editorColours["SpellingMarkers"] = \
             self.selectColour(self.spellingMarkerButton, 
-                self.editorColours["SpellingMarkers"])
+                self.editorColours["SpellingMarkers"], True)
     
     @pyqtSlot()
     def on_pwlButton_clicked(self):
--- a/Preferences/ConfigurationPages/EditorStylesPage.py	Thu Mar 10 17:40:11 2011 +0100
+++ b/Preferences/ConfigurationPages/EditorStylesPage.py	Thu Mar 10 19:07:05 2011 +0100
@@ -276,7 +276,7 @@
         """
         self.editorColours["CaretLineBackground"] = \
             self.selectColour(self.caretlineBackgroundButton, 
-                self.editorColours["CaretLineBackground"])
+                self.editorColours["CaretLineBackground"], True)
         
     @pyqtSlot()
     def on_selectionForegroundButton_clicked(self):
@@ -294,7 +294,7 @@
         """
         self.editorColours["SelectionBackground"] = \
             self.selectColour(self.selectionBackgroundButton, 
-                self.editorColours["SelectionBackground"])
+                self.editorColours["SelectionBackground"], True)
         
     @pyqtSlot()
     def on_currentLineMarkerButton_clicked(self):
@@ -303,7 +303,7 @@
         """
         self.editorColours["CurrentMarker"] = \
             self.selectColour(self.currentLineMarkerButton, 
-                self.editorColours["CurrentMarker"])
+                self.editorColours["CurrentMarker"], True)
         
     @pyqtSlot()
     def on_errorMarkerButton_clicked(self):
@@ -312,7 +312,7 @@
         """
         self.editorColours["ErrorMarker"] = \
             self.selectColour(self.errorMarkerButton, 
-                self.editorColours["ErrorMarker"])
+                self.editorColours["ErrorMarker"], True)
         
     @pyqtSlot()
     def on_marginsForegroundButton_clicked(self):
--- a/Preferences/__init__.py	Thu Mar 10 17:40:11 2011 +0100
+++ b/Preferences/__init__.py	Thu Mar 10 19:07:05 2011 +0100
@@ -1332,7 +1332,11 @@
     """
     col = prefClass.settings.value("Editor/Colour/" + key)
     if col is not None:
-        return QtGui.QColor(col)
+        if len(col) == 9:
+            # color string with alpha
+            return QtGui.QColor.fromRgba(int(col[1:],16))
+        else:
+            return QtGui.QColor(col)
     else:
         return prefClass.editorColourDefaults[key]
     
@@ -1344,7 +1348,11 @@
     @param value the colour to be set
     @param prefClass preferences class used as the storage area
     """
-    prefClass.settings.setValue("Editor/Colour/" + key, value.name())
+    if value.alpha() < 255:
+        val = "#{0:8x}".format(value.rgba())
+    else:
+        val = value.name()
+    prefClass.settings.setValue("Editor/Colour/" + key, val)
     
 def getEditorOtherFonts(key, prefClass = Prefs):
     """
--- a/QScintilla/QsciScintillaCompat.py	Thu Mar 10 17:40:11 2011 +0100
+++ b/QScintilla/QsciScintillaCompat.py	Thu Mar 10 19:07:05 2011 +0100
@@ -752,6 +752,11 @@
         
         self.SendScintilla(QsciScintilla.SCI_INDICSETSTYLE, indicator, style)
         self.SendScintilla(QsciScintilla.SCI_INDICSETFORE, indicator, color)
+        try:
+            self.SendScintilla(QsciScintilla.SCI_INDICSETALPHA, indicator,
+                               color.alpha())
+        except AttributeError:
+            pass
     
     def setCurrentIndicator(self, indicator):
         """
--- a/changelog	Thu Mar 10 17:40:11 2011 +0100
+++ b/changelog	Thu Mar 10 19:07:05 2011 +0100
@@ -11,6 +11,8 @@
 - extended the Mercurial log browser to indicate closed branches
 - changed the configuration dialog to remember the last show page name
 - added configuration options for visible whitespace (as of QScintilla 2.5)
+- added capability to configure the alpha channel for some colors
+  (as of QScintilla 2.5)
 
 Version 5.1-snapshot-20110123:
 - bug fixes

eric ide

mercurial