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
|
@ -5,6 +5,8 @@ set(BACKEND_SRCS
|
|||
exportfuncs.h
|
||||
plannershared.cpp
|
||||
plannershared.h
|
||||
roundrectitem.cpp
|
||||
roundrectitem.h
|
||||
)
|
||||
|
||||
add_library(subsurface_backend_shared STATIC ${BACKEND_SRCS})
|
||||
|
|
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();
|
||||
}
|
15
backend-shared/roundrectitem.h
Normal file
15
backend-shared/roundrectitem.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#ifndef ROUNDRECTITEM_H
|
||||
#define ROUNDRECTITEM_H
|
||||
|
||||
#include <QGraphicsRectItem>
|
||||
|
||||
class RoundRectItem : public QGraphicsRectItem {
|
||||
public:
|
||||
RoundRectItem(double radius, QGraphicsItem *parent);
|
||||
private:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
double radius;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue