Commit f63db12b authored by Eoin O'Neill's avatar Eoin O'Neill 🍀

Added Real-Time Preview when Changing Generator Layer Properties.

Colors and patterns will update when changing the values within the
properties window of a generator layer. The changes will only be registered
with the undo command system when accepting the change. Canceling your changes
will revert the layer back to the state before the properties panel was opened.

This should make changing the fill layer color a more artistic process,
letting you visually see the effects before applying the change.
parent 1272564e
......@@ -61,6 +61,7 @@ KisDlgGeneratorLayer::KisDlgGeneratorLayer(const QString & defaultName, KisViewM
dlgWidget.txtLayerName->setText( isEditing ? layer->name() : defaultName );
connect(dlgWidget.txtLayerName, SIGNAL(textChanged(QString)),
this, SLOT(slotNameChanged(QString)));
connect(dlgWidget.wdgGenerator, SIGNAL(previewConfiguration()), this, SLOT(previewGenerator()));
}
KisDlgGeneratorLayer::~KisDlgGeneratorLayer()
......@@ -77,7 +78,7 @@ KisDlgGeneratorLayer::~KisDlgGeneratorLayer()
QString xmlBefore = configBefore->toXML();
QString xmlAfter = configAfter->toXML();
if(xmlBefore != xmlAfter) {
if (xmlBefore != xmlAfter) {
KisChangeFilterCmd *cmd
= new KisChangeFilterCmd(layer,
configBefore->name(),
......@@ -89,7 +90,9 @@ KisDlgGeneratorLayer::~KisDlgGeneratorLayer()
m_view->undoAdapter()->addCommand(cmd);
m_view->document()->setModified(true);
}
}
else if(isEditing && result() == QDialog::Rejected){
layer->setFilter(configBefore);
}
}
......@@ -102,6 +105,12 @@ void KisDlgGeneratorLayer::slotNameChanged(const QString & text)
enableButtonOk(m_customName);
}
void KisDlgGeneratorLayer::previewGenerator()
{
if (isEditing && layer)
layer->setFilter(configuration());
}
void KisDlgGeneratorLayer::setConfiguration(const KisFilterConfigurationSP config)
{
dlgWidget.wdgGenerator->setConfiguration(config);
......
......@@ -55,6 +55,7 @@ public:
protected Q_SLOTS:
void slotNameChanged(const QString &);
void previewGenerator();
private:
Ui_WdgDlgGeneratorLayer dlgWidget;
......
......@@ -92,6 +92,7 @@ void KisWdgGenerator::initialize(KisViewManager *view)
KisGeneratorItem * item = new KisGeneratorItem(generator->name(),
d->uiWdgGenerators.lstGenerators,
QListWidgetItem::UserType + 1);
item->generator = generator;
}
connect(d->uiWdgGenerators.lstGenerators, SIGNAL(currentRowChanged(int)),
......@@ -116,6 +117,7 @@ void KisWdgGenerator::setConfiguration(const KisFilterConfigurationSP config)
if (wdg) {
wdg->setConfiguration(config);
}
return;
}
}
......@@ -156,6 +158,9 @@ void KisWdgGenerator::slotGeneratorActivated(int row)
d->uiWdgGenerators.centralWidgetHolder);
} else {
d->centralWidget = widget;
connect( widget, SIGNAL(sigConfigurationUpdated()), this, SIGNAL(previewConfiguration()));
widget->setView(d->view);
widget->setConfiguration(d->currentGenerator->defaultConfiguration());
}
......
......@@ -24,6 +24,7 @@
class KisFilterConfiguration;
class KisViewManager;
class KoColor;
/**
* A widget that allows users to select a generator and
......@@ -51,9 +52,10 @@ public:
KisFilterConfigurationSP configuration();
Q_SIGNALS:
void previewConfiguration();
private Q_SLOTS:
void slotGeneratorActivated(int);
private:
......
......@@ -40,6 +40,7 @@ KisWdgPattern::KisWdgPattern(QWidget* parent)
m_widget->lblPattern->setVisible(false);
m_widget->lblColor->setVisible(false);
m_widget->bnColor->setVisible(false);
connect(m_widget->patternChooser, SIGNAL(resourceSelected(KoResource*)), this, SIGNAL(sigConfigurationUpdated()));
}
KisWdgPattern::~KisWdgPattern()
......
......@@ -33,6 +33,7 @@ KisWdgColor::KisWdgColor(QWidget* parent, const KoColorSpace *cs)
m_widget = new Ui_WdgColorOptions();
m_widget->setupUi(this);
m_cs = cs;
connect(m_widget->bnColor, SIGNAL(changed(const KoColor&)), this, SIGNAL(sigConfigurationUpdated()));
}
KisWdgColor::~KisWdgColor()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment