]> git.sesse.net Git - kdenlive/commitdiff
Make monitor zone functional
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 22 Sep 2008 21:23:02 +0000 (21:23 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 22 Sep 2008 21:23:02 +0000 (21:23 +0000)
svn path=/branches/KDE4/; revision=2404

icons/hisc-action-kdenlive-zone-end.svgz [new file with mode: 0644]
icons/hisc-action-kdenlive-zone-start.svgz [new file with mode: 0644]
src/customruler.cpp
src/customruler.h
src/mainwindow.cpp
src/monitor.cpp
src/monitor.h
src/smallruler.cpp
src/smallruler.h
src/trackview.cpp
src/trackview.h

diff --git a/icons/hisc-action-kdenlive-zone-end.svgz b/icons/hisc-action-kdenlive-zone-end.svgz
new file mode 100644 (file)
index 0000000..e1df97c
Binary files /dev/null and b/icons/hisc-action-kdenlive-zone-end.svgz differ
diff --git a/icons/hisc-action-kdenlive-zone-start.svgz b/icons/hisc-action-kdenlive-zone-start.svgz
new file mode 100644 (file)
index 0000000..24214cf
Binary files /dev/null and b/icons/hisc-action-kdenlive-zone-start.svgz differ
index dde85f1d4c317464f9afba005a3c6b8b4ba83d93..44563d23d697aff41d793041f837bc46ce8b82cb 100644 (file)
@@ -74,6 +74,12 @@ CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent)
     setMouseTracking(true);
 }
 
+void CustomRuler::setZone(QPoint p) {
+    m_zoneStart = p.x();
+    m_zoneEnd = p.y();
+    update();
+}
+
 // virtual
 void CustomRuler::mousePressEvent(QMouseEvent * event) {
     if (event->button() == Qt::RightButton) {
index edcf7b60713c7de756d6af80eb6cde7c0dd929af..5f75f3d14f076316ed9e18a4dc53c344e6cdbe2b 100644 (file)
@@ -18,6 +18,7 @@ public:
     int outPoint() const;
     int inPoint() const;
     void setDuration(int d);
+    void setZone(QPoint p);
 
 protected:
     virtual void paintEvent(QPaintEvent * /*e*/);
index 0fc4cbc7516b5f522f1f0752ee70961fd6ab4ed7..d042e2e2c6e184a4e4f879fb16ce0a8323d98d9c 100644 (file)
@@ -1093,6 +1093,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
         m_activeDocument->backupMltPlaylist();
         if (m_activeTimeline) {
             disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
+            disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
             disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
             disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
             disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
@@ -1136,6 +1137,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
     connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
     connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
+    connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
     connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
     connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
     connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
index 29116122a7766d0cd40ac65b7426d141adfc9eaf..78c0f5ad35aa7c6464747da16440258fbea67c86 100644 (file)
@@ -54,10 +54,11 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
     m_playIcon = KIcon("media-playback-start");
     m_pauseIcon = KIcon("media-playback-pause");
 
-    QAction *m_rewAction = toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind"));
-    connect(m_rewAction, SIGNAL(triggered()), this, SLOT(slotRewind()));
-    QAction *m_rew1Action = toolbar->addAction(KIcon("media-skip-backward"), i18n("Rewind 1 frame"));
-    connect(m_rew1Action, SIGNAL(triggered()), this, SLOT(slotRewindOneFrame()));
+    toolbar->addAction(KIcon("kdenlive-zone-start"), i18n("Set zone start"), this, SLOT(slotSetZoneStart()));
+    toolbar->addAction(KIcon("kdenlive-zone-end"), i18n("Set zone end"), this, SLOT(slotSetZoneEnd()));
+
+    toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind"), this, SLOT(slotRewind()));
+    toolbar->addAction(KIcon("media-skip-backward"), i18n("Rewind 1 frame"), this, SLOT(slotRewindOneFrame()));
 
     QToolButton *playButton = new QToolButton(toolbar);
     QMenu *playMenu = new QMenu(i18n("Play..."), this);
@@ -68,19 +69,14 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
     m_playAction = playMenu->addAction(m_playIcon, i18n("Play"));
     m_playAction->setCheckable(true);
     connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
-    QAction *m_playSectionAction = playMenu->addAction(m_playIcon, i18n("Play Section"));
-    connect(m_playSectionAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
-    QAction *m_loopSectionAction = playMenu->addAction(m_playIcon, i18n("Loop Section"));
-    connect(m_loopSectionAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
+    playMenu->addAction(m_playIcon, i18n("Play Section"), this, SLOT(slotPlay()));
+    playMenu->addAction(m_playIcon, i18n("Loop Section"), this, SLOT(slotPlay()));
 
-    QAction *m_fwd1Action = toolbar->addAction(KIcon("media-skip-forward"), i18n("Forward 1 frame"));
-    connect(m_fwd1Action, SIGNAL(triggered()), this, SLOT(slotForwardOneFrame()));
-    QAction *m_fwdAction = toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward"));
-    connect(m_fwdAction, SIGNAL(triggered()), this, SLOT(slotForward()));
+    toolbar->addAction(KIcon("media-skip-forward"), i18n("Forward 1 frame"), this, SLOT(slotForwardOneFrame()));
+    toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward"), this, SLOT(slotForward()));
 
     playButton->setDefaultAction(m_playAction);
 
-
     QToolButton *configButton = new QToolButton(toolbar);
     QMenu *configMenu = new QMenu(i18n("Misc..."), this);
     configButton->setIcon(KIcon("system-run"));
@@ -113,8 +109,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
 
     m_contextMenu = new QMenu(this);
     m_contextMenu->addMenu(playMenu);
-    QAction *extractFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Extract frame"));
-    connect(extractFrame, SIGNAL(triggered()), this, SLOT(slotExtractCurrentFrame()));
+    QAction *extractFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame()));
     connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int)));
     connect(render, SIGNAL(durationChanged(int)), this, SLOT(adjustRulerSize(int)));
     connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
@@ -124,20 +119,16 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
     if (name != "clip") {
         connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int)));
         connect(render, SIGNAL(durationChanged(int)), this, SIGNAL(durationChanged(int)));
-        QAction *splitView = m_contextMenu->addAction(KIcon("document-new"), i18n("Split view"));
+        QAction *splitView = m_contextMenu->addAction(KIcon("document-new"), i18n("Split view"), render, SLOT(slotSplitView(bool)));
         splitView->setCheckable(true);
-        connect(splitView, SIGNAL(toggled(bool)), render, SLOT(slotSplitView(bool)));
         configMenu->addAction(splitView);
     } else {
-        QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail"));
-        connect(setThumbFrame, SIGNAL(triggered()), this, SLOT(slotSetThumbFrame()));
+        QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail"), this, SLOT(slotSetThumbFrame()));
         configMenu->addAction(setThumbFrame);
     }
     configMenu->addSeparator();
-    QAction *resize1Action = configMenu->addAction(KIcon("transform-scale"), i18n("Resize (100%)"));
-    connect(resize1Action, SIGNAL(triggered()), this, SLOT(slotSetSizeOneToOne()));
-    QAction *resize2Action = configMenu->addAction(KIcon("transform-scale"), i18n("Resize (50%)"));
-    connect(resize2Action, SIGNAL(triggered()), this, SLOT(slotSetSizeOneToTwo()));
+    configMenu->addAction(KIcon("transform-scale"), i18n("Resize (100%)"), this, SLOT(slotSetSizeOneToOne()));
+    configMenu->addAction(KIcon("transform-scale"), i18n("Resize (50%)"), this, SLOT(slotSetSizeOneToTwo()));
     //render->createVideoXWindow(ui.video_frame->winId(), -1);
     m_length = 0;
     m_monitorRefresh->show();
@@ -194,6 +185,16 @@ void Monitor::slotZoneMoved(int start, int end) {
     m_ruler->setZone(start, end);
 }
 
+void Monitor::slotSetZoneStart() {
+    m_ruler->setZone(m_position, -1);
+    emit zoneUpdated(m_ruler->zone());
+}
+
+void Monitor::slotSetZoneEnd() {
+    m_ruler->setZone(-1, m_position);
+    emit zoneUpdated(m_ruler->zone());
+}
+
 // virtual
 void Monitor::mousePressEvent(QMouseEvent * event) {
     if (event->button() != Qt::RightButton) {
index b91d929a9650952d80599209cea0857307675c0e..09d34ccef35beb1f58e1dc65583bcd497af79215 100644 (file)
@@ -84,6 +84,8 @@ private slots:
     void slotSetThumbFrame();
     void slotSetSizeOneToOne();
     void slotSetSizeOneToTwo();
+    void slotSetZoneStart();
+    void slotSetZoneEnd();
 
 public slots:
     void slotOpenFile(const QString &);
@@ -109,6 +111,7 @@ signals:
     void durationChanged(int);
     void refreshClipThumbnail(const QString &);
     void adjustMonitorSize();
+    void zoneUpdated(QPoint);
 };
 
 #endif
index 2a41544c966e0b8ece69365bf18ef10ee1c133d9..7575927a012d07b803cdb96c3fc51dd793771ca0 100644 (file)
@@ -52,11 +52,23 @@ void SmallRuler::adjustScale(int maximum) {
 }
 
 void SmallRuler::setZone(int start, int end) {
-    m_zoneStart = start;
-    m_zoneEnd = end;
+    if (start != -1) {
+        if (end != -1 && start >= end) return;
+        else if (end == -1 && start >= m_zoneEnd) return;
+        m_zoneStart = start;
+    }
+    if (end != -1) {
+        if (start != -1 && end <= start) end = m_zoneEnd;
+        else if (start == -1 && end <= m_zoneStart) end = m_zoneEnd;
+        m_zoneEnd = end;
+    }
     update();
 }
 
+QPoint SmallRuler::zone() {
+    return QPoint(m_zoneStart, m_zoneEnd);
+}
+
 // virtual
 void SmallRuler::mousePressEvent(QMouseEvent * event) {
     const int pos = event->x() / m_scale;
index 7e0a907206fc2c7b229925ffe9c4ef006c2c774f..44cc42903dedfe6e16a70c9191ae72c8b67a6882 100644 (file)
@@ -32,6 +32,7 @@ public:
     virtual void mouseMoveEvent(QMouseEvent * event);
     void adjustScale(int maximum);
     void setZone(int start, int end);
+    QPoint zone();
 
 protected:
     virtual void paintEvent(QPaintEvent *e);
index 6611a1886bf1c3a84fa2f1216ab7c92b7e7af40b..741d712bb134d703bf3ab66d019a4477c35fa1aa 100644 (file)
@@ -104,6 +104,10 @@ int TrackView::outPoint() const {
     return m_ruler->outPoint();
 }
 
+void TrackView::slotSetZone(QPoint p) {
+    m_ruler->setZone(p);
+}
+
 void TrackView::slotClipItemSelected(ClipItem*c) {
     emit clipItemSelected(c);
 }
index 977461e8149ce8db888201e39dae8459617870b2..1981e73ee2d0ef3d8c6e161adc814afdc02231f3 100644 (file)
@@ -65,6 +65,7 @@ public slots:
     void slotDeleteClip(const QString &clipId);
     void slotChangeZoom(int factor);
     void setDuration(int dur);
+    void slotSetZone(QPoint p);
 
 private:
     Ui::TimeLine_UI *view;