]> git.sesse.net Git - kdenlive/commitdiff
Add go to marker in timeline clip context menu:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 3 Feb 2010 19:02:53 +0000 (19:02 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 3 Feb 2010 19:02:53 +0000 (19:02 +0000)
http://kdenlive.org/mantis/view.php?id=1416

svn path=/trunk/kdenlive/; revision=4283

src/customtrackview.cpp
src/customtrackview.h
src/mainwindow.cpp

index f6ea43dba3606155a3e6bc9fc66a664e81cd75c6..da1aa4801d79e3489c0fbb93f3ef1c59d50b9773 100644 (file)
@@ -194,11 +194,16 @@ void CustomTrackView::setDocumentModified()
     m_document->setModified(true);
 }
 
-void CustomTrackView::setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup)
+void CustomTrackView::setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup, QMenu *markermenu)
 {
     m_timelineContextMenu = timeline;
     m_timelineContextClipMenu = clip;
     m_clipTypeGroup = clipTypeGroup;
+
+    m_markerMenu = new QMenu(i18n("Go to marker..."), this);
+    m_markerMenu->setEnabled(false);
+    markermenu->addMenu(m_markerMenu);
+    connect(m_markerMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotGoToMarker(QAction *)));
     QList <QAction *> list = m_timelineContextClipMenu->actions();
     for (int i = 0; i < list.count(); i++) {
         if (list.at(i)->data().toString() == "paste_effects") m_pasteEffectsAction = list.at(i);
@@ -1283,8 +1288,10 @@ void CustomTrackView::displayContextMenu(QPoint pos, AbstractClipItem *clip, Abs
 {
     m_deleteGuide->setEnabled(m_dragGuide != NULL);
     m_editGuide->setEnabled(m_dragGuide != NULL);
-    if (clip == NULL) m_timelineContextMenu->popup(pos);
-    else if (group != NULL) {
+    if (clip == NULL) {
+        m_timelineContextMenu->popup(pos);
+        m_markerMenu->setEnabled(false);
+    } else if (group != NULL) {
         m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
         m_ungroupAction->setEnabled(true);
         updateClipTypeActions(NULL);
@@ -1296,7 +1303,9 @@ void CustomTrackView::displayContextMenu(QPoint pos, AbstractClipItem *clip, Abs
             updateClipTypeActions(item);
             m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
             m_timelineContextClipMenu->popup(pos);
-        } else if (clip->type() == TRANSITIONWIDGET) m_timelineContextTransitionMenu->popup(pos);
+        } else if (clip->type() == TRANSITIONWIDGET) {
+            m_timelineContextTransitionMenu->popup(pos);
+        }
     }
 }
 
@@ -4762,14 +4771,14 @@ void CustomTrackView::pasteClipEffects()
 
     // expand groups
     for (int i = 0; i < clips.count(); ++i) {
-       if (clips.at(i)->type() == GROUPWIDGET) {
-           QList<QGraphicsItem *> children = clips.at(i)->childItems();
-           for (int j = 0; j < children.count(); j++) {
-               if (children.at(j)->type() == AVWIDGET && !clips.contains(children.at(j))) {
-                   clips.append(children.at(j));
-               }
-           }
-       }
+        if (clips.at(i)->type() == GROUPWIDGET) {
+            QList<QGraphicsItem *> children = clips.at(i)->childItems();
+            for (int j = 0; j < children.count(); j++) {
+                if (children.at(j)->type() == AVWIDGET && !clips.contains(children.at(j))) {
+                    clips.append(children.at(j));
+                }
+            }
+        }
     }
 
 
@@ -4790,10 +4799,10 @@ void CustomTrackView::pasteClipEffects()
 
     // adjust effects (fades, ...)
     for (int i = 0; i < clips.count(); ++i) {
-       if (clips.at(i)->type() == AVWIDGET) {
-           ClipItem *item = static_cast < ClipItem *>(clips.at(i));
-           updatePositionEffects(item, item->info());
-       }
+        if (clips.at(i)->type() == AVWIDGET) {
+            ClipItem *item = static_cast < ClipItem *>(clips.at(i));
+            updatePositionEffects(item, item->info());
+        }
     }
 }
 
@@ -5474,6 +5483,29 @@ void CustomTrackView::updateClipTypeActions(ClipItem *clip)
             }
         }
     }
+    if (clip == NULL) {
+        m_markerMenu->clear();
+        m_markerMenu->setEnabled(false);
+    } else {
+        m_markerMenu->clear();
+        QList <CommentedTime> markers = clip->baseClip()->commentedSnapMarkers();
+        int offset = clip->startPos().frames(m_document->fps());
+        if (!markers.isEmpty()) {
+            for (int i = 0; i < markers.count(); i++) {
+                int pos = (int) markers.at(i).time().frames(m_document->timecode().fps());
+                QString position = m_document->timecode().getTimecode(markers.at(i).time()) + ' ' + markers.at(i).comment();
+                QAction *go = m_markerMenu->addAction(position);
+                go->setData(pos + offset);
+            }
+        }
+        m_markerMenu->setEnabled(!m_markerMenu->isEmpty());
+    }
+}
+
+void CustomTrackView::slotGoToMarker(QAction *action)
+{
+    int pos = action->data().toInt();
+    setCursorPos(pos, true);
 }
 
 void CustomTrackView::reloadTransitionLumas()
index 1c3e33a91a9e27e318b146b0ee2bae49bd5e755a..8b1982a244ccdaf2d289bad95ad1cbdb364bb7ed 100644 (file)
@@ -80,7 +80,7 @@ public:
     int duration() const;
     void deleteSelectedClips();
     void cutSelectedClips();
-    void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup);
+    void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup, QMenu *markermenu);
     void checkTrackHeight();
     //QList <TrackInfo> tracksList() const;
     void setTool(PROJECTTOOL tool);
@@ -221,6 +221,7 @@ private:
     QMenu *m_timelineContextMenu;
     QMenu *m_timelineContextClipMenu;
     QMenu *m_timelineContextTransitionMenu;
+    QMenu *m_markerMenu;
     QAction *m_autoTransition;
     QAction *m_pasteEffectsAction;
     QAction *m_ungroupAction;
@@ -281,6 +282,7 @@ private slots:
     void slotDeleteTimeLineGuide();
     void slotFetchNextThumbs();
     void checkTrackSequence(int track);
+    void slotGoToMarker(QAction *action);
 
 signals:
     void cursorMoved(int, int);
index 0ca4c23cc2adfa119e90ddc48ce5553c4e14ca55..9be3cb3f6b8342a02b33598802bcfd901b6d781a 100644 (file)
@@ -2045,7 +2045,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
 
 
-    trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
+    trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
     m_activeTimeline = trackView;
     if (m_renderWidget) {
         m_renderWidget->setProfile(doc->mltProfile());