]> git.sesse.net Git - kdenlive/blobdiff - src/kdenlivedoc.cpp
Add animation feature to Slideshow Clip.
[kdenlive] / src / kdenlivedoc.cpp
index 538d5e72ef85bc9388fadfc172542f8c4174bab2..7ea9272a11a01febe267adc656dd95fa6675577a 100644 (file)
@@ -114,13 +114,13 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                         // Build tracks
                         QDomElement e;
                         QDomElement tracksinfo = infoXml.firstChildElement("tracksinfo");
-                        TrackInfo projectTrack;
                         if (!tracksinfo.isNull()) {
                             QDomNodeList trackslist = tracksinfo.childNodes();
                             int maxchild = trackslist.count();
                             for (int k = 0; k < maxchild; k++) {
                                 e = trackslist.at(k).toElement();
                                 if (e.tagName() == "trackinfo") {
+                                    TrackInfo projectTrack;
                                     if (e.attribute("type") == "audio") projectTrack.type = AUDIOTRACK;
                                     else projectTrack.type = VIDEOTRACK;
                                     projectTrack.isMute = e.attribute("mute").toInt();
@@ -262,29 +262,27 @@ int KdenliveDoc::setSceneList()
 
 QDomDocument KdenliveDoc::createEmptyDocument(int videotracks, int audiotracks)
 {
-    TrackInfo videoTrack;
-    videoTrack.type = VIDEOTRACK;
-    videoTrack.isMute = false;
-    videoTrack.isBlind = false;
-    videoTrack.isLocked = false;
-
-    TrackInfo audioTrack;
-    audioTrack.type = AUDIOTRACK;
-    audioTrack.isMute = false;
-    audioTrack.isBlind = true;
-    audioTrack.isLocked = false;
-
     m_tracksList.clear();
 
     // Tracks are added «backwards», so we need to reverse the track numbering
     // mbt 331: http://www.kdenlive.org/mantis/view.php?id=331
     // Better default names for tracks: Audio 1 etc. instead of blank numbers
     for (int i = 0; i < audiotracks; i++) {
+        TrackInfo audioTrack;
+        audioTrack.type = AUDIOTRACK;
+        audioTrack.isMute = false;
+        audioTrack.isBlind = true;
+        audioTrack.isLocked = false;
         audioTrack.trackName = QString("Audio ") + QString::number(audiotracks - i);
         m_tracksList.append(audioTrack);
 
     }
     for (int i = 0; i < videotracks; i++) {
+        TrackInfo videoTrack;
+        videoTrack.type = VIDEOTRACK;
+        videoTrack.isMute = false;
+        videoTrack.isBlind = false;
+        videoTrack.isLocked = false;
         videoTrack.trackName = QString("Video ") + QString::number(videotracks - i);
         m_tracksList.append(videoTrack);
     }
@@ -1076,9 +1074,15 @@ void KdenliveDoc::slotCreateColorClip(const QString &name, const QString &color,
     emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
 }
 
-void KdenliveDoc::slotCreateSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, QString group, const QString &groupId)
+void KdenliveDoc::slotCreateSlideshowClipFile(const QString name, const QString path, int count, const QString duration,
+                                              const bool loop, const bool crop, const bool fade,
+                                              const QString &luma_duration, const QString &luma_file, const int softness,
+                                              const QString &animation, QString group, const QString &groupId)
 {
-    m_clipManager->slotAddSlideshowClipFile(name, path, count, duration, loop, fade, luma_duration, luma_file, softness, group, groupId);
+    m_clipManager->slotAddSlideshowClipFile(name, path, count, duration, loop,
+                                            crop, fade, luma_duration,
+                                            luma_file, softness,
+                                            animation, group, groupId);
     setModified(true);
     emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
 }
@@ -1286,6 +1290,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);
 }
 
@@ -1318,7 +1348,6 @@ void KdenliveDoc::setTrackEffect(int trackIndex, int effectIndex, QDomElement ef
         kDebug() << "Invalid effect index: " << effectIndex;
         return;
     }
-    kDebug() << "CHange TRK EFFECT AT: " << trackIndex;
     effect.setAttribute("kdenlive_ix", effectIndex + 1);
     m_tracksList[trackIndex].effectsList.replace(effectIndex, effect);
 }