Commit 74848d9a authored by Mohit Goyal's avatar Mohit Goyal

Squashed commit and merged krita-mohit-testing into master. Introduces two

new features :
Dirty Presets : Keeps temporary tweaks made to the preset till the session ends

    Go to the Brush Editor box. Bottom left -- select "Temporarily save tweaks made to presets"
    Any time you make a change to any setting in the preset -- the textbox will turn pink and a "+" symbol will appear on the icon. The Reload button is used to reset the tweaks for that particular preset

Locked Settings : Keeps settings constant across presets

    In the brush editor box, for any paint option like "Size" on the left, there will be a "link" icon. Right click on that option to Lock the option. Now that particular setting will remain constant across all presets. If you cange it in one preset - the changes will reflect across all presets.
    To unlock any option : right click on a locked option and click on Drop Locked Settings. You can either use these settings in the preset or load the last settings available in the preset.

Cumulative Undo/Redo
1. To use this feature, you will have to first have to go to Settings->Dockers->Undo History to activate the docker.
2. Next right click on <empty> or on any stroke in the undo docker and select "Use Cumulative Undo/Redo"
3. This feature merges commands together so the the user doesn't have to undo a particular group one by one and has a much larger undo history than the initial 30 strokes. The feature works on three configurable parameters :
Time before merging strokes together : While strokes are made, the code keeps checking for a particular timelapse of T seconds before it merges the groups together
Time to group the strokes : According to this parameter -- groups are made. Every stroke is put into the same group till two consecutive strokes have a time gap of more than T seconds. Then a new group is started.
Individual strokes to leave at the end : A user may want to keep the ability of Undoing/Redoing his last N strokes. Once N is crossed -- the earlier strokes are merged into the group's first stroke.
parent 88648473
......@@ -557,7 +557,7 @@ void MainWindow::resourceChanged(int key, const QVariant& v)
return;
KisPaintOpPresetSP preset = v.value<KisPaintOpPresetSP>();
if(preset && d->sketchKisView != 0) {
KisPaintOpPresetSP clone = preset->clone();
KisPaintOpPresetSP clone = preset;
clone->settings()->setNode(d->sketchKisView->resourceProvider()->currentNode());
d->sketchKisView->resourceProvider()->setPaintOpPreset(clone);
}
......@@ -571,7 +571,7 @@ void MainWindow::resourceChangedSketch(int key, const QVariant& v)
return;
KisPaintOpPresetSP preset = v.value<KisPaintOpPresetSP>();
if(preset && d->desktopKisView != 0) {
KisPaintOpPresetSP clone = preset->clone();
KisPaintOpPresetSP clone = preset;
clone->settings()->setNode(d->desktopKisView->resourceProvider()->currentNode());
d->desktopKisView->resourceProvider()->setPaintOpPreset(clone);
}
......
......@@ -66,6 +66,9 @@ set(kritaimage_LIB_SRCS
brushengine/kis_paintop_preset.cpp
brushengine/kis_paintop_registry.cc
brushengine/kis_paintop_settings.cpp
brushengine/kis_locked_properties.cc
brushengine/kis_locked_properties_proxy.cpp
brushengine/kis_locked_properties_server.cpp
commands/kis_deselect_global_selection_command.cpp
commands/kis_image_change_layers_command.cpp
commands/kis_image_command.cpp
......@@ -340,4 +343,7 @@ install( FILES
filter/kis_filter_configuration.h
generator/kis_generator.h
generator/kis_generator_registry.h
brushengine/kis_locked_properties.h
brushengine/kis_locked_properties_proxy.h
brushengine/kis_locked_properties_server.h
DESTINATION ${INCLUDE_INSTALL_DIR}/krita)
/*
* Copyright (c) 2014 Dmitry Kazakov <dimula73@gmail.com>
* Copyright (c) 2014 Mohit Goyal <mohit.bits2011@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_locked_properties.h"
KisLockedProperties::KisLockedProperties()
{
m_lockedProperties = new KisPropertiesConfiguration();
}
KisLockedProperties::KisLockedProperties(KisPropertiesConfiguration *p)
{
m_lockedProperties = new KisPropertiesConfiguration();
QMap<QString, QVariant>::Iterator i;
for (i = p->getProperties().begin(); i != p->getProperties().end(); i++) {
m_lockedProperties->setProperty(i.key(), i.value());
}
}
void KisLockedProperties::addToLockedProperties(KisPropertiesConfiguration *p)
{
QMapIterator<QString, QVariant> i(p->getProperties());
while (i.hasNext()) {
i.next();
m_lockedProperties->setProperty(i.key(), QVariant(i.value()));
}
}
void KisLockedProperties::removeFromLockedProperties(KisPropertiesConfiguration *p)
{
KisPropertiesConfiguration *temp = new KisPropertiesConfiguration();
QMapIterator<QString, QVariant> i(m_lockedProperties->getProperties());
while (i.hasNext()) {
i.next();
temp->setProperty(i.key(), QVariant(i.value()));
}
m_lockedProperties->clearProperties();
QMapIterator<QString, QVariant> j(temp->getProperties());
while (j.hasNext()) {
j.next();
if (!p->hasProperty(j.key())) {
m_lockedProperties->setProperty(j.key(), QVariant(j.value()));
}
}
}
bool KisLockedProperties::hasProperty(const QString &p)
{
return m_lockedProperties->hasProperty(p);
}
KisPropertiesConfiguration *KisLockedProperties::lockedProperties()
{
return m_lockedProperties;
}
/*
* Copyright (c) 2014 Dmitry Kazakov <dimula73@gmail.com>
* Copyright (c) 2014 Mohit Goyal <mohit.bits2011@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KISLOCKEDPROPERTIES_H
#define KISLOCKEDPROPERTIES_H
#include "kis_properties_configuration.h"
#include "kis_paintop_settings.h"
/**
* This class maintains a list of all the PaintOp Options that are supposed to be
* constant across all paintops and presets.
* addToLockedProperties() adds all the settings mentioned in the parameter to the list
* removeFromLockedProperties() removes a particular set of properties from the list
* hasProperty() checks for a particular property in the list
*/
class KisLockedProperties
{
public:
KisLockedProperties();
KisLockedProperties(KisPropertiesConfiguration *p);
/**Whenever any setting is made locked**/
void addToLockedProperties(KisPropertiesConfiguration *p);
/**Whenever any property is unlocked**/
void removeFromLockedProperties(KisPropertiesConfiguration *p);
bool hasProperty(const QString &p);
KisPropertiesConfiguration *lockedProperties();
private:
KisPropertiesConfiguration* m_lockedProperties;
};
#endif // KISLOCKEDPROPERTIES_H
/*
* Copyright (c) 2014 Dmitry Kazakov <dimula73@gmail.com>
* Copyright (c) 2014 Mohit Goyal <mohit.bits2011@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_locked_properties_proxy.h"
KisLockedPropertiesProxy ::KisLockedPropertiesProxy()
{
m_lockedProperties = NULL;
m_parent = NULL;
}
KisLockedPropertiesProxy::KisLockedPropertiesProxy(KisLockedProperties* p)
{
m_lockedProperties = p;
}
KisLockedPropertiesProxy::KisLockedPropertiesProxy(const KisPropertiesConfiguration *p, KisLockedProperties *l)
{
m_lockedProperties = l;
m_parent = p;
}
QVariant KisLockedPropertiesProxy::getProperty(const QString &name) const
{
KisPropertiesConfiguration* temp = const_cast<KisPropertiesConfiguration*>(m_parent);
KisPaintOpSettings* t = dynamic_cast<KisPaintOpSettings*>(temp);
bool saveDirtyState = t->preset()->isPresetDirty();
if (m_lockedProperties->lockedProperties()) {
if (m_lockedProperties->lockedProperties()->hasProperty(name)) {
KisLockedPropertiesServer::instance()->setPropertiesFromLocked(true);
if (!m_parent->hasProperty(name + "_previous")) {
temp->setProperty(name + "_previous", m_parent->getProperty(name));
}
temp->setProperty(name, m_lockedProperties->lockedProperties()->getProperty(name));
t->preset()->setPresetDirty(saveDirtyState);
return m_lockedProperties->lockedProperties()->getProperty(name);
} else {
if (m_parent->hasProperty(name + "_previous")) {
KisPropertiesConfiguration* temp = const_cast<KisPropertiesConfiguration*>(m_parent);
temp->setProperty(name, m_parent->getProperty(name + "_previous"));
temp->removeProperty(name + "_previous");
}
}
}
t->preset()->setPresetDirty(saveDirtyState);
return m_parent->getProperty(name);
}
void KisLockedPropertiesProxy::setProperty(const QString & name, const QVariant & value)
{
KisPropertiesConfiguration* temp = const_cast<KisPropertiesConfiguration*>(m_parent);
KisPaintOpSettings* t = dynamic_cast<KisPaintOpSettings*>(temp);
bool saveDirtyState = t->preset()->isPresetDirty();
if (m_lockedProperties->lockedProperties()) {
if (m_lockedProperties->lockedProperties()->hasProperty(name)) {
m_lockedProperties->lockedProperties()->setProperty(name, value);
t->setProperty(name, value);
if (!m_parent->hasProperty(name + "_previous")) {
t->setProperty(name + "_previous", m_parent->getProperty(name));
}
t->preset()->setPresetDirty(saveDirtyState);
return;
}
}
t->setProperty(name, value);
}
/*
* Copyright (c) 2014 Dmitry Kazakov <dimula73@gmail.com>
* Copyright (c) 2014 Mohit Goyal <mohit.bits2011@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_LOCKED_PROPERTIES_PROXY_H
#define KIS_LOCKED_PROPERTIES_PROXY_H
#include "kis_locked_properties.h"
#include "kis_properties_configuration.h"
#include "kis_locked_properties_server.h"
#include "kis_paintop_preset.h"
#include "kis_paintop_settings.h"
/**
* This class acts as a proxy for all transfers between KisLockedPropertiesServer and KisPaintOpSettings
* while using setConfiguration and writeConfiguration methods. It is used to override the local settings of a
* paintop with the settings present in the KisLockedProperties List.
* Settings with the "_previous" suffix are used to save the local settings of a preset in the preset itself.
* Whenever the user selects the option of going back to the previous configuration of the preset or "unlocks" an option -- these settings are restored
* and the settings with the "_previous" suffix are destroyed.
*/
class KisLockedPropertiesServer;
class KisLockedPropertiesProxy: public KisPropertiesConfiguration
{
public:
KisLockedPropertiesProxy() ;
KisLockedPropertiesProxy(KisLockedProperties* p);
KisLockedPropertiesProxy(const KisPropertiesConfiguration *, KisLockedProperties *);
using KisPropertiesConfiguration::getProperty;
QVariant getProperty(const QString &name) const;
using KisPropertiesConfiguration::setProperty;
void setProperty(const QString & name, const QVariant & value);
private:
KisLockedProperties* m_lockedProperties;
const KisPropertiesConfiguration* m_parent;
};
#endif // KIS_LOCKED_PROPERTIES_PROXY_H
/*
* Copyright (c) 2014 Dmitry Kazakov <dimula73@gmail.com>
* Copyright (c) 2014 Mohit Goyal <mohit.bits2011@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_locked_properties_server.h"
KisLockedPropertiesServer::KisLockedPropertiesServer()
{
m_lockedProperties = new KisLockedProperties();
m_propertiesFromLocked = false;
}
KisLockedPropertiesProxy* KisLockedPropertiesServer::createLockedPropertiesProxy(const KisPropertiesConfiguration* config)
{
KisLockedPropertiesProxy* m = new KisLockedPropertiesProxy(config, lockedProperties());
return m;
}
KisLockedPropertiesServer* KisLockedPropertiesServer::instance()
{
K_GLOBAL_STATIC(KisLockedPropertiesServer, s_instance);
if (s_instance) {
return s_instance;
}
return NULL;
}
KisLockedProperties* KisLockedPropertiesServer::lockedProperties()
{
return m_lockedProperties;
}
void KisLockedPropertiesServer::addToLockedProperties(KisPropertiesConfiguration *p)
{
lockedProperties()->addToLockedProperties(p);
}
void KisLockedPropertiesServer::removeFromLockedProperties(KisPropertiesConfiguration *p)
{
lockedProperties()->removeFromLockedProperties(p);
}
void KisLockedPropertiesServer::setPropertiesFromLocked(bool value)
{
m_propertiesFromLocked = value;
}
bool KisLockedPropertiesServer::propertiesFromLocked()
{
return m_propertiesFromLocked;
}
bool KisLockedPropertiesServer::hasProperty(const QString &p)
{
return m_lockedProperties->hasProperty(p);
}
/*
* Copyright (c) 2014 Dmitry Kazakov <dimula73@gmail.com>
* Copyright (c) 2014 Mohit Goyal <mohit.bits2011@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_LOCKED_PROPERTIES_SERVER_H
#define KIS_LOCKED_PROPERTIES_SERVER_H
#include "kis_locked_properties.h"
#include "kis_locked_properties_proxy.h"
#include "kis_properties_configuration.h"
#include "kglobal.h"
class KisLockedPropertiesProxy;
/**
* The KisLockedPropertiesServer class
* This static class stores an object of KisLockedProperties and generates a KisLockedPropertiesProxy used
* by other classes/objects to access the LockedProperties object.
*/
class KRITAIMAGE_EXPORT KisLockedPropertiesServer: public QObject
{
public:
KisLockedPropertiesServer();
static KisLockedPropertiesServer* instance();
KisLockedProperties* lockedProperties();
void addToLockedProperties(KisPropertiesConfiguration *p);
void removeFromLockedProperties(KisPropertiesConfiguration *p);
void setPropertiesFromLocked(bool value);
bool propertiesFromLocked();
KisLockedPropertiesProxy* createLockedPropertiesProxy(const KisPropertiesConfiguration*);
bool hasProperty(const QString &p);
private:
KisLockedProperties* m_lockedProperties;
bool m_propertiesFromLocked;
};
#endif // KIS_LOCKED_PROPERTIES_SERVER_H
......@@ -94,12 +94,12 @@ KisPaintInformation::DistanceInformationRegistrar::
}
KisPaintInformation::KisPaintInformation(const QPointF & pos_,
qreal pressure_,
qreal xTilt_, qreal yTilt_,
qreal rotation_,
qreal tangentialPressure_,
qreal perspective_,
int time)
qreal pressure_,
qreal xTilt_, qreal yTilt_,
qreal rotation_,
qreal tangentialPressure_,
qreal perspective_,
int time)
: d(new Private)
{
d->pos = pos_;
......@@ -134,11 +134,11 @@ bool KisPaintInformation::isHoveringMode() const
KisPaintInformation
KisPaintInformation::createHoveringModeInfo(const QPointF &pos,
qreal pressure,
qreal xTilt, qreal yTilt,
qreal rotation,
qreal tangentialPressure,
qreal perspective)
qreal pressure,
qreal xTilt, qreal yTilt,
qreal rotation,
qreal tangentialPressure,
qreal perspective)
{
KisPaintInformation info(pos,
pressure,
......@@ -383,17 +383,17 @@ qreal KisPaintInformation::tiltElevation(const KisPaintInformation& info, qreal
{
qreal xTilt = qBound(qreal(-1.0), info.xTilt() / maxTiltX , qreal(1.0));
qreal yTilt = qBound(qreal(-1.0), info.yTilt() / maxTiltY , qreal(1.0));
qreal e;
if (fabs(xTilt) > fabs(yTilt)) {
e = sqrt(qreal(1.0) + yTilt*yTilt);
e = sqrt(qreal(1.0) + yTilt * yTilt);
} else {
e = sqrt(qreal(1.0) + xTilt*xTilt);
e = sqrt(qreal(1.0) + xTilt * xTilt);
}
qreal cosAlpha = sqrt(xTilt*xTilt + yTilt*yTilt)/e;
qreal cosAlpha = sqrt(xTilt * xTilt + yTilt * yTilt) / e;
qreal tiltElevation = acos(cosAlpha); // in radians in [0, 0.5 * PI]
// mapping to 0.0..1.0 if normalize is true
return normalize ? (tiltElevation / (M_PI * qreal(0.5))) : tiltElevation;
}
......
......@@ -62,7 +62,8 @@ public:
* of the return value. So if it doesn't work for some reason,
* please implement a proper copy c-tor
*/
class KRITAIMAGE_EXPORT DistanceInformationRegistrar {
class KRITAIMAGE_EXPORT DistanceInformationRegistrar
{
public:
DistanceInformationRegistrar(KisPaintInformation *_p, KisDistanceInformation *distanceInfo);
~DistanceInformationRegistrar();
......@@ -146,7 +147,7 @@ public:
/// reciprocal of distance on the perspective grid
qreal perspective() const;
/// Number of ms since the beginning of the stroke
int currentTime() const;
......@@ -172,11 +173,11 @@ public:
* \see isHoveringMode()
*/
static KisPaintInformation createHoveringModeInfo(const QPointF &pos,
qreal pressure = PRESSURE_DEFAULT,
qreal xTilt = 0.0, qreal yTilt = 0.0,
qreal rotation = 0.0,
qreal tangentialPressure = 0.0,
qreal perspective = 1.0);
qreal pressure = PRESSURE_DEFAULT,
qreal xTilt = 0.0, qreal yTilt = 0.0,
qreal rotation = 0.0,
qreal tangentialPressure = 0.0,
qreal perspective = 1.0);
void toXML(QDomDocument&, QDomElement&) const;
......@@ -186,8 +187,8 @@ public:
static KisPaintInformation mixOnlyPosition(qreal t, const KisPaintInformation& mixedPi, const KisPaintInformation& basePi);
static KisPaintInformation mix(const QPointF& p, qreal t, const KisPaintInformation& p1, const KisPaintInformation& p2);
static KisPaintInformation mix(qreal t, const KisPaintInformation& pi1, const KisPaintInformation& pi2);
static qreal tiltDirection(const KisPaintInformation& info, bool normalize=true);
static qreal tiltElevation(const KisPaintInformation& info, qreal maxTiltX=60.0, qreal maxTiltY=60.0, bool normalize=true);
static qreal tiltDirection(const KisPaintInformation& info, bool normalize = true);
static qreal tiltElevation(const KisPaintInformation& info, qreal maxTiltX = 60.0, qreal maxTiltY = 60.0, bool normalize = true);
private:
struct Private;
......
......@@ -180,7 +180,7 @@ void KisPaintOp::paintLine(const KisPaintInformation &pi1,
pi = KisPaintInformation::mix(pt, t, pi, pi2);
if (d->fanCornersEnabled &&
currentDistance->hasLastPaintInformation()) {
currentDistance->hasLastPaintInformation()) {
d->paintFan(currentDistance->lastPaintInformation(),
pi,
......@@ -203,7 +203,7 @@ bool KisPaintOp::Private::paintFan(const KisPaintInformation &pi1,
const qreal initialAngle = currentDistance->lastDrawingAngle();
const qreal finalAngle = pi2.drawingAngleSafe(*currentDistance);
const qreal fullDistance = shortestAngularDistance(initialAngle,
pi2.drawingAngleSafe(*currentDistance));
pi2.drawingAngleSafe(*currentDistance));
qreal lastAngle = initialAngle;
int i = 0;
......
......@@ -87,10 +87,10 @@ public:
KisDistanceInformation *currentDistance);
/**
* Whether this paintop can paint. Can be false in case that some setting isn't read correctly.
* @return if paintop is ready for painting, default is true
*/
/**
* Whether this paintop can paint. Can be false in case that some setting isn't read correctly.
* @return if paintop is ready for painting, default is true
*/
virtual bool canPaint() const {
return true;
}
......
......@@ -47,8 +47,7 @@ bool KisPaintOpFactory::userVisible(const KoColorSpace * cs) const
{
if (m_visibility == AUTO) {
return cs && cs->id() != "WET";
}
else if (m_visibility == NEVER) {
} else if (m_visibility == NEVER) {
return false;
}
return true;
......
......@@ -38,12 +38,16 @@
#include "kis_paint_device.h"
#include "kis_image.h"
struct KisPaintOpPreset::Private {
Private()
: settings(0)
{}
: settings(0) {
}
KisPaintOpSettingsSP settings;
bool dirtyPreset;
};
......@@ -51,6 +55,7 @@ KisPaintOpPreset::KisPaintOpPreset()
: KoResource(QString())
, m_d(new Private)
{
m_d->dirtyPreset = false;
}
KisPaintOpPreset::KisPaintOpPreset(const QString & fileName)
......@@ -67,17 +72,29 @@ KisPaintOpPreset::~KisPaintOpPreset()
KisPaintOpPreset* KisPaintOpPreset::clone() const
{
KisPaintOpPreset * preset = new KisPaintOpPreset();
if (settings()) {
preset->setSettings(settings()->clone());
}
preset->setPresetDirty(isPresetDirty());
// only valid if we could clone the settings
preset->setValid(settings());
preset->setPaintOp(paintOp());
preset->setName(name());
preset->settings()->setPreset(KisPaintOpPresetWSP(preset));
return preset;
}
void KisPaintOpPreset::setPresetDirty(bool value)
{
m_d->dirtyPreset = value;
}
bool KisPaintOpPreset::isPresetDirty() const
{
return m_d->dirtyPreset;
}
void KisPaintOpPreset::setPaintOp(const KoID & paintOp)
{
......@@ -96,12 +113,16 @@ void KisPaintOpPreset::setSettings(KisPaintOpSettingsSP settings)
Q_ASSERT(settings);
Q_ASSERT(!settings->getString("paintop", "").isEmpty());
bool saveDirtyPreset = isPresetDirty();
if (settings) {
m_d->settings = settings->clone();
}
else {
m_d->settings->setPreset(KisPaintOpPresetWSP(this));
} else {
m_d->settings = 0;
m_d->settings->setPreset(0);
}