Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_dlg_layer_style.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 Boudewijn Rempt <boud@valdyas.org>
3 * SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
8
9#include <QBuffer>
10#include <QCheckBox>
11#include <QDial>
12#include <QInputDialog>
13#include <QItemSelectionModel>
14#include <QListWidget>
15#include <QListWidgetItem>
16#include <QSpinBox>
17#include <QStackedWidget>
18#include <QTreeWidget>
19#include <QUuid>
20#include <QWidget>
21
22#include <KoColorPopupButton.h>
25#include <KoMD5Generator.h>
27
28#include "KisResourceTypes.h"
30#include "kis_config.h"
31#include "kis_cmb_contour.h"
32#include "kis_cmb_gradient.h"
34#include "kis_psd_layer_style.h"
35#include <KisAslStorage.h>
36#include <KisResourceLocator.h>
38#include <KisStorageModel.h>
40
41#include "kis_signals_blocker.h"
48
49#include <KoFileDialog.h>
50#include <QMessageBox>
51
52
53template <typename Type, typename TypeSP = QSharedPointer<Type>>
55 KisResourcesInterfaceSP resourcesInterface)
56{
57 if (signature.type.isEmpty()) return nullptr;
58
59 auto source = resourcesInterface->source<Type>(signature.type);
60
61 auto resource = source.bestMatch(signature.md5sum, signature.filename, signature.name);
62 if (!resource) {
63 qWarning() << "WARNING: failed to find a resource for layer sytle" << signature;
64 resource = source.fallbackResource();
65 }
66
67 return resource ? resource->clone().template dynamicCast<Type>() : nullptr;
68}
69
71{
72 return fetchResourceLazy<KoAbstractGradient>(signature, resourcesInterface);
73}
74
76{
77 return fetchResourceLazy<KoPattern>(signature, resourcesInterface);
78}
79
81{
82 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(gradient, nullptr);
83
84 auto clonedGradient = gradient->clone().dynamicCast<KoAbstractGradient>();
85
86 {
87 QBuffer buf;
88 buf.open(QFile::WriteOnly);
89 clonedGradient->saveToDevice(&buf);
90 buf.close();
91 clonedGradient->setMD5Sum(KoMD5Generator::generateHash(buf.data()));
92 }
93
94 clonedGradient->updatePreview();
95
96 return clonedGradient;
97}
98
100 : KoDialog(parent)
101 , m_layerStyle(layerStyle)
102 , m_initialLayerStyle(layerStyle->clone().dynamicCast<KisPSDLayerStyle>())
103 , m_isSwitchingPredefinedStyle(false)
104 , m_sanityLayerStyleDirty(false)
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}
212
216
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}
226
236
244
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}
271
279
287
288bool checkCustomNameAvailable(const QString &name)
289{
290 Q_UNUSED(name);
291 const QString customName = "CustomStyles.asl";
293 KoResourceSP resource = server->resource("", "", customName);
294 return !resource;
295}
296
297QString selectAvailableStyleName(const QString &name)
298{
299 QString finalName = name;
300 if (checkCustomNameAvailable(finalName)) {
301 return finalName;
302 }
303
304 int i = 0;
305
306 do {
307 finalName = QString("%1%2").arg(name).arg(i++);
308 } while (!checkCustomNameAvailable(finalName));
309
310 return finalName;
311}
312
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}
369
370QString createNewAslPath(QString resourceFolderPath, QString filename)
371{
372 return resourceFolderPath + '/' + "asl" + '/' + filename;
373}
374
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}
438
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}
457
458void KisDlgLayerStyle::changePage(QListWidgetItem *current, QListWidgetItem *previous)
459{
460 if (!current) {
461 current = previous;
462 }
463 wdgLayerStyles.stylesStack->setCurrentIndex(wdgLayerStyles.lstStyleSelector->row(current));
464}
465
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}
559
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}
602
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}
618
619/********************************************************************/
620/***** Styles Selector **********************************************/
621/********************************************************************/
622
624 : QSortFilterProxyModel(parent)
625{
626
627}
628
630{
631 m_enableFiltering = enableFiltering;
632 invalidateFilter();
633}
634
636{
637 m_locationToFilter = location;
638 invalidateFilter();
639}
640
641bool StylesSelector::LocationProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
642{
643 Q_UNUSED(source_parent);
644 if (!m_enableFiltering) {
645 return true;
646 }
647
648 QModelIndex idx = sourceModel()->index(source_row, 0);
649 QString location = sourceModel()->data(idx, Qt::UserRole + KisAbstractResourceModel::Location).toString();
650 qDebug() << sourceModel()->data(idx, Qt::UserRole + KisAbstractResourceModel::Location).toString()
651 << sourceModel()->data(idx, Qt::UserRole + KisAbstractResourceModel::Name).toString();
652 return location == m_locationToFilter;
653}
654
655
656
657
658class StyleItem : public QListWidgetItem {
659public:
661 : QListWidgetItem(style->name())
662 , m_style(style)
663 {
664 }
665
666public:
668};
669
670
672 : QWidget(parent)
673{
674 ui.setupUi(this);
675
678 m_locationsProxyModel->setSourceModel(m_resourceModel);
680
681 ui.listStyles->setModel(m_locationsProxyModel);
682 ui.listStyles->setModelColumn(KisAbstractResourceModel::Name);
683 // XXX: support editing
684 // KisResourceModel doesn't support data with the EditRole
685 ui.listStyles->setEditTriggers(QAbstractItemView::EditTrigger::NoEditTriggers);
686
687 connect(ui.cmbStyleCollections, SIGNAL(textActivated(QString)), this, SLOT(loadStyles(QString)));
688 connect(ui.listStyles, SIGNAL(clicked(QModelIndex)), this, SLOT(selectStyle(QModelIndex)));
689
691
692 if (ui.cmbStyleCollections->count()) {
693 ui.cmbStyleCollections->setCurrentIndex(0);
695 loadStyles(ui.cmbStyleCollections->currentText());
696 }
697}
698
700{
701 QStringList locationsList;
702 for (int i = 0; i < m_resourceModel->rowCount(); i++) {
703 QModelIndex idx = m_resourceModel->index(i, 0);
704 QString location = m_resourceModel->data(idx, Qt::UserRole + KisAbstractResourceModel::Location).toString();
705 if (!locationsList.contains(location)) {
706 locationsList << location;
707 }
708 }
709 ui.cmbStyleCollections->clear();
710 ui.cmbStyleCollections->addItems(locationsList);
711}
712
713void StylesSelector::notifyExternalStyleChanged(const QString &name, const QUuid &uuid)
714{
715 Q_UNUSED(name);
716 Q_UNUSED(uuid);
717 /*
718 int currentIndex = -1;
719
720 for (int i = 0; i < ui.listStyles->count(); i++ ) {
721 StyleItem *item = dynamic_cast<StyleItem*>(ui.listStyles->item(i));
722
723 QString itemName = item->m_style->name();
724
725 if (itemName == name) {
726 bool isDirty = item->m_style->uuid() != uuid;
727
728 if (isDirty) {
729 itemName += "*";
730 }
731
732 currentIndex = i;
733 }
734
735 item->setText(itemName);
736 }
737
738 ui.listStyles->setCurrentRow(currentIndex);
739 */
740}
741
742void StylesSelector::loadStyles(const QString &name)
743{
745}
746
747void StylesSelector::selectStyle(QModelIndex current)
748{
749
750 // the index is from the proxy model
751 QModelIndex sourceModelIndex = m_locationsProxyModel->mapToSource(current);
752 KoResourceSP resource = m_resourceModel->resourceForIndex(sourceModelIndex);
753 KisPSDLayerStyleSP layerStyle = resource.dynamicCast<KisPSDLayerStyle>();
754 qDebug() << "StylesSelector::selectStyle" << (resource.isNull() ? "(null)" : resource->name()) << (layerStyle.isNull() ? "(null)" : layerStyle->name());
755 if (layerStyle) {
756 Q_EMIT styleSelected(layerStyle);
757 }
758
759 /*
760 StyleItem *item = dynamic_cast<StyleItem*>(current);
761 if (item) {
762 Q_EMIT styleSelected(item->m_style);
763 }
764 */
765}
766
767void StylesSelector::loadCollection(const QString &fileName)
768{
769 Q_UNUSED(fileName);
770 // TODO: RESOURCES: implement or remove
771 warnKrita << "Collection cannot be loaded, because we do not use collections now; please use KisAslStorage instead.";
772
773 /*
774 if (!QFileInfo(fileName).exists()) {
775 warnKrita << "Loaded style collection doesn't exist!";
776 return;
777 }
778
779 KisPSDLayerStyleCollectionResourceSP collection = KisPSDLayerStyleCollectionResourceSP(new KisPSDLayerStyleCollectionResource(fileName));
780
781 collection->load();
782
783 KoResourceServer<KisPSDLayerStyleCollectionResource> *server = KisResourceServerProvider::instance()->layerStyleCollectionServer();
784 collection->setFilename(server->saveLocation() + '/' + collection->name());
785 server->addResource(collection);
786
787 refillCollections();
788
789 int index = ui.cmbStyleCollections->findText(collection->name());
790 ui.cmbStyleCollections->setCurrentIndex(index);
791 loadStyles(collection->name());
792 */
793}
794
796{
797 ENTER_FUNCTION() << "MODEL RESET!!!";
799}
800
801void StylesSelector::addNewStyle(const QString &location, KisPSDLayerStyleSP style)
802{
803 // m_resourceModel = new KisResourceModel(ResourceType::LayerStyles, this);
804 // m_locationsProxyModel->setSourceModel(m_resourceModel);
805 // ui.listStyles->setModel(m_locationsProxyModel);
806
808 ui.listStyles->reset();
809 ui.cmbStyleCollections->setCurrentText(location);
810 loadStyles(ui.cmbStyleCollections->currentText());
811 KIS_ASSERT(m_resourceModel->resourceForId(style->resourceId()));
812 ui.listStyles->setCurrentIndex(m_locationsProxyModel->mapFromSource(
813 m_resourceModel->indexForResource(style).siblingAtColumn(ui.listStyles->modelColumn())));
814
815 notifyExternalStyleChanged(style->name(), style->uuid());
816}
817
818/********************************************************************/
819/***** Bevel and Emboss *********************************************/
820/********************************************************************/
821
822BevelAndEmboss::BevelAndEmboss(Contour *contour, Texture *texture, QWidget *parent)
823 : QWidget(parent)
824 , m_contour(contour)
825 , m_texture(texture)
826{
827 ui.setupUi(this);
828
829 // Structure
830 ui.intDepth->setRange(0, 100);
831 KisSpinBoxI18nHelper::setText(ui.intDepth, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
832
833 ui.intSize->setRange(0, 250);
834 ui.intSize->setSuffix(i18n(" px"));
835 ui.intSize->setExponentRatio(2.0);
836
837 ui.intSoften->setRange(0, 18);
838 ui.intSoften->setSuffix(i18n(" px"));
839
840 connect(ui.cmbStyle, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
841 connect(ui.cmbTechnique, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
842 connect(ui.intDepth, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
843 connect(ui.cmbDirection, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
844 connect(ui.intSize, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
845 connect(ui.intSoften, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
846
847 // Shading
848 ui.intOpacity->setRange(0, 100);
849 KisSpinBoxI18nHelper::setText(ui.intOpacity, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
850
851 ui.intOpacity2->setRange(0, 100);
852 KisSpinBoxI18nHelper::setText(ui.intOpacity2, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
853
854 ui.angleSelector->enableGlobalLight(true);
855 connect(ui.angleSelector, SIGNAL(globalAngleChanged(int)), SIGNAL(globalAngleChanged(int)));
856 connect(ui.angleSelector, SIGNAL(configChanged()), SIGNAL(configChanged()));
857
858 connect(ui.intAltitude, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
859 connect(ui.cmbContour, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
860 connect(ui.chkAntiAliased, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
861 connect(ui.cmbHighlightMode, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
862 connect(ui.bnHighlightColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged()));
863 connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
864 connect(ui.cmbShadowMode, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
865 connect(ui.bnShadowColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged()));
866 connect(ui.intOpacity2, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
867
868 // Contour
869 m_contour->ui.intRange->setRange(1, 100);
871 i18nc("{n} is the number value, % is the percent sign", "{n}%"));
872
873 connect(m_contour->ui.cmbContour, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
874 connect(m_contour->ui.chkAntiAliased, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
875 connect(m_contour->ui.intRange, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
876
877 // Texture
878 m_texture->ui.intScale->setRange(0, 100);
880 i18nc("{n} is the number value, % is the percent sign", "{n}%"));
881
882 m_texture->ui.intDepth->setRange(-1000, 1000);
884 i18nc("{n} is the number value, % is the percent sign", "{n}%"));
885
886 connect(m_texture->ui.patternChooser, SIGNAL(resourceSelected(KoResourceSP )), SIGNAL(configChanged()));
887 connect(m_texture->ui.intScale, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
888 connect(m_texture->ui.intDepth, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
889 connect(m_texture->ui.chkInvert, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
890 connect(m_texture->ui.chkLinkWithLayer, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
891}
892
894{
895 ui.cmbStyle->setCurrentIndex((int)bevelAndEmboss->style());
896 ui.cmbTechnique->setCurrentIndex((int)bevelAndEmboss->technique());
897 ui.intDepth->setValue(bevelAndEmboss->depth());
898 ui.cmbDirection->setCurrentIndex((int)bevelAndEmboss->direction());
899 ui.intSize->setValue(bevelAndEmboss->size());
900 ui.intSoften->setValue(bevelAndEmboss->soften());
901
902 ui.angleSelector->setValue(bevelAndEmboss->angle());
903 ui.angleSelector->setUseGlobalLight(bevelAndEmboss->useGlobalLight());
904
905 ui.intAltitude->setValue(bevelAndEmboss->altitude());
906 // FIXME: curve editing
907 // ui.cmbContour;
908 ui.chkAntiAliased->setChecked(bevelAndEmboss->glossAntiAliased());
909 ui.cmbHighlightMode->selectCompositeOp(KoID(bevelAndEmboss->highlightBlendMode()));
910 ui.bnHighlightColor->setColor(bevelAndEmboss->highlightColor());
911 ui.intOpacity->setValue(bevelAndEmboss->highlightOpacity());
912 ui.cmbShadowMode->selectCompositeOp(KoID(bevelAndEmboss->shadowBlendMode()));
913 ui.bnShadowColor->setColor(bevelAndEmboss->shadowColor());
914 ui.intOpacity2->setValue(bevelAndEmboss->shadowOpacity());
915
916 // FIXME: curve editing
917 // m_contour->ui.cmbContour;
918 m_contour->ui.chkAntiAliased->setChecked(bevelAndEmboss->antiAliased());
919 m_contour->ui.intRange->setValue(bevelAndEmboss->contourRange());
920
921 KoPatternSP patternResource = fetchPatternLazy(bevelAndEmboss->texturePatternLink(), resourcesInterface);
922 if (patternResource) {
923 m_texture->ui.patternChooser->setCurrentPattern(patternResource);
924 }
925 m_texture->ui.intScale->setValue(bevelAndEmboss->textureScale());
926 m_texture->ui.intDepth->setValue(bevelAndEmboss->textureDepth());
927 m_texture->ui.chkInvert->setChecked(bevelAndEmboss->textureInvert());
928 m_texture->ui.chkLinkWithLayer->setChecked(bevelAndEmboss->textureAlignWithLayer());
929}
930
932{
933 bevelAndEmboss->setStyle((psd_bevel_style)ui.cmbStyle->currentIndex());
934 bevelAndEmboss->setTechnique((psd_technique_type)ui.cmbTechnique->currentIndex());
935 bevelAndEmboss->setDepth(ui.intDepth->value());
936 bevelAndEmboss->setDirection((psd_direction)ui.cmbDirection->currentIndex());
937 bevelAndEmboss->setSize(ui.intSize->value());
938 bevelAndEmboss->setSoften(ui.intSoften->value());
939
940 bevelAndEmboss->setAngle(ui.angleSelector->value());
941 bevelAndEmboss->setUseGlobalLight(ui.angleSelector->useGlobalLight());
942 bevelAndEmboss->setAltitude(ui.intAltitude->value());
943 bevelAndEmboss->setGlossAntiAliased(ui.chkAntiAliased->isChecked());
944 bevelAndEmboss->setHighlightBlendMode(ui.cmbHighlightMode->selectedCompositeOp().id());
945 bevelAndEmboss->setHighlightColor(ui.bnHighlightColor->color());
946 bevelAndEmboss->setHighlightOpacity(ui.intOpacity->value());
947 bevelAndEmboss->setShadowBlendMode(ui.cmbShadowMode->selectedCompositeOp().id());
948 bevelAndEmboss->setShadowColor(ui.bnShadowColor->color());
949 bevelAndEmboss->setShadowOpacity(ui.intOpacity2->value());
950
951 // FIXME: curve editing
952 bevelAndEmboss->setAntiAliased(m_contour->ui.chkAntiAliased->isChecked());
953 bevelAndEmboss->setContourRange(m_contour->ui.intRange->value());
954
955 auto patternResource = m_texture->ui.patternChooser->currentResource(true).staticCast<KoPattern>();
956 if (patternResource) {
957 auto clonedPatternResource = patternResource->clone().dynamicCast<KoPattern>();
958 bevelAndEmboss->setTexturePattern(clonedPatternResource);
959 uploadResourcesInterface->addResource(clonedPatternResource);
960 }
961
962 bevelAndEmboss->setTextureScale(m_texture->ui.intScale->value());
963 bevelAndEmboss->setTextureDepth(m_texture->ui.intDepth->value());
964 bevelAndEmboss->setTextureInvert(m_texture->ui.chkInvert->isChecked());
965 bevelAndEmboss->setTextureAlignWithLayer(m_texture->ui.chkLinkWithLayer->isChecked());
966}
967
968
969/********************************************************************/
970/***** Texture *********************************************/
971/********************************************************************/
972
973Texture::Texture(QWidget *parent)
974 : QWidget(parent)
975{
976 ui.setupUi(this);
977}
978
979/********************************************************************/
980/***** Contour *********************************************/
981/********************************************************************/
982
983Contour::Contour(QWidget *parent)
984 : QWidget(parent)
985{
986 ui.setupUi(this);
987}
988
989
990/********************************************************************/
991/***** Blending Options *********************************************/
992/********************************************************************/
993
995 : QWidget(parent)
996{
997 ui.setupUi(this);
998
999 // FIXME: Blend options are not implemented yet
1000 ui.grpBlendingOptions->setTitle(QString("%1 (%2)").arg(ui.grpBlendingOptions->title()).arg(i18n("Not Implemented Yet")));
1001 ui.grpBlendingOptions->setEnabled(false);
1002
1003}
1004
1005
1006/********************************************************************/
1007/***** Color Overlay *********************************************/
1008/********************************************************************/
1009
1010
1012 : QWidget(parent)
1013{
1014 ui.setupUi(this);
1015
1016 ui.intOpacity->setRange(0, 100);
1017 KisSpinBoxI18nHelper::setText(ui.intOpacity, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1018
1019 connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1020 connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1021 connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged()));
1022}
1023
1025{
1026 ui.cmbCompositeOp->selectCompositeOp(KoID(colorOverlay->blendMode()));
1027 ui.intOpacity->setValue(colorOverlay->opacity());
1028 ui.bnColor->setColor(colorOverlay->color());
1029}
1030
1032{
1033 colorOverlay->setBlendMode(ui.cmbCompositeOp->selectedCompositeOp().id());
1034 colorOverlay->setOpacity(ui.intOpacity->value());
1035 colorOverlay->setColor(ui.bnColor->color());
1036}
1037
1038
1039/********************************************************************/
1040/***** Drop Shadow **************************************************/
1041/********************************************************************/
1042
1043DropShadow::DropShadow(Mode mode, QWidget *parent)
1044 : QWidget(parent),
1045 m_mode(mode)
1046{
1047 ui.setupUi(this);
1048
1049 ui.intOpacity->setRange(0, 100);
1050 KisSpinBoxI18nHelper::setText(ui.intOpacity, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1051
1052 ui.intDistance->setRange(0, 500);
1053 ui.intDistance->setSuffix(i18n(" px"));
1054 ui.intDistance->setExponentRatio(3.0);
1055
1056 ui.intSpread->setRange(0, 100);
1057 KisSpinBoxI18nHelper::setText(ui.intSpread, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1058
1059 ui.intSize->setRange(0, 250);
1060 ui.intSize->setSuffix(i18n(" px"));
1061 ui.intSize->setExponentRatio(2.0);
1062
1063 ui.intNoise->setRange(0, 100);
1064 KisSpinBoxI18nHelper::setText(ui.intNoise, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1065
1066 ui.angleSelector->enableGlobalLight(true);
1067 connect(ui.angleSelector, SIGNAL(globalAngleChanged(int)), SIGNAL(globalAngleChanged(int)));
1068 connect(ui.angleSelector, SIGNAL(configChanged()), SIGNAL(configChanged()));
1069
1070 // connect everything to configChanged() signal
1071 connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1072 connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1073 connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged()));
1074
1075 connect(ui.intDistance, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1076 connect(ui.intSpread, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1077 connect(ui.intSize, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1078
1079 connect(ui.cmbContour, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1080 connect(ui.chkAntiAliased, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1081 connect(ui.intNoise, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1082
1083 connect(ui.chkLayerKnocksOutDropShadow, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1084
1085 if (m_mode == InnerShadowMode) {
1086 ui.chkLayerKnocksOutDropShadow->setVisible(false);
1087 ui.grpMain->setTitle(i18n("Inner Shadow"));
1088 ui.lblSpread->setText(i18n("Choke:"));
1089 }
1090}
1091
1093{
1094 ui.cmbCompositeOp->selectCompositeOp(KoID(shadow->blendMode()));
1095 ui.intOpacity->setValue(shadow->opacity());
1096 ui.bnColor->setColor(shadow->color());
1097
1098 ui.angleSelector->setValue(shadow->angle());
1099 ui.angleSelector->setUseGlobalLight(shadow->useGlobalLight());
1100
1101 ui.intDistance->setValue(shadow->distance());
1102 ui.intSpread->setValue(shadow->spread());
1103 ui.intSize->setValue(shadow->size());
1104
1105 // FIXME: curve editing
1106 // ui.cmbContour;
1107 ui.chkAntiAliased->setChecked(shadow->antiAliased());
1108
1109 ui.intNoise->setValue(shadow->noise());
1110
1111 if (m_mode == DropShadowMode) {
1112 const psd_layer_effects_drop_shadow *realDropShadow = dynamic_cast<const psd_layer_effects_drop_shadow*>(shadow);
1113 KIS_ASSERT_RECOVER_NOOP(realDropShadow);
1114
1115 ui.chkLayerKnocksOutDropShadow->setChecked(shadow->knocksOut());
1116 }
1117}
1118
1120{
1121 shadow->setBlendMode(ui.cmbCompositeOp->selectedCompositeOp().id());
1122 shadow->setOpacity(ui.intOpacity->value());
1123 shadow->setColor(ui.bnColor->color());
1124
1125 shadow->setAngle(ui.angleSelector->value());
1126 shadow->setUseGlobalLight(ui.angleSelector->useGlobalLight());
1127
1128 shadow->setDistance(ui.intDistance->value());
1129 shadow->setSpread(ui.intSpread->value());
1130 shadow->setSize(ui.intSize->value());
1131
1132 // FIXME: curve editing
1133 // ui.cmbContour;
1134 shadow->setAntiAliased(ui.chkAntiAliased->isChecked());
1135 shadow->setNoise(ui.intNoise->value());
1136
1137 if (m_mode == DropShadowMode) {
1138 psd_layer_effects_drop_shadow *realDropShadow = dynamic_cast<psd_layer_effects_drop_shadow*>(shadow);
1139 KIS_ASSERT_RECOVER_NOOP(realDropShadow);
1140
1141 realDropShadow->setKnocksOut(ui.chkLayerKnocksOutDropShadow->isChecked());
1142 }
1143}
1144
1145/********************************************************************/
1146/***** Gradient Overlay *********************************************/
1147/********************************************************************/
1148
1150 : QWidget(parent)
1151{
1152 ui.setupUi(this);
1153
1154 ui.intOpacity->setRange(0, 100);
1155 KisSpinBoxI18nHelper::setText(ui.intOpacity, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1156
1157 ui.intScale->setRange(0, 100);
1158 KisSpinBoxI18nHelper::setText(ui.intScale, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1159
1160 ui.angleSelector->angleSelector()->setResetAngle(90.0);
1161
1162 ui.cmbGradient->setCanvasResourcesInterface(resourceProvider->resourceManager()->canvasResourcesInterface());
1163
1164 connect(ui.angleSelector, SIGNAL(configChanged()), SIGNAL(configChanged()));
1165 connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1166 connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1167 connect(ui.cmbGradient, SIGNAL(gradientChanged(KoAbstractGradientSP)), SIGNAL(configChanged()));
1168 connect(ui.chkReverse, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1169 connect(ui.cmbStyle, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1170 connect(ui.chkAlignWithLayer, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1171 connect(ui.intScale, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1172 connect(ui.chkDither, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1173}
1174
1176{
1177 ui.cmbCompositeOp->selectCompositeOp(KoID(config->blendMode()));
1178 ui.intOpacity->setValue(config->opacity());
1179
1180 KoAbstractGradientSP gradient = fetchGradientLazy(config->gradientLink(), resourcesInterface);
1181 if (gradient) {
1182 ui.cmbGradient->setGradient(gradient);
1183 }
1184
1185 ui.chkReverse->setChecked(config->reverse());
1186 ui.cmbStyle->setCurrentIndex((int)config->style());
1187 ui.chkAlignWithLayer->setChecked(config->alignWithLayer());
1188 ui.chkAlignWithLayer->setCheckable(true);
1189 ui.angleSelector->setValue(config->angle());
1190 ui.intScale->setValue(config->scale());
1191 ui.chkDither->setChecked(config->dither());
1192}
1193
1195{
1196 config->setBlendMode(ui.cmbCompositeOp->selectedCompositeOp().id());
1197 config->setOpacity(ui.intOpacity->value());
1198
1199 auto gradient = ui.cmbGradient->gradient();
1200 if (gradient) {
1201 auto clonedGradient = cloneAndPrepareGradientFromGUI(gradient);
1202 uploadResourcesInterface->addResource(clonedGradient);
1203 config->setGradient(clonedGradient);
1204 }
1205
1206 config->setReverse(ui.chkReverse->isChecked());
1207 config->setStyle((psd_gradient_style)ui.cmbStyle->currentIndex());
1208 config->setAlignWithLayer(ui.chkAlignWithLayer->isChecked());
1209 config->setAngle(ui.angleSelector->value());
1210 config->setScale(ui.intScale->value());
1211 config->setDither(ui.chkDither->isChecked());
1212}
1213
1214/********************************************************************/
1215/***** Inner Glow **********************************************/
1216/********************************************************************/
1217
1218InnerGlow::InnerGlow(Mode mode, KisCanvasResourceProvider *resourceProvider, QWidget *parent)
1219 : QWidget(parent),
1220 m_mode(mode)
1221{
1222 ui.setupUi(this);
1223
1224 if (mode == OuterGlowMode) {
1225 ui.groupBox->setTitle(i18n("Outer Glow"));
1226 }
1227
1228 ui.intOpacity->setRange(0, 100);
1229 KisSpinBoxI18nHelper::setText(ui.intOpacity, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1230
1231 ui.intNoise->setRange(0, 100);
1232 KisSpinBoxI18nHelper::setText(ui.intNoise, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1233
1234 ui.intChoke->setRange(0, 100);
1235 KisSpinBoxI18nHelper::setText(ui.intChoke, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1236
1237 ui.intSize->setRange(0, 250);
1238 ui.intSize->setSuffix(i18n(" px"));
1239 ui.intSize->setExponentRatio(2.0);
1240
1241 ui.intRange->setRange(1, 100);
1242 KisSpinBoxI18nHelper::setText(ui.intRange, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1243
1244 ui.intJitter->setRange(0, 100);
1245 KisSpinBoxI18nHelper::setText(ui.intJitter, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1246
1247 ui.cmbGradient->setCanvasResourcesInterface(resourceProvider->resourceManager()->canvasResourcesInterface());
1248
1249 connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1250 connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1251 connect(ui.intNoise, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1252
1253 connect(ui.radioColor, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1254 connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged()));
1255 connect(ui.radioGradient, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1256 connect(ui.cmbGradient, SIGNAL(gradientChanged(KoAbstractGradientSP)), SIGNAL(configChanged()));
1257
1258 connect(ui.cmbTechnique, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1259 connect(ui.cmbSource, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1260 connect(ui.intChoke, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1261 connect(ui.intSize, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1262
1263 connect(ui.cmbContour, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1264 connect(ui.chkAntiAliased, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1265 connect(ui.intRange, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1266 connect(ui.intJitter, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1267
1268 if (m_mode == OuterGlowMode) {
1269 ui.cmbSource->hide();
1270 ui.lblSource->hide();
1271 ui.lblChoke->setText(i18nc("layer styles parameter", "Spread:"));
1272 }
1273
1274}
1275
1277{
1278 ui.cmbCompositeOp->selectCompositeOp(KoID(config->blendMode()));
1279 ui.intOpacity->setValue(config->opacity());
1280 ui.intNoise->setValue(config->noise());
1281
1282 ui.radioColor->setChecked(config->fillType() == psd_fill_solid_color);
1283 ui.bnColor->setColor(config->color());
1284 ui.radioGradient->setChecked(config->fillType() == psd_fill_gradient);
1285
1286 KoAbstractGradientSP gradient = fetchGradientLazy(config->gradientLink(), resourcesInterface);
1287 if (gradient) {
1288 ui.cmbGradient->setGradient(gradient);
1289 }
1290
1291 ui.cmbTechnique->setCurrentIndex((int)config->technique());
1292 ui.intChoke->setValue(config->spread());
1293 ui.intSize->setValue(config->size());
1294
1295 if (m_mode == InnerGlowMode) {
1296 const psd_layer_effects_inner_glow *iglow =
1297 dynamic_cast<const psd_layer_effects_inner_glow *>(config);
1299
1300 ui.cmbSource->setCurrentIndex(iglow->source() == psd_glow_edge);
1301 }
1302
1303 // FIXME: Curve editing
1304 //ui.cmbContour;
1305
1306 ui.chkAntiAliased->setChecked(config->antiAliased());
1307 ui.intRange->setValue(config->range());
1308 ui.intJitter->setValue(config->jitter());
1309}
1310
1312{
1313 config->setBlendMode(ui.cmbCompositeOp->selectedCompositeOp().id());
1314 config->setOpacity(ui.intOpacity->value());
1315 config->setNoise(ui.intNoise->value());
1316
1317 if (ui.radioColor->isChecked()) {
1319 }
1320 else {
1322 }
1323
1324 config->setColor(ui.bnColor->color());
1325 KoAbstractGradientSP gradient = ui.cmbGradient->gradient();
1326 if (gradient) {
1327 auto clonedGradient = cloneAndPrepareGradientFromGUI(gradient);
1328 uploadResourcesInterface->addResource(clonedGradient);
1329 config->setGradient(clonedGradient);
1330 }
1331 config->setTechnique((psd_technique_type)ui.cmbTechnique->currentIndex());
1332 config->setSpread(ui.intChoke->value());
1333 config->setSize(ui.intSize->value());
1334
1335 if (m_mode == InnerGlowMode) {
1337 dynamic_cast<psd_layer_effects_inner_glow *>(config);
1339
1340 iglow->setSource((psd_glow_source)ui.cmbSource->currentIndex());
1341 }
1342
1343 // FIXME: Curve editing
1344 //ui.cmbContour;
1345
1346 config->setAntiAliased(ui.chkAntiAliased->isChecked());
1347 config->setRange(ui.intRange->value());
1348 config->setJitter(ui.intJitter->value());
1349}
1350
1351
1352/********************************************************************/
1353/***** Pattern Overlay *********************************************/
1354/********************************************************************/
1355
1356
1358 : QWidget(parent)
1359{
1360 ui.setupUi(this);
1361
1362 ui.intOpacity->setRange(0, 100);
1363 KisSpinBoxI18nHelper::setText(ui.intOpacity, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1364
1365 ui.intScale->setRange(0, 100);
1366 KisSpinBoxI18nHelper::setText(ui.intScale, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1367
1368 connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1369 connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1370 connect(ui.patternChooser, SIGNAL(resourceSelected(KoResourceSP )), SIGNAL(configChanged()));
1371 connect(ui.chkLinkWithLayer, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1372 connect(ui.intScale, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1373}
1374
1376{
1377 ui.cmbCompositeOp->selectCompositeOp(KoID(pattern->blendMode()));
1378 ui.intOpacity->setValue(pattern->opacity());
1379 KoPatternSP patternResource = fetchPatternLazy(pattern->patternLink(), resourcesInterface);
1380 if (patternResource) {
1381 ui.patternChooser->setCurrentPattern(patternResource);
1382 }
1383 ui.chkLinkWithLayer->setChecked(pattern->alignWithLayer());
1384 ui.intScale->setValue(pattern->scale());
1385}
1386
1388{
1389 pattern->setBlendMode(ui.cmbCompositeOp->selectedCompositeOp().id());
1390 pattern->setOpacity(ui.intOpacity->value());
1391
1392 auto patternResource = ui.patternChooser->currentResource(true).staticCast<KoPattern>();
1393 if (patternResource) {
1394 auto clonedPatternResource = patternResource->clone().dynamicCast<KoPattern>();
1395 pattern->setPattern(clonedPatternResource);
1396 uploadResourcesInterface->addResource(clonedPatternResource);
1397 }
1398
1399 pattern->setAlignWithLayer(ui.chkLinkWithLayer->isChecked());
1400 pattern->setScale(ui.intScale->value());
1401}
1402
1403/********************************************************************/
1404/***** Satin *********************************************/
1405/********************************************************************/
1406
1407
1408Satin::Satin(QWidget *parent)
1409 : QWidget(parent)
1410{
1411 ui.setupUi(this);
1412
1413 ui.intOpacity->setRange(0, 100);
1414 KisSpinBoxI18nHelper::setText(ui.intOpacity, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1415
1416 ui.intDistance->setRange(0, 250);
1417 ui.intDistance->setSuffix(i18n(" px"));
1418
1419 ui.intSize->setRange(0, 250);
1420 ui.intSize->setSuffix(i18n(" px"));
1421 ui.intSize->setExponentRatio(2.0);
1422
1423 connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1424 connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged()));
1425 connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1426
1427 connect(ui.angleSelector, SIGNAL(configChanged()), SIGNAL(configChanged()));
1428 connect(ui.intDistance, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1429 connect(ui.intSize, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1430
1431 connect(ui.cmbContour, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1432 connect(ui.chkAntiAliased, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1433 connect(ui.chkInvert, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1434
1435}
1436
1438{
1439 ui.cmbCompositeOp->selectCompositeOp(KoID(satin->blendMode()));
1440 ui.bnColor->setColor(satin->color());
1441 ui.intOpacity->setValue(satin->opacity());
1442
1443 ui.angleSelector->setValue(satin->angle());
1444
1445 ui.intDistance->setValue(satin->distance());
1446 ui.intSize->setValue(satin->size());
1447
1448 // FIXME: Curve editing
1449 //ui.cmbContour;
1450
1451 ui.chkAntiAliased->setChecked(satin->antiAliased());
1452 ui.chkInvert->setChecked(satin->invert());
1453
1454}
1455
1457{
1458 satin->setBlendMode(ui.cmbCompositeOp->selectedCompositeOp().id());
1459 satin->setOpacity(ui.intOpacity->value());
1460 satin->setColor(ui.bnColor->color());
1461
1462 satin->setAngle(ui.angleSelector->value());
1463
1464 satin->setDistance(ui.intDistance->value());
1465 satin->setSize(ui.intSize->value());
1466
1467 // FIXME: curve editing
1468 // ui.cmbContour;
1469 satin->setAntiAliased(ui.chkAntiAliased->isChecked());
1470 satin->setInvert(ui.chkInvert->isChecked());
1471}
1472
1473/********************************************************************/
1474/***** Stroke *********************************************/
1475/********************************************************************/
1476
1477Stroke::Stroke(KisCanvasResourceProvider *resourceProvider, QWidget *parent)
1478 : QWidget(parent)
1479{
1480 ui.setupUi(this);
1481
1482 ui.intSize->setRange(0, 250);
1483 ui.intSize->setSuffix(i18n(" px"));
1484 ui.intSize->setExponentRatio(2.0);
1485
1486 ui.intOpacity->setRange(0, 100);
1487 KisSpinBoxI18nHelper::setText(ui.intOpacity, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1488
1489 ui.intScale->setRange(0, 100);
1490 KisSpinBoxI18nHelper::setText(ui.intScale, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1491
1492 ui.intScale_2->setRange(0, 100);
1493 KisSpinBoxI18nHelper::setText(ui.intScale_2, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
1494
1495 ui.cmbGradient->setCanvasResourcesInterface(resourceProvider->resourceManager()->canvasResourcesInterface());
1496
1497 connect(ui.cmbFillType, SIGNAL(currentIndexChanged(int)), ui.fillStack, SLOT(setCurrentIndex(int)));
1498
1499 connect(ui.intSize, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1500 connect(ui.cmbPosition, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1501 connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1502 connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1503
1504 connect(ui.cmbFillType, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1505
1506 connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged()));
1507
1508 connect(ui.cmbGradient, SIGNAL(gradientChanged(KoAbstractGradientSP)), SIGNAL(configChanged()));
1509 connect(ui.chkReverse, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1510 connect(ui.cmbStyle, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged()));
1511 connect(ui.chkAlignWithLayer, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1512 connect(ui.intScale, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1513
1514 connect(ui.patternChooser, SIGNAL(resourceSelected(KoResourceSP )), SIGNAL(configChanged()));
1515 connect(ui.angleSelector, SIGNAL(configChanged()), SIGNAL(configChanged()));
1516
1517 connect(ui.chkLinkWithLayer, SIGNAL(toggled(bool)), SIGNAL(configChanged()));
1518 connect(ui.intScale_2, SIGNAL(valueChanged(int)), SIGNAL(configChanged()));
1519
1520 // cold initialization
1521 ui.fillStack->setCurrentIndex(ui.cmbFillType->currentIndex());
1522}
1523
1525{
1526 ui.intSize->setValue(stroke->size());
1527 ui.cmbPosition->setCurrentIndex((int)stroke->position());
1528 ui.cmbCompositeOp->selectCompositeOp(KoID(stroke->blendMode()));
1529 ui.intOpacity->setValue(stroke->opacity());
1530
1531 ui.cmbFillType->setCurrentIndex((int)stroke->fillType());
1532 ui.bnColor->setColor(stroke->color());
1533
1534 KoAbstractGradientSP gradient = fetchGradientLazy(stroke->gradientLink(), resourcesInterface);
1535 if (gradient) {
1536 ui.cmbGradient->setGradient(gradient);
1537 }
1538
1539 ui.chkReverse->setChecked(stroke->antiAliased());
1540 ui.cmbStyle->setCurrentIndex((int)stroke->style());
1541 ui.chkAlignWithLayer->setChecked(stroke->alignWithLayer());
1542 ui.chkAlignWithLayer->setCheckable(true);
1543 ui.angleSelector->setValue(stroke->angle());
1544 ui.intScale->setValue(stroke->scale());
1545
1546 KoPatternSP pattern = fetchPatternLazy(stroke->patternLink(), resourcesInterface);
1547 if (pattern) {
1548 ui.patternChooser->setCurrentPattern(pattern);
1549 }
1550
1551 ui.chkLinkWithLayer->setChecked(stroke->alignWithLayer());
1552 ui.intScale_2->setValue(stroke->scale());
1553}
1554
1556{
1557 stroke->setSize(ui.intSize->value());
1558 stroke->setPosition((psd_stroke_position)ui.cmbPosition->currentIndex());
1559 stroke->setBlendMode(ui.cmbCompositeOp->selectedCompositeOp().id());
1560 stroke->setOpacity(ui.intOpacity->value());
1561
1562 psd_fill_type fillType = (psd_fill_type)ui.cmbFillType->currentIndex();
1563 stroke->setFillType(fillType);
1564
1565 stroke->setColor(ui.bnColor->color());
1566
1567 auto gradient = ui.cmbGradient->gradient();
1568 if (gradient) {
1569 auto clonedGradient = cloneAndPrepareGradientFromGUI(gradient);
1570 uploadResourcesInterface->addResource(clonedGradient);
1571 stroke->setGradient(clonedGradient);
1572 }
1573
1574 stroke->setReverse(ui.chkReverse->isChecked());
1575 stroke->setStyle((psd_gradient_style)ui.cmbStyle->currentIndex());
1576 if (fillType == psd_fill_gradient) {
1577 // there is only one boolean value, and it's shared with pattern's "link with layer"
1578 stroke->setAlignWithLayer(ui.chkAlignWithLayer->isChecked());
1579 }
1580 stroke->setAngle(ui.angleSelector->value());
1581 stroke->setScale(ui.intScale->value());
1582
1583 auto pattern = ui.patternChooser->currentResource(true).staticCast<KoPattern>();
1584 if (pattern) {
1585 auto clonedPattern = pattern->clone().dynamicCast<KoPattern>();
1586 uploadResourcesInterface->addResource(clonedPattern);
1587 stroke->setPattern(clonedPattern);
1588 }
1589
1590 if (fillType == psd_fill_pattern) {
1591 // there is only one boolean value, and it's shared with gradient's "align with layer"
1592 stroke->setAlignWithLayer(ui.chkLinkWithLayer->isChecked());
1593 }
1594 stroke->setScale(ui.intScale->value());
1595}
float value(const T *src, size_t ch)
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
QList< QString > QStringList
BevelAndEmboss(Contour *contour, Texture *texture, QWidget *parent)
void setBevelAndEmboss(const psd_layer_effects_bevel_emboss *bevelAndEmboss, KisResourcesInterfaceSP resourcesInterface)
void fetchBevelAndEmboss(psd_layer_effects_bevel_emboss *bevelAndEmboss, QSharedPointer< KisLocalStrokeResources > uploadResourcesInterface) const
Ui::WdgBevelAndEmboss ui
void globalAngleChanged(int value)
void configChanged()
Ui::WdgBlendingOptions ui
BlendingOptions(QWidget *parent)
ColorOverlay(QWidget *parent)
void setColorOverlay(const psd_layer_effects_color_overlay *colorOverlay)
Ui::WdgColorOverlay ui
void configChanged()
void fetchColorOverlay(psd_layer_effects_color_overlay *colorOverlay) const
Ui::WdgContour ui
Contour(QWidget *parent)
Ui::WdgDropShadow ui
void globalAngleChanged(int value)
void setShadow(const psd_layer_effects_shadow_common *shadow)
void fetchShadow(psd_layer_effects_shadow_common *shadow) const
void configChanged()
DropShadow(Mode mode, QWidget *parent)
Ui::WdgGradientOverlay ui
void fetchGradientOverlay(psd_layer_effects_gradient_overlay *gradient, QSharedPointer< KisLocalStrokeResources > uploadResourcesInterface) const
void setGradientOverlay(const psd_layer_effects_gradient_overlay *gradient, KisResourcesInterfaceSP resourcesInterface)
GradientOverlay(KisCanvasResourceProvider *resourceProvider, QWidget *parent)
void configChanged()
InnerGlow(Mode mode, KisCanvasResourceProvider *resourceProvider, QWidget *parent)
void fetchConfig(psd_layer_effects_glow_common *innerGlow, QSharedPointer< KisLocalStrokeResources > uploadResourcesInterface) const
Ui::WdgInnerGlow ui
void setConfig(const psd_layer_effects_glow_common *innerGlow, KisResourcesInterfaceSP resourcesInterface)
void configChanged()
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 void sideLoadLinkedResources(KisPSDLayerStyle *style, KisResourcesInterfaceSP resourcesInterface)
void setStyles(const QVector< KisPSDLayerStyleSP > &styles)
bool saveToFile(const QString &filename)
KoCanvasResourceProvider * resourceManager()
T readEntry(const QString &name, const T &defaultValue=T())
Definition kis_config.h:832
void changePage(QListWidgetItem *, QListWidgetItem *)
KisDlgLayerStyle(KisPSDLayerStyleSP layerStyle, KisCanvasResourceProvider *resourceProvider, QWidget *parent=0)
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
void setStyle(KisPSDLayerStyleSP style)
KisPSDLayerStyleSP style() const
KisPSDLayerStyleSP m_layerStyle
void notifyPredefinedStyleSelected(KisPSDLayerStyleSP style)
StylesSelector * m_stylesSelector
KisSignalCompressor * m_configChangedCompressor
static KisResourcesInterfaceSP instance()
a KisResourcesInterface-like resources storage for preloaded resources
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 KisResourceLocator * instance()
static KisAllResourcesModel * resourceModel(const QString &resourceType)
The KisResourceModel class provides the main access to resources. It is possible to filter the resour...
KoResourceSP resourceForId(int id) const
QModelIndex indexForResource(KoResourceSP resource) const override
indexFromResource
KoResourceSP resourceForIndex(QModelIndex index=QModelIndex()) const override
resourceForIndex returns a properly versioned and id'ed resource object
static KisResourceServerProvider * instance()
KoResourceServer< KisPSDLayerStyle > * layerStyleServer()
static bool addResourceWithUserInput(QWidget *widgetParent, KoResourceSP resource, QString storageLocation="")
KoCanvasResourcesInterfaceSP canvasResourcesInterface() const
A dialog base class with standard buttons and predefined layouts.
Definition KoDialog.h:116
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
Definition KoID.h:30
static QString generateHash(const QString &filename)
generateHash reads the given file and generates a hex-encoded md5sum for the file.
Write API docs here.
Definition KoPattern.h:21
KoResourceSP clone() const override
Definition KoPattern.cpp:74
static QString getAppDataLocation()
QSharedPointer< T > 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 r...
A simple wrapper object for the main information about the resource.
void fetchPatternOverlay(psd_layer_effects_pattern_overlay *pattern, QSharedPointer< KisLocalStrokeResources > uploadResourcesInterface) const
PatternOverlay(QWidget *parent)
void configChanged()
Ui::WdgPatternOverlay ui
void setPatternOverlay(const psd_layer_effects_pattern_overlay *pattern, KisResourcesInterfaceSP resourcesInterface)
Satin(QWidget *parent)
void configChanged()
void setSatin(const psd_layer_effects_satin *satin)
Ui::WdgSatin ui
void fetchSatin(psd_layer_effects_satin *satin) const
void configChanged()
Stroke(KisCanvasResourceProvider *resourceProvider, QWidget *parent)
void setStroke(const psd_layer_effects_stroke *stroke, KisResourcesInterfaceSP resourcesInterface)
void fetchStroke(psd_layer_effects_stroke *stroke, QSharedPointer< KisLocalStrokeResources > uploadResourcesInterface) const
Ui::WdgStroke ui
KisPSDLayerStyleSP m_style
StyleItem(KisPSDLayerStyleSP style)
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
void setEnableFiltering(bool enableFiltering)
void addNewStyle(const QString &location, const KisPSDLayerStyleSP style)
void notifyExternalStyleChanged(const QString &name, const QUuid &uuid)
void loadStyles(const QString &name)
void loadCollection(const QString &fileName)
void selectStyle(QModelIndex current)
StylesSelector(QWidget *parent)
Ui::WdgStylesSelector ui
void styleSelected(KisPSDLayerStyleSP style)
LocationProxyModel * m_locationsProxyModel
KisResourceModel * m_resourceModel
Texture(QWidget *parent)
Ui::WdgTexture ui
void setSource(psd_glow_source value)
Definition psd.h:610
psd_glow_source source() const
Definition psd.h:606
qint32 opacity() const
Definition psd.h:281
void setGradient(KoAbstractGradientSP value)
Definition psd.h:467
qint32 range() const
Definition psd.h:351
void setColor(KoColor value)
Definition psd.h:377
void setRange(qint32 value)
Definition psd.h:457
qint32 distance() const
Definition psd.h:296
bool useGlobalLight() const
Definition psd.h:291
QString blendMode() const
Definition psd.h:266
void setFillType(psd_fill_type value)
Definition psd.h:447
void setNoise(qint32 value)
Definition psd.h:427
bool knocksOut() const
Definition psd.h:326
void setUseGlobalLight(bool value)
Definition psd.h:397
qint32 spread() const
Definition psd.h:301
psd_technique_type technique() const
Definition psd.h:346
KoColor color() const
Definition psd.h:271
qint32 jitter() const
Definition psd.h:356
qint32 noise() const
Definition psd.h:321
void setTechnique(psd_technique_type value)
Definition psd.h:452
void setAntiAliased(bool value)
Definition psd.h:422
void setKnocksOut(bool value)
Definition psd.h:432
void setDistance(qint32 value)
Definition psd.h:402
void setAngle(qint32 value)
Definition psd.h:392
qint32 angle() const
Definition psd.h:286
qint32 size() const
Definition psd.h:306
void setBlendMode(QString value)
Definition psd.h:372
void setJitter(qint32 value)
Definition psd.h:462
void setOpacity(qint32 value)
Definition psd.h:387
psd_fill_type fillType() const
Definition psd.h:341
bool antiAliased() const
Definition psd.h:316
void setSpread(qint32 value)
Definition psd.h:407
KoResourceSignature gradientLink() const
Definition psd.h:361
void setSize(qint32 value)
Definition psd.h:412
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
#define KIS_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:97
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
#define KIS_ASSERT(cond)
Definition kis_assert.h:33
#define warnKrita
Definition kis_debug.h:87
#define ENTER_FUNCTION()
Definition kis_debug.h:178
TypeSP fetchResourceLazy(KoResourceSignature signature, KisResourcesInterfaceSP resourcesInterface)
bool checkCustomNameAvailable(const QString &name)
QString createNewAslPath(QString resourceFolderPath, QString filename)
KoPatternSP fetchPatternLazy(KoResourceSignature signature, KisResourcesInterfaceSP resourcesInterface)
KoAbstractGradientSP fetchGradientLazy(KoResourceSignature signature, KisResourcesInterfaceSP resourcesInterface)
QString selectAvailableStyleName(const QString &name)
KoAbstractGradientSP cloneAndPrepareGradientFromGUI(KoAbstractGradientSP gradient)
void createLocalResourcesSnapshot(T *object, KisResourcesInterfaceSP globalResourcesInterface=nullptr)
void setText(QSpinBox *spinBox, const QStringView textTemplate)
const QString LayerStyles
rgba palette[MAX_PALETTE]
Definition palette.c:35
psd_glow_source
Definition psd.h:129
@ psd_glow_edge
Definition psd.h:131
psd_direction
Definition psd.h:142
psd_gradient_style
Definition psd.h:101
psd_fill_type
Definition psd.h:123
@ psd_fill_solid_color
Definition psd.h:124
@ psd_fill_gradient
Definition psd.h:125
@ psd_fill_pattern
Definition psd.h:126
psd_technique_type
Definition psd.h:115
psd_bevel_style
Definition psd.h:134
psd_stroke_position
Definition psd.h:121
The KisPSDLayerStyle class implements loading, saving and applying the PSD layer effects.
QString filename
QString md5Sum(bool generateIfEmpty=true) const
void setTechnique(psd_technique_type value)
Definition psd.h:734
void setStyle(psd_bevel_style value)
Definition psd.h:725
void setTextureDepth(int value)
Definition psd.h:907
QString shadowBlendMode() const
Definition psd.h:821
psd_technique_type technique() const
Definition psd.h:730
KoResourceSignature texturePatternLink() const
Definition psd.h:875
void setShadowColor(KoColor value)
Definition psd.h:834
qint32 highlightOpacity() const
Definition psd.h:812
psd_bevel_style style() const
Definition psd.h:721
void setTextureScale(int value)
Definition psd.h:898
psd_direction direction() const
Definition psd.h:748
bool glossAntiAliased() const
Definition psd.h:785
void setDirection(psd_direction value)
Definition psd.h:752
void setTexturePattern(KoPatternSP value)
Definition psd.h:885
void setHighlightBlendMode(QString value)
Definition psd.h:798
void setAltitude(int value)
Definition psd.h:770
bool textureInvert() const
Definition psd.h:912
void setHighlightColor(KoColor value)
Definition psd.h:807
void setContourRange(int value)
Definition psd.h:861
qint32 shadowOpacity() const
Definition psd.h:839
bool textureAlignWithLayer() const
Definition psd.h:921
void setShadowBlendMode(QString value)
Definition psd.h:825
void setDepth(int value)
Definition psd.h:743
QString highlightBlendMode() const
Definition psd.h:794
void setGlossAntiAliased(bool value)
Definition psd.h:789
KoColor shadowColor() const
Definition psd.h:830
KoColor highlightColor() const
Definition psd.h:803
void setTextureAlignWithLayer(bool value)
Definition psd.h:925
void setShadowOpacity(qint32 value)
Definition psd.h:843
void setSoften(int value)
Definition psd.h:761
void setTextureInvert(bool value)
Definition psd.h:916
void setHighlightOpacity(qint32 value)
Definition psd.h:816
void setReverse(bool value)
Definition psd.h:1094
void setAlignWithLayer(bool value)
Definition psd.h:1084
KoResourceSignature patternLink() const
Definition psd.h:1057
void setStyle(psd_gradient_style value)
Definition psd.h:1099
bool alignWithLayer() const
Definition psd.h:1027
void setScale(int value)
Definition psd.h:1079
void setDither(bool value)
Definition psd.h:1089
psd_gradient_style style() const
Definition psd.h:1042
void setPattern(KoPatternSP value)
Definition psd.h:1115
void setInvert(bool value)
Definition psd.h:655
bool invert() const
Definition psd.h:650
void setPosition(psd_stroke_position value)
Definition psd.h:1284
psd_stroke_position position() const
Definition psd.h:1280