summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-18 07:01:06 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-18 07:01:06 (GMT)
commit30e996565f292159a088d6fb9f735f776fe5fed3 (patch)
treeae718c8ab2071de0c22631af0dc72c25b39cb391 /Swift
parent666ad146312a1c8abdefe8bba5582fd9ac042700 (diff)
downloadswift-contrib-30e996565f292159a088d6fb9f735f776fe5fed3.zip
swift-contrib-30e996565f292159a088d6fb9f735f776fe5fed3.tar.bz2
Try the roster item presence icon overlapping the avatar.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.cpp15
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.h3
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;
};
}