summaryrefslogtreecommitdiffstats
path: root/backend-shared/roundrectitem.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-03 12:46:56 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-03 13:56:05 -0800
commitb188560ae57304676fb10d8015dc2e3985e44c42 (patch)
tree81bd406f2de74d186c1113eb0634f1a38ba6f85f /backend-shared/roundrectitem.cpp
parent9759d5b21a330ae2908fe91ff1533d06f6a59f4f (diff)
downloadsubsurface-b188560ae57304676fb10d8015dc2e3985e44c42.tar.gz
ui: create a RoundRectItem class
Factor out code from ProfileWidget's ToolTipItem, but make the radius of the corners dynamic. Move into backend-shared, though a new ui-shared might be preferred. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'backend-shared/roundrectitem.cpp')
-rw-r--r--backend-shared/roundrectitem.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/backend-shared/roundrectitem.cpp b/backend-shared/roundrectitem.cpp
new file mode 100644
index 000000000..2dbfd7b03
--- /dev/null
+++ b/backend-shared/roundrectitem.cpp
@@ -0,0 +1,18 @@
+#include "roundrectitem.h"
+#include <QPainter>
+#include <QStyleOptionGraphicsItem>
+
+RoundRectItem::RoundRectItem(double radius, QGraphicsItem *parent) : QGraphicsRectItem(parent),
+ radius(radius)
+{
+}
+
+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();
+}