From cd294437d80978a72a8b7ce9e563afee0a518300 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Sat, 1 Aug 2009 15:01:38 +0100 Subject: Sort out the alignments in the roster. diff --git a/Swift/QtUI/Roster/RosterDelegate.cpp b/Swift/QtUI/Roster/RosterDelegate.cpp index aee58fa..3b3d6fe 100644 --- a/Swift/QtUI/Roster/RosterDelegate.cpp +++ b/Swift/QtUI/Roster/RosterDelegate.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "QtTreeWidgetItem.h" @@ -14,7 +15,7 @@ QSize RosterDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelI return QStyledItemDelegate::sizeHint(option, index); } //Doesn't work, yay! FIXME: why? - QSize size = (option.state & QStyle::State_Selected) ? QSize(200, 50) : QSize(100,50); + QSize size = (option.state & QStyle::State_Selected) ? QSize(150, 80) : QSize(150,56); qDebug() << "Returning size" << size; return size; } @@ -34,7 +35,7 @@ void RosterDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option painter->fillRect(fullRegion, option.palette.highlight()); painter->setPen(option.palette.highlightedText().color()); } - QRect avatarRegion(QPoint(0, fullRegion.top()), QSize(32, 32)); + QRect avatarRegion(QPoint(4, fullRegion.top() + 4), QSize(48, 48)); QIcon icon = index.data(AvatarRole).isValid() && !index.data(AvatarRole).value().isNull() ? index.data(AvatarRole).value() : QIcon(":/icons/avatar.png"); @@ -42,15 +43,21 @@ void RosterDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option QFont nameFont = painter->font(); QFont statusFont = painter->font(); - statusFont.setStyle(QFont::StyleItalic); - //statusFont.setSize(-1); + painter->setFont(nameFont); - QRect textRegion(fullRegion.adjusted(avatarRegion.width(), 0, 0, 0)); - QRect nameRegion(textRegion.adjusted(0,0,0,-25)); - painter->drawText(nameRegion, Qt::AlignVCenter, index.data(Qt::DisplayRole).toString()); + QRect textRegion(fullRegion.adjusted(56, 0, 0, 0)); + + QFontMetrics nameMetrics(nameFont); + int nameHeight = nameMetrics.height() + 8; + QRect nameRegion(textRegion.adjusted(0, 4, 0, -1 * nameHeight)); + painter->drawText(nameRegion, Qt::AlignTop, index.data(Qt::DisplayRole).toString()); + + statusFont.setStyle(QFont::StyleItalic); + statusFont.setPointSize(10); painter->setFont(statusFont); - QRect statusTextRegion(textRegion.adjusted(0, 25, 0, 0)); - painter->drawText(statusTextRegion, Qt::AlignVCenter, index.data(StatusTextRole).toString()); + painter->setPen(QPen(QColor(160,160,160))); + QRect statusTextRegion(textRegion.adjusted(0, nameHeight, 0, 0)); + painter->drawText(statusTextRegion, Qt::AlignTop, index.data(StatusTextRole).toString()); painter->restore(); } diff --git a/Swift/resources/icons/avatar.png b/Swift/resources/icons/avatar.png index 00374a6..4b932b0 100644 Binary files a/Swift/resources/icons/avatar.png and b/Swift/resources/icons/avatar.png differ -- cgit v0.10.2-6-g49f6