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

Revert Patch D18462

Patch for review D18462 snuck into commit cf5346cb. This reverts the
patch to restore original fill color window behavior.
parent 9838f9c6
......@@ -30,12 +30,9 @@
#include <filter/kis_filter_configuration.h>
#include <kis_paint_device.h>
#include <kis_transaction.h>
#include <commands/kis_change_filter_command.h>
#include <kis_generator_layer.h>
#include <KisViewManager.h>
#include <KisDocument.h>
KisDlgGeneratorLayer::KisDlgGeneratorLayer(const QString defaultName, KisViewManager *view, QWidget *parent, KisGeneratorLayerSP glayer = 0, const KisFilterConfigurationSP previousConfig = 0)
KisDlgGeneratorLayer::KisDlgGeneratorLayer(const QString & name, KisViewManager *view, QWidget *parent)
: KoDialog(parent)
, m_customName(false)
, m_freezeName(false)
......@@ -43,57 +40,16 @@ KisDlgGeneratorLayer::KisDlgGeneratorLayer(const QString defaultName, KisViewMan
setButtons(Ok | Cancel);
setDefaultButton(Ok);
isEditing = glayer && previousConfig;
if(isEditing){
setModal(false);
layer = glayer;
configBefore = previousConfig;
}
QWidget *page = new QWidget(this);
m_view = view;
QWidget * page = new QWidget(this);
dlgWidget.setupUi(page);
dlgWidget.wdgGenerator->initialize(m_view);
dlgWidget.wdgGenerator->initialize(view);
setMainWidget(page);
dlgWidget.txtLayerName->setText( isEditing ? layer->name() : defaultName );
dlgWidget.txtLayerName->setText(name);
connect(dlgWidget.txtLayerName, SIGNAL(textChanged(QString)),
this, SLOT(slotNameChanged(QString)));
}
KisDlgGeneratorLayer::~KisDlgGeneratorLayer()
{
/*Editing a layer should be using the show function with automatic deletion on close.
*Because of this, the action should be taken care of when the window is closed and
*the user has accepted the changes.*/
if(isEditing && result() == QDialog::Accepted) {
layer->setName(layerName());
KisFilterConfigurationSP configAfter(configuration());
Q_ASSERT(configAfter);
QString xmlBefore = configBefore->toXML();
QString xmlAfter = configAfter->toXML();
if(xmlBefore != xmlAfter) {
KisChangeFilterCmd *cmd
= new KisChangeFilterCmd(layer,
configBefore->name(),
xmlBefore,
configAfter->name(),
xmlAfter,
true);
// FIXME: check whether is needed
cmd->redo();
m_view->undoAdapter()->addCommand(cmd);
m_view->document()->setModified(true);
}
}
}
void KisDlgGeneratorLayer::slotNameChanged(const QString & text)
{
if (m_freezeName)
......
......@@ -43,26 +43,20 @@ public:
* @param name the proposed name for this layer
* @param view the view manager
* @param parent the widget parent of this dialog
* @param glayer optional generator layer for editing
* @param previousConfig optional configuration of layer being edited.
*/
KisDlgGeneratorLayer(const QString defaultLayerName, KisViewManager *arg_view, QWidget *parent, KisGeneratorLayerSP glayer, const KisFilterConfigurationSP previousConfig);
~KisDlgGeneratorLayer() override;
KisDlgGeneratorLayer(const QString & name, KisViewManager *view, QWidget *parent);
void setConfiguration(const KisFilterConfigurationSP config);
KisFilterConfigurationSP configuration() const;
QString layerName() const;
protected Q_SLOTS:
void slotNameChanged(const QString &);
private:
Ui_WdgDlgGeneratorLayer dlgWidget;
KisGeneratorLayerSP layer;
KisFilterConfigurationSP configBefore;
KisViewManager *m_view;
bool isEditing;
Ui_WdgDlgGeneratorLayer dlgWidget;
bool m_customName;
bool m_freezeName;
};
......
......@@ -292,21 +292,40 @@ void KisLayerManager::layerProperties()
}
}
else if (glayer && !multipleLayersSelected) {
KisDlgGeneratorLayer dlg(glayer->name(), m_view, m_view->mainWindow());
dlg.setCaption(i18n("Fill Layer Properties"));
KisFilterConfigurationSP configBefore(glayer->filter());
Q_ASSERT(configBefore);
QString xmlBefore = configBefore->toXML();
KisDlgGeneratorLayer *dlg = new KisDlgGeneratorLayer(glayer->name(), m_view, m_view->mainWindow(), glayer, configBefore);
dlg->setCaption(i18n("Fill Layer Properties"));
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg.setConfiguration(configBefore.data());
dlg.resize(dlg.minimumSizeHint());
dlg->setConfiguration(configBefore.data());
dlg->resize(dlg->minimumSizeHint());
if (dlg.exec() == QDialog::Accepted) {
Qt::WindowFlags flags = dlg->windowFlags();
dlg->setWindowFlags(flags | Qt::WindowStaysOnTopHint | Qt::Dialog);
dlg->show();
glayer->setName(dlg.layerName());
KisFilterConfigurationSP configAfter(dlg.configuration());
Q_ASSERT(configAfter);
QString xmlAfter = configAfter->toXML();
if(xmlBefore != xmlAfter) {
KisChangeFilterCmd *cmd
= new KisChangeFilterCmd(glayer,
configBefore->name(),
xmlBefore,
configAfter->name(),
xmlAfter,
true);
// FIXME: check whether is needed
cmd->redo();
m_view->undoAdapter()->addCommand(cmd);
m_view->document()->setModified(true);
}
}
} else if (flayer && !multipleLayersSelected){
QString basePath = QFileInfo(m_view->document()->url().toLocalFile()).absolutePath();
QString fileNameOld = flayer->fileName();
......@@ -655,8 +674,7 @@ KisNodeSP KisLayerManager::addGeneratorLayer(KisNodeSP activeNode)
KisImageWSP image = m_view->image();
QColor currentForeground = m_view->resourceProvider()->fgColor().toQColor();
KisDlgGeneratorLayer dlg(image->nextLayerName(), m_view, m_view->mainWindow(), 0, 0);
KisDlgGeneratorLayer dlg(image->nextLayerName(), m_view, m_view->mainWindow());
KisFilterConfigurationSP defaultConfig = dlg.configuration();
defaultConfig->setProperty("color", currentForeground);
dlg.setConfiguration(defaultConfig);
......
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