Several effect fixes (mostly track effect issues)

svn path=/trunk/kdenlive/; revision=4789
parent 7a255d98
......@@ -1789,6 +1789,7 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
return;
}
QDomElement effect = insertedEffect.cloneNode().toElement();
kDebug() << "// update effect ix: " << effect.attribute("kdenlive_ix");
if (pos < GenTime()) {
// editing a track effect
EffectsParameterList effectParams = getEffectArgs(effect);
......@@ -1803,7 +1804,8 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
}
if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - track, pos, effectParams))
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
m_document->setTrackEffect(track - 1, ix, effect);
m_document->setTrackEffect(m_document->tracksCount() - track - 1, ix, effect);
setDocumentModified();
return;
}
......
......@@ -215,7 +215,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
max = pa.attribute("max").toInt();
DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
pa.attribute("default").toInt(), pa.attribute("suffix"), this);
pa.attribute("default").toInt(), pa.attribute("suffix"), this);
m_vbox->addWidget(doubleparam);
m_valueItems[paramName] = doubleparam;
connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
......@@ -639,7 +639,7 @@ void EffectStackEdit::collectAllParameters()
} else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
QString realName = i18n(na.toElement().text().toUtf8().data());
QString val = m_keyframeEditor->getValue(realName);
kDebug() << "SET VALUE: " << val;
//kDebug() << "SET VALUE: " << val;
namenode.item(i).toElement().setAttribute("keyframes", val);
} else if (type == "url") {
KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
......
......@@ -123,7 +123,7 @@ void EffectStackView::slotSaveEffect()
if (name.isEmpty()) return;
QString path = KStandardDirs::locateLocal("appdata", "effects/", true);
path = path + name + ".xml";
if (QFile::exists(path)) if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return;
if (QFile::exists(path)) if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) == KMessageBox::No) return;
int i = m_ui.effectlist->currentRow();
QDomDocument doc;
......
......@@ -1284,6 +1284,32 @@ void KdenliveDoc::addTrackEffect(int ix, QDomElement effect)
return;
}
effect.setAttribute("kdenlive_ix", m_tracksList.at(ix).effectsList.count() + 1);
// Init parameter value & keyframes if required
QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
// Check if this effect has a variable parameter
if (e.attribute("default").startsWith('%')) {
double evaluatedValue = ProfilesDialog::getStringEval(m_profile, e.attribute("default"));
e.setAttribute("default", evaluatedValue);
if (e.hasAttribute("value") && e.attribute("value").startsWith('%')) {
e.setAttribute("value", evaluatedValue);
}
}
if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
QString def = e.attribute("default");
// Effect has a keyframe type parameter, we need to set the values
if (e.attribute("keyframes").isEmpty()) {
e.setAttribute("keyframes", "0:" + def + ';');
kDebug() << "///// EFFECT KEYFRAMES INITED: " << e.attribute("keyframes");
//break;
}
}
}
m_tracksList[ix].effectsList.append(effect);
}
......
......@@ -36,6 +36,14 @@ KeyframeEdit::KeyframeEdit(QDomElement e, int minFrame, int maxFrame, int minVal
{
kDebug() << " / / / /MODIFIED KFR: " << m_active_keyframe;
setupUi(this);
if (m_max == -1) {
// special case: keyframe for tracks, do not allow keyframes
button_add->setEnabled(false);
button_delete->setEnabled(false);
keyframe_seek->setEnabled(false);
label->setHidden(true);
keyframe_pos->setHidden(true);
}
m_params.append(e.cloneNode().toElement());
keyframe_list->setFont(KGlobalSettings::generalFont());
keyframe_seek->setChecked(KdenliveSettings::keyframeseek());
......@@ -234,7 +242,7 @@ void KeyframeEdit::slotGenerateParams(int row, int column)
int pos = getPos(row);
if (pos <= m_min)
pos = m_min;
if (pos > m_max)
if (m_max != -1 && pos > m_max)
pos = m_max;
QString val = getPosString(pos);
if (val != keyframe_list->verticalHeaderItem(row)->text())
......@@ -266,7 +274,7 @@ void KeyframeEdit::slotGenerateParams(int row, int column)
int pos = getPos(row);
if (pos <= m_min)
pos = m_min;
if (pos > m_max)
if (m_max != -1 && pos > m_max)
pos = m_max;
/*QList<QTreeWidgetItem *> duplicates = keyframe_list->findItems(val, Qt::MatchExactly, 0);
duplicates.removeAll(item);
......@@ -312,7 +320,7 @@ const QString KeyframeEdit::getValue(const QString &name)
for (int col = 0; col < keyframe_list->columnCount(); col++) {
QDomNode na = m_params.at(col).firstChildElement("name");
QString paramName = i18n(na.toElement().text().toUtf8().data());
kDebug() << paramName << " == " << name;
//kDebug() << paramName << " == " << name;
if (paramName == name)
return m_params.at(col).attribute("keyframes");
}
......
......@@ -1704,7 +1704,7 @@ bool MainWindow::saveFileAs()
}
if (QFile::exists(outputFile)) {
// Show the file dialog again if the user does not want to overwrite the file
if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
return saveFileAs();
}
return saveFileAs(outputFile);
......
......@@ -1527,6 +1527,7 @@ void Render::showFrame(Mlt::Frame& frame)
}
#endif
/*
* MLT playlist direct manipulation.
*/
......@@ -1789,7 +1790,7 @@ bool Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *pr
int ct = 0;
Mlt::Filter *filter = sourceService.filter(ct);
while (filter) {
if (filter->get("kdenlive_ix") != 0) {
if (filter->get_int("kdenlive_ix") != 0) {
filtersList.append(filter);
}
ct++;
......@@ -2072,7 +2073,7 @@ void Render::mltPasteEffects(Mlt::Producer *source, Mlt::Producer *dest)
int ct = 0;
Mlt::Filter *filter = sourceService.filter(ct);
while (filter) {
if (filter->get("kdenlive_ix") != 0) {
if (filter->get_int("kdenlive_ix") != 0) {
sourceService.detach(*filter);
destService.attach(*filter);
} else ct++;
......@@ -2258,7 +2259,6 @@ int Render::mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, dou
bool Render::mltRemoveTrackEffect(int track, QString index, bool updateIndex)
{
kDebug() << "REMOVE TK EFF: " << track << ", IX: " << index;
Mlt::Service service(m_mltProducer->parent().get_service());
bool success = false;
Mlt::Tractor tractor(service);
......@@ -2270,11 +2270,11 @@ bool Render::mltRemoveTrackEffect(int track, QString index, bool updateIndex)
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
if ((index == "-1" && strcmp(filter->get("kdenlive_id"), "")) || filter->get("kdenlive_ix") == index) {
if ((index == "-1" && strcmp(filter->get("kdenlive_id"), "")) || QString(filter->get("kdenlive_ix")) == index) {
if (clipService.detach(*filter) == 0) success = true;
} else if (updateIndex) {
// Adjust the other effects index
if (QString(filter->get("kdenlive_ix")).toInt() > index.toInt()) filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
if (filter->get_int("kdenlive_ix") > index.toInt()) filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") - 1);
ct++;
} else ct++;
filter = clipService.filter(ct);
......@@ -2317,12 +2317,12 @@ bool Render::mltRemoveEffect(int track, GenTime position, QString index, bool up
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
if ((index == "-1" && strcmp(filter->get("kdenlive_id"), "")) || filter->get("kdenlive_ix") == index) {// && filter->get("kdenlive_id") == id) {
if ((index == "-1" && strcmp(filter->get("kdenlive_id"), "")) || QString(filter->get("kdenlive_ix")) == index) {// && filter->get("kdenlive_id") == id) {
if (clipService.detach(*filter) == 0) success = true;
//kDebug()<<"Deleted filter id:"<<filter->get("kdenlive_id")<<", ix:"<<filter->get("kdenlive_ix")<<", SERVICE:"<<filter->get("mlt_service");
} else if (updateIndex) {
// Adjust the other effects index
if (QString(filter->get("kdenlive_ix")).toInt() > index.toInt()) filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
if (filter->get_int("kdenlive_ix") > index.toInt()) filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") - 1);
ct++;
} else ct++;
filter = clipService.filter(ct);
......@@ -2378,7 +2378,7 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int
int ct = 0;
Mlt::Filter *filter = service.filter(ct);
while (filter) {
if (QString(filter->get("kdenlive_ix")).toInt() == filter_ix) {
if (filter->get_int("kdenlive_ix") == filter_ix) {
// A filter at that position already existed, so we will increase all indexes later
updateIndex = true;
break;
......@@ -2392,8 +2392,8 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int
ct = 0;
filter = service.filter(ct);
while (filter) {
if (QString(filter->get("kdenlive_ix")).toInt() >= filter_ix) {
if (updateIndex) filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() + 1);
if (filter->get_int("kdenlive_ix") >= filter_ix) {
if (updateIndex) filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") + 1);
}
ct++;
filter = service.filter(ct);
......@@ -2409,7 +2409,7 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int
ct = 0;
filter = service.filter(ct);
while (filter) {
if (QString(filter->get("kdenlive_ix")).toInt() >= filter_ix) {
if (filter->get_int("kdenlive_ix") >= filter_ix) {
filtersList.append(filter);
service.detach(*filter);
} else ct++;
......@@ -2556,7 +2556,7 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int
for (int i = 0; i < filtersList.count(); i++) {
Mlt::Filter *filter = filtersList.at(i);
if (updateIndex)
filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() + 1);
filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") + 1);
service.attach(*filter);
}
m_isBlocked = false;
......@@ -2566,7 +2566,6 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int
bool Render::mltEditTrackEffect(int track, EffectsParameterList params)
{
kDebug() << "EDIT TK, FILTER: " << track;
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(track));
......@@ -2579,7 +2578,7 @@ bool Render::mltEditTrackEffect(int track, EffectsParameterList params)
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
if (filter->get("kdenlive_ix") == index) {
if (QString(filter->get("kdenlive_ix")) == index) {
break;
}
ct++;
......@@ -2620,8 +2619,10 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par
if (!params.paramValue("keyframes").isEmpty() || /*it.key().startsWith("#") || */tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle" || params.hasParam("region")) {
// This is a keyframe effect, to edit it, we remove it and re-add it.
mltRemoveEffect(track, position, index, false);
bool success = mltAddEffect(track, position, params);
bool success = mltRemoveEffect(track, position, index, false);
if (!success) kDebug() << "// ERROR Removing effect : " << index;
success = mltAddTrackEffect(track, params);
if (!success) kDebug() << "// ERROR Adding effect : " << index;
return success;
}
if (position < GenTime()) {
......@@ -2662,7 +2663,7 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
if (filter->get("kdenlive_ix") == index) {
if (QString(filter->get("kdenlive_ix")) == index) {
break;
}
ct++;
......@@ -2721,7 +2722,7 @@ void Render::mltUpdateEffectPosition(int track, GenTime position, int oldPos, in
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
int pos = QString(filter->get("kdenlive_ix")).toInt();
int pos = filter->get_int("kdenlive_ix");
if (pos == oldPos) {
filter->set("kdenlive_ix", newPos);
} else ct++;
......@@ -2765,19 +2766,19 @@ void Render::mltMoveEffect(int track, GenTime position, int oldPos, int newPos)
bool found = false;
if (newPos > oldPos) {
while (filter) {
if (!found && QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
if (!found && filter->get_int("kdenlive_ix") == oldPos) {
filter->set("kdenlive_ix", newPos);
filtersList.append(filter);
clipService.detach(*filter);
filter = clipService.filter(ct);
while (filter && QString(filter->get("kdenlive_ix")).toInt() <= newPos) {
filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
while (filter && filter->get_int("kdenlive_ix") <= newPos) {
filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") - 1);
ct++;
filter = clipService.filter(ct);
}
found = true;
}
if (filter && QString(filter->get("kdenlive_ix")).toInt() > newPos) {
if (filter && filter->get_int("kdenlive_ix") > newPos) {
filtersList.append(filter);
clipService.detach(*filter);
} else ct++;
......@@ -2785,7 +2786,7 @@ void Render::mltMoveEffect(int track, GenTime position, int oldPos, int newPos)
}
} else {
while (filter) {
if (QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
if (filter->get_int("kdenlive_ix") == oldPos) {
filter->set("kdenlive_ix", newPos);
filtersList.append(filter);
clipService.detach(*filter);
......@@ -2796,7 +2797,7 @@ void Render::mltMoveEffect(int track, GenTime position, int oldPos, int newPos)
ct = 0;
filter = clipService.filter(ct);
while (filter) {
int pos = QString(filter->get("kdenlive_ix")).toInt();
int pos = filter->get_int("kdenlive_ix");
if (pos >= newPos) {
if (pos < oldPos) filter->set("kdenlive_ix", pos + 1);
filtersList.append(filter);
......@@ -2830,19 +2831,19 @@ void Render::mltMoveTrackEffect(int track, int oldPos, int newPos)
bool found = false;
if (newPos > oldPos) {
while (filter) {
if (!found && QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
if (!found && filter->get_int("kdenlive_ix") == oldPos) {
filter->set("kdenlive_ix", newPos);
filtersList.append(filter);
clipService.detach(*filter);
filter = clipService.filter(ct);
while (filter && QString(filter->get("kdenlive_ix")).toInt() <= newPos) {
filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
while (filter && filter->get_int("kdenlive_ix") <= newPos) {
filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") - 1);
ct++;
filter = clipService.filter(ct);
}
found = true;
}
if (filter && QString(filter->get("kdenlive_ix")).toInt() > newPos) {
if (filter && filter->get_int("kdenlive_ix") > newPos) {
filtersList.append(filter);
clipService.detach(*filter);
} else ct++;
......@@ -2850,7 +2851,7 @@ void Render::mltMoveTrackEffect(int track, int oldPos, int newPos)
}
} else {
while (filter) {
if (QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
if (filter->get_int("kdenlive_ix") == oldPos) {
filter->set("kdenlive_ix", newPos);
filtersList.append(filter);
clipService.detach(*filter);
......@@ -2861,7 +2862,7 @@ void Render::mltMoveTrackEffect(int track, int oldPos, int newPos)
ct = 0;
filter = clipService.filter(ct);
while (filter) {
int pos = QString(filter->get("kdenlive_ix")).toInt();
int pos = filter->get_int("kdenlive_ix");
if (pos >= newPos) {
if (pos < oldPos) filter->set("kdenlive_ix", pos + 1);
filtersList.append(filter);
......
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