]> git.sesse.net Git - kdenlive/commitdiff
Do not allow deleting last track (also fixes a related crash)
authorTill Theato <root@ttill.de>
Thu, 3 Jun 2010 21:35:39 +0000 (21:35 +0000)
committerTill Theato <root@ttill.de>
Thu, 3 Jun 2010 21:35:39 +0000 (21:35 +0000)
svn path=/trunk/kdenlive/; revision=4500

src/customtrackview.cpp
src/customtrackview.h

index 3b73087af87a782f9ac284244f6821bf07ce53a9..2ff23eb3c831bc45c5f31d756388229136d49bb9 100644 (file)
@@ -5326,25 +5326,27 @@ void CustomTrackView::slotInsertTrack(int ix)
     }
 }
 
-void CustomTrackView::slotDeleteTrack(int ix)
-{
-    TrackDialog d(m_document, parentWidget());
-    d.label->setText(i18n("Delete track"));
-    d.before_select->setHidden(true);
-    d.track_nb->setMaximum(m_document->tracksCount() - 1);
-    d.track_nb->setValue(ix);
-    d.slotUpdateName(ix);
-    d.setWindowTitle(i18n("Delete Track"));
-    d.video_track->setHidden(true);
-    d.audio_track->setHidden(true);
-    if (d.exec() == QDialog::Accepted) {
-        ix = d.track_nb->value();
-        TrackInfo info = m_document->trackInfoAt(m_document->tracksCount() - ix - 1);
-        deleteTimelineTrack(ix, info);
-        setDocumentModified();
-        /*AddTrackCommand* command = new AddTrackCommand(this, ix, info, false);
-        m_commandStack->push(command);*/
+void CustomTrackView::slotDeleteTrack(int ix, bool dialog)
+{
+    if (m_document->tracksCount() < 2) return;
+    if (dialog) {
+        TrackDialog d(m_document, parentWidget());
+        d.label->setText(i18n("Delete track"));
+        d.before_select->setHidden(true);
+        d.track_nb->setMaximum(m_document->tracksCount() - 1);
+        d.track_nb->setValue(ix);
+        d.slotUpdateName(ix);
+        d.setWindowTitle(i18n("Delete Track"));
+        d.video_track->setHidden(true);
+        d.audio_track->setHidden(true);
+        if (d.exec() == QDialog::Accepted)
+            ix = d.track_nb->value();
+        else
+            return;
     }
+    TrackInfo info = m_document->trackInfoAt(m_document->tracksCount() - ix - 1);
+    deleteTimelineTrack(ix, info);
+    setDocumentModified();
 }
 
 void CustomTrackView::slotConfigTracks(int ix)
index 54b27988e52f0eb6cf3525b9cf1e6ff89cdbbe52..f1cc64488da12706855b6e8591f26124242cf452 100644 (file)
@@ -206,7 +206,11 @@ public slots:
     void slotUpdateAllThumbs();
     void slotCheckPositionScrolling();
     void slotInsertTrack(int ix);
-    void slotDeleteTrack(int ix);
+
+    /** @brief Shows a dialog for selecting a track to delete.
+    * @param ix Number of the track, which should be pre-selected in the dialog
+    * @param dialog Show dialog or directly delete track @param ix? */
+    void slotDeleteTrack(int ix, bool dialog = true);
     /** @brief Shows the configure tracks dialog. */
     void slotConfigTracks(int ix);
     void clipNameChanged(const QString id, const QString name);