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

#include <kis_dlg_layer_style.h>

+ Inheritance diagram for KisDlgLayerStyle:

Public Slots

void changePage (QListWidgetItem *, QListWidgetItem *)
 
void notifyGuiConfigChanged ()
 
void notifyPredefinedStyleSelected (KisPSDLayerStyleSP style)
 
void setStyle (KisPSDLayerStyleSP style)
 
void slotBevelAndEmbossChanged (QListWidgetItem *)
 
void slotLoadStyle ()
 
void slotMasterFxSwitchChanged (bool value)
 
void slotNewStyle ()
 
void slotNotifyOnAccept ()
 
void slotNotifyOnReject ()
 
void slotSaveStyle ()
 
void syncGlobalAngle (int angle)
 
- Public Slots inherited from KoDialog
void delayedDestruct ()
 
void enableButton (ButtonCode id, bool state)
 
void enableButtonApply (bool state)
 
void enableButtonCancel (bool state)
 
void enableButtonOk (bool state)
 
void enableLinkedHelp (bool state)
 
bool isDetailsWidgetVisible () const
 
virtual void setCaption (const QString &caption)
 
virtual void setCaption (const QString &caption, bool modified)
 
void setDetailsWidget (QWidget *detailsWidget)
 
void setDetailsWidgetVisible (bool visible)
 
void setHelp (const QString &anchor, const QString &appname=QString())
 
void setHelpLinkText (const QString &text)
 
virtual void setPlainCaption (const QString &caption)
 

Signals

void configChanged ()
 
- Signals inherited from KoDialog
void aboutToShowDetails ()
 
void applyClicked ()
 
void buttonClicked (KoDialog::ButtonCode button)
 
void cancelClicked ()
 
void closeClicked ()
 
void defaultClicked ()
 
void finished ()
 
void helpClicked ()
 
void hidden ()
 
void layoutHintChanged ()
 
void noClicked ()
 
void okClicked ()
 
void resetClicked ()
 
void tryClicked ()
 
void user1Clicked ()
 
void user2Clicked ()
 
void user3Clicked ()
 
void yesClicked ()
 

Public Member Functions

 KisDlgLayerStyle (KisPSDLayerStyleSP layerStyle, KisCanvasResourceProvider *resourceProvider, QWidget *parent=0)
 
KisPSDLayerStyleSP style () const
 
 ~KisDlgLayerStyle () override
 
- Public Member Functions inherited from KoDialog
QPushButton * button (ButtonCode id) const
 
QIcon buttonIcon (ButtonCode id) const
 
QString buttonText (ButtonCode id) const
 
QString buttonToolTip (ButtonCode id) const
 
QString buttonWhatsThis (ButtonCode id) const
 
ButtonCode defaultButton () const
 
QString helpLinkText () const
 
void incrementInitialSize (const QSize &size)
 
bool isButtonEnabled (ButtonCode id) const
 
 KoDialog (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
 
QWidget * mainWidget ()
 
QSize minimumSizeHint () const override
 
void setButtonFocus (ButtonCode id)
 
void setButtonGuiItem (ButtonCode id, const KGuiItem &item)
 
void setButtonIcon (ButtonCode id, const QIcon &icon)
 
void setButtons (ButtonCodes buttonMask)
 
void setButtonsOrientation (Qt::Orientation orientation)
 
void setButtonText (ButtonCode id, const QString &text)
 
void setButtonToolTip (ButtonCode id, const QString &text)
 
void setButtonWhatsThis (ButtonCode id, const QString &text)
 
void setDefaultButton (ButtonCode id)
 
void setEscapeButton (ButtonCode id)
 
void setInitialSize (const QSize &size)
 
void setMainWidget (QWidget *widget)
 
void showButton (ButtonCode id, bool state)
 
void showButtonSeparator (bool state)
 
QSize sizeHint () const override
 
 ~KoDialog () override
 

Private Attributes

BevelAndEmbossm_bevelAndEmboss
 
BlendingOptionsm_blendingOptions
 
ColorOverlaym_colorOverlay
 
KisSignalCompressorm_configChangedCompressor
 
Contourm_contour
 
DropShadowm_dropShadow
 
GradientOverlaym_gradientOverlay
 
KisPSDLayerStyleSP m_initialLayerStyle
 
InnerGlowm_innerGlow
 
DropShadowm_innerShadow
 
bool m_isSwitchingPredefinedStyle
 
KisPSDLayerStyleSP m_layerStyle
 
InnerGlowm_outerGlow
 
PatternOverlaym_patternOverlay
 
bool m_sanityLayerStyleDirty
 
Satinm_satin
 
Strokem_stroke
 
StylesSelectorm_stylesSelector
 
KisTemporaryResourceStorageLock m_temporaryStorageLock
 
Texturem_texture
 
Ui::WdgStylesDialog wdgLayerStyles
 

Additional Inherited Members

- Public Types inherited from KoDialog
enum  ButtonCode {
  None = 0x00000000 , Help = 0x00000001 , Default = 0x00000002 , Ok = 0x00000004 ,
  Apply = 0x00000008 , Try = 0x00000010 , Cancel = 0x00000020 , Close = 0x00000040 ,
  No = 0x00000080 , Yes = 0x00000100 , Reset = 0x00000200 , Details = 0x00000400 ,
  User1 = 0x00001000 , User2 = 0x00002000 , User3 = 0x00004000 , NoDefault = 0x00008000
}
 
enum  ButtonPopupMode { InstantPopup = 0 , DelayedPopup = 1 }
 
enum  CaptionFlag { NoCaptionFlags = 0 , AppNameCaption = 1 , ModifiedCaption = 2 , HIGCompliantCaption = AppNameCaption }
 
- Static Public Member Functions inherited from KoDialog
static int groupSpacingHint ()
 
static QString makeStandardCaption (const QString &userCaption, QWidget *window=0, CaptionFlags flags=HIGCompliantCaption)
 
static int marginHint ()
 
static void resizeLayout (QLayout *lay, int margin, int spacing)
 
static void resizeLayout (QWidget *widget, int margin, int spacing)
 
static int spacingHint ()
 
- Protected Slots inherited from KoDialog
virtual void slotButtonClicked (int button)
 
- Protected Member Functions inherited from KoDialog
void closeEvent (QCloseEvent *e) override
 
void hideEvent (QHideEvent *) override
 
void keyPressEvent (QKeyEvent *) override
 
void showEvent (QShowEvent *e) override
 

Detailed Description

Definition at line 255 of file kis_dlg_layer_style.h.

Constructor & Destructor Documentation

◆ KisDlgLayerStyle()

KisDlgLayerStyle::KisDlgLayerStyle ( KisPSDLayerStyleSP layerStyle,
KisCanvasResourceProvider * resourceProvider,
QWidget * parent = 0 )
explicit

Definition at line 99 of file kis_dlg_layer_style.cpp.

100 : KoDialog(parent)
101 , m_layerStyle(layerStyle)
102 , m_initialLayerStyle(layerStyle->clone().dynamicCast<KisPSDLayerStyle>())
105 , m_temporaryStorageLock("temporary layer style dependencies storage", std::defer_lock)
106{
107 setCaption(i18n("Layer Styles"));
110
113 connect(m_configChangedCompressor, SIGNAL(timeout()), SIGNAL(configChanged()));
114
115 QWidget *page = new QWidget(this);
116 wdgLayerStyles.setupUi(page);
117 setMainWidget(page);
118 wdgLayerStyles.chkPreview->setVisible(false);
119
120 connect(wdgLayerStyles.lstStyleSelector, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(notifyGuiConfigChanged()));
121
124 wdgLayerStyles.stylesStack->addWidget(m_stylesSelector);
125
127 wdgLayerStyles.stylesStack->addWidget(m_blendingOptions);
128 // currently unimplemented, hide for now
129 wdgLayerStyles.lstStyleSelector->item(1)->setHidden(true);
130
132 wdgLayerStyles.stylesStack->addWidget(m_dropShadow);
133 connect(m_dropShadow, SIGNAL(configChanged()), SLOT(notifyGuiConfigChanged()));
134
136 wdgLayerStyles.stylesStack->addWidget(m_innerShadow);
137 connect(m_innerShadow, SIGNAL(configChanged()), SLOT(notifyGuiConfigChanged()));
138
139 m_outerGlow = new InnerGlow(InnerGlow::OuterGlowMode, resourceProvider, this);
140 wdgLayerStyles.stylesStack->addWidget(m_outerGlow);
141 connect(m_outerGlow, SIGNAL(configChanged()), SLOT(notifyGuiConfigChanged()));
142
143 m_innerGlow = new InnerGlow(InnerGlow::InnerGlowMode, resourceProvider, this);
144 wdgLayerStyles.stylesStack->addWidget(m_innerGlow);
145 connect(m_innerGlow, SIGNAL(configChanged()), SLOT(notifyGuiConfigChanged()));
146
147 // Contour and Texture are sub-styles of Bevel and Emboss
148 // They are only applied to canvas when Bevel and Emboss is active.
149 m_contour = new Contour(this);
150 m_texture = new Texture(this);
152
153 wdgLayerStyles.stylesStack->addWidget(m_bevelAndEmboss);
154 wdgLayerStyles.stylesStack->addWidget(m_contour);
155 wdgLayerStyles.stylesStack->addWidget(m_texture);
156
157 // slotBevelAndEmbossChanged(QListWidgetItem*) enables/disables Contour and Texture on "Bevel and Emboss" toggle.
158 connect(wdgLayerStyles.lstStyleSelector, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(slotBevelAndEmbossChanged(QListWidgetItem*)));
159 connect(m_bevelAndEmboss, SIGNAL(configChanged()), SLOT(notifyGuiConfigChanged()));
160
161 m_satin = new Satin(this);
162 wdgLayerStyles.stylesStack->addWidget(m_satin);
163 connect(m_satin, SIGNAL(configChanged()), SLOT(notifyGuiConfigChanged()));
164
165 m_colorOverlay = new ColorOverlay(this);
166 wdgLayerStyles.stylesStack->addWidget(m_colorOverlay);
167 connect(m_colorOverlay, SIGNAL(configChanged()), SLOT(notifyGuiConfigChanged()));
168
169 m_gradientOverlay = new GradientOverlay(resourceProvider, this);
170 wdgLayerStyles.stylesStack->addWidget(m_gradientOverlay);
171 connect(m_gradientOverlay, SIGNAL(configChanged()), SLOT(notifyGuiConfigChanged()));
172
174 wdgLayerStyles.stylesStack->addWidget(m_patternOverlay);
175 connect(m_patternOverlay, SIGNAL(configChanged()), SLOT(notifyGuiConfigChanged()));
176
177 m_stroke = new Stroke(resourceProvider, this);
178 wdgLayerStyles.stylesStack->addWidget(m_stroke);
179 connect(m_stroke, SIGNAL(configChanged()), SLOT(notifyGuiConfigChanged()));
180
181 KisConfig cfg(true);
182 wdgLayerStyles.stylesStack->setCurrentIndex(cfg.readEntry("KisDlgLayerStyle::current", 0));
183 wdgLayerStyles.lstStyleSelector->setCurrentRow(cfg.readEntry("KisDlgLayerStyle::current", 0));
184
185 connect(wdgLayerStyles.lstStyleSelector,
186 SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
187 this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
188
189 // improve the checkbox visibility by altering the style sheet list a bit
190 // the dark themes make them hard to see
191 QPalette newPalette = palette();
192 newPalette.setColor(QPalette::Active, QPalette::Window, palette().text().color() );
193 wdgLayerStyles.lstStyleSelector->setPalette(newPalette);
194
195
197
198 connect(m_dropShadow, SIGNAL(globalAngleChanged(int)), SLOT(syncGlobalAngle(int)));
199 connect(m_innerShadow, SIGNAL(globalAngleChanged(int)), SLOT(syncGlobalAngle(int)));
200 connect(m_bevelAndEmboss, SIGNAL(globalAngleChanged(int)), SLOT(syncGlobalAngle(int)));
201
202
203 connect(wdgLayerStyles.btnNewStyle, SIGNAL(clicked()), SLOT(slotNewStyle()));
204 connect(wdgLayerStyles.btnLoadStyle, SIGNAL(clicked()), SLOT(slotLoadStyle()));
205 connect(wdgLayerStyles.btnSaveStyle, SIGNAL(clicked()), SLOT(slotSaveStyle()));
206
207 connect(wdgLayerStyles.chkMasterFxSwitch, SIGNAL(toggled(bool)), SLOT(slotMasterFxSwitchChanged(bool)));
208
209 connect(this, SIGNAL(accepted()), SLOT(slotNotifyOnAccept()));
210 connect(this, SIGNAL(rejected()), SLOT(slotNotifyOnReject()));
211}
void changePage(QListWidgetItem *, QListWidgetItem *)
KisPSDLayerStyleSP m_initialLayerStyle
void slotMasterFxSwitchChanged(bool value)
BevelAndEmboss * m_bevelAndEmboss
PatternOverlay * m_patternOverlay
GradientOverlay * m_gradientOverlay
KisTemporaryResourceStorageLock m_temporaryStorageLock
Ui::WdgStylesDialog wdgLayerStyles
BlendingOptions * m_blendingOptions
void slotBevelAndEmbossChanged(QListWidgetItem *)
void syncGlobalAngle(int angle)
ColorOverlay * m_colorOverlay
KisPSDLayerStyleSP m_layerStyle
void notifyPredefinedStyleSelected(KisPSDLayerStyleSP style)
StylesSelector * m_stylesSelector
KisSignalCompressor * m_configChangedCompressor
void setMainWidget(QWidget *widget)
Definition KoDialog.cpp:354
virtual void setCaption(const QString &caption)
Definition KoDialog.cpp:498
void setButtons(ButtonCodes buttonMask)
Definition KoDialog.cpp:195
void setDefaultButton(ButtonCode id)
Definition KoDialog.cpp:302
@ Ok
Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted)
Definition KoDialog.h:127
@ Cancel
Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected)
Definition KoDialog.h:130
KoDialog(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
Definition KoDialog.cpp:176
rgba palette[MAX_PALETTE]
Definition palette.c:35
The KisPSDLayerStyle class implements loading, saving and applying the PSD layer effects.

References KoDialog::Cancel, changePage(), configChanged(), DropShadow::DropShadowMode, InnerGlow::InnerGlowMode, DropShadow::InnerShadowMode, m_bevelAndEmboss, m_blendingOptions, m_colorOverlay, m_configChangedCompressor, m_contour, m_dropShadow, m_gradientOverlay, m_innerGlow, m_innerShadow, m_outerGlow, m_patternOverlay, m_satin, m_stroke, m_stylesSelector, m_texture, notifyGuiConfigChanged(), notifyPredefinedStyleSelected(), KoDialog::Ok, InnerGlow::OuterGlowMode, palette, KisSignalCompressor::POSTPONE, KisConfig::readEntry(), KoDialog::setButtons(), KoDialog::setCaption(), KoDialog::setDefaultButton(), KoDialog::setMainWidget(), slotBevelAndEmbossChanged(), slotLoadStyle(), slotMasterFxSwitchChanged(), slotNewStyle(), slotNotifyOnAccept(), slotNotifyOnReject(), slotSaveStyle(), syncGlobalAngle(), and wdgLayerStyles.

◆ ~KisDlgLayerStyle()

KisDlgLayerStyle::~KisDlgLayerStyle ( )
override

Definition at line 213 of file kis_dlg_layer_style.cpp.

214{
215}

Member Function Documentation

◆ changePage

void KisDlgLayerStyle::changePage ( QListWidgetItem * current,
QListWidgetItem * previous )
slot

Definition at line 458 of file kis_dlg_layer_style.cpp.

459{
460 if (!current) {
461 current = previous;
462 }
463 wdgLayerStyles.stylesStack->setCurrentIndex(wdgLayerStyles.lstStyleSelector->row(current));
464}

References wdgLayerStyles.

◆ configChanged

void KisDlgLayerStyle::configChanged ( )
signal

◆ notifyGuiConfigChanged

◆ notifyPredefinedStyleSelected

void KisDlgLayerStyle::notifyPredefinedStyleSelected ( KisPSDLayerStyleSP style)
slot

◆ setStyle

void KisDlgLayerStyle::setStyle ( KisPSDLayerStyleSP style)
slot

Upload all the unknown resources into the temporary storage so that immutable resource selectors could see them

Copy all the public resources into the internal storage

We only copy the KoResource-resources into the local storage, while keeping KoCanvasResource-resources still detached, hence we cannot use cloneWithResourcesSnapshot() here, which bakes canvas resources as well

Definition at line 466 of file kis_dlg_layer_style.cpp.

467{
468 // we may self-assign style is some cases
469 if (style != m_layerStyle) {
470 m_layerStyle = style->clone().dynamicCast<KisPSDLayerStyle>();
471 }
473
474 {
476
477 auto localResourcesInterface = m_layerStyle->resourcesInterface().dynamicCast<KisLocalStrokeResources>();
478 if (localResourcesInterface) {
481 Q_FOREACH (KoResourceSP resource, localResourcesInterface->resources()) {
482 auto &globalSource = KisGlobalResourcesInterface::instance()->source(resource->resourceType().first);
483 const KoResourceSignature sig = resource->signature();
484
485 if (!globalSource.exactMatch(sig.md5sum, sig.filename, sig.name)) {
486 KisAllResourcesModel *model = KisResourceModelProvider::resourceModel(resource->resourceType().first);
488 }
489 }
490 } else {
498 }
499
501 }
502
503 {
506 }
507
508 QListWidgetItem *item;
509 item = wdgLayerStyles.lstStyleSelector->item(2);
510 item->setCheckState(m_layerStyle->dropShadow()->effectEnabled() ? Qt::Checked : Qt::Unchecked);
511
512 item = wdgLayerStyles.lstStyleSelector->item(3);
513 item->setCheckState(m_layerStyle->innerShadow()->effectEnabled() ? Qt::Checked : Qt::Unchecked);
514
515 item = wdgLayerStyles.lstStyleSelector->item(4);
516 item->setCheckState(m_layerStyle->outerGlow()->effectEnabled() ? Qt::Checked : Qt::Unchecked);
517
518 item = wdgLayerStyles.lstStyleSelector->item(5);
519 item->setCheckState(m_layerStyle->innerGlow()->effectEnabled() ? Qt::Checked : Qt::Unchecked);
520
521 item = wdgLayerStyles.lstStyleSelector->item(6);
522 item->setCheckState(m_layerStyle->bevelAndEmboss()->effectEnabled() ? Qt::Checked : Qt::Unchecked);
523
524 item = wdgLayerStyles.lstStyleSelector->item(7);
525 item->setCheckState(m_layerStyle->bevelAndEmboss()->contourEnabled() ? Qt::Checked : Qt::Unchecked);
526
527 item = wdgLayerStyles.lstStyleSelector->item(8);
528 item->setCheckState(m_layerStyle->bevelAndEmboss()->textureEnabled() ? Qt::Checked : Qt::Unchecked);
529
530 item = wdgLayerStyles.lstStyleSelector->item(9);
531 item->setCheckState(m_layerStyle->satin()->effectEnabled() ? Qt::Checked : Qt::Unchecked);
532
533 item = wdgLayerStyles.lstStyleSelector->item(10);
534 item->setCheckState(m_layerStyle->colorOverlay()->effectEnabled() ? Qt::Checked : Qt::Unchecked);
535
536 item = wdgLayerStyles.lstStyleSelector->item(11);
537 item->setCheckState(m_layerStyle->gradientOverlay()->effectEnabled() ? Qt::Checked : Qt::Unchecked);
538
539 item = wdgLayerStyles.lstStyleSelector->item(12);
540 item->setCheckState(m_layerStyle->patternOverlay()->effectEnabled() ? Qt::Checked : Qt::Unchecked);
541
542 item = wdgLayerStyles.lstStyleSelector->item(13);
543 item->setCheckState(m_layerStyle->stroke()->effectEnabled() ? Qt::Checked : Qt::Unchecked);
544
545 m_dropShadow->setShadow(m_layerStyle->dropShadow());
546 m_innerShadow->setShadow(m_layerStyle->innerShadow());
547 m_outerGlow->setConfig(m_layerStyle->outerGlow(), m_layerStyle->resourcesInterface());
548 m_innerGlow->setConfig(m_layerStyle->innerGlow(), m_layerStyle->resourcesInterface());
549 m_bevelAndEmboss->setBevelAndEmboss(m_layerStyle->bevelAndEmboss(), m_layerStyle->resourcesInterface());
550 m_satin->setSatin(m_layerStyle->satin());
552 m_gradientOverlay->setGradientOverlay(m_layerStyle->gradientOverlay(), m_layerStyle->resourcesInterface());
553 m_patternOverlay->setPatternOverlay(m_layerStyle->patternOverlay(), m_layerStyle->resourcesInterface());
554 m_stroke->setStroke(m_layerStyle->stroke(), m_layerStyle->resourcesInterface());
555
556 wdgLayerStyles.chkMasterFxSwitch->setChecked(m_layerStyle->isEnabled());
558}
void setBevelAndEmboss(const psd_layer_effects_bevel_emboss *bevelAndEmboss, KisResourcesInterfaceSP resourcesInterface)
void setColorOverlay(const psd_layer_effects_color_overlay *colorOverlay)
void setShadow(const psd_layer_effects_shadow_common *shadow)
void setGradientOverlay(const psd_layer_effects_gradient_overlay *gradient, KisResourcesInterfaceSP resourcesInterface)
void setConfig(const psd_layer_effects_glow_common *innerGlow, KisResourcesInterfaceSP resourcesInterface)
The KisAllresourcesModel class provides access to the cache database for a particular resource type....
bool addResourceDeduplicateFileName(KoResourceSP resource, const QString &storageId=QString("")) override
addResource adds the given resource to the database and storage. If the resource already exists in th...
static KisResourcesInterfaceSP instance()
a KisResourcesInterface-like resources storage for preloaded resources
static KisAllResourcesModel * resourceModel(const QString &resourceType)
A simple wrapper object for the main information about the resource.
void setPatternOverlay(const psd_layer_effects_pattern_overlay *pattern, KisResourcesInterfaceSP resourcesInterface)
void setSatin(const psd_layer_effects_satin *satin)
void setStroke(const psd_layer_effects_stroke *stroke, KisResourcesInterfaceSP resourcesInterface)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
void createLocalResourcesSnapshot(T *object, KisResourcesInterfaceSP globalResourcesInterface=nullptr)

References KisAllResourcesModel::addResourceDeduplicateFileName(), KisRequiredResourcesOperators::createLocalResourcesSnapshot(), KoResourceSignature::filename, KisRequiredResourcesOperators::hasLocalResourcesSnapshot(), KisGlobalResourcesInterface::instance(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_bevelAndEmboss, m_colorOverlay, m_dropShadow, m_gradientOverlay, m_innerGlow, m_innerShadow, m_layerStyle, m_outerGlow, m_patternOverlay, m_sanityLayerStyleDirty, m_satin, m_stroke, m_stylesSelector, m_temporaryStorageLock, KoResourceSignature::md5sum, KoResourceSignature::name, StylesSelector::notifyExternalStyleChanged(), KisResourceModelProvider::resourceModel(), BevelAndEmboss::setBevelAndEmboss(), ColorOverlay::setColorOverlay(), InnerGlow::setConfig(), GradientOverlay::setGradientOverlay(), PatternOverlay::setPatternOverlay(), Satin::setSatin(), DropShadow::setShadow(), Stroke::setStroke(), slotMasterFxSwitchChanged(), KisTemporaryResourceStorageLockAdapter::storageLocation(), style(), and wdgLayerStyles.

◆ slotBevelAndEmbossChanged

void KisDlgLayerStyle::slotBevelAndEmbossChanged ( QListWidgetItem * )
slot

Definition at line 245 of file kis_dlg_layer_style.cpp.

245 {
246 QListWidgetItem *item;
247
248 if (wdgLayerStyles.lstStyleSelector->item(6)->checkState() == Qt::Checked) {
249 // Enable "Contour" (list item 7)
250 item = wdgLayerStyles.lstStyleSelector->item(7);
251 Qt::ItemFlags currentFlags7 = item->flags();
252 item->setFlags(currentFlags7 | Qt::ItemIsEnabled);
253
254 // Enable "Texture" (list item 8)
255 item = wdgLayerStyles.lstStyleSelector->item(8);
256 Qt::ItemFlags currentFlags8 = item->flags();
257 item->setFlags(currentFlags8 | Qt::ItemIsEnabled);
258 }
259 else {
260 // Disable "Contour"
261 item = wdgLayerStyles.lstStyleSelector->item(7);
262 Qt::ItemFlags currentFlags7 = item->flags();
263 item->setFlags(currentFlags7 & (~Qt::ItemIsEnabled));
264
265 // Disable "Texture"
266 item = wdgLayerStyles.lstStyleSelector->item(8);
267 Qt::ItemFlags currentFlags8 = item->flags();
268 item->setFlags(currentFlags8 & (~Qt::ItemIsEnabled));
269 }
270}

References wdgLayerStyles.

◆ slotLoadStyle

void KisDlgLayerStyle::slotLoadStyle ( )
slot

Definition at line 375 of file kis_dlg_layer_style.cpp.

376{
377 KoFileDialog dialog(this, KoFileDialog::OpenFile, "layerstyle");
378 dialog.setDefaultDir(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
379 dialog.setMimeTypeFilters({"application/x-photoshop-style-library"});
380 dialog.setCaption(i18n("Select ASL file"));
381
382 const QString filename = dialog.filename();
383
384 // XXX: implement a resource loader targeting layer style libraries
385 // const auto resource = KisResourceUserOperations::importResourceFileWithUserInput(this, "", ResourceType::LayerStylesLibrary, filename);
386 // if (resource) {
387 // m_stylesSelector->refillCollections();
388 // }
389
390 if (!filename.isEmpty()) {
391 const QFileInfo oldFileInfo(filename);
392
393 // 0. Validate layer style
394 {
396 KIS_ASSERT(!storage.isNull());
397
398 if (!storage->valid()) {
399 qWarning() << "Attempted to import an invalid layer style library!" << filename;
400 QMessageBox::warning(this,
401 i18nc("@title:window", "Krita"),
402 i18n("Could not load layer style library %1.", filename));
403 return;
404 }
405 }
406
407 // 1. Copy the layer style to the resource folder
408 const QString newDir = KoResourcePaths::getAppDataLocation();
409 const QString newName = oldFileInfo.fileName();
410 const QString newLocation = QStringLiteral("%1/%2").arg(newDir, newName);
411
412 const QFileInfo newFileInfo(newLocation);
413
414 if (newFileInfo.exists()) {
415 if (QMessageBox::warning(this,
416 i18nc("@title:window", "Warning"),
417 i18n("There is already a layer style library with this name installed. Do you "
418 "want to overwrite it?"),
419 QMessageBox::Ok | QMessageBox::Cancel)
420 == QMessageBox::Cancel) {
421 return;
422 } else {
423 QFile::remove(newLocation);
424 }
425 }
426
427 QFile::copy(filename, newLocation);
428
429 // 2. Add the layer style as a storage/update database
431 KIS_ASSERT(!storage.isNull());
432 if (!KisResourceLocator::instance()->addStorage(newLocation, storage)) {
433 qWarning() << "Could not add layer style library to the storages" << newLocation;
434 }
436 }
437}
static KisResourceLocator * instance()
static QString getAppDataLocation()
#define KIS_ASSERT(cond)
Definition kis_assert.h:33

References KoResourcePaths::getAppDataLocation(), KisResourceLocator::instance(), KIS_ASSERT, m_stylesSelector, KoFileDialog::OpenFile, and StylesSelector::refillCollections().

◆ slotMasterFxSwitchChanged

void KisDlgLayerStyle::slotMasterFxSwitchChanged ( bool value)
slot

Definition at line 217 of file kis_dlg_layer_style.cpp.

218{
219 wdgLayerStyles.lstStyleSelector->setEnabled(value);
220 wdgLayerStyles.stylesStack->setEnabled(value);
221 wdgLayerStyles.btnNewStyle->setEnabled(value);
222 wdgLayerStyles.btnLoadStyle->setEnabled(value);
223 wdgLayerStyles.btnSaveStyle->setEnabled(value);
225}
float value(const T *src, size_t ch)

References notifyGuiConfigChanged(), value(), and wdgLayerStyles.

◆ slotNewStyle

void KisDlgLayerStyle::slotNewStyle ( )
slot

Definition at line 313 of file kis_dlg_layer_style.cpp.

314{
315 bool success;
316 QString styleName =
317 QInputDialog::getText(this,
318 i18nc("@title:window", "Enter new style name"),
319 i18nc("@label:textbox", "Name:"),
320 QLineEdit::Normal,
321 i18nc("Default name for a new style", "New Style"),
322 &success);
323
324 if (!success)
325 return;
326
327 KisPSDLayerStyleSP clone = this->style()->clone().dynamicCast<KisPSDLayerStyle>();
328 clone->setName(styleName);
329 clone->setUuid(QUuid::createUuid());
330 clone->setFilename(clone->uuid().toString());
331 clone->setValid(true);
332
333 const QString customStylesStorageLocation = "asl/CustomStyles.asl";
334 QString resourceDir = KoResourcePaths::getAppDataLocation();
335 QString storagePath = resourceDir + "/" + customStylesStorageLocation;
336
337 bool resourceAdded = false;
338
339 if (KisResourceLocator::instance()->hasStorage(storagePath)) {
340 // we should side-load dependent resources to make sure they are loaded to the server as well
342 KisAslLayerStyleSerializer::sideLoadLinkedResources(clone.data(), clone->resourcesInterface());
343 clone->setResourcesInterface(KisGlobalResourcesInterface::instance());
344
345 // storage is named by the folder + filename, NOT the full filepath
346 resourceAdded = KisResourceUserOperations::addResourceWithUserInput(this, clone, customStylesStorageLocation);
347 } else {
349 serializer.setStyles(QVector<KisPSDLayerStyleSP>() << clone);
350 serializer.saveToFile(storagePath);
352 resourceAdded = KisResourceLocator::instance()->addStorage(storagePath, storage);
353
355 auto adapter = interface->source<KisPSDLayerStyle>(ResourceType::LayerStyles);
356 clone = adapter.bestMatch(clone->md5Sum(false), clone->filename(), clone->name());
357 resourceAdded = bool(clone);
358 }
359
360 if (resourceAdded) {
361 m_stylesSelector->addNewStyle(customStylesStorageLocation, clone);
362
363 setStyle(clone);
364
365 // focus on the recently added item
366 wdgLayerStyles.stylesStack->setCurrentWidget(m_stylesSelector);
367 }
368}
static void sideLoadLinkedResources(KisPSDLayerStyle *style, KisResourcesInterfaceSP resourcesInterface)
void setStyles(const QVector< KisPSDLayerStyleSP > &styles)
bool saveToFile(const QString &filename)
bool addStorage(const QString &storageLocation, KisResourceStorageSP storage)
addStorage Adds a new resource storage to the database. The storage is will be marked as not pre-inst...
static bool addResourceWithUserInput(QWidget *widgetParent, KoResourceSP resource, QString storageLocation="")
void addNewStyle(const QString &location, const KisPSDLayerStyleSP style)
const QString LayerStyles
QString filename
QString md5Sum(bool generateIfEmpty=true) const

References StylesSelector::addNewStyle(), KisResourceUserOperations::addResourceWithUserInput(), KisResourceLocator::addStorage(), KoResource::filename, KoResourcePaths::getAppDataLocation(), KisRequiredResourcesOperators::hasLocalResourcesSnapshot(), KisGlobalResourcesInterface::instance(), KisResourceLocator::instance(), KIS_SAFE_ASSERT_RECOVER_NOOP, ResourceType::LayerStyles, m_stylesSelector, KoResource::md5Sum(), KisPSDLayerStyle::name, KisAslLayerStyleSerializer::saveToFile(), setStyle(), KisAslLayerStyleSerializer::setStyles(), KisAslLayerStyleSerializer::sideLoadLinkedResources(), style(), and wdgLayerStyles.

◆ slotNotifyOnAccept

void KisDlgLayerStyle::slotNotifyOnAccept ( )
slot

◆ slotNotifyOnReject

◆ slotSaveStyle

void KisDlgLayerStyle::slotSaveStyle ( )
slot

Definition at line 439 of file kis_dlg_layer_style.cpp.

440{
441 QString filename; // default value?
442
443 KoFileDialog dialog(this, KoFileDialog::SaveFile, "layerstyle");
444 dialog.setCaption(i18n("Select ASL file"));
445 dialog.setMimeTypeFilters(QStringList() << "application/x-photoshop-style-library", "application/x-photoshop-style-library");
446 filename = dialog.filename();
447
449
450 KisPSDLayerStyleSP newStyle = style()->clone().dynamicCast<KisPSDLayerStyle>();
451 newStyle->setName(QFileInfo(filename).completeBaseName());
453 styles << newStyle;
454 serializer->setStyles(styles);
455 serializer->saveToFile(filename);
456}
QList< QString > QStringList

References KoFileDialog::SaveFile, and style().

◆ style()

KisPSDLayerStyleSP KisDlgLayerStyle::style ( ) const

Definition at line 560 of file kis_dlg_layer_style.cpp.

561{
562 // create a new local resource storage for the newly created resources,
563 // they are not uploaded to the database until the style itself is
564 // saved in the database
566
567 m_layerStyle->setEnabled(wdgLayerStyles.chkMasterFxSwitch->isChecked());
568
569 m_layerStyle->dropShadow()->setEffectEnabled(wdgLayerStyles.lstStyleSelector->item(2)->checkState() == Qt::Checked);
570 m_layerStyle->innerShadow()->setEffectEnabled(wdgLayerStyles.lstStyleSelector->item(3)->checkState() == Qt::Checked);
571 m_layerStyle->outerGlow()->setEffectEnabled(wdgLayerStyles.lstStyleSelector->item(4)->checkState() == Qt::Checked);
572 m_layerStyle->innerGlow()->setEffectEnabled(wdgLayerStyles.lstStyleSelector->item(5)->checkState() == Qt::Checked);
573 m_layerStyle->bevelAndEmboss()->setEffectEnabled(wdgLayerStyles.lstStyleSelector->item(6)->checkState() == Qt::Checked);
574 m_layerStyle->bevelAndEmboss()->setContourEnabled(wdgLayerStyles.lstStyleSelector->item(7)->checkState() == Qt::Checked);
575 m_layerStyle->bevelAndEmboss()->setTextureEnabled(wdgLayerStyles.lstStyleSelector->item(8)->checkState() == Qt::Checked);
576 m_layerStyle->satin()->setEffectEnabled(wdgLayerStyles.lstStyleSelector->item(9)->checkState() == Qt::Checked);
577 m_layerStyle->colorOverlay()->setEffectEnabled(wdgLayerStyles.lstStyleSelector->item(10)->checkState() == Qt::Checked);
578 m_layerStyle->gradientOverlay()->setEffectEnabled(wdgLayerStyles.lstStyleSelector->item(11)->checkState() == Qt::Checked);
579 m_layerStyle->patternOverlay()->setEffectEnabled(wdgLayerStyles.lstStyleSelector->item(12)->checkState() == Qt::Checked);
580 m_layerStyle->stroke()->setEffectEnabled(wdgLayerStyles.lstStyleSelector->item(13)->checkState() == Qt::Checked);
581
582
583 m_dropShadow->fetchShadow(m_layerStyle->dropShadow());
584 m_innerShadow->fetchShadow(m_layerStyle->innerShadow());
585 m_outerGlow->fetchConfig(m_layerStyle->outerGlow(), newLocalStyleResources);
586 m_innerGlow->fetchConfig(m_layerStyle->innerGlow(), newLocalStyleResources);
587 m_bevelAndEmboss->fetchBevelAndEmboss(m_layerStyle->bevelAndEmboss(), newLocalStyleResources);
590 m_gradientOverlay->fetchGradientOverlay(m_layerStyle->gradientOverlay(), newLocalStyleResources);
591 m_patternOverlay->fetchPatternOverlay(m_layerStyle->patternOverlay(), newLocalStyleResources);
592 m_stroke->fetchStroke(m_layerStyle->stroke(), newLocalStyleResources);
593
594 // reset the resources interface to the one with new resources
595 m_layerStyle->setResourcesInterface(newLocalStyleResources);
596
599
600 return m_layerStyle;
601}
void fetchBevelAndEmboss(psd_layer_effects_bevel_emboss *bevelAndEmboss, QSharedPointer< KisLocalStrokeResources > uploadResourcesInterface) const
void fetchColorOverlay(psd_layer_effects_color_overlay *colorOverlay) const
void fetchShadow(psd_layer_effects_shadow_common *shadow) const
void fetchGradientOverlay(psd_layer_effects_gradient_overlay *gradient, QSharedPointer< KisLocalStrokeResources > uploadResourcesInterface) const
void fetchConfig(psd_layer_effects_glow_common *innerGlow, QSharedPointer< KisLocalStrokeResources > uploadResourcesInterface) const
void fetchPatternOverlay(psd_layer_effects_pattern_overlay *pattern, QSharedPointer< KisLocalStrokeResources > uploadResourcesInterface) const
void fetchSatin(psd_layer_effects_satin *satin) const
void fetchStroke(psd_layer_effects_stroke *stroke, QSharedPointer< KisLocalStrokeResources > uploadResourcesInterface) const

References BevelAndEmboss::fetchBevelAndEmboss(), ColorOverlay::fetchColorOverlay(), InnerGlow::fetchConfig(), GradientOverlay::fetchGradientOverlay(), PatternOverlay::fetchPatternOverlay(), Satin::fetchSatin(), DropShadow::fetchShadow(), Stroke::fetchStroke(), m_bevelAndEmboss, m_colorOverlay, m_dropShadow, m_gradientOverlay, m_innerGlow, m_innerShadow, m_layerStyle, m_outerGlow, m_patternOverlay, m_sanityLayerStyleDirty, m_satin, m_stroke, m_stylesSelector, StylesSelector::notifyExternalStyleChanged(), and wdgLayerStyles.

◆ syncGlobalAngle

void KisDlgLayerStyle::syncGlobalAngle ( int angle)
slot

Definition at line 603 of file kis_dlg_layer_style.cpp.

604{
605 if (m_layerStyle->dropShadow()->useGlobalLight()) {
606 m_layerStyle->dropShadow()->setAngle(angle);
607 m_dropShadow->setShadow(m_layerStyle->dropShadow());
608 }
609 if (m_layerStyle->innerShadow()->useGlobalLight()) {
610 m_layerStyle->innerShadow()->setAngle(angle);
611 m_innerShadow->setShadow(m_layerStyle->innerShadow());
612 }
613 if (m_layerStyle->bevelAndEmboss()->useGlobalLight()) {
614 m_layerStyle->bevelAndEmboss()->setAngle(angle);
615 m_bevelAndEmboss->setBevelAndEmboss(m_layerStyle->bevelAndEmboss(), m_layerStyle->resourcesInterface());
616 }
617}

References m_bevelAndEmboss, m_dropShadow, m_innerShadow, m_layerStyle, BevelAndEmboss::setBevelAndEmboss(), and DropShadow::setShadow().

Member Data Documentation

◆ m_bevelAndEmboss

BevelAndEmboss* KisDlgLayerStyle::m_bevelAndEmboss
private

Definition at line 295 of file kis_dlg_layer_style.h.

◆ m_blendingOptions

BlendingOptions* KisDlgLayerStyle::m_blendingOptions
private

Definition at line 296 of file kis_dlg_layer_style.h.

◆ m_colorOverlay

ColorOverlay* KisDlgLayerStyle::m_colorOverlay
private

Definition at line 297 of file kis_dlg_layer_style.h.

◆ m_configChangedCompressor

KisSignalCompressor* KisDlgLayerStyle::m_configChangedCompressor
private

Definition at line 310 of file kis_dlg_layer_style.h.

◆ m_contour

Contour* KisDlgLayerStyle::m_contour
private

Definition at line 298 of file kis_dlg_layer_style.h.

◆ m_dropShadow

DropShadow* KisDlgLayerStyle::m_dropShadow
private

Definition at line 299 of file kis_dlg_layer_style.h.

◆ m_gradientOverlay

GradientOverlay* KisDlgLayerStyle::m_gradientOverlay
private

Definition at line 300 of file kis_dlg_layer_style.h.

◆ m_initialLayerStyle

KisPSDLayerStyleSP KisDlgLayerStyle::m_initialLayerStyle
private

Definition at line 291 of file kis_dlg_layer_style.h.

◆ m_innerGlow

InnerGlow* KisDlgLayerStyle::m_innerGlow
private

Definition at line 301 of file kis_dlg_layer_style.h.

◆ m_innerShadow

DropShadow* KisDlgLayerStyle::m_innerShadow
private

Definition at line 302 of file kis_dlg_layer_style.h.

◆ m_isSwitchingPredefinedStyle

bool KisDlgLayerStyle::m_isSwitchingPredefinedStyle
private

Definition at line 311 of file kis_dlg_layer_style.h.

◆ m_layerStyle

KisPSDLayerStyleSP KisDlgLayerStyle::m_layerStyle
private

Definition at line 290 of file kis_dlg_layer_style.h.

◆ m_outerGlow

InnerGlow* KisDlgLayerStyle::m_outerGlow
private

Definition at line 303 of file kis_dlg_layer_style.h.

◆ m_patternOverlay

PatternOverlay* KisDlgLayerStyle::m_patternOverlay
private

Definition at line 304 of file kis_dlg_layer_style.h.

◆ m_sanityLayerStyleDirty

bool KisDlgLayerStyle::m_sanityLayerStyleDirty
mutableprivate

Used for debugging purposes only to track if m_layerStyle is in sync with what is stored in the GUI

Definition at line 317 of file kis_dlg_layer_style.h.

◆ m_satin

Satin* KisDlgLayerStyle::m_satin
private

Definition at line 305 of file kis_dlg_layer_style.h.

◆ m_stroke

Stroke* KisDlgLayerStyle::m_stroke
private

Definition at line 306 of file kis_dlg_layer_style.h.

◆ m_stylesSelector

StylesSelector* KisDlgLayerStyle::m_stylesSelector
private

Definition at line 307 of file kis_dlg_layer_style.h.

◆ m_temporaryStorageLock

KisTemporaryResourceStorageLock KisDlgLayerStyle::m_temporaryStorageLock
private

Definition at line 319 of file kis_dlg_layer_style.h.

◆ m_texture

Texture* KisDlgLayerStyle::m_texture
private

Definition at line 308 of file kis_dlg_layer_style.h.

◆ wdgLayerStyles

Ui::WdgStylesDialog KisDlgLayerStyle::wdgLayerStyles
private

Definition at line 293 of file kis_dlg_layer_style.h.


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