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

#include <kis_dlg_generator_layer.h>

+ Inheritance diagram for KisDlgGeneratorLayer:

Public Member Functions

KisFilterConfigurationSP configuration () const
 
 KisDlgGeneratorLayer (const QString &defaultLayerName, KisViewManager *arg_view, QWidget *parent, KisGeneratorLayerSP glayer, const KisFilterConfigurationSP previousConfig, const KisStrokeId stroke)
 
QString layerName () const
 
void setConfiguration (const KisFilterConfigurationSP config)
 
 ~KisDlgGeneratorLayer () override
 

Protected Slots

void previewGenerator ()
 
void restoreLayer ()
 
void saveLayer ()
 
void slotDelayedPreviewGenerator ()
 
void slotNameChanged (const QString &)
 

Private Attributes

KisFilterConfigurationSP configBefore
 
Ui_WdgDlgGeneratorLayer dlgWidget
 
bool isEditing
 
KisGeneratorLayerSP layer
 
KisThreadSafeSignalCompressor m_compressor
 
bool m_customName
 
bool m_freezeName
 
KisStrokeId m_stroke
 
QWeakPointer< boost::none_t > m_updateCookie
 
KisViewManagerm_view
 

Detailed Description

Create a new generator layer

Definition at line 23 of file kis_dlg_generator_layer.h.

Constructor & Destructor Documentation

◆ KisDlgGeneratorLayer()

KisDlgGeneratorLayer::KisDlgGeneratorLayer ( const QString & defaultLayerName,
KisViewManager * arg_view,
QWidget * parent,
KisGeneratorLayerSP glayer = 0,
const KisFilterConfigurationSP previousConfig = 0,
const KisStrokeId stroke = KisStrokeId() )

Create a new generator layer

Parameters
defaultLayerNamethe proposed name for this layer
arg_viewthe view manager
parentthe widget parent of this dialog
glayeroptional generator layer for editing
previousConfigoptional configuration of layer being edited.

Definition at line 30 of file kis_dlg_generator_layer.cpp.

31 : QDialog(parent)
32 , layer(glayer)
33 , m_view(view)
34 , isEditing(layer && previousConfig)
35 , m_customName(false)
36 , m_freezeName(false)
37 , m_stroke(stroke)
39{
40 if(isEditing){
41 setModal(false);
42 configBefore = previousConfig->cloneWithResourcesSnapshot();
43 }
44
45 dlgWidget.setupUi(this);
46 dlgWidget.wdgGenerator->initialize(m_view);
47 dlgWidget.btnBox->button(QDialogButtonBox::Ok)->setDefault(true);
48 KGuiItem::assign(dlgWidget.btnBox->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
49 KGuiItem::assign(dlgWidget.btnBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
50
51 dlgWidget.txtLayerName->setText( isEditing ? layer->name() : defaultName );
52 connect(dlgWidget.txtLayerName, SIGNAL(textChanged(QString)),
53 this, SLOT(slotNameChanged(QString)));
54 connect(dlgWidget.wdgGenerator, SIGNAL(previewConfiguration()), this, SLOT(previewGenerator()));
55 connect(&m_compressor, SIGNAL(timeout()), this, SLOT(slotDelayedPreviewGenerator()));
56
57 dlgWidget.filterGalleryToggle->setIcon(KisIconUtils::loadIcon("sidebaricon"));
58 dlgWidget.filterGalleryToggle->setChecked(true);
59 connect(dlgWidget.filterGalleryToggle, SIGNAL(toggled(bool)), dlgWidget.wdgGenerator, SLOT(showFilterGallery(bool)));
60
61 connect(dlgWidget.btnBox, SIGNAL(accepted()), this, SLOT(accept()));
62 connect(dlgWidget.btnBox, SIGNAL(rejected()), this, SLOT(reject()));
63 connect(this, SIGNAL(accepted()), this, SLOT(saveLayer()));
64 connect(this, SIGNAL(rejected()), this, SLOT(restoreLayer()));
65
66 if (layer && !isEditing) {
68 }
69
70 restoreGeometry(KisConfig(true).readEntry("generatordialog/geometry", QByteArray()));
71}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisThreadSafeSignalCompressor m_compressor
Ui_WdgDlgGeneratorLayer dlgWidget
void slotNameChanged(const QString &)
KisFilterConfigurationSP configBefore
#define UPDATE_DELAY
QIcon loadIcon(const QString &name)
QString name() const

References configBefore, connect(), dlgWidget, isEditing, layer, KisIconUtils::loadIcon(), m_compressor, m_view, KisBaseNode::name(), previewGenerator(), restoreLayer(), saveLayer(), slotDelayedPreviewGenerator(), and slotNameChanged().

◆ ~KisDlgGeneratorLayer()

KisDlgGeneratorLayer::~KisDlgGeneratorLayer ( )
override

Definition at line 111 of file kis_dlg_generator_layer.cpp.

112{
113 KisConfig(false).writeEntry("generatordialog/geometry", saveGeometry());
114}
void writeEntry(const QString &name, const T &value)
Definition kis_config.h:779

References KisConfig::writeEntry().

Member Function Documentation

◆ configuration()

KisFilterConfigurationSP KisDlgGeneratorLayer::configuration ( ) const

Definition at line 152 of file kis_dlg_generator_layer.cpp.

153{
154 return dlgWidget.wdgGenerator->configuration();
155}

References dlgWidget.

◆ layerName()

QString KisDlgGeneratorLayer::layerName ( ) const

Definition at line 157 of file kis_dlg_generator_layer.cpp.

158{
159 return dlgWidget.txtLayerName->text();
160}

References dlgWidget.

◆ previewGenerator

void KisDlgGeneratorLayer::previewGenerator ( )
protectedslot

◆ restoreLayer

void KisDlgGeneratorLayer::restoreLayer ( )
protectedslot

Definition at line 103 of file kis_dlg_generator_layer.cpp.

104{
105 if (isEditing)
106 {
108 }
109}
void setFilter(KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true) override

References configBefore, isEditing, layer, and KisGeneratorLayer::setFilter().

◆ saveLayer

void KisDlgGeneratorLayer::saveLayer ( )
protectedslot

Definition at line 73 of file kis_dlg_generator_layer.cpp.

74{
75 /*
76 * Editing a layer should be using the show function with automatic deletion on close.
77 * Because of this, the action should be taken care of when the window is closed and
78 * the user has accepted the changes.
79 */
80 if (isEditing) {
82
84 Q_ASSERT(configAfter);
85 QString xmlBefore = configBefore->toXML();
86 QString xmlAfter = configAfter->toXML();
87
88 if (xmlBefore != xmlAfter) {
92 configAfter->cloneWithResourcesSnapshot());
93
95 m_view->document()->setModified(true);
96 }
97 } else {
100 }
101}
KisFilterConfigurationSP configuration() const
void setModified(bool _mod)
virtual void addCommand(KUndo2Command *cmd)=0
KisDocument * document() const
KisUndoAdapter * undoAdapter()
The undo adapter is used to add commands to the undo stack.
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
TypeSP cloneWithResourcesSnapshot(const T *object, KisResourcesInterfaceSP globalResourcesInterface=nullptr)
creates an exact copy of the object and loads all the linked resources into the local storage.
void setName(const QString &name)

References KisUndoAdapter::addCommand(), configBefore, configuration(), KisViewManager::document(), isEditing, KIS_ASSERT_RECOVER_RETURN, layer, layerName(), m_view, KisGeneratorLayer::setFilter(), KisDocument::setModified(), KisBaseNode::setName(), and KisViewManager::undoAdapter().

◆ setConfiguration()

void KisDlgGeneratorLayer::setConfiguration ( const KisFilterConfigurationSP config)

Definition at line 145 of file kis_dlg_generator_layer.cpp.

146{
147 dlgWidget.wdgGenerator->setConfiguration(config);
148 // hack! forcibly re-render the layer
150}

References dlgWidget, and slotDelayedPreviewGenerator().

◆ slotDelayedPreviewGenerator

void KisDlgGeneratorLayer::slotDelayedPreviewGenerator ( )
protectedslot

Definition at line 125 of file kis_dlg_generator_layer.cpp.

126{
127 if (!m_stroke.isNull()) {
128 if (m_updateCookie) {
130 } else {
133 }
134 } else {
137 }
138}
QWeakPointer< boost::none_t > m_updateCookie
void setFilterWithoutUpdate(KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true)
QWeakPointer< boost::none_t > previewWithStroke(const KisStrokeId stroke)

References configuration(), KIS_ASSERT_RECOVER_RETURN, layer, m_compressor, m_stroke, m_updateCookie, KisGeneratorLayer::previewWithStroke(), KisGeneratorLayer::setFilter(), KisGeneratorLayer::setFilterWithoutUpdate(), and KisThreadSafeSignalCompressor::start().

◆ slotNameChanged

void KisDlgGeneratorLayer::slotNameChanged ( const QString & text)
protectedslot

Definition at line 116 of file kis_dlg_generator_layer.cpp.

117{
118 if (m_freezeName)
119 return;
120
121 m_customName = !text.isEmpty();
122 dlgWidget.btnBox->button(QDialogButtonBox::Ok)->setEnabled(m_customName);
123}

References dlgWidget, m_customName, and m_freezeName.

Member Data Documentation

◆ configBefore

KisFilterConfigurationSP KisDlgGeneratorLayer::configBefore
private

Definition at line 60 of file kis_dlg_generator_layer.h.

◆ dlgWidget

Ui_WdgDlgGeneratorLayer KisDlgGeneratorLayer::dlgWidget
private

Definition at line 58 of file kis_dlg_generator_layer.h.

◆ isEditing

bool KisDlgGeneratorLayer::isEditing
private

Definition at line 62 of file kis_dlg_generator_layer.h.

◆ layer

KisGeneratorLayerSP KisDlgGeneratorLayer::layer
private

Definition at line 59 of file kis_dlg_generator_layer.h.

◆ m_compressor

KisThreadSafeSignalCompressor KisDlgGeneratorLayer::m_compressor
private

Definition at line 67 of file kis_dlg_generator_layer.h.

◆ m_customName

bool KisDlgGeneratorLayer::m_customName
private

Definition at line 64 of file kis_dlg_generator_layer.h.

◆ m_freezeName

bool KisDlgGeneratorLayer::m_freezeName
private

Definition at line 65 of file kis_dlg_generator_layer.h.

◆ m_stroke

KisStrokeId KisDlgGeneratorLayer::m_stroke
private

Definition at line 66 of file kis_dlg_generator_layer.h.

◆ m_updateCookie

QWeakPointer<boost::none_t> KisDlgGeneratorLayer::m_updateCookie
private

Definition at line 68 of file kis_dlg_generator_layer.h.

◆ m_view

KisViewManager* KisDlgGeneratorLayer::m_view
private

Definition at line 61 of file kis_dlg_generator_layer.h.


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