]> git.sesse.net Git - kdenlive/blobdiff - src/kdenlivedoc.cpp
Screengrab with audio now!
[kdenlive] / src / kdenlivedoc.cpp
index 3bebe75a166691868bd5efbb71e9f4c765a43dea..e08946c7580c55376fbf3e7cb543a72e03bb6c66 100644 (file)
 #include "mainwindow.h"
 
 
-KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), 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_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0) {
+KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), 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_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0), m_zoom(4) {
     kDebug() << "// init profile, ratnum: " << profile.frame_rate_num << ", " << profile.frame_rate_num << ", width: " << profile.width;
     m_clipManager = new ClipManager(this);
+    KdenliveSettings::setProject_fps(m_fps);
     if (!url.isEmpty()) {
         QString tmpFile;
         if (KIO::NetAccess::download(url.path(), tmpFile, parent)) {
@@ -52,6 +53,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoPro
                 QDomElement infoXml = infoXmlNode.toElement();
                 QString profilePath = infoXml.attribute("profile");
                 m_startPos = infoXml.attribute("position").toInt();
+                m_zoom = infoXml.attribute("zoom").toInt();
                 if (!profilePath.isEmpty()) setProfilePath(profilePath);
                 double version = infoXml.attribute("version").toDouble();
                 if (version < 0.7) convertDocument(version);
@@ -159,9 +161,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoPro
 
         for (uint i = 2; i < total ; i++) {
             QDomElement transition = m_document.createElement("transition");
-            transition.setAttribute("in", "0");
-            //TODO: Make audio mix last for all project duration
-            transition.setAttribute("out", "15000");
+            transition.setAttribute("always_active", "1");
 
             QDomElement property = m_document.createElement("property");
             property.setAttribute("name", "a_track");
@@ -240,6 +240,14 @@ void KdenliveDoc::slotAutoSave() {
 
 }
 
+void KdenliveDoc::setZoom(int factor) {
+    m_zoom = factor;
+}
+
+int KdenliveDoc::zoom() const {
+    return m_zoom;
+}
+
 void KdenliveDoc::convertDocument(double version) {
     // Opening a old Kdenlive document
     QDomNode westley = m_document.elementsByTagName("westley").at(1);
@@ -355,6 +363,7 @@ QDomElement KdenliveDoc::documentInfoXml() {
     addedXml.setAttribute("version", "0.7");
     addedXml.setAttribute("profile", profilePath());
     addedXml.setAttribute("position", m_render->seekPosition().frames(m_fps));
+    addedXml.setAttribute("zoom", m_zoom);
     QList <DocClipBase*> list = m_clipManager->documentClipList();
     for (int i = 0; i < list.count(); i++) {
         e = list.at(i)->toXML();
@@ -401,6 +410,7 @@ void KdenliveDoc::setProfilePath(QString path) {
     m_fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
     m_width = m_profile.width;
     m_height = m_profile.height;
+    KdenliveSettings::setProject_fps(m_fps);
     kDebug() << "KDEnnlive document, init timecode from path: " << path << ",  " << m_fps;
     if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
     else m_timecode.setFormat((int) m_fps);
@@ -597,9 +607,9 @@ void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group, const int
     setModified(true);
 }
 
-void KdenliveDoc::slotAddTextClipFile(const QString path, const QString group, const int groupId) {
+void KdenliveDoc::slotAddTextClipFile(const QString path, const QString xml, const QString group, const int groupId) {
     kDebug() << "/////////  DOCUM, ADD TXT CLP: " << path;
-    m_clipManager->slotAddTextClipFile(path, group, groupId);
+    m_clipManager->slotAddTextClipFile(path, xml, group, groupId);
     setModified(true);
 }
 
@@ -634,8 +644,8 @@ void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color,
     setModified(true);
 }
 
-void KdenliveDoc::slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, bool loop, const QString group, const int groupId) {
-    m_clipManager->slotAddSlideshowClipFile(name, path, count, duration, loop, group, groupId);
+void KdenliveDoc::slotAddSlideshowClipFile(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, const QString group, const int groupId) {
+    m_clipManager->slotAddSlideshowClipFile(name, path, count, duration, loop, fade, luma_duration, luma_file, softness, group, groupId);
     setModified(true);
 }
 
@@ -653,18 +663,23 @@ void KdenliveDoc::slotCreateTextClip(QString group, int groupId) {
         }
         QPixmap pix = dia_ui->renderedPixmap();
         pix.save(path + ".png");
-        dia_ui->saveTitle(path + ".kdenlivetitle");
-        slotAddTextClipFile(path, QString(), -1);
+        //dia_ui->saveTitle(path + ".kdenlivetitle");
+        slotAddTextClipFile(path, dia_ui->xml().toString(), QString(), -1);
     }
     delete dia_ui;
 }
 
 void KdenliveDoc::editTextClip(QString path, int id) {
-    TitleWidget *dia_ui = new TitleWidget(KUrl(path + ".kdenlivetitle"), path, m_render, kapp->activeWindow());
+    DocClipBase *clip = m_clipManager->getClipById(id);
+    if (!clip) return;
+    TitleWidget *dia_ui = new TitleWidget(KUrl()/*path + ".kdenlivetitle")*/, path, m_render, kapp->activeWindow());
+    QDomDocument doc;
+    doc.setContent(clip->getProperty("xmldata"));
+    dia_ui->setXml(doc);
     if (dia_ui->exec() == QDialog::Accepted) {
         QPixmap pix = dia_ui->renderedPixmap();
         pix.save(path + ".png");
-        dia_ui->saveTitle(path + ".kdenlivetitle");
+        //dia_ui->saveTitle(path + ".kdenlivetitle");
         //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
         emit refreshClipThumbnail(id);
     }