Kirigami2

paintedrectangleitem.h
1 /*
2  * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 #ifndef PAINTEDRECTANGLEITEM_H
8 #define PAINTEDRECTANGLEITEM_H
9 
10 #include <QQuickPaintedItem>
11 
12 /**
13  * A rectangle with a border and rounded corners, rendered through QPainter.
14  *
15  * This is a helper used by ShadowedRectangle as fallback for when software
16  * rendering is used, which means our shaders cannot be used.
17  *
18  * Since we cannot actually use QSGPaintedNode, we need to do some trickery
19  * using QQuickPaintedItem as a child of ShadowedRectangle.
20  *
21  * \warning This item is **not** intended as a general purpose item.
22  */
24 {
25  Q_OBJECT
26 public:
27  explicit PaintedRectangleItem(QQuickItem *parent = nullptr);
28 
29  void setColor(const QColor &color);
30  void setRadius(qreal radius);
31  void setBorderColor(const QColor &color);
32  void setBorderWidth(qreal width);
33 
34  void paint(QPainter *painter) override;
35 
36 private:
37  QColor m_color;
38  qreal m_radius = 0.0;
39  QColor m_borderColor;
40  qreal m_borderWidth = 0.0;
41 };
42 
43 #endif // PAINTEDRECTANGLEITEM_H
Q_OBJECTQ_OBJECT
A rectangle with a border and rounded corners, rendered through QPainter.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jan 29 2023 04:11:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.