]> git.sesse.net Git - kdenlive/blobdiff - src/kdenlivedoc.cpp
Looks like I finally got the profile switching work!
[kdenlive] / src / kdenlivedoc.cpp
index fa83913fd818ddc12af6190fa8a5d46a5add3917..e01e86f18cabf0d2e1b3721439001c18a97e9630 100644 (file)
 
 #include "kdenlivedoc.h"
 #include "docclipbase.h"
+#include "profilesdialog.h"
+#include "kdenlivesettings.h"
 
-KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *undoGroup, QWidget *parent): QObject(parent), m_render(NULL), m_url(url), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)) {
+KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *undoGroup, QWidget *parent): QObject(parent), m_render(NULL), m_url(url), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)), m_modified(false) {
     m_clipManager = new ClipManager(this);
     if (!url.isEmpty()) {
         QString tmpFile;
@@ -36,6 +38,12 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *u
             QFile file(tmpFile);
             m_document.setContent(&file, false);
             file.close();
+            QDomNode infoXmlNode = m_document.elementsByTagName("kdenlive").at(0);
+            if (!infoXmlNode.isNull()) {
+                QDomElement infoXml = infoXmlNode.toElement();
+                QString profilePath = infoXml.attribute("profile");
+                if (!profilePath.isEmpty()) setProfilePath(profilePath);
+            }
             KIO::NetAccess::removeTempFile(tmpFile);
         } else {
             KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
@@ -110,6 +118,15 @@ KdenliveDoc::~KdenliveDoc() {
     delete m_clipManager;
 }
 
+QDomElement KdenliveDoc::documentInfoXml() {
+    QDomDocument doc;
+    QDomElement addedXml = doc.createElement("kdenlive");
+    addedXml.setAttribute("version", "0.7");
+    addedXml.setAttribute("profile", profilePath());
+    return addedXml;
+}
+
+
 ClipManager *KdenliveDoc::clipManager() {
     return m_clipManager;
 }
@@ -124,6 +141,16 @@ QString KdenliveDoc::profilePath() const {
     return m_profile.path;
 }
 
+void KdenliveDoc::setProfilePath(QString path) {
+    KdenliveSettings::setCurrent_profile(path);
+    m_profile = ProfilesDialog::getVideoProfile(path);
+    m_fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
+    m_width = m_profile.width;
+    m_height = m_profile.height;
+    if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
+    else m_timecode.setFormat((int) m_fps);
+}
+
 void KdenliveDoc::setThumbsProgress(KUrl url, int progress) {
     emit thumbsProgress(url, progress);
 }
@@ -230,6 +257,11 @@ KUrl KdenliveDoc::url() const {
     return m_url;
 }
 
+void KdenliveDoc::setUrl(KUrl url) {
+    m_url = url;
+    m_modified = false;
+}
+
 QString KdenliveDoc::description() const {
     if (m_url.isEmpty())
         return i18n("Untitled") + " / " + m_profile.description;