Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

More fade fixes

parent 98a1c0e4
......@@ -76,7 +76,6 @@ AssetParameterModel::AssetParameterModel(Mlt::Properties *asset, const QDomEleme
QString name = currentParameter.attribute(QStringLiteral("name"));
QString type = currentParameter.attribute(QStringLiteral("type"));
QString value = currentParameter.attribute(QStringLiteral("value"));
if (value.isNull()) {
value = parseAttribute(QStringLiteral("default"), currentParameter).toString();
}
......
......@@ -30,7 +30,7 @@ PositionEditWidget::PositionEditWidget(std::shared_ptr<AssetParameterModel> mode
: AbstractParamWidget(std::move(model), index, parent)
{
auto *layout = new QHBoxLayout(this);
QString name = m_model->data(m_index, AssetParameterModel::NameRole).toString();
QString name = m_model->data(m_index, Qt::DisplayRole).toString();
QString comment = m_model->data(m_index, AssetParameterModel::CommentRole).toString();
//TODO: take absolute from effect data
m_absolute = false;
......
......@@ -428,6 +428,13 @@ void EffectStackModel::importEffects(std::shared_ptr<EffectStackModel> sourceSta
auto clone = EffectItemModel::construct(effect->getAssetId(), shared_from_this());
rootItem->appendChild(clone);
clone->setParameters(effect->getAllParameters());
const QString effectId = effect->getAssetId();
if (effectId == QLatin1String("fadein") || effectId == QLatin1String("fade_from_black")) {
fadeIns << clone->getId();
} else if (effectId == QLatin1String("fadeout") || effectId == QLatin1String("fade_to_black")) {
fadeOuts << clone->getId();
}
// TODO parent should not always be root
Fun redo = addItem_lambda(clone, rootItem->getId());
connect(effect.get(), &AssetParameterModel::modelChanged, this, &EffectStackModel::modelChanged);
......@@ -586,3 +593,25 @@ void EffectStackModel::replugEffect(std::shared_ptr<AssetParameterModel> asset)
}
}
void EffectStackModel::cleanFadeEffects(bool outEffects, Fun &undo, Fun &redo)
{
QList<int> toDelete = outEffects ? fadeOuts : fadeIns;
for (int id : toDelete) {
auto effect = std::static_pointer_cast<EffectItemModel>(getItemById(id));
Fun operation = removeItem_lambda(id);
if (operation()) {
Fun reverse = addItem_lambda(effect, rootItem->getId());
PUSH_LAMBDA(operation, redo);
PUSH_LAMBDA(reverse, undo);
}
}
if (!toDelete.isEmpty()) {
Fun update = [this]() {
//TODO: only update if effect is fade or keyframe
pCore->updateItemKeyframes(m_ownerId);
return true;
};
update();
PUSH_LAMBDA(update, redo);
}
}
......@@ -95,6 +95,8 @@ public:
Q_INVOKABLE double getFilter(const QString &effectId, const QString &paramName);
/** get the active effect's keyframe model */
Q_INVOKABLE KeyframeModel *getEffectKeyframeModel();
/** Remove unwanted fade effects, mostly after a cut operation */
void cleanFadeEffects(bool outEffects, Fun &undo, Fun &redo);
public slots:
/* @brief Delete an effect from the stack */
......@@ -124,7 +126,7 @@ private:
* in the producer, so we shouldn't plant them again. Setting this value to
* true will prevent planting in the producer */
bool m_loadingExisting;
private slots:
/** @brief: Some effects do not support dynamic changes like sox, and need to be unplugged / replugged on each param change
*/
......
......@@ -66,6 +66,11 @@ bool TimelineFunctions::requestClipCut(std::shared_ptr<TimelineItemModel> timeli
res = res && timeline->requestItemResize(clipId, position - start, true, true, undo, redo);
int newDuration = timeline->getClipPlaytime(clipId);
res = res && timeline->requestItemResize(newId, duration - newDuration, false, true, undo, redo);
// parse effects
std::shared_ptr<EffectStackModel> sourceStack = timeline->getClipEffectStackModel(clipId);
sourceStack->cleanFadeEffects(true, undo, redo);
std::shared_ptr<EffectStackModel> destStack = timeline->getClipEffectStackModel(newId);
destStack->cleanFadeEffects(false, undo, redo);
res = res && timeline->requestClipMove(newId, timeline->getClipTrackId(clipId), position, true, false, undo, redo);
return res;
}
......
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