]> git.sesse.net Git - kdenlive/commitdiff
Use MLT's "disable" attribute to easily disable filters instead of removing them...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 1 Feb 2010 23:43:35 +0000 (23:43 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 1 Feb 2010 23:43:35 +0000 (23:43 +0000)
http://kdenlive.org/mantis/view.php?id=1403

svn path=/trunk/kdenlive/; revision=4271

src/clipitem.cpp
src/customtrackview.cpp
src/effectstackview.cpp
src/trackview.cpp

index f97ed7195f425e018fef3aee7a7182b2b9c3e4b1..97e7658ffae51e568f0f6d10d53197b9662ac564 100644 (file)
@@ -314,7 +314,7 @@ bool ClipItem::checkKeyFrames()
 void ClipItem::setKeyframes(const int ix, const QString keyframes)
 {
     QDomElement effect = getEffectAt(ix);
-    if (effect.attribute("disabled") == "1") return;
+    if (effect.attribute("disable") == "1") return;
     QDomNodeList params = effect.elementsByTagName("parameter");
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
@@ -351,7 +351,7 @@ void ClipItem::setSelectedEffect(const int ix)
     QDomElement effect = effectAt(m_selectedEffect);
     if (effect.isNull() == false) {
         QDomNodeList params = effect.elementsByTagName("parameter");
-        if (effect.attribute("disabled") != "1")
+        if (effect.attribute("disable") != "1")
             for (int i = 0; i < params.count(); i++) {
                 QDomElement e = params.item(i).toElement();
                 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
@@ -401,7 +401,7 @@ void ClipItem::updateKeyframeEffect()
 {
     // regenerate xml parameter from the clip keyframes
     QDomElement effect = getEffectAt(m_selectedEffect);
-    if (effect.attribute("disabled") == "1") return;
+    if (effect.attribute("disable") == "1") return;
     QDomNodeList params = effect.elementsByTagName("parameter");
 
     for (int i = 0; i < params.count(); i++) {
@@ -1315,7 +1315,7 @@ EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animat
     parameters.addParam("tag", effect.attribute("tag"));
     parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
     if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
-    if (effect.hasAttribute("disabled")) parameters.addParam("disabled", effect.attribute("disabled"));
+    if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
 
 
     QString effectId = effect.attribute("id");
@@ -1428,7 +1428,7 @@ EffectsParameterList ClipItem::getEffectArgs(const QDomElement effect)
     parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
     parameters.addParam("id", effect.attribute("id"));
     if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
-    if (effect.hasAttribute("disabled")) parameters.addParam("disabled", effect.attribute("disabled"));
+    if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
 
     QDomNodeList params = effect.elementsByTagName("parameter");
     for (int i = 0; i < params.count(); i++) {
@@ -1635,7 +1635,7 @@ bool ClipItem::isVideoOnly() const
 
 void ClipItem::insertKeyframe(QDomElement effect, int pos, int val)
 {
-    if (effect.attribute("disabled") == "1") return;
+    if (effect.attribute("disable") == "1") return;
     effect.setAttribute("active_keyframe", pos);
     m_editedKeyframe = pos;
     QDomNodeList params = effect.elementsByTagName("parameter");
@@ -1664,7 +1664,7 @@ void ClipItem::insertKeyframe(QDomElement effect, int pos, int val)
 
 void ClipItem::movedKeyframe(QDomElement effect, int oldpos, int newpos, double value)
 {
-    if (effect.attribute("disabled") == "1") return;
+    if (effect.attribute("disable") == "1") return;
     effect.setAttribute("active_keyframe", newpos);
     QDomNodeList params = effect.elementsByTagName("parameter");
     int start = cropStart().frames(m_fps);
index 849311378fd6841a856df84678128c962085477b..9747412e0e559c2f9b44d2d9feaed59aae778075 100644 (file)
@@ -1498,11 +1498,6 @@ void CustomTrackView::addEffect(int track, GenTime pos, QDomElement effect)
             return;
         }
         EffectsParameterList params = clip->addEffect(effect);
-        if (effect.attribute("disabled") == "1") {
-            // Effect is disabled, don't add it to MLT playlist
-            if (clip->isSelected()) emit clipItemSelected(clip);
-            return;
-        }
         if (!m_document->renderer()->mltAddEffect(track, pos, params))
             emit displayMessage(i18n("Problem adding effect to clip"), ErrorMessage);
         if (clip->isSelected()) emit clipItemSelected(clip);
@@ -1523,8 +1518,8 @@ void CustomTrackView::deleteEffect(int track, GenTime pos, QDomElement effect)
             return;
         }
     }
-    if (!m_document->renderer()->mltRemoveEffect(track, pos, index, true) && effect.attribute("disabled") != "1") {
-        kDebug() << "// ERROR REMOV EFFECT: " << index << ", DISABLE: " << effect.attribute("disabled");
+    if (!m_document->renderer()->mltRemoveEffect(track, pos, index, true)) {
+        kDebug() << "// ERROR REMOV EFFECT: " << index << ", DISABLE: " << effect.attribute("disable");
         emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
         return;
     }
@@ -1655,7 +1650,7 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
     if (clip) {
         // Special case: speed effect
         if (effect.attribute("id") == "speed") {
-            if (effect.attribute("disabled") == "1") doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
+            if (effect.attribute("disable") == "1") doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
             else {
                 double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
                 int strobe = EffectsList::parameter(effect, "strobe").toInt();
@@ -1680,11 +1675,7 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
             clip->initEffect(effect);
             effectParams = clip->getEffectArgs(effect);
         }
-        if (effectParams.paramValue("disabled") == "1") {
-            if (m_document->renderer()->mltRemoveEffect(track, pos, effectParams.paramValue("kdenlive_ix"), false)) {
-                kDebug() << "//////  DISABLING EFFECT: " << ix << ", CURRENTLA: " << clip->selectedEffectIndex();
-            } else emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
-        } else if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams))
+        if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams))
             emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
 
         clip->setEffectAt(ix, effect);
@@ -1731,7 +1722,7 @@ void CustomTrackView::slotChangeEffectState(ClipItem *clip, int effectPos, bool
     QDomElement effect = clip->effectAt(effectPos);
     QDomElement oldEffect = effect.cloneNode().toElement();
 
-    effect.setAttribute("disabled", (int) disable);
+    effect.setAttribute("disable", (int) disable);
     EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldEffect, effect, effectPos, true);
     m_commandStack->push(command);
     setDocumentModified();;
index 2b6688405a0e040e9faa21176b36934220b729df..dccceb75eeedac082f8db5418083c7e05d2317fa 100644 (file)
@@ -175,7 +175,7 @@ void EffectStackView::slotItemChanged(QListWidgetItem *item)
     m_ui.buttonReset->setEnabled(!disable);
     int activeRow = m_ui.effectlist->currentRow();
     if (activeRow >= 0) {
-        m_effectedit->updateParameter("disabled", QString::number((int) disable));
+        m_effectedit->updateParameter("disable", QString::number((int) disable));
         emit changeEffectState(m_clipref, activeRow, disable);
     }
 }
@@ -216,7 +216,7 @@ void EffectStackView::setupListView(int ix)
                 item = new QListWidgetItem(videoIcon, i18n(namenode.toElement().text().toUtf8().data()), m_ui.effectlist);
             }
             item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
-            if (d.attribute("disabled") == "1") item->setCheckState(Qt::Unchecked);
+            if (d.attribute("disable") == "1") item->setCheckState(Qt::Unchecked);
             else item->setCheckState(Qt::Checked);
         }
     }
index 7052392d7b74ed8f8b4d0ef6eddf43f273efa718..f91abc35b871e51146332e79f8f1f5dab11dff43 100644 (file)
@@ -645,6 +645,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                 // parse clip effects
                 QDomNodeList effects = elem.childNodes();
                 for (int ix = 0; ix < effects.count(); ix++) {
+                    bool disableeffect = false;
                     QDomElement effect = effects.at(ix).toElement();
                     if (effect.tagName() == "filter") {
                         // add effect to clip
@@ -660,6 +661,9 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                                 effecttag = effectparam.text();
                             } else if (effectparam.attribute("name") == "kdenlive_id") {
                                 effectid = effectparam.text();
+                            } else if (effectparam.attribute("name") == "disable" && effectparam.text().toInt() == 1) {
+                                // Fix effects index
+                                disableeffect = true;
                             } else if (effectparam.attribute("name") == "kdenlive_ix") {
                                 // Fix effects index
                                 effectparam.firstChild().setNodeValue(effectindex);
@@ -814,6 +818,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                                 }
                                 currenteffect.setAttribute("src", ladspaEffectFile);
                             }
+                            if (disableeffect) currenteffect.setAttribute("disable", "1");
                             item->addEffect(currenteffect, false);
                         }
                     }