X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftitledocument.cpp;h=d48cc6fedc1dfff2cd3201ab9dfe1e00c8ff57ae;hb=d20fa38526368d808a18d9558c25747bb731c38a;hp=7aebd8f434261937214d3d798b39277cfc6496a3;hpb=256f950ea776efeabd417bf9477747ea2c2bd35d;p=kdenlive diff --git a/src/titledocument.cpp b/src/titledocument.cpp index 7aebd8f4..d48cc6fe 100644 --- a/src/titledocument.cpp +++ b/src/titledocument.cpp @@ -37,6 +37,8 @@ #include #include +#include + #if QT_VERSION >= 0x040600 #include #include @@ -58,6 +60,8 @@ QByteArray fileToByteArray(const QString& filename) TitleDocument::TitleDocument() { m_scene = NULL; + m_width = 0; + m_height = 0; } void TitleDocument::setScene(QGraphicsScene* _scene, int width, int height) @@ -121,6 +125,9 @@ QDomDocument TitleDocument::xml(QGraphicsRectItem* startv, QGraphicsRectItem* en QDomElement main = doc.createElement("kdenlivetitle"); main.setAttribute("width", m_width); main.setAttribute("height", m_height); + // Save locale + const char *locale = setlocale(LC_NUMERIC, NULL); + main.setAttribute("LC_NUMERIC", locale); doc.appendChild(main); foreach(QGraphicsItem * item, m_scene->items()) { @@ -166,11 +173,16 @@ QDomDocument TitleDocument::xml(QGraphicsRectItem* startv, QGraphicsRectItem* en QColor fontcolor = cursor.charFormat().foreground().color(); content.setAttribute("font-color", colorToString(fontcolor)); if (!t->data(101).isNull()) content.setAttribute("font-outline", t->data(101).toDouble()); - if (!t->data(102).isNull()) content.setAttribute("font-outline-color", colorToString(QColor(t->data(102).toString()))); + if (!t->data(102).isNull()) { + QVariant variant = t->data(102); + QColor outlineColor = variant.value(); + content.setAttribute("font-outline-color", colorToString(outlineColor)); + } } if (!t->data(100).isNull()) { QStringList effectParams = t->data(100).toStringList(); QString effectName = effectParams.takeFirst(); + content.setAttribute("textwidth", QString::number(t->sceneBoundingRect().width())); content.setAttribute(effectName, effectParams.join(";")); } @@ -273,20 +285,23 @@ QColor TitleDocument::getBackgroundColor() } -bool TitleDocument::saveDocument(const KUrl& url, QGraphicsRectItem* startv, QGraphicsRectItem* endv, int out, bool embed) +bool TitleDocument::saveDocument(const KUrl& url, QGraphicsRectItem* startv, QGraphicsRectItem* endv, int duration, bool embed) { if (!m_scene) return false; QDomDocument doc = xml(startv, endv, embed); - doc.documentElement().setAttribute("out", out); + doc.documentElement().setAttribute("duration", duration); + // keep some time for backwards compatibility (opening projects with older versions) - 26/12/12 + doc.documentElement().setAttribute("out", duration); KTemporaryFile tmpfile; if (!tmpfile.open()) { kWarning() << "///// CANNOT CREATE TMP FILE in: " << tmpfile.fileName(); return false; } QFile xmlf(tmpfile.fileName()); - xmlf.open(QIODevice::WriteOnly); + if (!xmlf.open(QIODevice::WriteOnly)) + return false; xmlf.write(doc.toString().toUtf8()); if (xmlf.error() != QFile::NoError) { xmlf.close(); @@ -296,7 +311,7 @@ bool TitleDocument::saveDocument(const KUrl& url, QGraphicsRectItem* startv, QGr return KIO::NetAccess::upload(tmpfile.fileName(), url, 0); } -int TitleDocument::loadFromXml(QDomDocument doc, QGraphicsRectItem* startv, QGraphicsRectItem* endv, int *out, const QString& projectpath) +int TitleDocument::loadFromXml(QDomDocument doc, QGraphicsRectItem* startv, QGraphicsRectItem* endv, int *duration, const QString& projectpath) { m_projectPath = projectpath; QDomNodeList titles = doc.elementsByTagName("kdenlivetitle"); @@ -322,10 +337,12 @@ int TitleDocument::loadFromXml(QDomDocument doc, QGraphicsRectItem* startv, QGra } } //TODO: get default title duration instead of hardcoded one - if (doc.documentElement().hasAttribute("out")) - *out = doc.documentElement().attribute("out").toInt(); + if (doc.documentElement().hasAttribute("duration")) + *duration = doc.documentElement().attribute("duration").toInt(); + else if (doc.documentElement().hasAttribute("out")) + *duration = doc.documentElement().attribute("out").toInt(); else - *out = 125; + *duration = 125; int maxZValue = 0; if (titles.size()) {