Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCanvasResourceProvider.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2006 Boudewijn Rempt (boud@valdyas.org)
3 SPDX-FileCopyrightText: 2007, 2010 Thomas Zander <zander@kde.org>
4 SPDX-FileCopyrightText: 2008 Carlos Licea <carlos.licea@kdemail.net>
5 SPDX-FileCopyrightText: 2011 Jan Hambrecht <jaham@gmx.net>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8 */
10
11#include <QVariant>
12#include <FlakeDebug.h>
13
14#include "KoShape.h"
15#include "KoShapeStroke.h"
16#include "KoResourceManager_p.h"
18
20
22{
24 : m_provider(provider)
25 {
26 }
27
28 QVariant resource(int key) const override {
29 return m_provider->resource(key);
30 }
31
32private:
33 KoCanvasResourceProvider *m_provider = 0;
34};
35
36
48
62
67
68void KoCanvasResourceProvider::setResource(int key, const QVariant &value)
69{
70 d->manager.setResource(key, value);
71}
72
74{
75 return d->manager.resource(key);
76}
77
79{
80 QVariant v;
81 v.setValue(color);
82 setResource(key, v);
83}
84
86{
87 QVariant v;
88 v.setValue(shape);
89 setResource(key, v);
90}
91
93{
94 QVariant v;
95 v.setValue(unit);
96 setResource(key, v);
97}
98
100{
101 return d->manager.koColorResource(key);
102}
103
108
113
118
123
125{
126 return d->manager.koShapeResource(key);
127}
128
130{
131 return resource(key).value<KoUnit>();
132}
133
135{
136 // do not allow arbitrary small handles
137 if (handleSize < 5)
138 handleSize = 5;
139 setResource(KoCanvasResource::HandleRadius, QVariant(handleSize));
140}
141
143{
146 return 5; // default value (and is used just about everywhere)
147}
148
155
162
164{
165 setResource(KoCanvasResource::UsingOtherColor, QVariant(usingOtherColor));
166}
167
174
176{
177 return d->manager.boolResource(key);
178}
179
181{
182 return d->manager.intResource(key);
183}
184
186{
187 return d->manager.stringResource(key);
188}
189
191{
192 return d->manager.sizeResource(key);
193}
194
196{
197 return d->manager.hasResource(key);
198}
199
201{
202 d->manager.clearResource(key);
203}
204
206{
207 d->manager.addDerivedResourceConverter(converter);
208}
209
211{
212 return d->manager.hasDerivedResourceConverter(key);
213}
214
216{
217 d->manager.removeDerivedResourceConverter(key);
218}
219
221{
222 return d->manager.hasAbstractResource(key);
223}
224
226{
227 d->manager.removeAbstractResource(key);
228}
229
231{
232 d->manager.addResourceUpdateMediator(mediator);
233}
234
236{
237 return d->manager.hasResourceUpdateMediator(key);
238}
239
241{
242 d->manager.removeResourceUpdateMediator(key);
243}
244
246{
247 d->manager.addActiveCanvasResourceDependency(dep);
248}
249
251{
252 return d->manager.hasActiveCanvasResourceDependency(sourceKey, targetKey);
253}
254
256{
257 d->manager.removeActiveCanvasResourceDependency(sourceKey, targetKey);
258}
259
261{
262 d->manager.setAbstractResource(abstractResource);
263}
264
float value(const T *src, size_t ch)
qreal v
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
int decorationThickness() const
decorationThickness
KoCanvasResourceProvider(QObject *parent=0)
void addActiveCanvasResourceDependency(KoActiveCanvasResourceDependencySP dep)
KoShape * koShapeResource(int key) const
void setBackgroundColor(const KoColor &color)
bool isUsingOtherColor() const
isUsingOtherColor
KoCanvasResourcesInterfaceSP canvasResourcesInterface() const
void canvasResourceChanged(int key, const QVariant &value)
QSharedPointer< CanvasResourceProviderInterfaceWrapper > interfaceWrapper
KoColor koColorResource(int key) const
int handleRadius() const
Returns the actual handle radius.
void canvasResourceChangeAttempted(int key, const QVariant &value)
void setDecorationThickness(int decorationThickness)
setDecorationThickness Set the minimum decoration thickness.
void setForegroundColor(const KoColor &color)
QString stringResource(int key) const
void removeActiveCanvasResourceDependency(int sourceKey, int targetKey)
void setUsingOtherColor(bool usingOtherColor)
setUsingOtherColor Set whether the user requested the current action to use the colors the other way ...
bool hasActiveCanvasResourceDependency(int sourceKey, int targetKey) const
Private(KoCanvasResourceProvider *q)
void addResourceUpdateMediator(KoResourceUpdateMediatorSP mediator)
void setAbstractResource(KoAbstractCanvasResourceInterfaceSP abstractResource)
void setResource(int key, const QVariant &value)
void addDerivedResourceConverter(KoDerivedResourceConverterSP converter)
An abstract class for providing access to canvas resources like current gradient and Fg/Bg colors.
The KoResourceManager class provides access to the currently active resources for a given canvas....
void resourceChangeAttempted(int key, const QVariant &value)
void resourceChanged(int key, const QVariant &value)
@ DecorationThickness
Integer, the thickness of single px decorations, will be adjusted by HiDPI settings....
@ HandleRadius
The handle radius used for drawing handles of any kind.
@ BackgroundColor
The active background color selected for this canvas.
@ ForegroundColor
The active foreground color selected for this canvas.
CanvasResourceProviderInterfaceWrapper(KoCanvasResourceProvider *provider)
static KoColorSpaceRegistry * instance()
const KoColorSpace * rgb8(const QString &profileName=QString())