Project clip: correctly handle effect change on child producers

parent ec38fa3d
......@@ -100,6 +100,7 @@ AssetParameterModel::AssetParameterModel(Mlt::Properties *asset, const QDomEleme
}
qDebug() << "END parsing of "<<assetId<<". Number of found parameters"<<m_rows.size();
emit modelChanged();
}
void AssetParameterModel::prepareKeyframes()
......@@ -138,6 +139,7 @@ void AssetParameterModel::setParameter(const QString &name, const QString &value
m_fixedParams[name] = value;
}
}
emit modelChanged();
pCore->refreshProjectItem(m_ownerId);
pCore->invalidateItem(m_ownerId);
}
......@@ -151,6 +153,7 @@ void AssetParameterModel::setParameter(const QString &name, double &value)
} else {
m_fixedParams[name] = value;
}
emit modelChanged();
pCore->refreshProjectItem(m_ownerId);
pCore->invalidateItem(m_ownerId);
}
......
......@@ -162,6 +162,9 @@ protected:
std::unique_ptr<Mlt::Properties> m_asset;
std::shared_ptr<KeyframeModelList> m_keyframes;
signals:
void modelChanged();
};
#endif
......@@ -157,9 +157,12 @@ ProjectClip::~ProjectClip()
void ProjectClip::connectEffectStack()
{
connect(m_effectStack.get(), &EffectStackModel::dataChanged, [&](QModelIndex,QModelIndex,QVector<int>){
connect(m_effectStack.get(), &EffectStackModel::modelChanged, this, &ProjectClip::updateChildProducers);
connect(m_effectStack.get(), &EffectStackModel::dataChanged, this, &ProjectClip::updateChildProducers);
/*connect(m_effectStack.get(), &EffectStackModel::modelChanged, [&](){
qDebug()<<"/ / / STACK CHANGED";
updateChildProducers();
});
});*/
}
......@@ -418,7 +421,7 @@ std::shared_ptr<Mlt::Producer> ProjectClip::timelineProducer(PlaylistState::Clip
return m_timelineProducers.find(0)->second;
}
std::shared_ptr<Mlt::Producer> videoProd = cloneProducer();
videoProd->set("audio_index", -1);
videoProd->parent().set("audio_index", -1);
m_timelineProducers[0] = videoProd;
return videoProd;
}
......@@ -427,7 +430,7 @@ std::shared_ptr<Mlt::Producer> ProjectClip::timelineProducer(PlaylistState::Clip
return m_timelineProducers.find(-track)->second;
}
std::shared_ptr<Mlt::Producer> audioProd = cloneProducer();
audioProd->set("video_index", -1);
audioProd->parent().set("video_index", -1);
m_timelineProducers[-track] = audioProd;
return audioProd;
}
......@@ -459,7 +462,8 @@ std::shared_ptr<Mlt::Producer> ProjectClip::cloneProducer()
s.set("ignore_points", ignore);
}
const QByteArray clipXml = c.get("string");
std::shared_ptr<Mlt::Producer> prod(new Mlt::Producer(*m_masterProducer->profile(), "xml-string", clipXml.constData()));
QScopedPointer<Mlt::Producer> parent(new Mlt::Producer(*m_masterProducer->profile(), "xml-string", clipXml.constData()));
std::shared_ptr<Mlt::Producer> prod(parent->cut());
return prod;
}
......@@ -1344,9 +1348,12 @@ bool ProjectClip::isIncludedInTimeline()
void ProjectClip::updateChildProducers()
{
// pass effect stack on all child producers
QMutexLocker locker(&m_producerMutex);
for (const auto &clip : m_timelineProducers) {
if (auto producer = clip.second) {
Clip(*producer.get()).replaceEffects(*m_masterProducer);
Clip clp(producer->parent());
clp.deleteEffects();
clp.replaceEffects(*m_masterProducer);
}
}
}
......
......@@ -25,6 +25,7 @@
#include "effects/effectsrepository.hpp"
#include "effectstackmodel.hpp"
#include <utility>
#include <KLocalizedString>
AbstractEffectItem::AbstractEffectItem(EffectItemType type, const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &stack, bool isRoot)
: TreeItem(data, stack, isRoot)
......
......@@ -23,7 +23,6 @@
#define ABSTRACTEFFECTITEM_H
#include "abstractmodel/treeitem.hpp"
#include "assets/model/assetparametermodel.hpp"
#include <mlt++/MltFilter.h>
enum class EffectItemType {Effect, Group};
......
......@@ -49,7 +49,6 @@ std::shared_ptr<EffectItemModel> EffectItemModel::construct(const QString &effec
std::shared_ptr<EffectItemModel> self(new EffectItemModel(data, effect, xml, effectId, std::move(stack)));
baseFinishConstruct(self);
return self;
}
......
......@@ -50,7 +50,6 @@ void EffectStackModel::loadEffects()
{
auto ptr = m_service.lock();
if (ptr) {
qDebug()<<"// FOUND FILTERS IN CLIP: "<<ptr->filter_count();
for (int i = 0; i < ptr->filter_count(); i++) {
if (ptr->filter(i)->get("kdenlive_id") == nullptr) {
// don't consider internal MLT stuff
......@@ -58,13 +57,14 @@ void EffectStackModel::loadEffects()
}
auto effect = EffectItemModel::construct(ptr->filter(i), shared_from_this());
//effect->setParameters
qDebug()<<"// Adding effect: "<<effect->getAssetId();
Fun redo = addItem_lambda(effect, rootItem->getId());
bool res = redo();
connect(effect.get(), &AssetParameterModel::modelChanged, this, &EffectStackModel::modelChanged);
}
} else {
qDebug()<<"// CANNOT LOCK CLIP SEEVCE";
}
this->modelChanged();
}
......@@ -108,6 +108,7 @@ void EffectStackModel::copyEffect(std::shared_ptr<AbstractEffectItem> sourceItem
Fun undo = removeItem_lambda(effect->getId());
// TODO the parent should probably not always be the root
Fun redo = addItem_lambda(effect, rootItem->getId());
connect(effect.get(), &AssetParameterModel::modelChanged, this, &EffectStackModel::modelChanged);
bool res = redo();
if (res) {
QString effectName = EffectsRepository::get()->getName(effectId);
......@@ -121,6 +122,7 @@ void EffectStackModel::appendEffect(const QString &effectId)
Fun undo = removeItem_lambda(effect->getId());
// TODO the parent should probably not always be the root
Fun redo = addItem_lambda(effect, rootItem->getId());
connect(effect.get(), &AssetParameterModel::modelChanged, this, &EffectStackModel::modelChanged);
bool res = redo();
if (res) {
if (effectId == QLatin1String("fadein") || effectId == QLatin1String("fade_from_black")) {
......@@ -308,6 +310,7 @@ void EffectStackModel::importEffects(std::shared_ptr<EffectStackModel> sourceSta
clone->setParameters(effect->getAllParameters());
// TODO parent should not always be root
Fun redo = addItem_lambda(clone, rootItem->getId());
connect(effect.get(), &AssetParameterModel::modelChanged, this, &EffectStackModel::modelChanged);
redo();
}
}
......
......@@ -119,6 +119,9 @@ private:
mutable QReadWriteLock m_lock;
QList <int> fadeIns;
QList <int> fadeOuts;
signals:
void modelChanged();
};
#endif
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