]> git.sesse.net Git - kdenlive/blobdiff - src/kdenlivedoc.cpp
Remove (old) LADSPA related code.
[kdenlive] / src / kdenlivedoc.cpp
index bac79c220bc08b53f6be84e86aff504d4e00d51a..f453f70dc1ccaf4db089d323f8442fa6e4b195f2 100644 (file)
@@ -52,7 +52,7 @@
 
 #include <mlt++/Mlt.h>
 
-const double DOCUMENTVERSION = 0.86;
+const double DOCUMENTVERSION = 0.87;
 
 KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap <QString, QString> properties, const QPoint tracks, Render *render, KTextEdit *notes, bool *openBackup, MainWindow *parent, KProgressDialog *progressDialog) :
     QObject(parent),
@@ -152,6 +152,9 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                             QDomElement mlt = m_document.firstChildElement("mlt");
                             QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
 
+                            // Set profile, fps, etc for the document
+                            setProfilePath(infoXml.attribute("profile"));
+
                             // Check embedded effects
                             QDomElement customeffects = infoXml.firstChildElement("customeffects");
                             if (!customeffects.isNull() && customeffects.hasChildNodes()) {
@@ -257,7 +260,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                                 QDomNamedNodeMap props = docproperties.attributes();
                                 for (int i = 0; i < props.count(); i++)
                                     m_documentProperties.insert(props.item(i).nodeName(), props.item(i).nodeValue());
-                                setProfilePath(infoXml.attribute("profile"));
+
                                 if (validator.isModified()) setModified(true);
                                 kDebug() << "Reading file: " << url.path() << ", found clips: " << producers.count();
                             }
@@ -267,7 +270,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
             }
         }
     }
-
+    
     // Something went wrong, or a new file was requested: create a new project
     if (!success) {
         m_url.clear();
@@ -275,9 +278,6 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
         m_document = createEmptyDocument(tracks.x(), tracks.y());
     }
 
-    // Set the video profile (empty == default)
-    KdenliveSettings::setCurrent_profile(profilePath());
-
     // Ask to create the project directory if it does not exist
     if (!QFile::exists(m_projectFolder.path())) {
         int create = KMessageBox::questionYesNo(parent, i18n("Project directory %1 does not exist. Create it?", m_projectFolder.path()));
@@ -299,7 +299,6 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
     // Make sure that the necessary folders exist
     KStandardDirs::makeDir(m_projectFolder.path(KUrl::AddTrailingSlash) + "titles/");
     KStandardDirs::makeDir(m_projectFolder.path(KUrl::AddTrailingSlash) + "thumbs/");
-    KStandardDirs::makeDir(m_projectFolder.path(KUrl::AddTrailingSlash) + "ladspa/");
     KStandardDirs::makeDir(m_projectFolder.path(KUrl::AddTrailingSlash) + "proxy/");
 
     updateProjectFolderPlacesEntry();
@@ -324,7 +323,7 @@ KdenliveDoc::~KdenliveDoc()
 
 int KdenliveDoc::setSceneList()
 {
-    m_render->resetProfile(KdenliveSettings::current_profile());
+    m_render->resetProfile(KdenliveSettings::current_profile(), true);
     if (m_render->setSceneList(m_document.toString(), m_documentProperties.value("position").toInt()) == -1) {
         // INVALID MLT Consumer, something is wrong
         return -1;
@@ -371,9 +370,9 @@ QDomDocument KdenliveDoc::createEmptyDocument(QList <TrackInfo> tracks)
     // Creating new document
     QDomDocument doc;
     QDomElement mlt = doc.createElement("mlt");
+    mlt.setAttribute("LC_NUMERIC", "");
     doc.appendChild(mlt);
-
-
+    
     // Create black producer
     // For some unknown reason, we have to build the black producer here and not in renderer.cpp, otherwise
     // the composite transitions with the black track are corrupted.
@@ -390,7 +389,7 @@ QDomDocument KdenliveDoc::createEmptyDocument(QList <TrackInfo> tracks)
 
     property = doc.createElement("property");
     property.setAttribute("name", "aspect_ratio");
-    value = doc.createTextNode(QString::number(0.0));
+    value = doc.createTextNode(QString::number(0));
     property.appendChild(value);
     blk.appendChild(property);
 
@@ -566,6 +565,18 @@ QDomDocument KdenliveDoc::xmlSceneList(const QString &scene, const QStringList e
         return sceneList;
     }
 
+    // Set playlist audio volume to 100%
+    QDomElement tractor = mlt.firstChildElement("tractor");
+    if (!tractor.isNull()) {
+        QDomNodeList props = tractor.elementsByTagName("property");
+        for (int i = 0; i < props.count(); i++) {
+            if (props.at(i).toElement().attribute("name") == "meta.volume") {
+                props.at(i).firstChild().setNodeValue("1");
+                break;
+            }
+        }
+    }
+
     QDomElement addedXml = sceneList.createElement("kdenlivedoc");
     mlt.appendChild(addedXml);
 
@@ -749,7 +760,6 @@ void KdenliveDoc::setProjectFolder(KUrl url)
 void KdenliveDoc::moveProjectData(KUrl url)
 {
     QList <DocClipBase*> list = m_clipManager->documentClipList();
-    //TODO: Also move ladspa effects files
     for (int i = 0; i < list.count(); i++) {
         DocClipBase *clip = list.at(i);
         if (clip->clipType() == TEXT) {
@@ -842,6 +852,7 @@ bool KdenliveDoc::setProfilePath(QString path)
     m_height = m_profile.height;
     kDebug() << "Kdenlive document, init timecode from path: " << path << ",  " << m_fps;
     m_timecode.setFormat(m_fps);
+    KdenliveSettings::setCurrent_profile(m_profile.path);
     return (current_fps != m_fps);
 }
 
@@ -874,10 +885,10 @@ void KdenliveDoc::setRenderer(Render *render) {
     emit progressInfo(QString(), -1);
 }*/
 
-void KdenliveDoc::checkProjectClips(bool displayRatioChanged)
+void KdenliveDoc::checkProjectClips(bool displayRatioChanged, bool fpsChanged)
 {
     if (m_render == NULL) return;
-    m_clipManager->resetProducersList(m_render->producersList(), displayRatioChanged);
+    m_clipManager->resetProducersList(m_render->producersList(), displayRatioChanged, fpsChanged);
 }
 
 Render *KdenliveDoc::renderer()
@@ -961,6 +972,7 @@ void KdenliveDoc::setUrl(KUrl url)
 
 void KdenliveDoc::setModified(bool mod)
 {
+    if (isReadOnly()) return;
     if (!m_url.isEmpty() && mod && KdenliveSettings::crashrecovery()) {
         m_autoSaveTimer->start(3000);
     }
@@ -1343,21 +1355,10 @@ void KdenliveDoc::cachePixmap(const QString &fileId, const QPixmap &pix) const
     pix.save(m_projectFolder.path(KUrl::AddTrailingSlash) + "thumbs/" + fileId + ".png");
 }
 
-QString KdenliveDoc::getLadspaFile() const
-{
-    int ct = 0;
-    QString counter = QString::number(ct).rightJustified(5, '0', false);
-    while (QFile::exists(m_projectFolder.path(KUrl::AddTrailingSlash) + "ladspa/" + counter + ".ladspa")) {
-        ct++;
-        counter = QString::number(ct).rightJustified(5, '0', false);
-    }
-    return m_projectFolder.path(KUrl::AddTrailingSlash) + "ladspa/" + counter + ".ladspa";
-}
-
 bool KdenliveDoc::checkDocumentClips(QDomNodeList infoproducers)
 {
     DocumentChecker d(infoproducers, m_document);
-    return (d.hasMissingClips() == false);
+    return (d.hasErrorInClips() == false);
 
     /*    int clipType;
         QDomElement e;
@@ -1426,7 +1427,7 @@ void KdenliveDoc::addTrackEffect(int ix, QDomElement effect)
         QDomElement e = params.item(i).toElement();
 
         // Check if this effect has a variable parameter
-        if (e.attribute("default").startsWith('%')) {
+        if (e.attribute("default").contains('%')) {
             double evaluatedValue = ProfilesDialog::getStringEval(m_profile, e.attribute("default"));
             e.setAttribute("default", evaluatedValue);
             if (e.hasAttribute("value") && e.attribute("value").startsWith('%')) {
@@ -1636,6 +1637,11 @@ void KdenliveDoc::backupLastSavedVersion(const QString &path)
     }    
 }
 
+bool KdenliveDoc::isReadOnly() const
+{
+    return m_documentProperties.contains("readonly");
+}
+
 void KdenliveDoc::cleanupBackupFiles()
 {
     KUrl backupFile = m_projectFolder;