]> git.sesse.net Git - kdenlive/commitdiff
Add revert action to revert project to last saved version:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 26 Sep 2009 22:21:27 +0000 (22:21 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 26 Sep 2009 22:21:27 +0000 (22:21 +0000)
http://www.kdenlive.org/mantis/view.php?id=1063

svn path=/trunk/kdenlive/; revision=3942

src/mainwindow.cpp
src/mainwindow.h

index 01585755ca12b576b2b862e4df0bee698a9186bd..fbab57bc184afd3fe85714194c96241e3e0c9bd5 100644 (file)
@@ -176,9 +176,10 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
 
     KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
-    m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
-                       actionCollection());
+    m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
     readOptions();
+    m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
+    m_fileRevert->setEnabled(false);
 
     //slotDetectAudioDriver();
 
@@ -1251,6 +1252,7 @@ void MainWindow::slotRunWizard()
 void MainWindow::newFile(bool showProjectSettings)
 {
     if (!m_timelineArea->isEnabled()) return;
+    m_fileRevert->setEnabled(false);
     QString profileName;
     KUrl projectFolder;
     QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
@@ -1300,7 +1302,7 @@ void MainWindow::activateDocument()
     connectDocument(currentTab, currentDoc);
 }
 
-void MainWindow::closeCurrentDocument()
+void MainWindow::closeCurrentDocument(bool saveChanges)
 {
     QWidget *w = m_timelineArea->currentWidget();
     if (!w) return;
@@ -1310,7 +1312,7 @@ void MainWindow::closeCurrentDocument()
     m_timelineArea->setCurrentIndex(ix);
     TrackView *tabToClose = (TrackView *) w;
     KdenliveDoc *docToClose = tabToClose->document();
-    if (docToClose && docToClose->isModified()) {
+    if (docToClose && docToClose->isModified() && saveChanges) {
         switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
         case KMessageBox::Yes :
             // save document here. If saving fails, return false;
@@ -1365,6 +1367,7 @@ bool MainWindow::saveFileAs(const QString &outputFileName)
     m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
     m_activeDocument->setModified(false);
     m_fileOpenRecent->addUrl(KUrl(outputFileName));
+    m_fileRevert->setEnabled(true);
     return true;
 }
 
@@ -1460,6 +1463,7 @@ void MainWindow::openFile(const KUrl &url)
 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
 {
     if (!m_timelineArea->isEnabled()) return;
+    m_fileRevert->setEnabled(true);
     KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
     if (stale == NULL) {
         stale = new KAutoSaveFile(url, doc);
@@ -2849,7 +2853,12 @@ void MainWindow::slotRemoveFocus()
     statusBar()->clearFocus();
 }
 
-
-
+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);
+}
 
 #include "mainwindow.moc"
index dad8b34e6f8623e502c406b8608944d7fdb589c7..b953edf27a261a87ec0062c4767b08451e8730a2 100644 (file)
@@ -157,6 +157,7 @@ private:
 #endif /* NO_JOGSHUTTLE */
 
     KRecentFilesAction *m_fileOpenRecent;
+    KAction *m_fileRevert;
     KAction *m_projectSearch;
     KAction *m_projectSearchNext;
 
@@ -239,7 +240,7 @@ private slots:
     void slotZoomIn();
     void slotZoomOut();
     void slotFitZoom();
-    void closeCurrentDocument();
+    void closeCurrentDocument(bool saveChanges = true);
     void slotDeleteTimelineClip();
     void slotAddClipMarker();
     void slotDeleteClipMarker();
@@ -315,6 +316,7 @@ private slots:
     void slotCleanProject();
     void slotSetZoom(int value);
     void slotUpdateClipMarkers(DocClipBase *clip);
+    void slotRevert();
 
 signals:
     Q_SCRIPTABLE void abortRenderJob(const QString &url);