diff options
Diffstat (limited to 'Swift/QtUI/Roster')
-rw-r--r-- | Swift/QtUI/Roster/RosterDelegate.cpp | 15 | ||||
-rw-r--r-- | Swift/QtUI/Roster/RosterDelegate.h | 3 |
2 files changed, 11 insertions, 7 deletions
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<QIcon>().isNull() - ? index.data(PresenceIconRole).value<QIcon>() - : 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<QIcon>().isNull() ? index.data(AvatarRole).value<QIcon>() : 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<QIcon>().isNull() + ? index.data(PresenceIconRole).value<QIcon>() + : 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; }; } |