Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPresetShadowUpdater Class Reference

#include <KisPresetShadowUpdater.h>

+ Inheritance diagram for KisPresetShadowUpdater:

Classes

struct  Private
 

Public Slots

void slotCacheGenerationFinished (int sequenceNumber, KoResourceCacheInterfaceSP cacheInterface)
 
void slotCanvasResourceChanged (int key, const QVariant &value)
 
void slotPresetChanged ()
 
void slotStartPresetPreparation ()
 

Public Member Functions

 KisPresetShadowUpdater (KisViewManager *view)
 
 ~KisPresetShadowUpdater ()
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

Definition at line 16 of file KisPresetShadowUpdater.h.

Constructor & Destructor Documentation

◆ KisPresetShadowUpdater()

KisPresetShadowUpdater::KisPresetShadowUpdater ( KisViewManager * view)

Definition at line 95 of file KisPresetShadowUpdater.cpp.

96 : m_d(new Private)
97{
98 m_d->view = view;
99 connect(&m_d->updateStartCompressor, SIGNAL(timeout()),
100 this, SLOT(slotStartPresetPreparation()));
101}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
const QScopedPointer< Private > m_d

References connect(), m_d, and slotStartPresetPreparation().

◆ ~KisPresetShadowUpdater()

KisPresetShadowUpdater::~KisPresetShadowUpdater ( )

Definition at line 103 of file KisPresetShadowUpdater.cpp.

104{
105}

Member Function Documentation

◆ slotCacheGenerationFinished

void KisPresetShadowUpdater::slotCacheGenerationFinished ( int sequenceNumber,
KoResourceCacheInterfaceSP cacheInterface )
slot

Definition at line 176 of file KisPresetShadowUpdater.cpp.

177{
178 if (sequenceNumber == m_d->sequenceNumber) {
179 m_d->view->canvasResourceProvider()->resourceManager()->
181 QVariant::fromValue(cacheInterface));
182 }
183}
@ CurrentPaintOpPresetCache
the cache associated with the currently active preset (this cache may be different per canvas if the ...

References KoCanvasResource::CurrentPaintOpPresetCache, and m_d.

◆ slotCanvasResourceChanged

void KisPresetShadowUpdater::slotCanvasResourceChanged ( int key,
const QVariant & value )
slot

if the current preset depends on the canvas resources, we should reset its cache and restart cache generation

Definition at line 107 of file KisPresetShadowUpdater.cpp.

108{
110 m_d->currentPreset = value.value<KisPaintOpPresetSP>();
111
112 m_d->proxyConnections.clear();
113
114 if (m_d->currentPreset) {
115 m_d->currentUpdateProxy = m_d->currentPreset->updateProxy();
116 m_d->proxyConnections.addConnection(
117 m_d->currentUpdateProxy, SIGNAL(sigSettingsChangedUncompressedEarlyWarning()),
118 this, SLOT(slotPresetChanged()));
120 } else {
121 m_d->view->canvasResourceProvider()->resourceManager()->
123 QVariant::fromValue(KoResourceCacheInterfaceSP()));
124 }
125 } else if (m_d->currentPreset) {
128
129 if (m_d->currentPreset->requiredCanvasResources().contains(key)) {
131 }
132 }
133}
float value(const T *src, size_t ch)
QSharedPointer< KoResourceCacheInterface > KoResourceCacheInterfaceSP

References KoCanvasResource::CurrentPaintOpPreset, KoCanvasResource::CurrentPaintOpPresetCache, m_d, slotPresetChanged(), and value().

◆ slotPresetChanged

void KisPresetShadowUpdater::slotPresetChanged ( )
slot

Definition at line 135 of file KisPresetShadowUpdater.cpp.

136{
137 m_d->sequenceNumber++;
138 m_d->updateStartCompressor.start();
139
140 m_d->view->canvasResourceProvider()->resourceManager()->
142 QVariant::fromValue(KoResourceCacheInterfaceSP()));
143
144}

References KoCanvasResource::CurrentPaintOpPresetCache, and m_d.

◆ slotStartPresetPreparation

void KisPresetShadowUpdater::slotStartPresetPreparation ( )
slot

a fallback solution when a preset is selected on Krita loading, when there is no image present

Definition at line 146 of file KisPresetShadowUpdater.cpp.

147{
148 if (m_d->currentPreset) {
149 KisImageSP image = m_d->view->image();
150 if (image) {
151 KisPaintOpPresetSP preset =
152 m_d->currentPreset->cloneWithResourcesSnapshot(
154 m_d->view->canvasResourceProvider()->resourceManager()->canvasResourcesInterface(),
155 nullptr);
156
157 ShadowUpdatePresetJob *job = new ShadowUpdatePresetJob(preset, m_d->sequenceNumber);
158
159 connect(job, SIGNAL(sigCacheGenerationFinished(int, KoResourceCacheInterfaceSP)),
161
162 image->addSpontaneousJob(job);
163 } else {
166
167 KoResourceCacheInterfaceSP cacheInterface =
169
170 m_d->currentPreset->regenerateResourceCache(cacheInterface);
171 slotCacheGenerationFinished(m_d->sequenceNumber, cacheInterface);
172 }
173 }
174}
static KisResourcesInterfaceSP instance()
void addSpontaneousJob(KisSpontaneousJob *spontaneousJob)
void slotCacheGenerationFinished(int sequenceNumber, KoResourceCacheInterfaceSP cacheInterface)
QSharedPointer< T > toQShared(T *ptr)

References KisImage::addSpontaneousJob(), connect(), KisGlobalResourcesInterface::instance(), m_d, slotCacheGenerationFinished(), and toQShared().

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisPresetShadowUpdater::m_d
private

Definition at line 34 of file KisPresetShadowUpdater.h.


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