Krita Source Code Documentation
Loading...
Searching...
No Matches
KoColorBackground.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2008 Jan Hambrecht <jaham@gmx.net>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#include "KoColorBackground.h"
9#include <KoXmlNS.h>
10
11#include <QColor>
12#include <QPainter>
13
14class KoColorBackground::Private : public QSharedData
15{
16public:
18 : QSharedData()
19 , color(Qt::black)
20 , style(Qt::SolidPattern)
21 {}
22
23 QColor color;
24 Qt::BrushStyle style;
25};
26
32
33KoColorBackground::KoColorBackground(const QColor &color, Qt::BrushStyle style)
35 , d(new Private)
36{
37 if (style < Qt::SolidPattern || style >= Qt::LinearGradientPattern) {
38 style = Qt::SolidPattern;
39 }
40
41 d->style = style;
42 d->color = color;
43}
44
48
50 : d(new Private(*rhs.d))
51{
52}
53
55{
56 d = rhs.d;
57 return *this;
58}
59
61{
62 const KoColorBackground *bg = dynamic_cast<const KoColorBackground*>(other);
63 return bg && bg->color() == d->color;
64}
65
67{
68 return d->color;
69}
70
71void KoColorBackground::setColor(const QColor &color)
72{
73 d->color = color;
74}
75
76Qt::BrushStyle KoColorBackground::style() const
77{
78 return d->style;
79}
80
82{
83 return QBrush(d->color, d->style);
84}
85
86void KoColorBackground::paint(QPainter &painter, const QPainterPath &fillPath) const
87{
88 painter.setBrush(brush());
89 painter.drawPath(fillPath);
90}
91
A simple solid color shape background.
bool compareTo(const KoShapeBackground *other) const override
void paint(QPainter &painter, const QPainterPath &fillPath) const override
Paints the background using the given fill path.
void setColor(const QColor &color)
Sets the background color.
Qt::BrushStyle style() const
Returns the background style.
QSharedDataPointer< Private > d
KoColorBackground & operator=(const KoColorBackground &)
QColor color() const
Returns the background color.