From 606fda3391fd070d695e76368052d844ab6efe44 Mon Sep 17 00:00:00 2001 From: Alberto Villa Date: Sat, 20 Jun 2009 10:55:52 +0000 Subject: [PATCH] warn the user that titles are going to be converted from point size to pixel size, and ask him if he wants to: http://www.kdenlive.org/mantis/view.php?id=749 svn path=/trunk/kdenlive/; revision=3601 --- src/clipitem.cpp | 2 +- src/documentvalidator.cpp | 34 ++++++++++++++++++++-------------- src/titledocument.cpp | 7 ++++++- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/clipitem.cpp b/src/clipitem.cpp index c3061f54..9e43db23 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -413,7 +413,7 @@ void ClipItem::resetThumbs(bool clearExistingThumbs) if (clearExistingThumbs) { m_startPix = QPixmap(); m_endPix = QPixmap(); - m_audioThumbCachePic.clear(); + m_audioThumbCachePic.clear(); } slotFetchThumbs(); } diff --git a/src/documentvalidator.cpp b/src/documentvalidator.cpp index 9e4f1158..83727c76 100644 --- a/src/documentvalidator.cpp +++ b/src/documentvalidator.cpp @@ -674,29 +674,35 @@ bool DocumentValidator::upgrade(double version, const double currentVersion) if (version <= 0.83) { // Replace point size with pixel size in text titles + KMessageBox::ButtonCode convert; if (m_doc.toString().contains("font-size")) { QDomNodeList kproducerNodes = m_doc.elementsByTagName("kdenlive_producer"); - for (int i = 0; i < kproducerNodes.count(); ++i) { + for (int i = 0; i < kproducerNodes.count() && convert != KMessageBox::No; ++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) { + for (int j = 0; j < items.count() && convert != KMessageBox::No; ++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()); - /* - * You may be tempted to delete the preview file - * to force its recreation: bad idea (see - * http://www.kdenlive.org/mantis/view.php?id=749) - */ + if (textProperties.namedItem("font-pixel-size").isNull() && !textProperties.namedItem("font-size").isNull()) { + // Ask the user if he wants to convert + if (convert != KMessageBox::Yes && convert != KMessageBox::No) + convert = (KMessageBox::ButtonCode)KMessageBox::warningYesNo(kapp->activeWindow(), i18n("Some of your text clips were saved with size in points, which means different sizes on different displays. Do you want to convert them to pixel size, making them portable? It is recommended you do this on the computer they were first created on, or you could have to adjust their size."), i18n("Update Text Clips")); + if (convert == KMessageBox::Yes) { + 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()); + /* + * You may be tempted to delete the preview file + * to force its recreation: bad idea (see + * http://www.kdenlive.org/mantis/view.php?id=749) + */ + } } } } diff --git a/src/titledocument.cpp b/src/titledocument.cpp index 7febfb02..16f38b5e 100644 --- a/src/titledocument.cpp +++ b/src/titledocument.cpp @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include #include #include @@ -222,10 +225,12 @@ int TitleDocument::loadFromXml(QDomDocument doc, QGraphicsPolygonItem* /*startv* font.setUnderline(txtProperties.namedItem("font-underline").nodeValue().toInt()); // Older Kdenlive version did not store pixel size but point size if (txtProperties.namedItem("font-pixel-size").isNull()) { + KMessageBox::information(kapp->activeWindow(), i18n("Some of your text clips were saved with size in points, which means different sizes on different displays. They will be converted to pixel size, making them portable, but you could have to adjust their size."), i18n("Text Clips Updated")); QFont f2; f2.setPointSize(txtProperties.namedItem("font-size").nodeValue().toInt()); font.setPixelSize(QFontInfo(f2).pixelSize()); - } else font.setPixelSize(txtProperties.namedItem("font-pixel-size").nodeValue().toInt()); + } else + font.setPixelSize(txtProperties.namedItem("font-pixel-size").nodeValue().toInt()); QColor col(stringToColor(txtProperties.namedItem("font-color").nodeValue())); QGraphicsTextItem *txt = m_scene->addText(items.item(i).namedItem("content").firstChild().nodeValue(), font); txt->setDefaultTextColor(col); -- 2.39.2