mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
9759d5b21a
commit
b188560ae5
6 changed files with 40 additions and 15 deletions
18
backend-shared/roundrectitem.cpp
Normal file
18
backend-shared/roundrectitem.cpp
Normal file
|
@ -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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue