]> git.sesse.net Git - kdenlive/commitdiff
Make project monitor usable
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 10 Feb 2008 11:45:30 +0000 (11:45 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 10 Feb 2008 11:45:30 +0000 (11:45 +0000)
svn path=/branches/KDE4/; revision=1830

src/customtrackview.cpp
src/customtrackview.h
src/kdenlivedoc.cpp
src/mainwindow.cpp
src/monitor.cpp
src/monitor.h
src/monitormanager.h
src/renderer.cpp
src/renderer.h
src/trackview.cpp
src/trackview.h

index 1207ee6110ea93750dedbbc3582df4ea199bd9e2..562a2ecc7bf95687e67dba5595dfb65964b1a7b0 100644 (file)
@@ -349,7 +349,7 @@ void CustomTrackView::dropEvent ( QDropEvent * event ) {
   if (m_dropItem) {
     AddTimelineClipCommand *command = new AddTimelineClipCommand(this, m_dropItem->xml(), m_dropItem->track(), m_dropItem->startPos(), m_dropItem->rect(), m_dropItem->duration(), false);
     m_commandStack->push(command);
-    m_document->renderer()->mltInsertClip(m_dropItem->track(), GenTime(m_dropItem->startPos(), 25), m_dropItem->xml());
+    m_document->renderer()->mltInsertClip(m_tracksCount - m_dropItem->track() + 1, GenTime(m_dropItem->startPos(), 25), m_dropItem->xml());
   }
   m_dropItem = NULL;
 }
@@ -392,12 +392,12 @@ void CustomTrackView::removeTrack ()
   m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), 50 * m_tracksCount);
 }
 
-void CustomTrackView::setCursorPos(int pos)
+void CustomTrackView::setCursorPos(int pos, bool seek)
 {
   m_cursorPos = pos;
   m_cursorLine->setPos(pos, 0);
   int frame = mapToScene(QPoint(pos, 0)).x() / m_scale;
-  m_document->renderer()->seek(GenTime(frame, 25));
+  if (seek) m_document->renderer()->seek(GenTime(frame, 25));
 }
 
 int CustomTrackView::cursorPos()
index 8bc238b371e9110c6eb3ba849b1222f7f8b8bc3f..897d0307c4dd8bfc6323d3a85309454a0a8601be 100644 (file)
@@ -51,7 +51,7 @@ class CustomTrackView : public QGraphicsView
     void setScale(double scaleFactor);
 
   public slots:
-    void setCursorPos(int pos);
+    void setCursorPos(int pos, bool seek = true);
 
   protected:
     virtual void drawBackground ( QPainter * painter, const QRectF & rect );
index 05844d167efbdf98c05eb260822f88812a33f633..edf64942df786d597af0d52a4aab294bbc643ca6 100644 (file)
@@ -65,7 +65,8 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, double fps, int width, int height, QWi
 
     QDomElement tractor = m_document.createElement("tractor");
     QDomElement multitrack = m_document.createElement("multitrack");
-
+    QDomElement playlist = m_document.createElement("playlist");
+    multitrack.appendChild(playlist);
     QDomElement playlist1 = m_document.createElement("playlist");
     playlist1.setAttribute("id", "playlist1");
     multitrack.appendChild(playlist1);
index 95f0d704814401ad954f58f46b7a50489330982e..8c19cb8a0f7e183516826bab800f656a654a6b33 100644 (file)
@@ -325,7 +325,9 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //chang
     m_activeDocument->setProducers(m_projectList->producersList());
     m_activeDocument->setRenderer(NULL);
   }
+  connect(trackView, SIGNAL(cursorMoved(int)), m_projectMonitor, SLOT(slotSeek(int)));
   connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
+  connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
   m_projectList->setDocument(doc);
   m_monitorManager->setTimecode(doc->timecode());
   doc->setRenderer(m_projectMonitor->render);
index 7d0a5938a1337cdee71bfc0e2094769e3a0c7a54..88f902d4616e83f2aacc495cfe222aecd2de6ed0 100644 (file)
@@ -55,6 +55,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
   connect(render, SIGNAL(playListDuration(int)), this, SLOT(adjustRulerSize(int)));
   connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
   connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int)));
+  if (name != "clip") connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int)));
   //render->createVideoXWindow(ui.video_frame->winId(), -1);
   int width = m_ruler->width();
   m_ruler->setLength(width);
index bf20b6643e384390c3abff8290acb167186e187b..d2694d6e29c0d632f5e5f9ae903ea7df797e8826 100644 (file)
@@ -59,7 +59,6 @@ class Monitor : public QWidget
     void adjustRulerSize(int length);
     void seekCursor(int pos);
     void rendererStopped(int pos);
-    void slotSeek(int pos);
     void slotRewindOneFrame();
     void slotForwardOneFrame();
     void slotForward();
@@ -70,8 +69,12 @@ class Monitor : public QWidget
     void slotSetXml(const QDomElement &e);
     void initMonitor();
     void refreshMonitor(bool visible);
+    void slotSeek(int pos);
     void stop();
     void start();
+
+  signals:
+    void renderPosition(int);
 };
 
 #endif
index f9b8d76d1d831fb51e8f8777bea262b3d8fefd9f..4ce7db23309a1da3a3c5cc5c7d69dbe32bd7c0b7 100644 (file)
@@ -32,12 +32,13 @@ class MonitorManager : public QObject
   
   public:
     MonitorManager(QWidget *parent=0);
-
     void initMonitors(Monitor *clipMonitor, Monitor *projectMonitor);
-    void activateMonitor(QString name);
     Timecode timecode();
     void setTimecode(Timecode tc);
 
+  public slots:
+    void activateMonitor(QString name = QString::null);
+
   private:
     Monitor *m_clipMonitor;
     Monitor *m_projectMonitor;
index aac9bad2b28acccc2f243d95791eb3abbcfddd8f..4627dff4d5f1ec10f75521221f3dcd42941200db 100644 (file)
@@ -965,7 +965,7 @@ void Render::mltCheckLength()
         Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
         duration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime() - 1;
        m_mltProducer->set("out", duration);
-       emit durationChanged();
+       emit playListDuration(duration);
        return;
     }
     while (trackNb > 1) {
@@ -1001,7 +1001,7 @@ void Render::mltCheckLength()
        mltInsertClip(0, GenTime(), black);
 
        m_mltProducer->set("out", duration);
-       emit durationChanged();
+       emit playListDuration(duration);
     }
 }
 
@@ -1023,7 +1023,7 @@ void Render::mltInsertClip(int track, GenTime position, QDomElement element)
     QDomDocument doc;
     doc.appendChild(doc.importNode(element, true));
     QString resource = doc.toString();
-    kDebug()<<"///////  ADDING CLIP TMLNE: "<<resource;
+    kDebug()<<"///////  ADDING CLIP TMLNE: "<<resource<<" ON TRACK: "<<track;
     Mlt::Producer trackProducer(tractor.track(track));
     Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
     char *tmp = decodedString(resource);
@@ -1036,7 +1036,7 @@ void Render::mltInsertClip(int track, GenTime position, QDomElement element)
     tractor.refresh();
     if (track != 0) mltCheckLength();
     double duration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime();
-    kDebug()<<"// +  +INSERTING CLIP: "<<resource<<" AT: "<<position.frames(m_fps)<<" on track: "<<track<<", DURATION: "<<duration;
+    //kDebug()<<"// +  +INSERTING CLIP: "<<resource<<" AT: "<<position.frames(m_fps)<<" on track: "<<track<<", DURATION: "<<duration;
 
 
 }
index fd4120083a5c810cf4074a23d5b2579d63ca1eb3..213aaf154a84442d9035503aa205beb76214653b 100644 (file)
@@ -237,7 +237,6 @@ class Render:public QObject {
 //    void positionChanged(const GenTime &);
        /** Emitted when an error occurs within this renderer. */
     void error(const QString &, const QString &);
-    void durationChanged();
     void playListDuration(int);
     void rendererPosition(int);
     void rendererStopped(int);
index 77b32b6a37060ca46ae1fca53a89d773fa47d3e7..7a727caf280b426003c0be088e761c4223a34f56 100644 (file)
@@ -122,12 +122,17 @@ void TrackView::parseDocument(QDomDocument doc)
 
 void TrackView::setCursorPos(int pos)
 {
+  emit cursorMoved(pos);
   m_trackview->setCursorPos(pos * m_scale);
 }
 
+void TrackView::moveCursorPos(int pos)
+{
+  m_trackview->setCursorPos(pos * m_scale, false);
+}
+
 void TrackView::slotCursorMoved(int pos, bool emitSignal)
 {
-  kDebug()<<"///// CURSOR: "<<pos;
   m_ruler->slotNewValue(pos * FRAME_SIZE / m_scale, emitSignal); //(int) m_trackview->mapToScene(QPoint(pos, 0)).x());
   //m_trackview->setCursorPos(pos);
   //m_trackview->invalidateScene(QRectF(), QGraphicsScene::ForegroundLayer);
index a13b92ee028a429f68338cda8c056e9953e8b7be..8944bee4907634b2e7785f242ab4ad3229636786 100644 (file)
@@ -96,9 +96,11 @@ class TrackView : public QWidget
     void slotZoomIn();
     void slotZoomOut();
     void setCursorPos(int pos);
+    void moveCursorPos(int pos);
 
   signals:
     void mousePosition(int);
+    void cursorMoved(int);
 };
 
 #endif