From 550121536ded61b29021930c705dd4dd844016a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20K=C3=B6necke?= Date: Fri, 24 Oct 2025 12:55:44 +0200 Subject: [PATCH 1/3] improve path readability by muting color of directory string --- gitfourchette/filelists/filelist.py | 36 ++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/gitfourchette/filelists/filelist.py b/gitfourchette/filelists/filelist.py index 5322aef4..db71d51d 100644 --- a/gitfourchette/filelists/filelist.py +++ b/gitfourchette/filelists/filelist.py @@ -72,7 +72,41 @@ def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIn painter.setFont(font) fullText = index.data(Qt.ItemDataRole.DisplayRole) text = painter.fontMetrics().elidedText(fullText, option.textElideMode, textRect.width()) - painter.drawText(textRect, option.displayAlignment, text) + + # Split path into directory and filename for better readability + dirPortion = None + filePortion = None + + if '/' in fullText and not isSelected: + slashesInFull = fullText.count('/') + slashesInElided = text.count('/') + + if slashesInFull > slashesInElided: + # A slash was elided - gray everything up to the ellipsis + ellipsisPos = text.find('\u2026') + dirPortion = text[:ellipsisPos + 1] + filePortion = text[ellipsisPos + 1:] + elif slashesInElided > 0: + # No slash elided - gray up to the last slash + lastSlash = text.rfind('/') + dirPortion = text[:lastSlash + 1] + filePortion = text[lastSlash + 1:] + + if dirPortion is not None: + # Draw directory with muted color + mutedColor = option.palette.color(colorGroup, QPalette.ColorRole.WindowText) + mutedColor.setAlphaF(0.4) + painter.setPen(mutedColor) + painter.drawText(textRect, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter, dirPortion) + + # Draw filename with normal color + painter.setPen(option.palette.color(colorGroup, QPalette.ColorRole.WindowText)) + dirWidth = painter.fontMetrics().horizontalAdvance(dirPortion) + fileRect = QRect(textRect) + fileRect.setLeft(textRect.left() + dirWidth) + painter.drawText(fileRect, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter, filePortion) + else: + painter.drawText(textRect, option.displayAlignment, text) # Highlight search term if searchTerm and searchTerm in fullText.lower(): From 6f77e4d2229cf6fccf01e14c345c5d3b4c0fa707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20K=C3=B6necke?= Date: Mon, 27 Oct 2025 14:04:48 +0100 Subject: [PATCH 2/3] gray text also for selected entries --- gitfourchette/filelists/filelist.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gitfourchette/filelists/filelist.py b/gitfourchette/filelists/filelist.py index db71d51d..791835f4 100644 --- a/gitfourchette/filelists/filelist.py +++ b/gitfourchette/filelists/filelist.py @@ -77,7 +77,7 @@ def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIn dirPortion = None filePortion = None - if '/' in fullText and not isSelected: + if '/' in fullText: slashesInFull = fullText.count('/') slashesInElided = text.count('/') @@ -93,14 +93,16 @@ def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIn filePortion = text[lastSlash + 1:] if dirPortion is not None: + textColor = QPalette.ColorRole.WindowText if not isSelected else QPalette.ColorRole.HighlightedText + # Draw directory with muted color - mutedColor = option.palette.color(colorGroup, QPalette.ColorRole.WindowText) + mutedColor = option.palette.color(colorGroup, textColor) mutedColor.setAlphaF(0.4) painter.setPen(mutedColor) painter.drawText(textRect, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter, dirPortion) # Draw filename with normal color - painter.setPen(option.palette.color(colorGroup, QPalette.ColorRole.WindowText)) + painter.setPen(option.palette.color(colorGroup, textColor)) dirWidth = painter.fontMetrics().horizontalAdvance(dirPortion) fileRect = QRect(textRect) fileRect.setLeft(textRect.left() + dirWidth) From f7c8ec8cb6c80fb69c35af38c0079932bd373eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20K=C3=B6necke?= Date: Tue, 28 Oct 2025 08:21:52 +0100 Subject: [PATCH 3/3] remove whitespace from blank line --- gitfourchette/filelists/filelist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitfourchette/filelists/filelist.py b/gitfourchette/filelists/filelist.py index 791835f4..aabdd736 100644 --- a/gitfourchette/filelists/filelist.py +++ b/gitfourchette/filelists/filelist.py @@ -94,7 +94,7 @@ def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIn if dirPortion is not None: textColor = QPalette.ColorRole.WindowText if not isSelected else QPalette.ColorRole.HighlightedText - + # Draw directory with muted color mutedColor = option.palette.color(colorGroup, textColor) mutedColor.setAlphaF(0.4)