diff options
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/Roster/GroupItemDelegate.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/Swift/QtUI/Roster/GroupItemDelegate.cpp b/Swift/QtUI/Roster/GroupItemDelegate.cpp index 819352d..bca83c7 100644 --- a/Swift/QtUI/Roster/GroupItemDelegate.cpp +++ b/Swift/QtUI/Roster/GroupItemDelegate.cpp @@ -69,30 +69,29 @@ void GroupItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opt } void GroupItemDelegate::paintExpansionTriangle(QPainter* painter, const QRect& region, int width, int height, bool expanded) const { - QBrush triangleBrush(QColor(110, 110, 110)); - QBrush triangleShadowBrush(QColor(47, 47, 47)); - QPainterPath trianglePath; - QPainterPath triangleShadowPath; + // height is the height of the downward pointing triangle QPolygonF triangle; - QPolygonF triangleShadow; - QPointF triangleTopLeft(region.left(), region.top() + region.height() / 2 - height / 2); - QPointF shadowOffset(0,-1); - QPointF trianglePoint2; - QPointF trianglePoint3; - if (expanded) { - triangleTopLeft += QPoint(0, 1); - trianglePoint2 = triangleTopLeft + QPointF(width, 0); - trianglePoint3 = trianglePoint2 + QPointF(-1 * (width / 2), height); - //qDebug() << "Plotting expanded" << triangleTopLeft << ", " << trianglePoint2 << ", " << trianglePoint3; - } else { - trianglePoint2 = triangleTopLeft + QPointF(0, width); - trianglePoint3 = trianglePoint2 + QPointF(height, -1 * (width / 2)); - //qDebug() << "Plotting collapsed" << triangleTopLeft << ", " << trianglePoint2 << ", " << trianglePoint3; + QPointF triangleTopLeft(region.left(), region.top() + region.height() / 2 - height / 2); + triangle << triangleTopLeft; + triangle << triangleTopLeft + QPointF(width, 0); + triangle << triangleTopLeft + QPointF(width / 2, height); } - triangle << triangleTopLeft << trianglePoint2 << trianglePoint3 << triangleTopLeft; - triangleShadow << triangleTopLeft + shadowOffset << trianglePoint2 + shadowOffset << trianglePoint3 + shadowOffset << triangleTopLeft + shadowOffset; - + else { + QPointF triangleTopLeft(region.left(), region.top() + region.height() / 2 - width / 2); + triangle << triangleTopLeft; + triangle << triangleTopLeft + QPointF(height, width / 2); + triangle << triangleTopLeft + QPointF(0, width); + } + //qDebug() << "Painting triangle: " << triangle; + + QPolygonF triangleShadow(triangle); + triangleShadow.translate(QPointF(0, -1)); + + QPainterPath trianglePath; + QPainterPath triangleShadowPath; + QBrush triangleBrush(QColor(110, 110, 110)); + QBrush triangleShadowBrush(QColor(47, 47, 47)); trianglePath.addPolygon(triangle); triangleShadowPath.addPolygon(triangleShadow); painter->fillPath(triangleShadowPath, triangleShadowBrush); |