]> git.sesse.net Git - kdenlive/commitdiff
Fix bug on insert space in all tracks, add context menu to remove space from track.
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 27 Nov 2008 12:54:50 +0000 (12:54 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 27 Nov 2008 12:54:50 +0000 (12:54 +0000)
svn path=/branches/KDE4/; revision=2738

src/customtrackview.h
src/kdenliveui.rc
src/mainwindow.cpp
src/mainwindow.h
src/renderer.cpp
src/renderer.h

index 6b98865a8bdcb5ac0d1dfa1c602bc9fd746ab2f1..838b9d09e2452ce8eb55e7955df21143a1ce0a98 100644 (file)
@@ -99,6 +99,7 @@ public:
     void setInPoint();
     void setOutPoint();
     void slotInsertSpace();
+    void slotRemoveSpace();
     void insertSpace(const GenTime &pos, int track, const GenTime duration, bool add);
 
 public slots:
index 52dcb3e2e53289078cb4133d905cad18aae55020..56f8ed1b15ac267e68a0f24c75e9524677b74265 100644 (file)
@@ -41,6 +41,7 @@
                <Action name="delete_all_guides" />
       </Menu>
       <Action name="insert_space" />
+      <Action name="delete_space" />
       <Separator />
       <Menu name="video_effects_menu" ><text>Add Video Effect</text>
       </Menu>
index fb25443284e49a4c7d52946ee8e0c501ef902af4..eb3a8c37a3cf3f2c1fd52438728a29faa337c212 100644 (file)
@@ -299,6 +299,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
 
     m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
+    m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
     m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
 
     m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
@@ -798,6 +799,10 @@ void MainWindow::setupActions() {
     collection->addAction("insert_space", insertSpace);
     connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
 
+    KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
+    collection->addAction("delete_space", removeSpace);
+    connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
+
     KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
     collection->addAction("add_guide", addGuide);
     connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
@@ -1503,6 +1508,11 @@ void MainWindow::slotInsertSpace() {
         m_activeTimeline->projectView()->slotInsertSpace();
 }
 
+void MainWindow::slotRemoveSpace() {
+    if (m_activeTimeline)
+        m_activeTimeline->projectView()->slotRemoveSpace();
+}
+
 void MainWindow::slotEditGuide() {
     if (m_activeTimeline)
         m_activeTimeline->projectView()->slotEditGuide();
index f3410dcf4dd7288d1ac7fa776d4ec1fcaa8c7815..1190a5487b1f29e433c2c22014f37578ae84ba33 100644 (file)
@@ -246,6 +246,7 @@ private slots:
     void slotFindNext();
 
     void slotInsertSpace();
+    void slotRemoveSpace();
     void slotAddGuide();
     void slotEditGuide();
     void slotDeleteGuide();
index d220f3ec231d4cd3e3d0403ec135d8f37763e099..13b13725541dfb24377ed5351cd6149fb5a4bbcd 100644 (file)
@@ -1445,6 +1445,29 @@ bool Render::mltRemoveClip(int track, GenTime position) {
     return true;
 }
 
+int Render::mltGetSpaceLength(const GenTime pos, int track) {
+    if (!m_mltProducer) {
+        kDebug() << "PLAYLIST NOT INITIALISED //////";
+        return -1;
+    }
+    Mlt::Producer parentProd(m_mltProducer->parent());
+    if (parentProd.get_producer() == NULL) {
+        kDebug() << "PLAYLIST BROKEN, CANNOT INSERT CLIP //////";
+        return -1;
+    }
+
+    Mlt::Service service(parentProd.get_service());
+    Mlt::Tractor tractor(service);
+    int insertPos = pos.frames(m_fps);
+
+    Mlt::Producer trackProducer(tractor.track(track));
+    Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
+    int clipIndex = trackPlaylist.get_clip_index_at(insertPos);
+    if (!trackPlaylist.is_blank_at(clipIndex)) return -1;
+    return trackPlaylist.clip_length(clipIndex);
+}
+
+
 void Render::mltInsertSpace(const GenTime pos, int track, const GenTime duration) {
     if (!m_mltProducer) {
         kDebug() << "PLAYLIST NOT INITIALISED //////";
index b0f019da7fb3ef3259ef36dae7e857f7083c5c33..20800cbef8b7dca474f9d2a9205d9758c1916a2c 100644 (file)
@@ -151,6 +151,7 @@ Q_OBJECT public:
     void mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
     void mltCutClip(int track, GenTime position);
     void mltInsertSpace(const GenTime pos, int track, const GenTime duration);
+    int mltGetSpaceLength(const GenTime pos, int track);
     bool mltResizeClipEnd(ItemInfo info, GenTime clipDuration);
     bool mltResizeClipStart(ItemInfo info, GenTime diff);
     bool mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart, Mlt::Producer *prod);