From ef4d48c56c39f19efc751488cc2df6ee5af24a7f Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 26 Aug 2026 15:58:40 +0200 Subject: feat: fade the account colour across a card --- src/carddelegate.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/carddelegate.cpp') diff --git a/src/carddelegate.cpp b/src/carddelegate.cpp index 9a98c69..6541932 100644 --- a/src/carddelegate.cpp +++ b/src/carddelegate.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -100,6 +101,18 @@ QColor CardDelegate::mutedChipColour(const QColor &chipColour) return QColor::fromHslF(h, s * kSaturationScale, l, a); } +QRect CardDelegate::fadeRectFor(const QRect &card, const QRect &innermostSpine) +{ + // The EXCLUSIVE right edge, then a rect built from it: QRect::right() is + // inclusive, which is the trap CardLayout already documents. + const int end = card.left() + int(card.width() * kFadeFraction); + const int start = innermostSpine.isEmpty() ? card.left() + : innermostSpine.left(); + if (end <= start) + return QRect(); + return QRect(start, card.top(), end - start, card.height()); +} + QColor CardDelegate::accentLineColour(const QColor &accountColour) { if (!accountColour.isValid()) @@ -178,6 +191,24 @@ void CardDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, root.data(ThreadListModel::AccountColourRole).value(); const QColor lineColour = accentLineColour(accountColour); + // The account's fade. Under everything but the chrome, so the selection + // highlight and the doomed-row tint still cover it: a selected row reading + // mostly as selection is expected, not a fault. + const QRect fade = + fadeRectFor(option.rect, + card.spines.isEmpty() ? QRect() : card.spines.last()); + if (!fade.isEmpty() && accountColour.isValid()) { + QColor from = lineColour; + // A reply's wash is weaker than its root's, so an expanded thread + // reads as one block with the root leading it. + from.setAlphaF(card.accentRect.isEmpty() ? 0.14 : 0.30); + QLinearGradient gradient(fade.topLeft(), fade.topRight()); + gradient.setColorAt(0.0, from); + from.setAlphaF(0.0); + gradient.setColorAt(1.0, from); + painter->fillRect(fade, gradient); + } + // The accent bar, thread cards only. Drawn after the chrome so the // selection highlight cannot cover it: which account a card belongs to // must stay readable on the row the user is looking at. -- cgit v1.2.3