QTextStream out(&file);
out << sceneList.toString();
+ if (file.error() != QFile::NoError) {
+ KMessageBox::error(kapp->activeWindow(), i18n("Cannot write to file %1", path));
+ file.close();
+ return false;
+ }
file.close();
return true;
}
switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
case KMessageBox::Yes :
// save document here. If saving fails, return false;
- saveFile();
+ if (saveFile() == false) return;
break;
case KMessageBox::Cancel :
return;
// Generate script file
QFile file(scriptExport);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- m_messageLabel->setMessage(i18n("Cannot write to file %1", scriptExport), ErrorMessage);
+ KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
return;
}
out << "SOURCE=" << "\"" + scriptExport + ".westley\"" << "\n";
out << "TARGET=" << "\"" + dest + "\"" << "\n";
out << renderer << " " << args.join(" ") << "\n" << "\n";
+ if (file.error() != QFile::NoError) {
+ KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
+ file.close();
+ return;
+ }
file.close();
QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
}
}
QTextStream out(&file);
out << "description=" << m_view.description->text() << "\n" << "frame_rate_num=" << m_view.frame_num->value() << "\n" << "frame_rate_den=" << m_view.frame_den->value() << "\n" << "width=" << m_view.size_w->value() << "\n" << "height=" << m_view.size_h->value() << "\n" << "progressive=" << m_view.progressive->isChecked() << "\n" << "sample_aspect_num=" << m_view.aspect_num->value() << "\n" << "sample_aspect_den=" << m_view.aspect_den->value() << "\n" << "display_aspect_num=" << m_view.display_num->value() << "\n" << "display_aspect_den=" << m_view.display_den->value() << "\n";
+ if (file.error() != QFile::NoError) {
+ KMessageBox::error(this, i18n("Cannot write to file %1", path));
+ }
file.close();
}
return playlist;
}
-void Render::saveSceneList(QString path, QDomElement kdenliveData) {
+bool Render::saveSceneList(QString path, QDomElement kdenliveData) {
QFile file(path);
QDomDocument doc;
doc.setContent(sceneList(), false);
}
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
kWarning() << "////// ERROR writing to file: " << path;
- return;
+ return false;
}
QTextStream out(&file);
out << doc.toString();
+ if (file.error() != QFile::NoError) {
+ file.close();
+ return false;
+ }
file.close();
+ return true;
}
void setSceneList(QString playlist, int position = 0);
void setProducer(Mlt::Producer *producer, int position);
const QString sceneList();
- void saveSceneList(QString path, QDomElement kdenliveData = QDomElement());
+ bool saveSceneList(QString path, QDomElement kdenliveData = QDomElement());
/** Wraps the VEML command of the same name. Tells the renderer to
play the current scene at the speed specified, relative to normal
}
QTextStream out(&file);
out << doc.toString();
+ if (file.error() != QFile::NoError) {
+ KMessageBox::error(this, i18n("Cannot write to file %1", exportFile));
+ file.close();
+ return;
+ }
file.close();
parseProfiles(newMetaGroupId, newGroupName, newProfileName);
}
profiles.appendChild(profileElement);
//QCString save = doc.toString().utf8();
-
+ delete d;
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- KMessageBox::sorry(this, i18n("Unable to write to file %1", exportFile));
- delete d;
+ KMessageBox::error(this, i18n("Cannot write to file %1", exportFile));
return;
}
QTextStream out(&file);
out << doc.toString();
+ if (file.error() != QFile::NoError) {
+ KMessageBox::error(this, i18n("Cannot write to file %1", exportFile));
+ file.close();
+ return;
+ }
file.close();
parseProfiles(newMetaGroupId, newGroupName, newProfileName);
- }
- delete d;
+ } else delete d;
}
void RenderWidget::slotDeleteProfile(bool refresh) {
}
QTextStream out(&file);
out << doc.toString();
+ if (file.error() != QFile::NoError) {
+ KMessageBox::error(this, i18n("Cannot write to file %1", exportFile));
+ file.close();
+ return;
+ }
file.close();
if (refresh) {
parseProfiles(metaGroupId, currentGroup);
case 8:
e.setAttribute("type", "QGraphicsTextItem");
t = static_cast<QGraphicsTextItem *>(item);
- // Don't save empty text nodes
- if (t->toPlainText().simplified().isEmpty()) continue;
+ // Don't save empty text nodes
+ if (t->toPlainText().simplified().isEmpty()) continue;
//content.appendChild(doc.createTextNode(((QGraphicsTextItem*)item)->toHtml()));
content.appendChild(doc.createTextNode(t->toPlainText()));
font = t->font();
QDomDocument doc = xml(startv, endv);
KTemporaryFile tmpfile;
- if (!tmpfile.open()) kWarning() << "///// CANNOT CREATE TMP FILE in: " << tmpfile.fileName();
+ if (!tmpfile.open()) {
+ kWarning() << "///// CANNOT CREATE TMP FILE in: " << tmpfile.fileName();
+ return false;
+ }
QFile xmlf(tmpfile.fileName());
xmlf.open(QIODevice::WriteOnly);
xmlf.write(doc.toString().toUtf8());
+ if (xmlf.error() != QFile::NoError) {
+ xmlf.close();
+ return false;
+ }
xmlf.close();
- kDebug() << KIO::NetAccess::upload(tmpfile.fileName(), url, 0);
- return true;
+ return KIO::NetAccess::upload(tmpfile.fileName(), url, 0);
}
int TitleDocument::loadDocument(const KUrl& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv) {
int zValue = items.item(i).attributes().namedItem("z-index").nodeValue().toInt();
if (zValue > -1000)
if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsTextItem") {
- QDomNamedNodeMap txtProperties = items.item(i).namedItem("content").attributes();
+ QDomNamedNodeMap txtProperties = items.item(i).namedItem("content").attributes();
QFont font(txtProperties.namedItem("font").nodeValue());
font.setBold(txtProperties.namedItem("font-bold").nodeValue().toInt());
font.setItalic(txtProperties.namedItem("font-italic").nodeValue().toInt());
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()) {
- 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());
+ // Older Kdenlive version did not store pixel size but point size
+ if (txtProperties.namedItem("font-pixel-size").isNull()) {
+ 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());
QColor col(stringToColor(txtProperties.namedItem("font-color").nodeValue()));
QGraphicsTextItem *txt = scene->addText(items.item(i).namedItem("content").firstChild().nodeValue(), font);
txt->setDefaultTextColor(col);
#include <KGlobalSettings>
#include <KFileDialog>
#include <KStandardDirs>
+#include <KMessageBox>
#include <QDomDocument>
#include <QGraphicsItem>
void TitleWidget::saveTitle(KUrl url) {
if (url.isEmpty()) url = KFileDialog::getSaveUrl(KUrl(m_projectPath), "*.kdenlivetitle", this, i18n("Save Title"));
- if (!url.isEmpty()) m_titledocument.saveDocument(url, startViewport, endViewport);
+ if (!url.isEmpty()) {
+ if (m_titledocument.saveDocument(url, startViewport, endViewport) == false)
+ KMessageBox::error(this, i18n("Cannot write to file %1", url.path()));
+ }
}
QDomDocument TitleWidget::xml() {