Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions gitfourchette/graphview/commitlogdelegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from gitfourchette.porcelain import *
from gitfourchette.qt import *
from gitfourchette.repomodel import UC_FAKEID, UC_FAKEREF, RepoModel, GpgStatus
from gitfourchette.settings import CommitHashDisplay
from gitfourchette.toolbox import *


Expand Down Expand Up @@ -157,10 +158,16 @@ def _paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelI
dateWidth = 0
elif rect.width() <= NARROW_WIDTH[1]:
authorWidth = int(lerp(authorWidth/2, authorWidth, rect.width(), NARROW_WIDTH[0], NARROW_WIDTH[1]))
leftBoundHash = rect.left()
leftBoundSummary = leftBoundHash + hcw * settings.prefs.shortHashChars + XSPACING

hashLeft = settings.prefs.commitHashDisplay == CommitHashDisplay.Left
hashRight = settings.prefs.commitHashDisplay == CommitHashDisplay.Right
hashWidth = hcw * settings.prefs.shortHashChars + XSPACING * (3 if hashRight else 1)
hashMonospace = hashLeft

leftBoundSummary = rect.left() + (hashWidth if hashLeft else 0)
leftBoundDate = rect.width() - dateWidth
leftBoundName = leftBoundDate - authorWidth
leftBoundName = leftBoundDate - authorWidth - (hashWidth if hashRight else 0)
leftBoundHash = rect.left() if hashLeft else leftBoundDate - hashWidth
rightBound = rect.right()

# Get the info we need about the commit
Expand Down Expand Up @@ -197,7 +204,7 @@ def _paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelI
else:
commit = None
oid = None
hashText = "·" * settings.prefs.shortHashChars
hashText = "·" * settings.prefs.shortHashChars if hashLeft else ""
authorText = ""
dateText = ""
searchTerm = ""
Expand Down Expand Up @@ -237,14 +244,19 @@ def highlight(fullText: str, needlePos: int, needleLen: int):
SearchBar.highlightNeedle(painter, rect, fullText, needlePos, needleLen)

# ------ Hash
charRect = QRect(leftBoundHash, rect.top(), hcw, rect.height())
painter.save()
if not isSelected: # use muted color for hash if not selected
painter.setPen(palette.color(colorGroup, QPalette.ColorRole.PlaceholderText))
for hashChar in hashText:
painter.drawText(charRect, Qt.AlignmentFlag.AlignCenter, hashChar)
charRect.translate(hcw, 0)
painter.restore()
if hashLeft or hashRight:
width = hcw if hashMonospace else hashWidth
charRect = QRect(leftBoundHash, rect.top(), width, rect.height())
painter.save()
if not isSelected: # use muted color for hash if not selected
painter.setPen(palette.color(colorGroup, QPalette.ColorRole.PlaceholderText))
if hashMonospace:
for hashChar in hashText:
painter.drawText(charRect, Qt.AlignmentFlag.AlignCenter, hashChar)
charRect.translate(hcw, 0)
else:
painter.drawText(charRect, Qt.AlignmentFlag.AlignVCenter, hashText)
painter.restore()

# ------ Highlight searched hash
if searchTerm and searchTermLooksLikeHash and commit and str(commit).startswith(searchTerm):
Expand Down
7 changes: 7 additions & 0 deletions gitfourchette/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ class GraphRowHeight(enum.IntEnum):
Spacious = 175


class CommitHashDisplay(enum.IntEnum):
Left = 0
Right = 1
Hide = 2


class GraphRefBoxWidth(enum.IntEnum):
IconsOnly = 0
Standard = 120
Expand Down Expand Up @@ -105,6 +111,7 @@ class Prefs(PrefsFile):
graphRowHeight : GraphRowHeight = GraphRowHeight.Relaxed
refBoxMaxWidth : GraphRefBoxWidth = GraphRefBoxWidth.Standard
authorDisplayStyle : AuthorDisplayStyle = AuthorDisplayStyle.FullName
commitHashDisplay : CommitHashDisplay = CommitHashDisplay.Left
shortTimeFormat : str = list(SHORT_DATE_PRESETS.values())[0]
maxCommits : int = 10000
authorDiffAsterisk : bool = True
Expand Down
9 changes: 8 additions & 1 deletion gitfourchette/trtables.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _init_enums():
from gitfourchette.porcelain import FileMode, NameValidationError
from gitfourchette.toolbox import toLengthVariants
from gitfourchette.sidebar.sidebarmodel import SidebarItem
from gitfourchette.settings import GraphRowHeight, QtApiNames, GraphRefBoxWidth, RefSort
from gitfourchette.settings import CommitHashDisplay, GraphRowHeight, QtApiNames, GraphRefBoxWidth, RefSort
from gitfourchette.toolbox import PatchPurpose, PathDisplayStyle, AuthorDisplayStyle
from gitfourchette.repomodel import GpgStatus

Expand Down Expand Up @@ -205,6 +205,12 @@ def _init_enums():
AuthorDisplayStyle.EmailUserName: _("Abbreviated email"),
},

CommitHashDisplay: {
CommitHashDisplay.Left : _p("show commit hashes", "On left"),
CommitHashDisplay.Right : _p("show commit hashes", "On right"),
CommitHashDisplay.Hide : _p("show commit hashes", "Hide"),
},

GraphRowHeight: {
GraphRowHeight.Cramped : _p("row spacing", "Cramped"),
GraphRowHeight.Tight : _p("row spacing", "Tight"),
Expand Down Expand Up @@ -381,6 +387,7 @@ def _init_prefKeys():
"shortTimeFormat_help": TrTables._timeFormatTable(),
"pathDisplayStyle": _("Path display style"),
"authorDisplayStyle": _("Author display style"),
"commitHashDisplay": _("Show commit hashes"),
"maxRecentRepos": _("Remember up to # recent repositories"),
"showStatusBar": _("Show status bar"),
"showToolBar": _("Show toolbar"),
Expand Down
Loading