]> git.sesse.net Git - kdenlive/blobdiff - src/kdenlivedoc.cpp
Save vertical zoom in project:
[kdenlive] / src / kdenlivedoc.cpp
index fd557ee17a829c0f9d1d516fc4f2353c1bfabc28..a205aafcaadc541fe1762a5c654c24b94e9fbf45 100644 (file)
@@ -66,6 +66,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
 
     // init default document properties
     m_documentProperties["zoom"] = "7";
+    m_documentProperties["verticalzoom"] = "1";
     m_documentProperties["zonein"] = "0";
     m_documentProperties["zoneout"] = "100";
 
@@ -95,12 +96,11 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                     // TODO: backup the document or alert the user?
                     success = validator.validate(DOCUMENTVERSION);
                     if (success) { // Let the validator handle error messages
-                        setModified(validator.isModified());
                         QDomElement mlt = m_document.firstChildElement("mlt");
                         QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
 
                         profileName = infoXml.attribute("profile");
-                        m_projectFolder = infoXml.attribute("projectfolder");
+                        m_projectFolder = KUrl(infoXml.attribute("projectfolder"));
                         QDomElement docproperties = infoXml.firstChildElement("documentproperties");
                         QDomNamedNodeMap props = docproperties.attributes();
                         for (int i = 0; i < props.count(); i++) {
@@ -192,6 +192,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                                 infoXml.removeChild(markers);
                             }
                             setProfilePath(profileName);
+                            setModified(validator.isModified());
                             kDebug() << "Reading file: " << url.path() << ", found clips: " << producers.count();
                         }
                     }
@@ -387,14 +388,15 @@ void KdenliveDoc::slotAutoSave()
     }
 }
 
-void KdenliveDoc::setZoom(int factor)
+void KdenliveDoc::setZoom(int horizontal, int vertical)
 {
-    m_documentProperties["zoom"] = QString::number(factor);
+    m_documentProperties["zoom"] = QString::number(horizontal);
+    m_documentProperties["verticalzoom"] = QString::number(vertical);
 }
 
-int KdenliveDoc::zoom() const
+QPoint KdenliveDoc::zoom() const
 {
-    return m_documentProperties.value("zoom").toInt();
+    return QPoint(m_documentProperties.value("zoom").toInt(), m_documentProperties.value("verticalzoom").toInt());
 }
 
 void KdenliveDoc::setZone(int start, int end)
@@ -915,7 +917,7 @@ void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem)
     if (createClipItem) {
         emit addProjectClip(clip);
         qApp->processEvents();
-        m_render->getFileProperties(clip->toXML(), clip->getId(), false);
+        m_render->getFileProperties(clip->toXML(), clip->getId(), true);
     }
 }
 
@@ -1170,18 +1172,18 @@ QPoint KdenliveDoc::getTracksCount() const
 
 void KdenliveDoc::cachePixmap(const QString &fileId, const QPixmap &pix) const
 {
-    pix.save(m_projectFolder.path() + "/thumbs/" + fileId + ".png");
+    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() + "/ladspa/" + counter + ".ladspa")) {
+    while (QFile::exists(m_projectFolder.path(KUrl::AddTrailingSlash) + "ladspa/" + counter + ".ladspa")) {
         ct++;
         counter = QString::number(ct).rightJustified(5, '0', false);
     }
-    return m_projectFolder.path() + "/ladspa/" + counter + ".ladspa";
+    return m_projectFolder.path(KUrl::AddTrailingSlash) + "ladspa/" + counter + ".ladspa";
 }
 
 bool KdenliveDoc::checkDocumentClips(QDomNodeList infoproducers)
@@ -1194,13 +1196,23 @@ bool KdenliveDoc::checkDocumentClips(QDomNodeList infoproducers)
     for (int i = 0; i < infoproducers.count(); i++) {
         e = infoproducers.item(i).toElement();
         clipType = e.attribute("type").toInt();
-        if (clipType == TEXT || clipType == COLOR) continue;
+        if (clipType == COLOR) continue;
+        if (clipType == TEXT) {
+            //TODO: Check is clip template is missing (xmltemplate) or hash changed
+            continue;
+        }
         id = e.attribute("id");
         resource = e.attribute("resource");
         if (clipType == SLIDESHOW) resource = KUrl(resource).directory();
         if (!KIO::NetAccess::exists(KUrl(resource), KIO::NetAccess::SourceSide, 0)) {
             // Missing clip found
             missingClips.append(e);
+        } else {
+            // Check if the clip has changed
+            if (clipType != SLIDESHOW && e.hasAttribute("file_hash")) {
+                if (e.attribute("file_hash") != DocClipBase::getHash(e.attribute("resource")))
+                    e.removeAttribute("file_hash");
+            }
         }
     }
     if (missingClips.isEmpty()) return true;