Krita Source Code Documentation
Loading...
Searching...
No Matches
GradientResourceServer Class Reference
+ Inheritance diagram for GradientResourceServer:

Public Member Functions

 GradientResourceServer (const QString &type)
 
void insertSpecialGradients ()
 
- Public Member Functions inherited from KoResourceServer< KoAbstractGradient >
void addObserver (ObserverType *observer)
 
bool addResource (QSharedPointer< KoAbstractGradient > resource, bool save=true)
 Adds an already loaded resource to the server.
 
QVector< KisTagSP > assignedTagsList (KoResourceSP resource) const
 
QSharedPointer< KoAbstractGradient > firstResource () const
 Return the first resource available.
 
KoResourceSP importResourceFile (const QString &filename, const bool allowOverwrite)
 
 KoResourceServer (const QString &type)
 
bool reloadResource (QSharedPointer< KoAbstractGradient > resource)
 
void removeObserver (ObserverType *observer)
 
void removeResourceFile (const QString &filename)
 Removes the resource file from the resource server.
 
bool removeResourceFromServer (QSharedPointer< KoAbstractGradient > resource)
 Remove a resource from Resource Server but not from a file.
 
QSharedPointer< KoAbstractGradient > resource (const QString &md5, const QString &fileName, const QString &name)
 resource retrieves a resource. If the md5sum is not empty, the resource will only be retrieved if a resource with that md5sum exists. If it is empty, a fallback to filename or name is possible.
 
int resourceCount () const
 
KisResourceModel * resourceModel () const
 
QString saveLocation ()
 Returns path where to save user defined and imported resources to.
 
bool updateResource (QSharedPointer< KoAbstractGradient > resource)
 
virtual ~KoResourceServer ()
 

Private Member Functions

KoAbstractGradientSP createResource (const QString &filename)
 

Private Attributes

KoAbstractGradientSP m_foregroundToBackground
 
KoAbstractGradientSP m_foregroundToTransparent
 

Friends

class KoResourceBundle
 

Additional Inherited Members

- Public Types inherited from KoResourceServer< KoAbstractGradient >
typedef KoResourceServerObserver< KoAbstractGradient > ObserverType
 
- Protected Member Functions inherited from KoResourceServer< KoAbstractGradient >
void notifyRemovingResource (QSharedPointer< KoAbstractGradient > resource)
 
void notifyResourceAdded (QSharedPointer< KoAbstractGradient > resource)
 
void notifyResourceChanged (QSharedPointer< KoAbstractGradient > resource)
 

Detailed Description

Definition at line 27 of file KoResourceServerProvider.cpp.

Constructor & Destructor Documentation

◆ GradientResourceServer()

GradientResourceServer::GradientResourceServer ( const QString & type)
inline

Member Function Documentation

◆ createResource()

KoAbstractGradientSP GradientResourceServer::createResource ( const QString & filename)
inlineprivate

Definition at line 76 of file KoResourceServerProvider.cpp.

76 {
77
78 QString fileExtension;
79 int index = filename.lastIndexOf('.');
80
81 if (index != -1)
82 fileExtension = filename.mid(index).toLower();
83
85
86 if(fileExtension == ".svg") {
87 grad.reset(new KoStopGradient(filename));
88 }
89 else if(fileExtension == ".ggr" ) {
90 grad.reset(new KoSegmentGradient(filename));
91 }
92
93 return grad;
94 }
QLatin1String fileExtension(RecorderFormat format)

◆ insertSpecialGradients()

void GradientResourceServer::insertSpecialGradients ( )
inline

Definition at line 37 of file KoResourceServerProvider.cpp.

38 {
41
42 KoStopGradientSP gradient(new KoStopGradient());
43 gradient->setType(QGradient::LinearGradient);
44 gradient->setName(i18n("1. Foreground to Transparent"));
45 gradient->setFilename("Foreground to Transparent.svg");
46 stops << KoGradientStop(0.0, KoColor(Qt::black, cs), FOREGROUNDSTOP);
47 stops << KoGradientStop(1.0, KoColor(QColor(0, 0, 0, 0), cs), COLORSTOP);
48
49 gradient->setStops(stops);
50 gradient->setValid(true);
51 gradient->setPermanent(true);
52 addResource(gradient, false);
54
55 gradient.reset(new KoStopGradient());
56 gradient->setType(QGradient::LinearGradient);
57 gradient->setName(i18n("0. Foreground to Background"));
58 gradient->setFilename("Foreground to Background.svg");
59
60 stops.clear();
61 stops << KoGradientStop(0.0, KoColor(Qt::black, cs), FOREGROUNDSTOP);
62 stops << KoGradientStop(1.0, KoColor(Qt::white, cs), BACKGROUNDSTOP);
63
64 gradient->setStops(stops);
65 gradient->setValid(true);
66 gradient->setPermanent(true);
67 addResource(gradient, false);
68
69 m_foregroundToBackground = gradient;
70 }
@ FOREGROUNDSTOP
@ BACKGROUNDSTOP
@ COLORSTOP
KoAbstractGradientSP m_foregroundToBackground
KoAbstractGradientSP m_foregroundToTransparent
bool addResource(QSharedPointer< KoAbstractGradient > resource, bool save=true)
Adds an already loaded resource to the server.
static KoColorSpaceRegistry * instance()
const KoColorSpace * rgb8(const QString &profileName=QString())

References KoResourceServer< KoAbstractGradient >::addResource(), BACKGROUNDSTOP, COLORSTOP, FOREGROUNDSTOP, KoColorSpaceRegistry::instance(), m_foregroundToBackground, m_foregroundToTransparent, and KoColorSpaceRegistry::rgb8().

Friends And Related Symbol Documentation

◆ KoResourceBundle

friend class KoResourceBundle
friend

Definition at line 74 of file KoResourceServerProvider.cpp.

Member Data Documentation

◆ m_foregroundToBackground

KoAbstractGradientSP GradientResourceServer::m_foregroundToBackground
private

Definition at line 97 of file KoResourceServerProvider.cpp.

◆ m_foregroundToTransparent

KoAbstractGradientSP GradientResourceServer::m_foregroundToTransparent
private

Definition at line 96 of file KoResourceServerProvider.cpp.


The documentation for this class was generated from the following file: