eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py

changeset 7455
9d0852f0bb2c
parent 7454
a4392387052c
child 7489
6543bcd150fd
diff -r a4392387052c -r 9d0852f0bb2c eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py
--- a/eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py	Wed Mar 11 19:29:33 2020 +0100
+++ b/eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py	Sat Mar 14 11:11:51 2020 +0100
@@ -15,7 +15,7 @@
     pyqtSlot, Qt, QDate, QProcess, QTimer, QRegExp, QSize, QPoint, QFileInfo
 )
 from PyQt5.QtGui import (
-    QCursor, QColor, QPixmap, QPainter, QPen, QIcon, QTextCursor
+    QCursor, QColor, QPixmap, QPainter, QPen, QIcon, QTextCursor, QPalette
 )
 from PyQt5.QtWidgets import (
     QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication,
@@ -40,7 +40,11 @@
               "gray", "yellow", "darkred", "darkgreen", "darkblue",
               "darkcyan", "darkmagenta", "blue"]
 COLORS = [str(QColor(x).name()) for x in COLORNAMES]
-# TODO: make colors configurable
+
+LIGHTCOLORS = ["#aaaaff", "#7faa7f", "#ffaaaa", "#aaffaa", "#7f7faa",
+               "#ffaaff", "#aaffff", "#d5d579", "#ffaaff", "#d57979",
+               "#d579d5", "#79d5d5", "#d5d5d5", "#d5d500",
+               ]
 
 
 class GitLogBrowserDialog(QWidget, Ui_GitLogBrowserDialog):
@@ -109,6 +113,9 @@
         self.__logTreeNormalFont.setBold(False)
         self.__logTreeBoldFont = self.logTree.font()
         self.__logTreeBoldFont.setBold(True)
+        self.__logTreeHasDarkBackground = (
+            self.logTree.palette().color(QPalette.Window).lightness() < 128
+        )
         
         font = Preferences.getEditorOtherFonts("MonospacedFont")
         self.diffEdit.setFontFamily(font.family())
@@ -470,10 +477,15 @@
         """
         Private method to get the (rotating) name of the color given an index.
         
-        @param n color index (integer)
-        @return color name (string)
+        @param n color index
+        @type int
+        @return color name
+        @type str
         """
-        return COLORS[n % len(COLORS)]
+        if self.__logTreeHasDarkBackground:
+            return LIGHTCOLORS[n % len(LIGHTCOLORS)]
+        else:
+            return COLORS[n % len(COLORS)]
     
     def __generateEdges(self, commitId, parents):
         """
@@ -559,25 +571,16 @@
         dot_y = h // 2
         
         pix = QPixmap(w, h)
-        pix.fill(QColor(0, 0, 0, 0))
+        pix.fill(QColor(0, 0, 0, 0))        # draw transparent background
         painter = QPainter(pix)
         painter.setRenderHint(QPainter.Antialiasing)
         
-        pen = QPen(Qt.blue)
-        pen.setWidth(2)
-        painter.setPen(pen)
-        
-        lpen = QPen(pen)
-        lpen.setColor(Qt.black)
-        painter.setPen(lpen)
-        
         # draw the revision history lines
         for y1, y2, lines in ((0, h, bottomedges),
                               (-h, 0, topedges)):
             if lines:
                 for start, end, ecolor in lines:
-                    lpen = QPen(pen)
-                    lpen.setColor(QColor(self.__getColor(ecolor)))
+                    lpen = QPen(QColor(self.__getColor(ecolor)))
                     lpen.setWidth(2)
                     painter.setPen(lpen)
                     x1 = col2x(start, radius)
@@ -585,7 +588,7 @@
                     painter.drawLine(x1, dot_y + y1, x2, dot_y + y2)
         
         penradius = 1
-        pencolor = Qt.black
+        pencolor = self.logTree.palette().color(QPalette.Text)
         
         dot_y = (h // 2) - radius // 2
         

eric ide

mercurial