X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fclipmanager.cpp;h=8eea860b1c9135bf09fbf2550b6119faba421e9c;hb=8391434d0cdba5bc4c00afea00eb426d1f8a3e22;hp=38ae8e90ab374e93c148fab423e8715d1cb9222f;hpb=bdfcbfc3ec309800eaa9e106203c9ad840fed35e;p=kdenlive diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index 38ae8e90..8eea860b 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -604,15 +604,23 @@ void ClipManager::slotAddClipList(const KUrl::List urls, QMap } } } - QString titleData = txtdoc.toString(); - prod.setAttribute("xmldata", titleData); prod.setAttribute("transparency", 1); prod.setAttribute("in", 0); - int out = txtdoc.documentElement().attribute("out").toInt(); - if (out > 0) - prod.setAttribute("out", out); - else - prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); + if (!txtdoc.documentElement().hasAttribute("out")) { + prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); + txtdoc.documentElement().setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); + } + else { + int out = txtdoc.documentElement().attribute("out").toInt(); + if (out >= 0) + prod.setAttribute("out", out); + else { + prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); + txtdoc.documentElement().setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); + } + } + QString titleData = txtdoc.toString(); + prod.setAttribute("xmldata", titleData); } else txtfile.close(); } @@ -730,16 +738,22 @@ void ClipManager::slotAddTextTemplateClip(QString titleName, const KUrl &path, c prod.setAttribute("transparency", "1"); prod.setAttribute("in", "0"); - int out = 0; + int duration = 0; QDomDocument titledoc; QFile txtfile(path.path()); if (txtfile.open(QIODevice::ReadOnly) && titledoc.setContent(&txtfile)) { txtfile.close(); - out = titledoc.documentElement().attribute("out").toInt(); + if (titledoc.documentElement().hasAttribute("duration")) { + duration = titledoc.documentElement().attribute("duration").toInt(); + } + else { + // keep some time for backwards compatibility - 26/12/12 + duration = titledoc.documentElement().attribute("out").toInt(); + } } else txtfile.close(); - if (out == 0) out = m_doc->getFramePos(KdenliveSettings::image_duration()); - prod.setAttribute("out", out); + if (duration == 0) duration = m_doc->getFramePos(KdenliveSettings::title_duration()); + prod.setAttribute("out", duration - 1); AddClipCommand *command = new AddClipCommand(m_doc, doc.documentElement(), QString::number(id), true); m_doc->commandStack()->push(command);