From 30e996565f292159a088d6fb9f735f776fe5fed3 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Tue, 18 Aug 2009 08:01:06 +0100 Subject: Try the roster item presence icon overlapping the avatar. diff --git a/Swift/QtUI/Roster/RosterDelegate.cpp b/Swift/QtUI/Roster/RosterDelegate.cpp index f3f07ee..c6b8a8c 100644 --- a/Swift/QtUI/Roster/RosterDelegate.cpp +++ b/Swift/QtUI/Roster/RosterDelegate.cpp @@ -36,17 +36,20 @@ void RosterDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option painter->setPen(option.palette.highlightedText().color()); } - QRect presenceIconRegion(QPoint(margin_, fullRegion.top()), QSize(presenceIconSize_, fullRegion.height())); - QIcon presenceIcon = index.data(PresenceIconRole).isValid() && !index.data(PresenceIconRole).value().isNull() - ? index.data(PresenceIconRole).value() - : QIcon(":/icons/offline.png"); - presenceIcon.paint(painter, presenceIconRegion, Qt::AlignVCenter | Qt::AlignHCenter); + QRect presenceIconRegion(QPoint(margin_, fullRegion.top()), QSize(presenceIconWidth_, fullRegion.height())); - QRect avatarRegion(QPoint(presenceIconRegion.right() + margin_, fullRegion.top()), QSize(avatarSize_, fullRegion.height())); + //This overlaps the presenceIcon, so must be painted first + QRect avatarRegion(QPoint(presenceIconRegion.right() - presenceIconWidth_ / 2, fullRegion.top()), QSize(avatarSize_, fullRegion.height())); QIcon avatar = index.data(AvatarRole).isValid() && !index.data(AvatarRole).value().isNull() ? index.data(AvatarRole).value() : QIcon(":/icons/avatar.png"); avatar.paint(painter, avatarRegion, Qt::AlignVCenter | Qt::AlignHCenter); + + //Paint the presence icon over the top of the avatar + QIcon presenceIcon = index.data(PresenceIconRole).isValid() && !index.data(PresenceIconRole).value().isNull() + ? index.data(PresenceIconRole).value() + : QIcon(":/icons/offline.png"); + presenceIcon.paint(painter, presenceIconRegion, Qt::AlignBottom | Qt::AlignHCenter); QFont nameFont = painter->font(); QFont statusFont = painter->font(); diff --git a/Swift/QtUI/Roster/RosterDelegate.h b/Swift/QtUI/Roster/RosterDelegate.h index 0d923ac..5986ab2 100644 --- a/Swift/QtUI/Roster/RosterDelegate.h +++ b/Swift/QtUI/Roster/RosterDelegate.h @@ -9,7 +9,8 @@ namespace Swift { void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; private: static const int avatarSize_ = 28; - static const int presenceIconSize_ = 16; + static const int presenceIconHeight_ = 16; + static const int presenceIconWidth_ = 16; static const int margin_ = 4; }; } -- cgit v0.10.2-6-g49f6