Timeline preview fixes: Don't invalidate on expand/collapse effect, invalidate on master clip edit

parent a568c015
......@@ -2617,7 +2617,7 @@ void Bin::slotEffectDropped(QString id, QDomElement effect)
m_doc->commandStack()->push(command);
}
void Bin::slotUpdateEffect(QString id, QDomElement oldEffect, QDomElement newEffect, int ix, bool refreshStack)
void Bin::slotUpdateEffect(QString id, QDomElement oldEffect, QDomElement newEffect, int ix, bool refreshStack, bool updateClip)
{
if (id.isEmpty()) {
id = m_monitor->activeClipId();
......@@ -2625,7 +2625,7 @@ void Bin::slotUpdateEffect(QString id, QDomElement oldEffect, QDomElement newEff
if (id.isEmpty()) {
return;
}
UpdateBinEffectCommand *command = new UpdateBinEffectCommand(this, id, oldEffect, newEffect, ix, refreshStack);
UpdateBinEffectCommand *command = new UpdateBinEffectCommand(this, id, oldEffect, newEffect, ix, refreshStack, updateClip);
m_doc->commandStack()->push(command);
}
......@@ -2728,14 +2728,16 @@ void Bin::addEffect(const QString &id, QDomElement &effect)
m_monitor->refreshMonitorIfActive();
}
void Bin::updateEffect(const QString &id, QDomElement &effect, int ix, bool refreshStackWidget)
void Bin::updateEffect(const QString &id, QDomElement &effect, int ix, bool refreshStackWidget, bool updateClip)
{
ProjectClip *currentItem = m_rootFolder->clip(id);
if (!currentItem) {
return;
}
currentItem->updateEffect(m_monitor->profileInfo(), effect, ix, refreshStackWidget);
m_monitor->refreshMonitorIfActive();
currentItem->updateEffect(m_monitor->profileInfo(), effect, ix, refreshStackWidget, updateClip);
if (updateClip) {
m_monitor->refreshMonitorIfActive();
}
}
void Bin::changeEffectState(const QString &id, const QList<int> &indexes, bool disable, bool refreshStack)
......@@ -3260,7 +3262,7 @@ void Bin::slotGotFilterJobResults(const QString &id, int startPos, int track, co
EffectsList::setParameter(newEffect, i.key(), i.value());
++i;
}
ctl->updateEffect(pCore->monitorManager()->projectMonitor()->profileInfo(), newEffect, effect.attribute(QStringLiteral("kdenlive_ix")).toInt());
ctl->updateEffect(pCore->monitorManager()->projectMonitor()->profileInfo(), newEffect, effect.attribute(QStringLiteral("kdenlive_ix")).toInt(), true);
emit masterClipUpdated(ctl, m_monitor);
// TODO use undo / redo for bin clip edit effect
/*EditEffectCommand *command = new EditEffectCommand(this, clip->track(), clip->startPos(), effect, newEffect, clip->selectedEffectIndex(), true, true);
......
......@@ -301,7 +301,7 @@ public:
/** @brief Add an effect to a bin clip. */
void addEffect(const QString &id, QDomElement &effect);
/** @brief Update a bin clip effect. */
void updateEffect(const QString &id, QDomElement &effect, int ix, bool refreshStackWidget);
void updateEffect(const QString &id, QDomElement &effect, int ix, bool refreshStackWidget, bool updateClip);
void changeEffectState(const QString &id, const QList<int> &indexes, bool disable, bool refreshStack);
/** @brief Edit an effect settings to a bin clip. */
void editMasterEffect(ClipController *ctl);
......@@ -370,7 +370,7 @@ private slots:
void slotItemDropped(const QStringList &ids, const QModelIndex &parent);
void slotItemDropped(const QList<QUrl> &urls, const QModelIndex &parent);
void slotEffectDropped(const QString &effect, const QModelIndex &parent);
void slotUpdateEffect(QString id, QDomElement oldEffect, QDomElement newEffect, int ix, bool refreshStack = false);
void slotUpdateEffect(QString id, QDomElement oldEffect, QDomElement newEffect, int ix, bool refreshStack = false, bool updateClip = true);
void slotChangeEffectState(QString id, const QList<int> &indexes, bool disable);
void slotItemEdited(const QModelIndex &, const QModelIndex &, const QVector<int> &);
void slotAddUrl(const QString &url, int folderId, const QMap<QString, QString> &data = QMap<QString, QString>());
......
......@@ -154,26 +154,27 @@ void RemoveBinEffectCommand::redo()
m_bin->removeEffect(m_clipId, m_effect);
}
UpdateBinEffectCommand::UpdateBinEffectCommand(Bin *bin, const QString &clipId, QDomElement &oldEffect, QDomElement &newEffect, int ix, bool refreshStack, QUndoCommand *parent) :
UpdateBinEffectCommand::UpdateBinEffectCommand(Bin *bin, const QString &clipId, QDomElement &oldEffect, QDomElement &newEffect, int ix, bool refreshStack, bool updateClip, QUndoCommand *parent) :
QUndoCommand(parent),
m_bin(bin),
m_clipId(clipId),
m_oldEffect(oldEffect),
m_newEffect(newEffect),
m_ix(ix),
m_refreshStack(refreshStack)
m_refreshStack(refreshStack),
m_updateClip(updateClip)
{
setText(i18n("Edit Bin Effect"));
}
// virtual
void UpdateBinEffectCommand::undo()
{
m_bin->updateEffect(m_clipId, m_oldEffect, m_ix, m_refreshStack);
m_bin->updateEffect(m_clipId, m_oldEffect, m_ix, m_refreshStack, m_updateClip);
}
// virtual
void UpdateBinEffectCommand::redo()
{
m_bin->updateEffect(m_clipId, m_newEffect, m_ix, m_refreshStack);
m_bin->updateEffect(m_clipId, m_newEffect, m_ix, m_refreshStack, m_updateClip);
m_refreshStack = true;
}
......
......@@ -106,7 +106,7 @@ private:
class UpdateBinEffectCommand : public QUndoCommand
{
public:
explicit UpdateBinEffectCommand(Bin *bin, const QString &clipId, QDomElement &oldEffect, QDomElement &newEffect, int ix, bool refreshStack, QUndoCommand *parent = nullptr);
explicit UpdateBinEffectCommand(Bin *bin, const QString &clipId, QDomElement &oldEffect, QDomElement &newEffect, int ix, bool refreshStack, bool updateClip, QUndoCommand *parent = nullptr);
void undo() Q_DECL_OVERRIDE;
void redo() Q_DECL_OVERRIDE;
private:
......@@ -116,6 +116,7 @@ private:
QDomElement m_newEffect;
int m_ix;
bool m_refreshStack;
bool m_updateClip;
};
class ChangeMasterEffectStateCommand : public QUndoCommand
......
......@@ -845,9 +845,9 @@ void ProjectClip::addEffect(const ProfileInfo &pInfo, QDomElement &effect)
bin()->emitItemUpdated(this);
}
void ProjectClip::updateEffect(const ProfileInfo &pInfo, QDomElement &effect, int ix, bool refreshStack)
void ProjectClip::updateEffect(const ProfileInfo &pInfo, QDomElement &effect, int ix, bool refreshStack, bool updateClip)
{
m_controller->updateEffect(pInfo, effect, ix);
m_controller->updateEffect(pInfo, effect, ix, updateClip);
if (refreshStack) {
bin()->updateMasterEffect(m_controller);
}
......
......@@ -193,7 +193,7 @@ public:
void addMarkers(QList<CommentedTime> &markers);
/** @brief Add an effect to bin clip. */
void addEffect(const ProfileInfo &pInfo, QDomElement &effect);
void updateEffect(const ProfileInfo &pInfo, QDomElement &effect, int ix, bool refreshStack);
void updateEffect(const ProfileInfo &pInfo, QDomElement &effect, int ix, bool refreshStack, bool updateClip);
void removeEffect(int ix);
/** @brief Create audio thumbnail for this clip. */
void createAudioThumbs();
......
......@@ -450,7 +450,7 @@ void CollapsibleEffect::updateCollapsedState()
QString info = m_info.toString();
if (info != m_effect.attribute(QStringLiteral("kdenlive_info"))) {
m_effect.setAttribute(QStringLiteral("kdenlive_info"), info);
emit parameterChanged(m_original_effect, m_effect, effectIndex());
emit parameterChanged(m_original_effect, m_effect, effectIndex(), false);
}
}
......
......@@ -141,7 +141,7 @@ protected:
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
signals:
void parameterChanged(const QDomElement &, const QDomElement &, int);
void parameterChanged(const QDomElement &, const QDomElement &, int, bool update = true);
void syncEffectsPos(int);
void effectStateChanged(bool, int ix, MonitorSceneType effectNeedsMonitorScene);
void deleteEffect(const QDomElement &);
......
......@@ -776,16 +776,16 @@ CollapsibleEffect *EffectStackView2::getEffectByIndex(int ix)
return nullptr;
}
void EffectStackView2::slotUpdateEffectParams(const QDomElement &old, const QDomElement &e, int ix)
void EffectStackView2::slotUpdateEffectParams(const QDomElement &old, const QDomElement &e, int ix, bool update)
{
if (m_status == TIMELINE_TRACK) {
emit updateEffect(nullptr, m_trackindex, old, e, ix, false);
emit updateEffect(nullptr, m_trackindex, old, e, ix, false, update);
} else if (m_status == TIMELINE_CLIP && m_clipref) {
emit updateEffect(m_clipref, -1, old, e, ix, false);
emit updateEffect(m_clipref, -1, old, e, ix, false, update);
// Make sure the changed effect is currently displayed
slotSetCurrentEffect(ix);
} else if (m_status == MASTER_CLIP) {
emit updateMasterEffect(m_masterclipref->clipId(), old, e, ix);
emit updateMasterEffect(m_masterclipref->clipId(), old, e, ix, false, update);
}
m_scrollTimer.start();
}
......
......@@ -196,7 +196,7 @@ private slots:
/** @brief Checks whether the monitor scene has to be displayed. */
void slotCheckMonitorPosition(int renderPos);
void slotUpdateEffectParams(const QDomElement &old, const QDomElement &e, int ix);
void slotUpdateEffectParams(const QDomElement &old, const QDomElement &e, int ix, bool update);
/** @brief Move an effect in the stack.
* @param indexes The list of effect index in the stack
......@@ -261,9 +261,9 @@ signals:
void removeMasterEffect(const QString &id, const QDomElement &);
void addMasterEffect(const QString &id, const QDomElement &);
/** Parameters for an effect changed, update the filter in timeline */
void updateEffect(ClipItem *, int, const QDomElement &, const QDomElement &, int, bool);
void updateEffect(ClipItem *, int, const QDomElement &, const QDomElement &, int, bool refreshStack, bool updateClip = true);
/** Parameters for an effect changed, update the filter in timeline */
void updateMasterEffect(QString, const QDomElement &, const QDomElement &, int ix,bool refreshStack = false);
void updateMasterEffect(QString, const QDomElement &, const QDomElement &, int ix,bool refreshStack = false, bool updateClip = true);
/** An effect in stack was moved, we need to regenerate
all effects for this clip in the playlist */
void refreshEffectStack(ClipItem *);
......
......@@ -134,7 +134,7 @@ private:
bool m_conditionParameter;
signals:
void parameterChanged(const QDomElement &, const QDomElement &, int);
void parameterChanged(const QDomElement &, const QDomElement &, int, bool update = true);
void syncEffectsPos(int);
void disableCurrentFilter(bool);
void checkMonitorPosition(int);
......
......@@ -323,7 +323,7 @@ void MainWindow::init(const QString &MltPath, const QUrl &Url, const QString &cl
connect(pCore->bin(), &Bin::masterClipSelected, m_effectStack, &EffectStackView2::slotMasterClipItemSelected);
connect(pCore->bin(), &Bin::masterClipUpdated, m_effectStack, &EffectStackView2::slotRefreshMasterClipEffects);
connect(m_effectStack, SIGNAL(addMasterEffect(QString, QDomElement)), pCore->bin(), SLOT(slotEffectDropped(QString, QDomElement)));
connect(m_effectStack, SIGNAL(updateMasterEffect(QString,QDomElement,QDomElement,int,bool)), pCore->bin(), SLOT(slotUpdateEffect(QString,QDomElement,QDomElement,int,bool)));
connect(m_effectStack, SIGNAL(updateMasterEffect(QString,QDomElement,QDomElement,int,bool,bool)), pCore->bin(), SLOT(slotUpdateEffect(QString,QDomElement,QDomElement,int,bool,bool)));
connect(m_effectStack, SIGNAL(changeMasterEffectState(QString, QList<int>, bool)), pCore->bin(), SLOT(slotChangeEffectState(QString, QList<int>, bool)));
connect(m_effectStack, &EffectStackView2::removeMasterEffect, pCore->bin(), &Bin::slotDeleteEffect);
connect(m_effectStack, SIGNAL(changeEffectPosition(QString, QList<int>, int)), pCore->bin(), SLOT(slotMoveEffect(QString, QList<int>, int)));
......
......@@ -784,7 +784,7 @@ void ClipController::changeEffectState(const QList<int> &indexes, bool disable)
m_binController->updateTrackProducer(clipId());
}
void ClipController::updateEffect(const ProfileInfo &pInfo, const QDomElement &e, int ix)
void ClipController::updateEffect(const ProfileInfo &pInfo, const QDomElement &e, int ix, bool updateClip)
{
QString tag = e.attribute(QStringLiteral("id"));
if (tag == QLatin1String("autotrack_rectangle") || tag.startsWith(QLatin1String("ladspa")) || tag == QLatin1String("sox")) {
......@@ -813,7 +813,9 @@ void ClipController::updateEffect(const ProfileInfo &pInfo, const QDomElement &e
}
service.unlock();
}
m_binController->updateTrackProducer(clipId());
if (updateClip) {
m_binController->updateTrackProducer(clipId());
}
//slotRefreshTracks();
}
......
......@@ -172,7 +172,7 @@ public:
EffectsList effectList();
/** @brief Enable/disable an effect. */
void changeEffectState(const QList<int> &indexes, bool disable);
void updateEffect(const ProfileInfo &pInfo, const QDomElement &e, int ix);
void updateEffect(const ProfileInfo &pInfo, const QDomElement &e, int ix, bool updateClip);
/** @brief Returns true if the bin clip has effects */
bool hasEffects() const;
/** @brief Returns info about clip audio */
......
......@@ -1497,7 +1497,7 @@ void CustomTrackView::mouseDoubleClickEvent(QMouseEvent *event)
item->insertKeyframe(m_document->getProfileInfo(), item->getEffectAtIndex(item->selectedEffectIndex()), keyFramePos.frames(m_document->fps()), val);
//QString next = item->keyframes(item->selectedEffectIndex());
QDomElement newEffect = item->selectedEffect().cloneNode().toElement();
EditEffectCommand *command = new EditEffectCommand(this, item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, false, true);
EditEffectCommand *command = new EditEffectCommand(this, item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, true, false, true);
m_commandStack->push(command);
updateEffect(item->track(), item->startPos(), item->selectedEffect());
emit clipItemSelected(item, item->selectedEffectIndex());
......@@ -1646,7 +1646,7 @@ void CustomTrackView::slotAttachKeyframeToEnd(bool attach)
QDomElement oldEffect = item->selectedEffect().cloneNode().toElement();
item->attachKeyframeToEnd(item->getEffectAtIndex(item->selectedEffectIndex()), attach);
QDomElement newEffect = item->selectedEffect().cloneNode().toElement();
EditEffectCommand *command = new EditEffectCommand(this, item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, false, false);
EditEffectCommand *command = new EditEffectCommand(this, item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, true, false, false);
m_commandStack->push(command);
updateEffect(item->track(), item->startPos(), item->selectedEffect());
emit clipItemSelected(item, item->selectedEffectIndex());
......@@ -1659,7 +1659,7 @@ void CustomTrackView::slotEditKeyframeType(QAction *action)
QDomElement oldEffect = item->selectedEffect().cloneNode().toElement();
item->editKeyframeType(item->getEffectAtIndex(item->selectedEffectIndex()), type);
QDomElement newEffect = item->selectedEffect().cloneNode().toElement();
EditEffectCommand *command = new EditEffectCommand(this, item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, false, false);
EditEffectCommand *command = new EditEffectCommand(this, item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, true, false, false);
m_commandStack->push(command);
updateEffect(item->track(), item->startPos(), item->selectedEffect());
emit clipItemSelected(item, item->selectedEffectIndex());
......@@ -2471,7 +2471,7 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, const QDomElem
}
}
void CustomTrackView::updateEffect(int track, GenTime pos, const QDomElement &insertedEffect, bool updateEffectStack, bool replaceEffect, bool refreshMonitor)
void CustomTrackView::updateEffect(int track, GenTime pos, const QDomElement &insertedEffect, bool updateEffectStack, bool replaceEffect, bool refreshMonitor, bool updateClip)
{
if (insertedEffect.isNull()) {
//qCDebug(KDENLIVE_LOG)<<"// Trying to add null effect";
......@@ -2492,11 +2492,13 @@ void CustomTrackView::updateEffect(int track, GenTime pos, const QDomElement &in
if (!m_timeline->track(track)->editTrackEffect(effectParams, replaceEffect)) {
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
}
m_timeline->setTrackEffect(track, ix, effect);
if (refreshMonitor && effect.attribute(QStringLiteral("type")) != QLatin1String("audio")) {
m_timeline->setTrackEffect(track, ix, effect, updateClip);
if (updateClip && refreshMonitor && effect.attribute(QStringLiteral("type")) != QLatin1String("audio")) {
monitorRefresh();
}
emit updateTrackEffectState(track);
if (updateClip) {
emit updateTrackEffectState(track);
}
return;
}
......@@ -2544,7 +2546,7 @@ void CustomTrackView::updateEffect(int track, GenTime pos, const QDomElement &in
bool success = m_timeline->track(clip->track())->editEffect(clip->startPos().seconds(), effectParams, replaceEffect);
if (success) {
clip->updateEffect(effect);
if (refreshMonitor && clip->hasVisibleVideo() && effect.attribute(QStringLiteral("type")) != QLatin1String("audio")) {
if (updateClip && refreshMonitor && clip->hasVisibleVideo() && effect.attribute(QStringLiteral("type")) != QLatin1String("audio")) {
monitorRefresh(clip->info(), true);
}
if (updateEffectStack && clip->isSelected()) {
......@@ -2686,7 +2688,7 @@ void CustomTrackView::slotChangeEffectState(ClipItem *clip, int track, QList<int
speedEffectIndexes << effectIndexes.at(i);
QDomElement newEffect = effect.cloneNode().toElement();
newEffect.setAttribute(QStringLiteral("disable"), (int) disable);
EditEffectCommand *editcommand = new EditEffectCommand(this, clip->track(), clip->startPos(), effect, newEffect, effectIndexes.at(i), false, true, true);
EditEffectCommand *editcommand = new EditEffectCommand(this, clip->track(), clip->startPos(), effect, newEffect, effectIndexes.at(i), false, true, true, true);
m_commandStack->push(editcommand);
}
}
......@@ -2710,13 +2712,13 @@ void CustomTrackView::slotChangeEffectPosition(ClipItem *clip, int track, const
m_commandStack->push(command);
}
void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, int track, const QDomElement &oldeffect, const QDomElement &effect, int ix, bool refreshEffectStack)
void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, int track, const QDomElement &oldeffect, const QDomElement &effect, int ix, bool refreshEffectStack, bool updateClip)
{
EditEffectCommand *command;
if (clip) {
command = new EditEffectCommand(this, clip->track(), clip->startPos(), oldeffect.cloneNode().toElement(), effect.cloneNode().toElement(), ix, refreshEffectStack, true, true);
command = new EditEffectCommand(this, clip->track(), clip->startPos(), oldeffect.cloneNode().toElement(), effect.cloneNode().toElement(), ix, refreshEffectStack, updateClip, true, true);
} else {
command = new EditEffectCommand(this, track, GenTime(-1), oldeffect.cloneNode().toElement(), effect.cloneNode().toElement(), ix, refreshEffectStack, true, true);
command = new EditEffectCommand(this, track, GenTime(-1), oldeffect.cloneNode().toElement(), effect.cloneNode().toElement(), ix, refreshEffectStack, updateClip, true, true);
}
m_commandStack->push(command);
}
......@@ -2726,7 +2728,7 @@ void CustomTrackView::slotUpdateClipRegion(ClipItem *clip, int ix, const QString
QDomElement effect = clip->getEffectAtIndex(ix);
QDomElement oldeffect = effect.cloneNode().toElement();
effect.setAttribute(QStringLiteral("region"), region);
EditEffectCommand *command = new EditEffectCommand(this, clip->track(), clip->startPos(), oldeffect, effect, ix, true, true, true);
EditEffectCommand *command = new EditEffectCommand(this, clip->track(), clip->startPos(), oldeffect, effect, ix, true, true, true, true);
m_commandStack->push(command);
}
......@@ -8347,7 +8349,7 @@ void CustomTrackView::slotGotFilterJobResults(const QString &/*id*/, int startPo
EffectsList::setParameter(newEffect, i.key(), i.value());
++i;
}
EditEffectCommand *command = new EditEffectCommand(this, clip->track(), clip->startPos(), effect, newEffect, clip->selectedEffectIndex(), true, true, true);
EditEffectCommand *command = new EditEffectCommand(this, clip->track(), clip->startPos(), effect, newEffect, clip->selectedEffectIndex(), true, true, true, true);
m_commandStack->push(command);
emit clipItemSelected(clip);
} else {
......@@ -8467,7 +8469,11 @@ void CustomTrackView::slotUpdateTimelineProducer(const QString &id)
{
Mlt::Producer *prod = m_document->renderer()->getBinProducer(id);
for (int i = 1; i < m_timeline->tracksCount(); i++) {
m_timeline->track(i)->updateEffects(id, prod);
const QList<ItemInfo> range = m_timeline->track(i)->updateEffects(id, prod);
if (!range.isEmpty()) {
// TODO: only on video clips
monitorRefresh(range, true);
}
}
}
......
......@@ -90,7 +90,7 @@ public:
void slotAddGroupEffect(const QDomElement &effect, AbstractGroupItem *group, AbstractClipItem *dropTarget = nullptr);
void addEffect(int track, GenTime pos, const QDomElement &effect);
void deleteEffect(int track, const GenTime &pos, const QDomElement &effect);
void updateEffect(int track, GenTime pos, const QDomElement &insertedEffect, bool refreshEffectStack = false, bool replaceEffect = false, bool refreshMonitor = true);
void updateEffect(int track, GenTime pos, const QDomElement &insertedEffect, bool refreshEffectStack = false, bool replaceEffect = false, bool refreshMonitor = true, bool updateClip = true);
/** @brief Enable / disable a list of effects */
void updateEffectState(int track, GenTime pos, const QList<int> &effectIndexes, bool disable, bool updateEffectStack);
void moveEffect(int track, const GenTime &pos, const QList<int> &oldPos, const QList<int> &newPos);
......@@ -337,7 +337,7 @@ public slots:
void slotDeleteEffect(ClipItem *clip, int track, const QDomElement &effect, bool affectGroup = true, QUndoCommand *parentCommand = nullptr);
void slotChangeEffectState(ClipItem *clip, int track, QList<int> effectIndexes, bool disable);
void slotChangeEffectPosition(ClipItem *clip, int track, const QList<int> &currentPos, int newPos);
void slotUpdateClipEffect(ClipItem *clip, int track, const QDomElement &oldeffect, const QDomElement &effect, int ix, bool refreshEffectStack = true);
void slotUpdateClipEffect(ClipItem *clip, int track, const QDomElement &oldeffect, const QDomElement &effect, int ix, bool refreshEffectStack = true, bool updateClip = true);
void slotUpdateClipRegion(ClipItem *clip, int ix, const QString &region);
void slotRefreshEffects(ClipItem *clip);
void setDuration(int duration);
......
......@@ -279,7 +279,7 @@ void SelectManager::mouseRelease(QMouseEvent *event, GenTime pos)
QDomElement newEffect = item->selectedEffect().cloneNode().toElement();
EditEffectCommand *command = new EditEffectCommand(m_view, item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, false, true);
EditEffectCommand *command = new EditEffectCommand(m_view, item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, true, false, true);
m_commandStack->push(command);
m_view->updateEffect(item->track(), item->startPos(), item->selectedEffect());
m_view->clipItemSelected(item);
......
......@@ -1508,7 +1508,7 @@ bool Timeline::removeTrackEffect(int trackIndex, int effectIndex, const QDomElem
return success;
}
void Timeline::setTrackEffect(int trackIndex, int effectIndex, QDomElement effect)
void Timeline::setTrackEffect(int trackIndex, int effectIndex, QDomElement effect, bool updateTrack)
{
if (trackIndex < 0 || trackIndex >= m_tracks.count()) {
qCWarning(KDENLIVE_LOG) << "Set Track effect outisde of range";
......@@ -1523,7 +1523,7 @@ void Timeline::setTrackEffect(int trackIndex, int effectIndex, QDomElement effec
sourceTrack->effectsList.removeAt(effect.attribute(QStringLiteral("kdenlive_ix")).toInt());
effect.setAttribute(QStringLiteral("kdenlive_ix"), effectIndex);
sourceTrack->effectsList.insert(effect);
if (effect.attribute(QStringLiteral("type")) != QLatin1String("audio")) {
if (updateTrack && effect.attribute(QStringLiteral("type")) != QLatin1String("audio")) {
invalidateTrack(trackIndex);
}
}
......
......@@ -123,7 +123,7 @@ public:
QStringList getTrackNames();
void addTrackEffect(int trackIndex, QDomElement effect, bool addToPlaylist = true);
bool removeTrackEffect(int trackIndex, int effectIndex, const QDomElement &effect);
void setTrackEffect(int trackIndex, int effectIndex, QDomElement effect);
void setTrackEffect(int trackIndex, int effectIndex, QDomElement effect, bool updateTrack = true);
bool enableTrackEffects(int trackIndex, const QList<int> &effectIndexes, bool disable);
const EffectsList getTrackEffects(int trackIndex);
QDomElement getTrackEffect(int trackIndex, int effectIndex);
......
......@@ -287,7 +287,7 @@ void ConfigTracksCommand::redo()
}
}
EditEffectCommand::EditEffectCommand(CustomTrackView *view, const int track, const GenTime &pos, const QDomElement &oldeffect, const QDomElement &effect, int stackPos, bool refreshEffectStack, bool doIt, bool refreshMonitor, QUndoCommand *parent) :
EditEffectCommand::EditEffectCommand(CustomTrackView *view, const int track, const GenTime &pos, const QDomElement &oldeffect, const QDomElement &effect, int stackPos, bool refreshEffectStack, bool updateClip, bool doIt, bool refreshMonitor, QUndoCommand *parent) :
QUndoCommand(parent),
m_view(view),
m_track(track),
......@@ -297,6 +297,7 @@ EditEffectCommand::EditEffectCommand(CustomTrackView *view, const int track, con
m_stackPos(stackPos),
m_doIt(doIt),
m_refreshEffectStack(refreshEffectStack),
m_updateClip(updateClip),
m_replaceEffect(false),
m_refreshMonitor(refreshMonitor)
{
......@@ -343,13 +344,13 @@ bool EditEffectCommand::mergeWith(const QUndoCommand *other)
// virtual
void EditEffectCommand::undo()
{
m_view->updateEffect(m_track, m_pos, m_oldeffect, true, m_replaceEffect, m_refreshMonitor);
m_view->updateEffect(m_track, m_pos, m_oldeffect, true, m_replaceEffect, m_refreshMonitor, m_updateClip);
}
// virtual
void EditEffectCommand::redo()
{
if (m_doIt) {
m_view->updateEffect(m_track, m_pos, m_effect, m_refreshEffectStack, m_replaceEffect, m_refreshMonitor);
m_view->updateEffect(m_track, m_pos, m_effect, m_refreshEffectStack, m_replaceEffect, m_refreshMonitor, m_updateClip);
}
m_doIt = true;
m_refreshEffectStack = true;
......
......@@ -167,7 +167,7 @@ private:
class EditEffectCommand : public QUndoCommand
{
public:
EditEffectCommand(CustomTrackView *view, const int track, const GenTime &pos, const QDomElement &oldeffect, const QDomElement &effect, int stackPos, bool refreshEffectStack, bool doIt, bool refreshMonitor, QUndoCommand *parent = nullptr);
EditEffectCommand(CustomTrackView *view, const int track, const GenTime &pos, const QDomElement &oldeffect, const QDomElement &effect, int stackPos, bool refreshEffectStack, bool updateClip, bool doIt, bool refreshMonitor, QUndoCommand *parent = nullptr);
int id() const Q_DECL_OVERRIDE;
bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
void undo() Q_DECL_OVERRIDE;
......@@ -181,6 +181,7 @@ private:
int m_stackPos;
bool m_doIt;
bool m_refreshEffectStack;
bool m_updateClip;
bool m_replaceEffect;
bool m_refreshMonitor;
};
......
......@@ -475,12 +475,13 @@ bool Track::replace(qreal t, Mlt::Producer *prod, PlaylistState::ClipState state
return ok;
}
void Track::updateEffects(const QString &id, Mlt::Producer *original)
const QList<ItemInfo> Track::updateEffects(const QString &id, Mlt::Producer *original)
{
QString idForAudioTrack;
QString idForVideoTrack;
QString service = original->parent().get("mlt_service");
QString idForTrack = original->parent().get("id");
QList<ItemInfo> range;
if (needsDuplicate(service)) {
// We have to use the track clip duplication functions, because of audio glitches in MLT's multitrack
idForAudioTrack = idForTrack + QLatin1Char('_') + m_playlist.get("id") + QStringLiteral("_audio");
......@@ -491,21 +492,37 @@ void Track::updateEffects(const QString &id, Mlt::Producer *original)
for (int i = 0; i < m_playlist.count(); i++) {
if (m_playlist.is_blank(i)) continue;
QScopedPointer<Mlt::Producer> p(m_playlist.get_clip(i));
Mlt::Producer origin = p->parent();
Mlt::Producer origin = p->parent();
QString current = origin.get("id");
if (current.startsWith(QLatin1String("slowmotion:"))) {
if (current.startsWith(QLatin1String("slowmotion:"))) {
if (current.section(QLatin1Char(':'), 1, 1) == id) {
Clip(origin).replaceEffects(*original);
Clip(origin).replaceEffects(*original);
ItemInfo cInfo;
cInfo.startPos = GenTime(m_playlist.clip_start(i), fps());
cInfo.endPos = cInfo.startPos + GenTime(m_playlist.clip_length(i), fps());
cInfo.track = m_index;
range << cInfo;
}
}
else if (current == id) {
}
else if (current == id) {
// we are directly using original producer, no need to update effects
ItemInfo cInfo;
cInfo.startPos = GenTime(m_playlist.clip_start(i), fps());
cInfo.endPos = cInfo.startPos + GenTime(m_playlist.clip_length(i), fps());
cInfo.track = m_index;
range << cInfo;
continue;
}
else if (current.section(QLatin1Char('_'), 0, 0) == id) {
}
else if (current.section(QLatin1Char('_'), 0, 0) == id) {
Clip(origin).replaceEffects(*original);
}
ItemInfo cInfo;
cInfo.startPos = GenTime(m_playlist.clip_start(i), fps());
cInfo.endPos = cInfo.startPos + GenTime(m_playlist.clip_length(i), fps());
cInfo.track = m_index;
range << cInfo;
}
}
return range;
}
/*Mlt::Producer &Track::find(const QByteArray &name, const QByteArray &value, int startindex) {
......@@ -904,7 +921,7 @@ bool Track::addTrackEffect(const EffectsParameterList &params)
return effect.addEffect(params, duration);
}
bool Track::editEffect(double start, const EffectsParameterList &params, bool replace)
bool Track::editEffect(double start, const EffectsParameterList &params, bool replace, bool updateClip)
{
int pos = frame(start);
int clipIndex = m_playlist.get_clip_index_at(pos);
......
......@@ -142,7 +142,7 @@ public:
* @param newSlowMos the slowmotion producers required for replacement
* @return list of in/out that were replaced */
QList<ItemInfo> replaceAll(const QString &id, Mlt::Producer *original, Mlt::Producer *videoOnlyProducer, const QMap<QString, Mlt::Producer *> &newSlowMos);
void updateEffects(const QString &id, Mlt::Producer *original);
const QList<ItemInfo> updateEffects(const QString &id, Mlt::Producer *original);
/** @brief replace an instance of a clip with another resource
* @param t is the clip time in playlist
* @param prod is the replacement clip
......@@ -199,7 +199,7 @@ public:
bool isLastClip(qreal t);
bool addEffect(double start, const EffectsParameterList &params);
bool addTrackEffect(const EffectsParameterList &params);
bool editEffect(double start, const EffectsParameterList &params, bool replace);
bool editEffect(double start, const EffectsParameterList &params, bool replace, bool updateClip = true);
bool editTrackEffect(const EffectsParameterList &params, bool replace);
bool removeEffect(double start, int effectIndex, bool updateIndex);
bool removeTrackEffect(int effectIndex, bool updateIndex);
......
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