]> git.sesse.net Git - kdenlive/commitdiff
Fix timeline tabs appearing when canceling opening of a doc
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 3 Sep 2010 23:49:46 +0000 (23:49 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 3 Sep 2010 23:49:46 +0000 (23:49 +0000)
svn path=/trunk/kdenlive/; revision=4831

src/mainwindow.cpp
src/mainwindow.h

index 5de3702c6cf08bb187a61991739535fb30223ecd..e6d97e99a1de713884f4a3b6e8aee042cc0de486 100644 (file)
@@ -1582,13 +1582,13 @@ void MainWindow::newFile(bool showProjectSettings, bool force)
     KUrl projectFolder;
     QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
     if (!showProjectSettings) {
-        if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
+        if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
         profileName = KdenliveSettings::default_profile();
         projectFolder = KdenliveSettings::defaultprojectfolder();
     } else {
         ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
         if (w->exec() != QDialog::Accepted) return;
-        if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
+        if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
         if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
         if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
         profileName = w->selectedProfile();
@@ -1627,10 +1627,10 @@ void MainWindow::activateDocument()
     connectDocument(currentTab, currentDoc);
 }
 
-void MainWindow::closeCurrentDocument(bool saveChanges)
+bool MainWindow::closeCurrentDocument(bool saveChanges)
 {
     QWidget *w = m_timelineArea->currentWidget();
-    if (!w) return;
+    if (!w) return true;
     // closing current document
     int ix = m_timelineArea->currentIndex() + 1;
     if (ix == m_timelineArea->count()) ix = 0;
@@ -1646,10 +1646,10 @@ void MainWindow::closeCurrentDocument(bool saveChanges)
         switch (KMessageBox::warningYesNoCancel(this, message)) {
         case KMessageBox::Yes :
             // save document here. If saving fails, return false;
-            if (saveFile() == false) return;
+            if (saveFile() == false) return false;
             break;
         case KMessageBox::Cancel :
-            return;
+            return false;
             break;
         default:
             break;
@@ -1675,6 +1675,7 @@ void MainWindow::closeCurrentDocument(bool saveChanges)
     } else {
         delete w;
     }
+    return true;
 }
 
 bool MainWindow::saveFileAs(const QString &outputFileName)
@@ -1774,6 +1775,8 @@ void MainWindow::openFile(const KUrl &url)
         return;
     }
 
+    if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
+
     // Check for backup file
     QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
     if (!staleFiles.isEmpty()) {
@@ -1791,7 +1794,6 @@ void MainWindow::openFile(const KUrl &url)
             }
         }
     }
-    if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
     m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
     m_messageLabel->repaint();
     doOpenFile(url, NULL);
@@ -1836,7 +1838,6 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
 
 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
 {
-    if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
     foreach(KAutoSaveFile *stale, staleFiles) {
         /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
                   // show an error message; we could not steal the lockfile
@@ -3509,8 +3510,8 @@ void MainWindow::slotRevert()
 {
     if (KMessageBox::warningContinueCancel(this, i18n("This will delete all changes made since you last saved your project. Are you sure you want to continue?"), i18n("Revert to last saved version")) == KMessageBox::Cancel) return;
     KUrl url = m_activeDocument->url();
-    closeCurrentDocument(false);
-    doOpenFile(url, NULL);
+    if (closeCurrentDocument(false))
+        doOpenFile(url, NULL);
 }
 
 
@@ -3765,7 +3766,7 @@ void MainWindow::slotUpdateColorScopes()
 {
     bool request = false;
     for (int i = 0; i < m_scopesList.count(); i++) {
-       // Check if we need the renderer to send a new frame for update
+        // Check if we need the renderer to send a new frame for update
         if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
         static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
     }
index a6a4fd0a3c1df08dac77a5a195fc4d084cf57123..06902e5d66979dd6e06ba0ca848fa8803d234777 100644 (file)
@@ -346,8 +346,8 @@ private slots:
     *
     * Adopted from Dolphin (src/statusbar/dolphinstatusbar.cpp) */
     void slotShowZoomSliderToolTip(int zoomlevel = -1);
-
-    void closeCurrentDocument(bool saveChanges = true);
+    /** @brief Close currently opened document. Returns false if something went wrong (cannot save modifications, ...). */
+    bool closeCurrentDocument(bool saveChanges = true);
     /** @brief Deletes item in timeline, project tree or effect stack depending on focus. */
     void slotDeleteItem();
     void slotAddClipMarker();