summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-01 14:01:38 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-01 14:01:38 (GMT)
commitcd294437d80978a72a8b7ce9e563afee0a518300 (patch)
tree75fd0c82ca93c71227bcdd76d89ce54514854165 /Swift
parentcd40e329581cb942603140402c9d1970e71ebbd0 (diff)
downloadswift-cd294437d80978a72a8b7ce9e563afee0a518300.zip
swift-cd294437d80978a72a8b7ce9e563afee0a518300.tar.bz2
Sort out the alignments in the roster.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.cpp25
-rw-r--r--Swift/resources/icons/avatar.pngbin1003 -> 2429 bytes
2 files changed, 16 insertions, 9 deletions
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 <QPainter>
#include <QColor>
#include <QBrush>
+#include <QFontMetrics>
#include <qdebug.h>
#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<QIcon>().isNull()
? index.data(AvatarRole).value<QIcon>()
: 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
--- a/Swift/resources/icons/avatar.png
+++ b/Swift/resources/icons/avatar.png
Binary files differ