]> git.sesse.net Git - kdenlive/commitdiff
Check if saving is successful before quitting app:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 18 Nov 2008 00:29:08 +0000 (00:29 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 18 Nov 2008 00:29:08 +0000 (00:29 +0000)
http://www.kdenlive.org/mantis/view.php?id=360

svn path=/branches/KDE4/; revision=2711

src/mainwindow.cpp
src/mainwindow.h

index 34247298bca35a305528d9cdde50b922c3010136..b082cc3ec542d6ee7c6005c60e4de46b926d9b92 100644 (file)
@@ -360,8 +360,7 @@ bool MainWindow::queryClose() {
         switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
         case KMessageBox::Yes :
             // save document here. If saving fails, return false;
-            saveFile();
-            return true;
+            return saveFile();
         case KMessageBox::No :
             return true;
         default: // cancel
@@ -933,10 +932,10 @@ void MainWindow::closeCurrentDocument() {
     }
 }
 
-void MainWindow::saveFileAs(const QString &outputFileName) {
+bool MainWindow::saveFileAs(const QString &outputFileName) {
     QDomDocument currentSceneList = m_projectMonitor->sceneList();
     if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
-        return;
+        return false;
     m_activeDocument->setUrl(KUrl(outputFileName));
     if (m_activeDocument->m_autosave == NULL) {
         m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
@@ -946,28 +945,31 @@ void MainWindow::saveFileAs(const QString &outputFileName) {
     m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
     m_activeDocument->setModified(false);
     m_fileOpenRecent->addUrl(KUrl(outputFileName));
+    return true;
 }
 
-void MainWindow::saveFileAs() {
+bool MainWindow::saveFileAs() {
     // Check that the Kdenlive mime type is correctly installed
     QString mimetype = "application/x-kdenlive";
     KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
     if (!mime) mimetype = "*.kdenlive";
 
     QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
+    if (outputFile.isEmpty()) return false;
     if (QFile::exists(outputFile)) {
-        if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
+        if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
     }
-    saveFileAs(outputFile);
+    return saveFileAs(outputFile);
 }
 
-void MainWindow::saveFile() {
-    if (!m_activeDocument) return;
+bool MainWindow::saveFile() {
+    if (!m_activeDocument) return true;
     if (m_activeDocument->url().isEmpty()) {
-        saveFileAs();
+        return saveFileAs();
     } else {
-        saveFileAs(m_activeDocument->url().path());
+        bool result = saveFileAs(m_activeDocument->url().path());
         m_activeDocument->m_autosave->resize(0);
+        return result;
     }
 }
 
index f629ce8d007562389b7109dbdf0cb0b101836284..c320d4b66d6ca99cca535c719e8d2c2e424f73ed 100644 (file)
@@ -192,9 +192,9 @@ private slots:
     void connectDocument(TrackView*, KdenliveDoc*);
     void openFile();
     void openLastFile();
-    void saveFile();
-    void saveFileAs();
-    void saveFileAs(const QString &outputFileName);
+    bool saveFile();
+    bool saveFileAs();
+    bool saveFileAs(const QString &outputFileName);
     void slotPreferences(int page = -1, int option = -1);
     void updateConfiguration();
     void slotConnectMonitors();