#include <KApplication>
#include <KLocale>
+#include <QFile>
#include <QColor>
DocumentValidator::DocumentValidator(QDomDocument doc):
if (!upgrade(kdenlivedocElm.attribute("version").toDouble(), currentVersion))
return false;
- /*
+ /*
* Check the syntax (this will be replaced by XSD validation with Qt 4.6)
* and correct some errors
*/
kDebug() << "Opening a document with version " << version;
// No conversion needed
- if (version == currentVersion)
- return true;
+ if (version == currentVersion) {
+ if (!m_doc.toString().contains("font-size")) // TODO: remove when currentVersion == 0.84
+ return true;
+ }
// The document is too new
if (version > currentVersion) {
return false;
}
- // <kdenlivedoc />
- QDomNode infoXmlNode = m_doc.elementsByTagName("kdenlivedoc").at(0);
- QDomElement infoXml = infoXmlNode.toElement();
-
// Unsupported document versions
if (version == 0.5 || version == 0.7) {
kDebug() << "Unable to open document with version " << version;
return false;
}
+ // <kdenlivedoc />
+ QDomNode infoXmlNode = m_doc.elementsByTagName("kdenlivedoc").at(0);
+ QDomElement infoXml = infoXmlNode.toElement();
+
if (version <= 0.6) {
QDomElement infoXml_old = infoXmlNode.cloneNode(true).toElement(); // Needed for folders
QDomNode westley = m_doc.elementsByTagName("westley").at(1);
}
}
+ if (version <= 0.83) {
+ // Replace point size with pixel size in text titles
+ if (m_doc.toString().contains("font-size")) {
+ QDomNodeList kproducerNodes = m_doc.elementsByTagName("kdenlive_producer");
+ for (int i = 0; i < kproducerNodes.count(); ++i) {
+ QDomElement kproducer = kproducerNodes.at(i).toElement();
+ if (kproducer.attribute("type").toInt() == TEXT) {
+ QDomDocument data;
+ data.setContent(kproducer.attribute("xmldata"));
+ QDomNodeList items = data.firstChild().childNodes();
+ for (int j = 0; j < items.count(); ++j) {
+ if (items.at(j).attributes().namedItem("type").nodeValue() == "QGraphicsTextItem") {
+ QDomNamedNodeMap textProperties = items.at(j).namedItem("content").attributes();
+ if (textProperties.namedItem("font-pixel-size").isNull()) {
+ QFont font;
+ font.setPointSize(textProperties.namedItem("font-size").nodeValue().toInt());
+ QDomElement content = items.at(j).namedItem("content").toElement();
+ content.setAttribute("font-pixel-size", QFontInfo(font).pixelSize());
+ content.removeAttribute("font-size");
+ kproducer.setAttribute("xmldata", data.toString());
+ QString resource = kproducer.attribute("resource");
+ if (QFile::exists(resource)) {
+ // TODO: delete the preview file
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
// The document has been converted: mark it as modified
infoXml.setAttribute("version", currentVersion);
m_modified = true;