Commit aa6e7390 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix update and undo when changing layer visibility using timeline

Conflicts:
	krita/ui/kis_node_model.cpp
parent 5346ee8f
......@@ -20,7 +20,11 @@
#include "kis_node.h"
#include "kis_layer.h"
#include "kis_image.h"
#include "kis_selection_mask.h"
#include "kis_paint_layer.h"
#include "commands/kis_node_property_list_command.h"
#include "kis_undo_adapter.h"
KisNodePropertyListCommand::KisNodePropertyListCommand(KisNodeSP node, KisNodeModel::PropertyList newPropertyList)
......@@ -75,3 +79,36 @@ void KisNodePropertyListCommand::doUpdate(const KisNodeModel::PropertyList &oldP
m_node->setDirty(); // TODO check if visibility was changed or not
}
}
void KisNodePropertyListCommand::setNodePropertiesNoUndo(KisNodeSP node, KisImageSP image, PropertyList proplist)
{
bool undo = true;
foreach(const KisNodeModel::Property &prop, proplist) {
if (prop.name == i18n("Visible") && node->visible() != prop.state.toBool()) undo = false;
if (prop.name == i18n("Locked") && node->userLocked() != prop.state.toBool()) undo = false;
if (prop.name == i18n("Active")) {
if (KisSelectionMask *m = dynamic_cast<KisSelectionMask*>(node.data())) {
if (m->active() != prop.state.toBool()) {
undo = false;
}
}
}
if (prop.name == i18n("Alpha Locked")) {
if (KisPaintLayer* l = dynamic_cast<KisPaintLayer*>(node.data())) {
if (l->alphaLocked() != prop.state.toBool()) {
undo = false;
}
}
}
}
QScopedPointer<KUndo2Command> cmd(new KisNodePropertyListCommand(node, proplist));
if (undo) {
image->undoAdapter()->addCommand(cmd.take());
}
else {
image->setModified();
cmd->redo();
}
}
......@@ -37,6 +37,10 @@ public:
virtual void redo();
virtual void undo();
typedef KisNodeModel::PropertyList PropertyList;
static void setNodePropertiesNoUndo(KisNodeSP node, KisImageSP image, PropertyList proplist);
private:
void doUpdate(const KisNodeModel::PropertyList &oldPropertyList,
const KisNodeModel::PropertyList &newPropertyList);
......
......@@ -37,6 +37,7 @@
#include "kis_post_execution_undo_adapter.h"
#include "kis_animation_frame_cache.h"
#include "kis_animation_player.h"
#include <commands/kis_node_property_list_command.h>
struct TimelineFramesModel::Private
......@@ -129,7 +130,7 @@ struct TimelineFramesModel::Private
KisNodeDummy *dummy = converter->dummyFromRow(row);
if (!dummy) return false;
dummy->node()->setSectionModelProperties(props);
KisNodePropertyListCommand::setNodePropertiesNoUndo(dummy->node(), image, props);
return true;
}
......
......@@ -486,36 +486,7 @@ bool KisNodeModel::setData(const QModelIndex &index, const QVariant &value, int
{
// don't record undo/redo for visibility, locked or alpha locked changes
PropertyList proplist = value.value<PropertyList>();
bool undo = true;
foreach(const KisNodeModel::Property &prop, proplist) {
if (prop.name == i18n("Visible") && node->visible() !=prop.state.toBool()) undo = false;
if (prop.name == i18n("Locked") && node->userLocked() != prop.state.toBool()) undo = false;
if (prop.name == i18n("Active")) {
if (KisSelectionMask *m = dynamic_cast<KisSelectionMask*>(node.data())) {
if (m->active() != prop.state.toBool()) {
undo = false;
}
}
}
if (prop.name == i18n("Alpha Locked")) {
if (KisPaintLayer* l = dynamic_cast<KisPaintLayer*>(node.data())) {
if (l->alphaLocked() != prop.state.toBool()) {
undo = false;
}
}
}
}
KUndo2Command *cmd = new KisNodePropertyListCommand(node, proplist);
if (undo) {
m_d->image->undoAdapter()->addCommand(cmd);
}
else {
m_d->image->setModified();
cmd->redo();
delete cmd;
}
KisNodePropertyListCommand::setNodePropertiesNoUndo(node, m_d->image, proplist);
break;
}
......
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