]> git.sesse.net Git - kdenlive/commitdiff
Start of spacer tool: space can now be inserted via timeline context menu
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 24 Nov 2008 22:20:36 +0000 (22:20 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 24 Nov 2008 22:20:36 +0000 (22:20 +0000)
svn path=/branches/KDE4/; revision=2729

16 files changed:
src/CMakeLists.txt
src/clipproperties.cpp
src/customtrackview.cpp
src/customtrackview.h
src/insertspacecommand.cpp [new file with mode: 0644]
src/insertspacecommand.h [new file with mode: 0644]
src/kdenliveui.rc
src/mainwindow.cpp
src/mainwindow.h
src/markerdialog.cpp
src/markerdialog.h
src/renderer.cpp
src/renderer.h
src/spacerdialog.cpp [new file with mode: 0644]
src/spacerdialog.h [new file with mode: 0644]
src/widgets/spacerdialog_ui.ui [new file with mode: 0644]

index 67de7cd3012e10907546d1515d5919e76ef532ec..eba7e5d8f3ebb013a52b388fa47cc8780151a57b 100644 (file)
@@ -59,6 +59,7 @@ kde4_add_ui_files(kdenlive_UI
   widgets/geometryval_ui.ui
   widgets/wizardstandard_ui.ui
   widgets/wizardextra_ui.ui
+  widgets/spacerdialog_ui.ui
 )
  
 set(kdenlive_SRCS 
@@ -132,6 +133,8 @@ set(kdenlive_SRCS
   abstractgroupitem.cpp
   keyframehelper.cpp
   editclipcommand.cpp
+  insertspacecommand.cpp
+  spacerdialog.cpp
 )
 
 if(NO_JOGSHUTTLE)
index f1187069e604f8cf0ed3fa914553153d0ccf429b..71d4540ffeb4db06afc1b50940a773b87dc4d51b 100644 (file)
@@ -222,7 +222,7 @@ void ClipProperties::slotFillMarkersList() {
 
 void ClipProperties::slotAddMarker() {
     CommentedTime marker(GenTime(), i18n("Marker"));
-    MarkerDialog d(m_clip, marker, m_tc, this);
+    MarkerDialog d(m_clip, marker, m_tc, i18n("Add Marker"), this);
     if (d.exec() == QDialog::Accepted) {
         emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
     }
@@ -233,7 +233,7 @@ void ClipProperties::slotEditMarker() {
     QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
     int pos = m_view.markers_list->currentIndex().row();
     if (pos < 0 || pos > marks.count() - 1) return;
-    MarkerDialog d(m_clip, marks.at(pos), m_tc, this);
+    MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
     if (d.exec() == QDialog::Accepted) {
         emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
     }
index 94cb4597e4f6c2adfdfd15590f9c19eabb38cc17..0165af3d99eaae8cc901d922c2f745a372331837 100644 (file)
@@ -61,7 +61,8 @@
 #include "ui_keyframedialog_ui.h"
 #include "clipdurationdialog.h"
 #include "abstractgroupitem.h"
-
+#include "insertspacecommand.h"
+#include "spacerdialog.h"
 
 //TODO:
 // disable animation if user asked it in KDE's global settings
@@ -1291,6 +1292,39 @@ void CustomTrackView::slotSwitchTrackVideo(int ix) {
     m_document->renderer()->mltChangeTrackState(tracknumber, m_scene->m_tracksList.at(tracknumber - 1).isMute, m_scene->m_tracksList.at(tracknumber - 1).isBlind);
 }
 
+void CustomTrackView::slotInsertSpace() {
+    GenTime pos;
+    int track = 0;
+    if (m_menuPosition.isNull()) {
+        pos = GenTime(cursorPos(), m_document->fps());
+    } else {
+        pos = GenTime((int)(mapToScene(m_menuPosition).x()), m_document->fps());
+        track = (int)(mapToScene(m_menuPosition).y() / m_tracksHeight) + 1;
+    }
+    SpacerDialog d(GenTime(65, m_document->fps()), m_document->timecode(), track, m_scene->m_tracksList.count(), this);
+    if (d.exec() != QDialog::Accepted) return;
+    GenTime spaceDuration = d.selectedDuration();
+    track = d.selectedTrack();
+    InsertSpaceCommand *command = new InsertSpaceCommand(this, pos, track, spaceDuration, true);
+    m_commandStack->push(command);
+}
+
+void CustomTrackView::insertSpace(const GenTime &pos, int track, const GenTime duration, bool add) {
+    int diff = duration.frames(m_document->fps());
+    if (!add) diff = -diff;
+    QList<QGraphicsItem *> itemList;
+    if (track == -1) itemList = items();
+    else itemList = scene()->items(pos.frames(m_document->fps()) , track * m_tracksHeight + m_tracksHeight / 2, sceneRect().width() - pos.frames(m_document->fps()), m_tracksHeight / 4);
+    for (int i = 0; i < itemList.count(); i++) {
+        if (itemList.at(i)->type() == AVWIDGET) {
+            ClipItem *item = (ClipItem *)itemList.at(i);
+            if (item->endPos() > pos) item->moveBy(diff, 0);
+        }
+    }
+    if (track != -1) track = m_scene->m_tracksList.count() - track;
+    m_document->renderer()->mltInsertSpace(pos, track, duration, add);
+}
+
 void CustomTrackView::deleteClip(const QString &clipId) {
     QList<QGraphicsItem *> itemList = items();
     for (int i = 0; i < itemList.count(); i++) {
@@ -1969,7 +2003,7 @@ void CustomTrackView::slotAddClipMarker() {
     QString id = clip->baseClip()->getId();
     GenTime position = pos - item->startPos() + item->cropStart();
     CommentedTime marker(position, i18n("Marker"));
-    MarkerDialog d(clip->baseClip(), marker, m_document->timecode(), this);
+    MarkerDialog d(clip->baseClip(), marker, m_document->timecode(), i18n("Add Marker"), this);
     if (d.exec() == QDialog::Accepted) {
         slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
     }
@@ -2067,7 +2101,7 @@ void CustomTrackView::slotEditClipMarker() {
     }
 
     CommentedTime marker(position, oldcomment);
-    MarkerDialog d(clip->baseClip(), marker, m_document->timecode(), this);
+    MarkerDialog d(clip->baseClip(), marker, m_document->timecode(), i18n("Edit Marker"), this);
     if (d.exec() == QDialog::Accepted) {
         if (d.newMarker().time() == position) {
             // marker position was not changed, only text
@@ -2140,7 +2174,7 @@ bool CustomTrackView::addGuide(const GenTime pos, const QString &comment) {
 
 void CustomTrackView::slotAddGuide() {
     CommentedTime marker(GenTime(m_cursorPos, m_document->fps()), i18n("Guide"));
-    MarkerDialog d(NULL, marker, m_document->timecode(), this);
+    MarkerDialog d(NULL, marker, m_document->timecode(), i18n("Add Guide"), this);
     if (d.exec() != QDialog::Accepted) return;
     if (addGuide(d.newMarker().time(), d.newMarker().comment())) {
         EditGuideCommand *command = new EditGuideCommand(this, GenTime(), QString(), d.newMarker().time(), d.newMarker().comment(), false);
@@ -2162,7 +2196,7 @@ void CustomTrackView::slotEditGuide() {
 }
 
 void CustomTrackView::slotEditGuide(CommentedTime guide) {
-    MarkerDialog d(NULL, guide, m_document->timecode(), this);
+    MarkerDialog d(NULL, guide, m_document->timecode(), i18n("Edit Guide"), this);
     if (d.exec() == QDialog::Accepted) {
         EditGuideCommand *command = new EditGuideCommand(this, guide.time(), guide.comment(), d.newMarker().time(), d.newMarker().comment(), true);
         m_commandStack->push(command);
index 30d09246e6ebc36b299922a1422cabc76e0dc160..79a0510b0d7b36151ccafe423bdfcd3a942bcf30 100644 (file)
@@ -98,6 +98,8 @@ public:
     void setDocumentModified();
     void setInPoint();
     void setOutPoint();
+    void slotInsertSpace();
+    void insertSpace(const GenTime &pos, int track, const GenTime duration, bool add);
 
 public slots:
     void setCursorPos(int pos, bool seek = true);
diff --git a/src/insertspacecommand.cpp b/src/insertspacecommand.cpp
new file mode 100644 (file)
index 0000000..5d43b12
--- /dev/null
@@ -0,0 +1,41 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+#include <KLocale>
+
+#include "insertspacecommand.h"
+#include "customtrackview.h"
+
+InsertSpaceCommand::InsertSpaceCommand(CustomTrackView *view, const GenTime &pos, int track, const GenTime &duration, bool doIt, QUndoCommand * parent) : QUndoCommand(parent), m_view(view), m_pos(pos), m_track(track), m_duration(duration), m_doIt(doIt) {
+    setText(i18n("Insert space"));
+}
+
+// virtual
+void InsertSpaceCommand::undo() {
+    // kDebug()<<"----  undoing action";
+    m_view->insertSpace(m_pos, m_track, m_duration, false);
+}
+// virtual
+void InsertSpaceCommand::redo() {
+    // kDebug() << "----  redoing action cut: " << m_cutTime.frames(25);
+    if (m_doIt)
+        m_view->insertSpace(m_pos, m_track, m_duration, true);
+    m_doIt = true;
+}
+
diff --git a/src/insertspacecommand.h b/src/insertspacecommand.h
new file mode 100644 (file)
index 0000000..42a9ba6
--- /dev/null
@@ -0,0 +1,47 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+
+#ifndef INSERTSPACECOMMAND_H
+#define INSERTSPACECOMMAND_H
+
+#include <QUndoCommand>
+#include <QGraphicsView>
+
+#include <KDebug>
+#include "definitions.h"
+
+class CustomTrackView;
+
+class InsertSpaceCommand : public QUndoCommand {
+public:
+    InsertSpaceCommand(CustomTrackView *view, const GenTime &pos, int track, const GenTime &duration, bool doIt, QUndoCommand * parent = 0);
+    virtual void undo();
+    virtual void redo();
+
+private:
+    CustomTrackView *m_view;
+    GenTime m_pos;
+    GenTime m_duration;
+    int m_track;
+    bool m_doIt;
+};
+
+#endif
+
index 5db17ae5b6960ea7b916ab15d06e3ab64233ac21..4cb9365cc3b616dc78f31ee49e54fedc45a9096e 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<gui name="kdenlive" version="23">
+<gui name="kdenlive" version="24">
   <ToolBar name="extraToolBar" >
     <text>Extra Toolbar</text>
        <Action name="project_render" />
@@ -39,6 +39,7 @@
                <Action name="delete_guide" />
                <Action name="delete_all_guides" />
       </Menu>
+      <Action name="insert_space" />
       <Separator />
       <Menu name="video_effects_menu" ><text>Add Video Effect</text>
       </Menu>
index 1d1e01d8431bbc058cfdf784fa1924ba4bd142d4..1e0e7db13054f7d8244de24ce137f12a4f7c5f52 100644 (file)
@@ -298,6 +298,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(KStandardAction::name(KStandardAction::Paste)));
 
     m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
@@ -782,6 +783,10 @@ void MainWindow::setupActions() {
     collection->addAction("edit_clip_marker", editClipMarker);
     connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
 
+    KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
+    collection->addAction("insert_space", insertSpace);
+    connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
+
     KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
     collection->addAction("add_guide", addGuide);
     connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
@@ -1482,6 +1487,11 @@ void MainWindow::slotAddGuide() {
         m_activeTimeline->projectView()->slotAddGuide();
 }
 
+void MainWindow::slotInsertSpace() {
+    if (m_activeTimeline)
+        m_activeTimeline->projectView()->slotInsertSpace();
+}
+
 void MainWindow::slotEditGuide() {
     if (m_activeTimeline)
         m_activeTimeline->projectView()->slotEditGuide();
index c320d4b66d6ca99cca535c719e8d2c2e424f73ed..2dd854c8b0368d2f67d5283d89706aa23d2bd110 100644 (file)
@@ -244,6 +244,7 @@ private slots:
     void findTimeout();
     void slotFindNext();
 
+    void slotInsertSpace();
     void slotAddGuide();
     void slotEditGuide();
     void slotDeleteGuide();
index de34f80c55e8279d5cd3fc3e9839d83265d7f9ae..a26b33791ca71db294ab6ef8198fa844ff3655f1 100644 (file)
 #include "kthumb.h"
 #include "kdenlivesettings.h"
 
-MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, QWidget * parent): QDialog(parent), m_tc(tc), m_clip(clip), m_marker(t), m_producer(NULL), m_profile(NULL) {
+MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, const QString &caption, QWidget * parent): QDialog(parent), m_tc(tc), m_clip(clip), m_marker(t), m_producer(NULL), m_profile(NULL) {
     setFont(KGlobalSettings::toolBarFont());
     m_fps = m_tc.fps();
     m_view.setupUi(this);
-
+    setWindowTitle(caption);
     m_previewTimer = new QTimer(this);
 
     if (m_clip != NULL) {
@@ -74,13 +74,14 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, QWid
     } else m_view.clip_thumb->setHidden(true);
 
     m_view.marker_position->setText(tc.getTimecode(t.time(), m_fps));
-    m_view.marker_comment->setText(t.comment());
-    connect(m_view.position_up, SIGNAL(clicked()), this, SLOT(slotTimeUp()));
-    connect(m_view.position_down, SIGNAL(clicked()), this, SLOT(slotTimeDown()));
 
+    m_view.marker_comment->setText(t.comment());
     m_view.marker_comment->selectAll();
     m_view.marker_comment->setFocus();
 
+    connect(m_view.position_up, SIGNAL(clicked()), this, SLOT(slotTimeUp()));
+    connect(m_view.position_down, SIGNAL(clicked()), this, SLOT(slotTimeDown()));
+
     adjustSize();
 }
 
index aa7bbfcf984cfdcd7f728129849d8b8852c15f2f..6a238c0d818e8bef94564ab0f5510cbe9e7daf47 100644 (file)
@@ -36,7 +36,7 @@ class MarkerDialog : public QDialog {
     Q_OBJECT
 
 public:
-    MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, QWidget * parent = 0);
+    MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, const QString &caption, QWidget * parent = 0);
     ~MarkerDialog();
     CommentedTime newMarker();
 
index 7e7b048b162df891a6b2eeab6fc4a06d8dfc88a8..384000b0b2fbf8a9becd25170b2415c38dee92f5 100644 (file)
@@ -125,6 +125,7 @@ void Render::buildConsumer() {
     m_mltConsumer->set("resize", 1);
     m_mltConsumer->set("window_id", m_winid);
     m_mltConsumer->set("terminate_on_pause", 1);
+    //m_mltConsumer->set("fullscreen", 1);
     m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
     m_mltConsumer->set("rescale", "nearest");
 
@@ -1444,6 +1445,48 @@ bool Render::mltRemoveClip(int track, GenTime position) {
     return true;
 }
 
+void Render::mltInsertSpace(const GenTime pos, int track, const GenTime duration, bool add) {
+    if (!m_mltProducer) {
+        kDebug() << "PLAYLIST NOT INITIALISED //////";
+        return;
+    }
+    Mlt::Producer parentProd(m_mltProducer->parent());
+    if (parentProd.get_producer() == NULL) {
+        kDebug() << "PLAYLIST BROKEN, CANNOT INSERT CLIP //////";
+        return;
+    }
+
+    Mlt::Service service(parentProd.get_service());
+    Mlt::Tractor tractor(service);
+    mlt_service_lock(service.get_service());
+
+    if (track != -1) {
+        // insert space in one track only
+        Mlt::Producer trackProducer(tractor.track(track));
+        Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
+        int clipIndex = trackPlaylist.get_clip_index_at(pos.frames(m_fps));
+        if (add) trackPlaylist.insert_blank(clipIndex,  duration.frames(m_fps) - 1);
+        else {
+            int position = trackPlaylist.clip_start(clipIndex);
+            trackPlaylist.remove_region(position, duration.frames(m_fps) - 1);
+        }
+    } else {
+        int trackNb = tractor.count();
+        while (trackNb > 1) {
+            Mlt::Producer trackProducer(tractor.track(trackNb - 1));
+            Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
+            int clipIndex = trackPlaylist.get_clip_index_at(pos.frames(m_fps));
+            if (add) trackPlaylist.insert_blank(clipIndex,  duration.frames(m_fps) - 1);
+            else {
+                int position = trackPlaylist.clip_start(clipIndex);
+                trackPlaylist.remove_region(position, duration.frames(m_fps) - 1);
+            }
+            trackNb--;
+        }
+    }
+    mlt_service_unlock(service.get_service());
+}
+
 int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, Mlt::Producer *prod) {
     m_isBlocked = true;
     int newLength = 0;
index 7e0b0ac2f56f39286d480fe19b9ac494f1190b4c..d4b712af1358f068a806dd9e271cd10cf136b9db 100644 (file)
@@ -150,6 +150,7 @@ Q_OBJECT public:
     void mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
     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, bool add);
     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);
diff --git a/src/spacerdialog.cpp b/src/spacerdialog.cpp
new file mode 100644 (file)
index 0000000..756dd5e
--- /dev/null
@@ -0,0 +1,81 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+#include <QWheelEvent>
+#include <KDebug>
+
+#include "spacerdialog.h"
+#include "kthumb.h"
+#include "kdenlivesettings.h"
+
+SpacerDialog::SpacerDialog(const GenTime duration, Timecode tc, int track, int trackNumber, QWidget * parent): QDialog(parent), m_tc(tc) {
+    setFont(KGlobalSettings::toolBarFont());
+    m_fps = m_tc.fps();
+    m_view.setupUi(this);
+    m_view.space_duration->setText(tc.getTimecode(duration, m_fps));
+    QStringList tracks;
+    tracks << i18n("All tracks");
+    for (int i = 0; i < trackNumber - 1; i++) {
+        tracks << QString::number(i);
+    }
+    m_view.track_number->addItems(tracks);
+    m_view.track_number->setCurrentIndex(track);
+
+    connect(m_view.position_up, SIGNAL(clicked()), this, SLOT(slotTimeUp()));
+    connect(m_view.position_down, SIGNAL(clicked()), this, SLOT(slotTimeDown()));
+
+    adjustSize();
+}
+
+SpacerDialog::~SpacerDialog() {
+}
+
+void SpacerDialog::slotTimeUp() {
+    int duration = m_tc.getFrameCount(m_view.space_duration->text(), m_fps);
+    duration ++;
+    m_view.space_duration->setText(m_tc.getTimecode(GenTime(duration, m_fps), m_fps));
+}
+
+void SpacerDialog::slotTimeDown() {
+    int duration = m_tc.getFrameCount(m_view.space_duration->text(), m_fps);
+    if (duration <= 0) return;
+    duration --;
+    m_view.space_duration->setText(m_tc.getTimecode(GenTime(duration, m_fps), m_fps));
+}
+
+GenTime SpacerDialog::selectedDuration() {
+    return GenTime(m_tc.getFrameCount(m_view.space_duration->text(), m_fps), m_fps);
+}
+
+void SpacerDialog::wheelEvent(QWheelEvent * event) {
+    if (m_view.space_duration->underMouse()) {
+        if (event->delta() > 0)
+            slotTimeUp();
+        else
+            slotTimeDown();
+    }
+}
+
+int SpacerDialog::selectedTrack() {
+    return m_view.track_number->currentIndex() - 1;
+}
+
+#include "spacerdialog.moc"
+
+
diff --git a/src/spacerdialog.h b/src/spacerdialog.h
new file mode 100644 (file)
index 0000000..e474a3b
--- /dev/null
@@ -0,0 +1,54 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+
+#ifndef SPACERDIALOG_H
+#define SPACERDIALOG_H
+
+#include <QDialog>
+
+#include "timecode.h"
+#include "ui_spacerdialog_ui.h"
+
+class SpacerDialog : public QDialog {
+    Q_OBJECT
+
+public:
+    SpacerDialog(const GenTime duration, Timecode tc, int track, int trackNumber, QWidget * parent = 0);
+    ~SpacerDialog();
+    GenTime selectedDuration();
+    int selectedTrack();
+
+private slots:
+    void slotTimeUp();
+    void slotTimeDown();
+
+protected:
+    void wheelEvent(QWheelEvent * event);
+
+private:
+    Ui::SpacerDialog_UI m_view;
+    Timecode m_tc;
+    double m_fps;
+
+};
+
+
+#endif
+
diff --git a/src/widgets/spacerdialog_ui.ui b/src/widgets/spacerdialog_ui.ui
new file mode 100644 (file)
index 0000000..39cb3c2
--- /dev/null
@@ -0,0 +1,135 @@
+<ui version="4.0" >
+ <class>SpacerDialog_UI</class>
+ <widget class="QDialog" name="SpacerDialog_UI" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>331</width>
+    <height>111</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Add space</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout" >
+   <item row="0" column="3" >
+    <layout class="QHBoxLayout" name="horizontalLayout" >
+     <item>
+      <widget class="KRestrictedLine" name="space_duration" >
+       <property name="inputMask" >
+        <string>99:99:99:99; </string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout" >
+       <item>
+        <widget class="KArrowButton" name="position_up" />
+       </item>
+       <item>
+        <widget class="KArrowButton" name="position_down" >
+         <property name="arrowType" stdset="0" >
+          <number>2</number>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item row="3" column="0" colspan="4" >
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons" >
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1" >
+    <widget class="QLabel" name="clip_filesize_3" >
+     <property name="text" >
+      <string>Track</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1" colspan="3" >
+    <spacer name="verticalSpacer" >
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0" >
+      <size>
+       <width>218</width>
+       <height>2</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="0" column="1" >
+    <widget class="QLabel" name="clip_filesize_2" >
+     <property name="text" >
+      <string>Duration</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="2" colspan="2" >
+    <widget class="KComboBox" name="track_number" />
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KArrowButton</class>
+   <extends>QPushButton</extends>
+   <header>karrowbutton.h</header>
+  </customwidget>
+  <customwidget>
+   <class>KComboBox</class>
+   <extends>QComboBox</extends>
+   <header>kcombobox.h</header>
+  </customwidget>
+  <customwidget>
+   <class>KRestrictedLine</class>
+   <extends>KLineEdit</extends>
+   <header>krestrictedline.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>SpacerDialog_UI</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>SpacerDialog_UI</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>