13 |
13 |
14 from PyQt5.QtCore import ( |
14 from PyQt5.QtCore import ( |
15 pyqtSlot, Qt, QDate, QProcess, QTimer, QRegExp, QSize, QPoint, QFileInfo |
15 pyqtSlot, Qt, QDate, QProcess, QTimer, QRegExp, QSize, QPoint, QFileInfo |
16 ) |
16 ) |
17 from PyQt5.QtGui import ( |
17 from PyQt5.QtGui import ( |
18 QCursor, QColor, QPixmap, QPainter, QPen, QIcon, QTextCursor |
18 QCursor, QColor, QPixmap, QPainter, QPen, QIcon, QTextCursor, QPalette |
19 ) |
19 ) |
20 from PyQt5.QtWidgets import ( |
20 from PyQt5.QtWidgets import ( |
21 QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication, |
21 QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication, |
22 QLineEdit, QMenu, QInputDialog |
22 QLineEdit, QMenu, QInputDialog |
23 ) |
23 ) |
38 |
38 |
39 COLORNAMES = ["red", "green", "purple", "cyan", "olive", "magenta", |
39 COLORNAMES = ["red", "green", "purple", "cyan", "olive", "magenta", |
40 "gray", "yellow", "darkred", "darkgreen", "darkblue", |
40 "gray", "yellow", "darkred", "darkgreen", "darkblue", |
41 "darkcyan", "darkmagenta", "blue"] |
41 "darkcyan", "darkmagenta", "blue"] |
42 COLORS = [str(QColor(x).name()) for x in COLORNAMES] |
42 COLORS = [str(QColor(x).name()) for x in COLORNAMES] |
43 # TODO: make colors configurable |
43 |
|
44 LIGHTCOLORS = ["#aaaaff", "#7faa7f", "#ffaaaa", "#aaffaa", "#7f7faa", |
|
45 "#ffaaff", "#aaffff", "#d5d579", "#ffaaff", "#d57979", |
|
46 "#d579d5", "#79d5d5", "#d5d5d5", "#d5d500", |
|
47 ] |
44 |
48 |
45 |
49 |
46 class GitLogBrowserDialog(QWidget, Ui_GitLogBrowserDialog): |
50 class GitLogBrowserDialog(QWidget, Ui_GitLogBrowserDialog): |
47 """ |
51 """ |
48 Class implementing a dialog to browse the log history. |
52 Class implementing a dialog to browse the log history. |
107 |
111 |
108 self.__logTreeNormalFont = self.logTree.font() |
112 self.__logTreeNormalFont = self.logTree.font() |
109 self.__logTreeNormalFont.setBold(False) |
113 self.__logTreeNormalFont.setBold(False) |
110 self.__logTreeBoldFont = self.logTree.font() |
114 self.__logTreeBoldFont = self.logTree.font() |
111 self.__logTreeBoldFont.setBold(True) |
115 self.__logTreeBoldFont.setBold(True) |
|
116 self.__logTreeHasDarkBackground = ( |
|
117 self.logTree.palette().color(QPalette.Window).lightness() < 128 |
|
118 ) |
112 |
119 |
113 font = Preferences.getEditorOtherFonts("MonospacedFont") |
120 font = Preferences.getEditorOtherFonts("MonospacedFont") |
114 self.diffEdit.setFontFamily(font.family()) |
121 self.diffEdit.setFontFamily(font.family()) |
115 self.diffEdit.setFontPointSize(font.pointSize()) |
122 self.diffEdit.setFontPointSize(font.pointSize()) |
116 |
123 |
468 |
475 |
469 def __getColor(self, n): |
476 def __getColor(self, n): |
470 """ |
477 """ |
471 Private method to get the (rotating) name of the color given an index. |
478 Private method to get the (rotating) name of the color given an index. |
472 |
479 |
473 @param n color index (integer) |
480 @param n color index |
474 @return color name (string) |
481 @type int |
475 """ |
482 @return color name |
476 return COLORS[n % len(COLORS)] |
483 @type str |
|
484 """ |
|
485 if self.__logTreeHasDarkBackground: |
|
486 return LIGHTCOLORS[n % len(LIGHTCOLORS)] |
|
487 else: |
|
488 return COLORS[n % len(COLORS)] |
477 |
489 |
478 def __generateEdges(self, commitId, parents): |
490 def __generateEdges(self, commitId, parents): |
479 """ |
491 """ |
480 Private method to generate edge info for the give data. |
492 Private method to generate edge info for the give data. |
481 |
493 |
557 |
569 |
558 dot_x = col2x(column, radius) - radius // 2 |
570 dot_x = col2x(column, radius) - radius // 2 |
559 dot_y = h // 2 |
571 dot_y = h // 2 |
560 |
572 |
561 pix = QPixmap(w, h) |
573 pix = QPixmap(w, h) |
562 pix.fill(QColor(0, 0, 0, 0)) |
574 pix.fill(QColor(0, 0, 0, 0)) # draw transparent background |
563 painter = QPainter(pix) |
575 painter = QPainter(pix) |
564 painter.setRenderHint(QPainter.Antialiasing) |
576 painter.setRenderHint(QPainter.Antialiasing) |
565 |
|
566 pen = QPen(Qt.blue) |
|
567 pen.setWidth(2) |
|
568 painter.setPen(pen) |
|
569 |
|
570 lpen = QPen(pen) |
|
571 lpen.setColor(Qt.black) |
|
572 painter.setPen(lpen) |
|
573 |
577 |
574 # draw the revision history lines |
578 # draw the revision history lines |
575 for y1, y2, lines in ((0, h, bottomedges), |
579 for y1, y2, lines in ((0, h, bottomedges), |
576 (-h, 0, topedges)): |
580 (-h, 0, topedges)): |
577 if lines: |
581 if lines: |
578 for start, end, ecolor in lines: |
582 for start, end, ecolor in lines: |
579 lpen = QPen(pen) |
583 lpen = QPen(QColor(self.__getColor(ecolor))) |
580 lpen.setColor(QColor(self.__getColor(ecolor))) |
|
581 lpen.setWidth(2) |
584 lpen.setWidth(2) |
582 painter.setPen(lpen) |
585 painter.setPen(lpen) |
583 x1 = col2x(start, radius) |
586 x1 = col2x(start, radius) |
584 x2 = col2x(end, radius) |
587 x2 = col2x(end, radius) |
585 painter.drawLine(x1, dot_y + y1, x2, dot_y + y2) |
588 painter.drawLine(x1, dot_y + y1, x2, dot_y + y2) |
586 |
589 |
587 penradius = 1 |
590 penradius = 1 |
588 pencolor = Qt.black |
591 pencolor = self.logTree.palette().color(QPalette.Text) |
589 |
592 |
590 dot_y = (h // 2) - radius // 2 |
593 dot_y = (h // 2) - radius // 2 |
591 |
594 |
592 # draw a dot for the revision |
595 # draw a dot for the revision |
593 if currentCommit: |
596 if currentCommit: |