move INV button from footer into channel delegate rows (second button left of plus)

This commit is contained in:
evgeny committed 2026-08-04 22:57:36 +03:00
1 parent 24316e8cf8
commit 44c99f603d
3 files changed
+58 -21

No files matched your search

+30
View File
@@ -12,6 +12,13 @@ QRect ChannelDelegate::inviteButtonRect(const QRect &itemRect) {
InviteBtnSize, InviteBtnSize);
}
QRect ChannelDelegate::inviteByLinkButtonRect(const QRect &itemRect) {
const int margin = 6;
return QRect(itemRect.right() - margin - InviteBtnSize * 2 - InviteBtnGap,
itemRect.bottom() - margin - InviteBtnSize,
InviteBtnSize, InviteBtnSize);
}
void ChannelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const {
painter->save();
@@ -169,6 +176,29 @@ void ChannelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
painter->drawLine(plusRect.left() + 5, plusRect.center().y(),
plusRect.right() - 5, plusRect.center().y());
/* ── invite-by-link button (left of plus, orange square with arrow) ── */
QRect invRect = inviteByLinkButtonRect(option.rect);
bool invHovered = index.data(ChannelInviteByLinkBtnHoveredRole).toInt() != 0;
painter->setRenderHint(QPainter::Antialiasing);
if (invHovered) {
painter->setBrush(QColor(0xE6, 0x7E, 0x22));
painter->setPen(Qt::NoPen);
painter->drawRoundedRect(invRect, 3, 3);
painter->setPen(QPen(Qt::white, 1.5));
} else {
painter->setBrush(QColor(0xE6, 0x7E, 0x22, 110));
painter->setPen(Qt::NoPen);
painter->drawRoundedRect(invRect, 3, 3);
painter->setPen(QPen(QColor(0xE6, 0x7E, 0x22), 1.5));
}
/* arrow pointing into a box: →| or a simple arrow-left: ← */
int cx = invRect.center().x(), cy = invRect.center().y();
int dx = 3;
painter->drawLine(cx + dx, cy - 3, cx - dx, cy);
painter->drawLine(cx + dx, cy + 3, cx - dx, cy);
painter->drawLine(cx + dx + 1, cy, cx + dx + 1, cy - 3 + 1);
painter->drawLine(cx + dx + 1, cy, cx + dx + 1, cy + 3 - 1);
painter->restore();
}