Commit 6fce2816 authored by Till Theato's avatar Till Theato

Do not duplicate effect stack after split audio but move audio effects only.

svn path=/trunk/kdenlive/; revision=5804
parent 03a6f800
......@@ -21,6 +21,7 @@ HEAD
* Allow use of different ffmpeg preset for 1st and 2nd render pass.
* Notes widget: context menu now allows to insert clickable timecode to make easy reference to some place in the project.
* Do not duplicate effect stack after split audio but move audio effects only.
* Fix issues related to the usage of comma as numeric separator in some locales.
* Fix build on GNU/kFreeBSD.
* Fix cursor not visible in title widget. (http://kdenlive.org/mantis/view.php?id=2231)
......
......@@ -5917,7 +5917,9 @@ void CustomTrackView::splitAudio()
if (clip->parentItem()) {
emit displayMessage(i18n("Cannot split audio of grouped clips"), ErrorMessage);
} else {
new SplitAudioCommand(this, clip->track(), clip->startPos(), splitCommand);
EffectsList effects;
effects.clone(clip->effectList());
new SplitAudioCommand(this, clip->track(), clip->startPos(), effects, splitCommand);
}
}
}
......@@ -5928,7 +5930,7 @@ void CustomTrackView::splitAudio()
}
}
void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList effects, bool split)
{
ClipItem *clip = getClipItemAt(pos, track);
if (clip == NULL) {
......@@ -5973,6 +5975,20 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
}
audioClip->setSelected(true);
audioClip->setAudioOnly(true);
// keep video effects, move audio effects to audio clip
int videoIx = 0;
int audioIx = 0;
for (int i = 0; i < effects.count(); ++i) {
if (effects.at(i).attribute("type") == "audio") {
deleteEffect(m_document->tracksCount() - track, pos, clip->effectAt(videoIx));
audioIx++;
} else {
deleteEffect(freetrack, pos, audioClip->effectAt(audioIx));
videoIx++;
}
}
groupSelectedItems(false, true);
}
}
......@@ -5994,9 +6010,18 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
ItemInfo info = clip->info();
deleteClip(clp->info());
clip->setVideoOnly(false);
if (!m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - info.track, info.startPos.frames(m_document->fps()), clip->baseClip()->producer(info.track))) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
}
// re-add audio effects
for (int i = 0; i < effects.count(); ++i) {
if (effects.at(i).attribute("type") == "audio") {
addEffect(m_document->tracksCount() - track, pos, effects.at(i));
}
}
break;
}
}
......
......@@ -143,7 +143,7 @@ public:
* @param pos Position of the clip to split
* @param track Track of the clip
* @param split Split or unsplit */
void doSplitAudio(const GenTime &pos, int track, bool split);
void doSplitAudio(const GenTime &pos, int track, EffectsList effects, bool split);
void setVideoOnly();
void setAudioOnly();
void setAudioAndVideo();
......
......@@ -23,11 +23,12 @@
#include <KLocale>
SplitAudioCommand::SplitAudioCommand(CustomTrackView *view, const int track, const GenTime &pos, QUndoCommand * parent) :
SplitAudioCommand::SplitAudioCommand(CustomTrackView *view, const int track, const GenTime &pos, EffectsList effects, QUndoCommand * parent) :
QUndoCommand(parent),
m_view(view),
m_pos(pos),
m_track(track)
m_track(track),
m_effects(effects)
{
setText(i18n("Split audio"));
}
......@@ -35,13 +36,11 @@ SplitAudioCommand::SplitAudioCommand(CustomTrackView *view, const int track, con
// virtual
void SplitAudioCommand::undo()
{
// kDebug()<<"---- undoing action";
m_view->doSplitAudio(m_pos, m_track, false);
m_view->doSplitAudio(m_pos, m_track, m_effects, false);
}
// virtual
void SplitAudioCommand::redo()
{
kDebug() << "---- redoing action";
m_view->doSplitAudio(m_pos, m_track, true);
m_view->doSplitAudio(m_pos, m_track, m_effects, true);
}
......@@ -34,7 +34,7 @@ class CustomTrackView;
class SplitAudioCommand : public QUndoCommand
{
public:
SplitAudioCommand(CustomTrackView *view, const int track, const GenTime &pos, QUndoCommand * parent = 0);
SplitAudioCommand(CustomTrackView *view, const int track, const GenTime &pos, EffectsList effects, QUndoCommand * parent = 0);
virtual void undo();
virtual void redo();
......@@ -42,6 +42,7 @@ private:
CustomTrackView *m_view;
const GenTime m_pos;
const int m_track;
EffectsList m_effects;
};
#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