Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeFillResourceConnector.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
11
12#include "kis_assert.h"
14
15#include <KoColor.h>
16#include <KoFlake.h>
17#include <KoShapeFillWrapper.h>
18#include <KoSelection.h>
19#include <KoCanvasBase.h>
20
21
22
30
32 : QObject(parent),
33 m_d(new Private())
34{
35}
36
40
42{
43 m_d->resourceManagerConnections.clear();
44 m_d->canvas = 0;
45
48
49 m_d->canvas = canvas;
50
51 if (m_d->canvas) {
52 m_d->resourceManagerConnections.addConnection(
53 canvas->resourceManager(), SIGNAL(canvasResourceChanged(int,QVariant)),
54 this, SLOT(slotCanvasResourceChanged(int,QVariant)));
55 }
56}
57
62
64{
66
68 m_d->applyShapeColoring(KoFlake::Fill, value.value<KoColor>());
69 } else if (key == KoCanvasResource::BackgroundColor) {
70 m_d->applyShapeColoring(KoFlake::StrokeFill, value.value<KoColor>());
71 }
72}
73
74
76{
78
79 if (selectedEditableShapes.isEmpty()) {
80 return;
81 }
82
83 KoShapeFillWrapper wrapper(selectedEditableShapes, fillVariant);
84 KUndo2Command *command = wrapper.setColor(color.toQColor()); // TODO: do the conversion in a better way!
85
86 if (command) {
87 canvas->addCommand(command);
88 }
89}
float value(const T *src, size_t ch)
virtual void addCommand(KUndo2Command *command)=0
QPointer< KoCanvasResourceProvider > resourceManager
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
void toQColor(QColor *c) const
a convenience method for the above.
Definition KoColor.cpp:198
virtual KoSelection * selection()=0
const QList< KoShape * > selectedEditableShapes() const
void slotCanvasResourceChanged(int key, const QVariant &value)
KUndo2Command * setColor(const QColor &color)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
@ BackgroundColor
The active background color selected for this canvas.
@ ForegroundColor
The active foreground color selected for this canvas.
FillVariant
Definition KoFlake.h:28
@ StrokeFill
Definition KoFlake.h:30
@ Fill
Definition KoFlake.h:29
void applyShapeColoring(KoFlake::FillVariant fillVariant, const KoColor &color)
KisSignalAutoConnectionsStore resourceManagerConnections