Fix copy effect or split does not keep disabled state

BUG: 408242
parent b10d53bf
Pipeline #4006 passed with stage
in 27 minutes and 2 seconds
......@@ -46,7 +46,7 @@ EffectItemModel::EffectItemModel(const QList<QVariant> &effectData, std::unique_
}
// static
std::shared_ptr<EffectItemModel> EffectItemModel::construct(const QString &effectId, std::shared_ptr<AbstractTreeModel> stack)
std::shared_ptr<EffectItemModel> EffectItemModel::construct(const QString &effectId, std::shared_ptr<AbstractTreeModel> stack, bool effectEnabled)
{
Q_ASSERT(EffectsRepository::get()->exists(effectId));
QDomElement xml = EffectsRepository::get()->getXml(effectId);
......@@ -57,7 +57,7 @@ std::shared_ptr<EffectItemModel> EffectItemModel::construct(const QString &effec
QList<QVariant> data;
data << EffectsRepository::get()->getName(effectId) << effectId;
std::shared_ptr<EffectItemModel> self(new EffectItemModel(data, std::move(effect), xml, effectId, stack, true));
std::shared_ptr<EffectItemModel> self(new EffectItemModel(data, std::move(effect), xml, effectId, stack, effectEnabled));
baseFinishConstruct(self);
return self;
......
......@@ -37,7 +37,7 @@ public:
/* This construct an effect of the given id
@param is a ptr to the model this item belongs to. This is required to send update signals
*/
static std::shared_ptr<EffectItemModel> construct(const QString &effectId, std::shared_ptr<AbstractTreeModel> stack);
static std::shared_ptr<EffectItemModel> construct(const QString &effectId, std::shared_ptr<AbstractTreeModel> stack, bool effectEnabled = true);
/* This construct an effect with an already existing filter
Only used when loading an existing clip
*/
......
......@@ -216,6 +216,13 @@ QDomElement EffectStackModel::toXml(QDomDocument &document)
sub.setAttribute(QStringLiteral("in"), filterIn);
sub.setAttribute(QStringLiteral("out"), filterOut);
}
QStringList passProps {QStringLiteral("disable"), QStringLiteral("kdenlive:collapsed")};
for (const QString &param : passProps) {
int paramVal = sourceEffect->filter().get_int(param.toUtf8().constData());
if (paramVal > 0) {
Xml::setXmlProperty(sub, param, QString::number(paramVal));
}
}
QVector<QPair<QString, QVariant>> params = sourceEffect->getAllParameters();
QLocale locale;
for (const auto &param : params) {
......@@ -247,7 +254,11 @@ bool EffectStackModel::fromXml(const QDomElement &effectsXml, Fun &undo, Fun &re
} else if (state != PlaylistState::VideoOnly) {
continue;
}
auto effect = EffectItemModel::construct(effectId, shared_from_this());
bool effectEnabled = true;
if (Xml::hasXmlProperty(node, QLatin1String("disable"))) {
effectEnabled = Xml::getXmlProperty(node, QLatin1String("disable")).toInt() != 1;
}
auto effect = EffectItemModel::construct(effectId, shared_from_this(), effectEnabled);
const QString in = node.attribute(QStringLiteral("in"));
const QString out = node.attribute(QStringLiteral("out"));
if (!out.isEmpty()) {
......@@ -323,8 +334,12 @@ bool EffectStackModel::copyEffect(const std::shared_ptr<AbstractEffectItem> &sou
}
std::shared_ptr<EffectItemModel> sourceEffect = std::static_pointer_cast<EffectItemModel>(sourceItem);
const QString effectId = sourceEffect->getAssetId();
auto effect = EffectItemModel::construct(effectId, shared_from_this());
bool enabled = sourceEffect->isEnabled();
auto effect = EffectItemModel::construct(effectId, shared_from_this(), enabled);
effect->setParameters(sourceEffect->getAllParameters());
if (!enabled) {
effect->filter().set("disable", 1);
}
effect->filter().set("in", sourceEffect->filter().get_int("in"));
effect->filter().set("out", sourceEffect->filter().get_int("out"));
Fun local_undo = removeItem_lambda(effect->getId());
......
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