]> git.sesse.net Git - kdenlive/commitdiff
Make it possible to add a marker or guide quickly during playback by not showing...
authorTill Theato <root@ttill.de>
Fri, 1 Oct 2010 22:09:11 +0000 (22:09 +0000)
committerTill Theato <root@ttill.de>
Fri, 1 Oct 2010 22:09:11 +0000 (22:09 +0000)
svn path=/trunk/kdenlive/; revision=4961

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

index 05850070339ad26c1c115499828ae12b59e1c798..01038de29843ffa8b9586ed2c16c7a0a0394b939 100644 (file)
@@ -4936,13 +4936,18 @@ bool CustomTrackView::addGuide(const GenTime pos, const QString &comment)
     return true;
 }
 
-void CustomTrackView::slotAddGuide()
+void CustomTrackView::slotAddGuide(bool dialog)
 {
     CommentedTime marker(GenTime(m_cursorPos, m_document->fps()), i18n("Guide"));
-    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);
+    if (dialog) {
+        MarkerDialog d(NULL, marker, m_document->timecode(), i18n("Add Guide"), this);
+        if (d.exec() != QDialog::Accepted) return;
+        marker.setComment(d.newMarker().comment());
+    } else {
+        marker.setComment(m_document->timecode().getDisplayTimecodeFromFrames(m_cursorPos, false));
+    }
+    if (addGuide(marker.time(), marker.comment())) {
+        EditGuideCommand *command = new EditGuideCommand(this, GenTime(), QString(), marker.time(), marker.comment(), false);
         m_commandStack->push(command);
     }
 }
index 2287ea739533ffcfb64f08f55a6fd6c5a4f6b485..afa0b44912c8de691c94dcca7a81cc23347da628 100644 (file)
@@ -204,9 +204,17 @@ public slots:
     void slotSwitchTrackVideo(int ix);
     void slotSwitchTrackLock(int ix);
     void slotUpdateClip(const QString &clipId, bool reload = true);
+
+    /** @brief Creates a AddClipCommand to add, edit or delete a marker.
+     * @param id Id of the marker's clip
+     * @param t Position of the marker
+     * @param c Comment of the marker */
     void slotAddClipMarker(const QString &id, GenTime t, QString c);
     bool addGuide(const GenTime pos, const QString &comment);
-    void slotAddGuide();
+
+    /** @brief Shows a dialog for adding a guide.
+     * @param dialog (default = true) false = do not show the dialog but use current position as position and comment */
+    void slotAddGuide(bool dialog = true);
     void slotEditGuide(CommentedTime guide);
     void slotEditGuide(int guidePos = -1);
     void slotDeleteGuide(int guidePos = -1);
index fb40138e4404b9f477300526e2abee83fcce5771..37e3a1216831f680c0a3d14040a36353e9ebd725 100644 (file)
@@ -1355,6 +1355,11 @@ void MainWindow::setupActions()
     collection->addAction("edit_clip_marker", editClipMarker);
     connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
 
+    KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
+    addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
+    collection->addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
+    connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
+
     KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
     collection->addAction("split_audio", splitAudio);
     connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
@@ -2689,6 +2694,26 @@ void MainWindow::slotEditClipMarker()
     }
 }
 
+void MainWindow::slotAddMarkerGuideQuickly()
+{
+    if (!m_activeTimeline || !m_activeDocument)
+        return;
+
+    if (m_clipMonitor->isActive()) {
+        DocClipBase *clip = m_clipMonitor->activeClip();
+        GenTime pos = m_clipMonitor->position();
+
+        if (!clip) {
+            m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
+            return;
+        }
+
+        m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
+    } else {
+        m_activeTimeline->projectView()->slotAddGuide(false);
+    }
+}
+
 void MainWindow::slotAddGuide()
 {
     if (m_activeTimeline)
index 723ca769c73c15ac172e212d8403ba82e1c995d1..0930166bf0fcd0a58fc8e5de9989d846529b165d 100644 (file)
@@ -369,6 +369,13 @@ private slots:
     void slotDeleteClipMarker();
     void slotDeleteAllClipMarkers();
     void slotEditClipMarker();
+
+    /** @brief Adds marker or auide at the current position without showing the marker dialog.
+     * 
+     * Adds a marker if clip monitor is active, otherwise a guide.
+     * The comment is set to the current position (therefore not dialog).
+     * This can be useful to mark something during playback. */
+    void slotAddMarkerGuideQuickly();
     void slotCutTimelineClip();
     void slotInsertClipOverwrite();
     void slotSelectTimelineClip();