summaryrefslogtreecommitdiffstats
path: root/backend-shared/roundrectitem.cpp
blob: 52200b0171fb2a47d2087123ea67f5edc250524d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "roundrectitem.h"
#include <QPainter>
#include <QStyleOptionGraphicsItem>

RoundRectItem::RoundRectItem(double radius, QGraphicsItem *parent) : QGraphicsRectItem(parent),
	radius(radius)
{
}

RoundRectItem::RoundRectItem(double radius) : RoundRectItem(radius, nullptr)
{
}

void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
	painter->save();
	painter->setClipRect(option->rect);
	painter->setPen(pen());
	painter->setBrush(brush());
	painter->drawRoundedRect(rect(), radius, radius, Qt::AbsoluteSize);
	painter->restore();
}