From 1508333316d70a93b3e4e0596cda09b95c0dc135 Mon Sep 17 00:00:00 2001 From: Ryan Jensen Date: Sun, 25 Feb 2024 14:40:27 -0600 Subject: [PATCH 1/2] Highlight selected commit's backgrounds with painter->fillRect Qt was adding additional highlighting that was distracting. This commit fixes that issue by manually drawing the highlighted background color instead of relying on Qt to do that. See https://github.com/Murmele/Gittyup/issues/699 --- src/ui/CommitList.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ui/CommitList.cpp b/src/ui/CommitList.cpp index 21a923f5..b33b75cd 100644 --- a/src/ui/CommitList.cpp +++ b/src/ui/CommitList.cpp @@ -635,9 +635,6 @@ public: Settings::instance()->value(Setting::Id::ShowCommitsId, true).toBool(); LayoutConstants constants = layoutConstants(compact); - // Draw background. - QStyledItemDelegate::paint(painter, opt, index); - bool active = (opt.state & QStyle::State_Active); bool selected = (opt.state & QStyle::State_Selected); auto group = active ? QPalette::Active : QPalette::Inactive; @@ -646,10 +643,16 @@ public: QPalette palette = Application::theme()->commitList(); QColor text = palette.color(group, textRole); QColor bright = palette.color(group, brightRole); + QColor highlight = palette.color(group, QPalette::Highlight); painter->save(); painter->setRenderHints(QPainter::Antialiasing); + // Draw background. + if (selected) { + painter->fillRect(opt.rect, highlight); + } + // Draw busy indicator. if (opt.features & QStyleOptionViewItem::HasDecoration) { QRect rect = decorationRect(option, index); From 22d81be025bfed7393ceb961e71d4a892c4f0626 Mon Sep 17 00:00:00 2001 From: Ryan Jensen Date: Sun, 25 Feb 2024 15:43:02 -0600 Subject: [PATCH 2/2] Render 'Uncommitted changes' in italics --- src/ui/CommitList.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ui/CommitList.cpp b/src/ui/CommitList.cpp index b33b75cd..49835ea3 100644 --- a/src/ui/CommitList.cpp +++ b/src/ui/CommitList.cpp @@ -787,7 +787,16 @@ public: // Draw content. git::Commit commit = index.data(CommitList::Role::CommitRole).value(); - if (commit.isValid()) { + if (!commit.isValid()) { + // special case for uncommitted changes + QString message = index.model()->data(index).toString(); + painter->save(); + QFont italic = opt.font; + italic.setItalic(true); + painter->setFont(italic); + painter->drawText(opt.rect, Qt::AlignCenter, message); + painter->restore(); + } else { const QFontMetrics &fm = opt.fontMetrics; QRect star = rect;