eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py

changeset 7455
9d0852f0bb2c
parent 7454
a4392387052c
child 7489
6543bcd150fd
diff -r a4392387052c -r 9d0852f0bb2c eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Wed Mar 11 19:29:33 2020 +0100
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Sat Mar 14 11:11:51 2020 +0100
@@ -13,7 +13,8 @@
 
 from PyQt5.QtCore import pyqtSlot, Qt, QDate, QRegExp, QSize, QPoint, QFileInfo
 from PyQt5.QtGui import (
-    QCursor, QColor, QPixmap, QPainter, QPen, QBrush, QIcon, QTextCursor
+    QCursor, QColor, QPixmap, QPainter, QPen, QBrush, QIcon, QTextCursor,
+    QPalette
 )
 from PyQt5.QtWidgets import (
     QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication,
@@ -36,7 +37,11 @@
               "cyan", "olive", "magenta", "darkred", "darkmagenta",
               "darkcyan", "gray", "yellow"]
 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 HgLogBrowserDialog(QWidget, Ui_HgLogBrowserDialog):
@@ -222,6 +227,9 @@
         self.__logTreeNormalFont.setBold(False)
         self.__logTreeBoldFont = self.logTree.font()
         self.__logTreeBoldFont.setBold(True)
+        self.__logTreeHasDarkBackground = (
+            self.logTree.palette().color(QPalette.Window).lightness() < 128
+        )
         
         self.detailsEdit.anchorClicked.connect(self.__revisionClicked)
         
@@ -522,10 +530,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 __branchColor(self, branchName):
         """
@@ -623,6 +636,8 @@
             """
             return int(1.2 * radius) * col + radius // 2 + 3
         
+        textColor = self.logTree.palette().color(QPalette.Text)
+        
         radius = self.__dotRadius
         w = len(bottomedges) * radius + 20
         h = self.__rowHeight
@@ -631,25 +646,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)
@@ -657,13 +663,13 @@
                     painter.drawLine(x1, dot_y + y1, x2, dot_y + y2)
         
         penradius = 1
-        pencolor = Qt.black
+        pencolor = textColor
         
         dot_y = (h // 2) - radius // 2
         
-        # draw a dot for the revision
+        # draw an indicator for the revision
         if currentRev:
-            # enlarge dot for the current revision
+            # enlarge for the current revision
             delta = 1
             radius += 2 * delta
             dot_y -= delta

eric ide

mercurial