Fix titles from 0.9.x kdenlive versions broken on locales with comma separator

Don't block opening project on missing font
Fix error in importing old project files that was not processing all clips
BUG: 358033
parent a3b3ab8e
......@@ -201,7 +201,6 @@ bool DocumentChecker::hasErrorInClips()
item->setData(0, idRole, l);
item->setData(0, statusRole, LUMAMISSING);
}
m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_missingClips.isEmpty() && missingProxies.isEmpty() && missingSources.isEmpty());
max = m_missingClips.count();
m_missingProxyIds.clear();
......@@ -241,6 +240,7 @@ bool DocumentChecker::hasErrorInClips()
item->setData(0, typeOriginalResource, e.attribute("resource"));
} else if (status == TITLE_FONT_ELEMENT) {
item->setIcon(0, KoIconUtils::themedIcon("dialog-warning"));
item->setData(0, statusRole, CLIPPLACEHOLDER);
item->setToolTip(1, e.attribute("name"));
QString ft = e.attribute("resource");
QString newft = QFontInfo(QFont(ft)).family();
......@@ -892,7 +892,6 @@ void DocumentChecker::checkMissingImagesAndFonts(const QStringList &images, cons
}
}
void DocumentChecker::slotCheckButtons()
{
if (m_ui.treeWidget->currentItem()) {
......
......@@ -1120,7 +1120,6 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
else trackRenaming.insert(entryId, newId);
entry.setAttribute("producer", newId);
}
if (!trackRenaming.isEmpty()) {
for (int i = 0; i < producers.count(); ++i) {
QDomElement prod = producers.at(i).toElement();
......@@ -1183,6 +1182,10 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
QDomElement entry = m_doc.createElement("entry");
entry.setAttribute("producer", id);
main_playlist.appendChild(entry);
QString service = EffectsList::property(prod, QStringLiteral("mlt_service"));
if (service == QLatin1String("kdenlivetitle")) {
fixTitleProducerLocale(prod);
}
QDomElement source = m_source_producers.value(id);
if (!source.isNull()) {
updateProducerInfo(prod, source);
......@@ -1190,6 +1193,8 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
entry.setAttribute("out", QString::number(source.attribute("duration").toInt() - 1));
}
frag.appendChild(prod);
// Changing prod parent removes it from list, so rewind index
i--;
}
else {
QDomElement originalProd = prod.cloneNode().toElement();
......@@ -1264,6 +1269,9 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
entry.setAttribute("out", QString::number(prod.attribute("duration").toInt() - 1));
entry.setAttribute("producer", id);
main_playlist.appendChild(entry);
if (type == 6) {
fixTitleProducerLocale(originalProd);
}
frag.appendChild(originalProd);
ids << id;
}
......@@ -1879,3 +1887,49 @@ void DocumentValidator::checkOrphanedProducers()
}
}
void DocumentValidator::fixTitleProducerLocale(QDomElement &producer)
{
QString data = EffectsList::property(producer, "xmldata");
QDomDocument doc;
doc.setContent(data);
QDomNodeList nodes = doc.elementsByTagName(QStringLiteral("position"));
bool fixed = false;
for (int i = 0; i < nodes.count(); i++) {
QDomElement pos = nodes.at(i).toElement();
QString x = pos.attribute(QStringLiteral("x"));
QString y = pos.attribute(QStringLiteral("y"));
if (x.contains(QLatin1Char(','))) {
// x pos was saved in locale format, fix
x = x.section(QStringLiteral(","), 0, 0);
pos.setAttribute(QStringLiteral("x"), x);
fixed = true;
}
if (y.contains(QLatin1Char(','))) {
// x pos was saved in locale format, fix
y = y.section(QStringLiteral(","), 0, 0);
pos.setAttribute(QStringLiteral("y"), y);
fixed = true;
}
}
nodes = doc.elementsByTagName(QStringLiteral("content"));
for (int i = 0; i < nodes.count(); i++) {
QDomElement pos = nodes.at(i).toElement();
QString x = pos.attribute(QStringLiteral("font-outline"));
QString y = pos.attribute(QStringLiteral("textwidth"));
if (x.contains(QLatin1Char(','))) {
// x pos was saved in locale format, fix
x = x.section(QStringLiteral(","), 0, 0);
pos.setAttribute(QStringLiteral("font-outline"), x);
fixed = true;
}
if (y.contains(QLatin1Char(','))) {
// x pos was saved in locale format, fix
y = y.section(QStringLiteral(","), 0, 0);
pos.setAttribute(QStringLiteral("textwidth"), y);
fixed = true;
}
}
if (fixed) EffectsList::setProperty(producer, QStringLiteral("xmldata"), doc.toString());
}
......@@ -59,6 +59,8 @@ private:
bool updateEffectParameters(const QDomNodeList &parameters, const QScriptValue *updateRules, const double serviceVersion, const double effectVersion);
*/
QString factorizeGeomValue(QString value, double factor);
/** @brief Kdenlive <= 0.9.10 saved title clip item position/opacity with locale which was wrong, fix. */
void fixTitleProducerLocale(QDomElement &producer);
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment