[Kdenlive-devel] patch, Add "play clip" action

espinosa_cz espinosa_cz at centrum.cz
Fri Jul 6 13:34:05 UTC 2007


Whooohoo, my first patch!
- Add "play clip" action (context menu, project menu) for any clip in
project tree
- print some debug info, what is played and the length (to track other
similar issues)
- update status line with current clip name
- improve documentation (in Doxygen style)

Bugfixing:
http://www.kdenlive.org/bbforum/viewtopic.php?f=16&t=71

I'm puzzled by the indentation in  kdenlive source. It a mess of tabs
and spaces.
Also the state of documentation is pitiful :(

P.S.
this is my first ever patch to C/C++ application. I'm no C/C++ expert,
I'm a Java developer by profession, so have a considerations..

Espinosa

Index: /home/espinosa/src/kdenlive/kdenlive/kdenlive.cpp
===================================================================
--- /home/espinosa/src/kdenlive/kdenlive/kdenlive.cpp    (revision 1627)
+++ /home/espinosa/src/kdenlive/kdenlive/kdenlive.cpp    (working copy)
@@ -985,6 +985,14 @@
         SLOT(slotProjectEditClip()), actionCollection(),
         "edit_clip");
     editClip->setToolTip(i18n("Edit Clip Properties"));
+
+    // Add support for playing selected clip from project list, the
action is added
+    // to various menus in rc files using 'play_clip' reference
+    // Espinosa
+        KAction *playClip = new KAction(i18n("Play Clip"), 0, this,
+        SLOT(slotPlayClip()), actionCollection(),
+        "play_clip");
+    playClip->setToolTip(i18n("Play Clip In Clip Monitor"));
         
         KAction *editParentClip = new KAction(i18n("Clip Properties"),
0, this,
         SLOT(slotProjectEditParentClip()), actionCollection(),
@@ -3244,6 +3252,20 @@
     slotStatusMsg(i18n("Ready."));
     }
 
+    /**
+     * Play selected clip, selected in project list.
+     * Usage: called from project list context menu, project menu, etc.
+     * Position is not defined, so it should start from beginning.
+     * This slot is part of global action collection list, callable
from many menus.
+     * 5.7.2007 - created - Espinosa
+     */
+    void KdenliveApp::slotPlayClip() {
+    slotStatusMsg(i18n("Play clip"));
+    DocClipRef *refClip = m_projectList->currentSelection().first();
+    slotStatusMsg(i18n("Play clip") + ": " + refClip->name());
+    slotSetClipMonitorSource(refClip);
+    }
+
     /* Edit existing clip */
     void KdenliveApp::slotProjectEditClip() {
     slotStatusMsg(i18n("Editing Clips"));
@@ -3741,23 +3763,39 @@
     addCommand(macroCommand, true);
     }
 
-/** Returns the render manager. */
+    /** Returns the render manager. */
     KRenderManager *KdenliveApp::renderManager() {
     return m_renderManager;
     }
 
-/** Sets the clip monitor source to be the given clip. */
+    /** Sets the clip monitor source to be the given clip, activates
clip monitor.
+     * However playback is not automatically started.
+     * Position is not defined, so it should start from beginning.
+     * Usage: called when user hits 'play clip' in menu or adds a new
clip to project
+     * 6.7.2007 - Espinosa - added some debug output to track a
possible bug
+     */
     void KdenliveApp::slotSetClipMonitorSource(DocClipRef * clip) {
-        if (clip) {
-       slotFocusClipMonitor();
-       m_clipMonitor->slotSetClip(clip);
-        }
-        else activateWorkspaceMonitor();
+    if (clip) {
+        kdDebug() << "slotSetClipMonitorSource " << clip->name()
+        << " duration:" << clip->duration().seconds() <<  "sec " << endl;
+        slotFocusClipMonitor();
+        m_clipMonitor->slotSetClip(clip);
+    }
+        else {
+        kdDebug() << "slotSetClipMonitorSource " << "[ none clip ]" <<
endl;
+        activateWorkspaceMonitor();
+    }
     }
     
-            /** Sets the clip monitor source to be the given clip. */
+    /** Sets the clip monitor source to be the given clip and set the
position.
+     * Activates clip monitor. However playback is not automatically
started.
+     * Usage: called when user doubleclicked on specified position on
the clip on timeline track
+     * 6.7.2007 - Espinosa - added some debug output to track a
possible bug
+     */
     void KdenliveApp::slotSetClipMonitorSourceAndSeek(DocClipRef * clip) {
         if (clip) {
+        kdDebug() << "slotSetClipMonitorSource " << clip->name()
+        << " duration:" << clip->duration().seconds() <<  "sec " << endl;
             GenTime value = getDocument()->renderer()->seekPosition();
             GenTime trackStart = clip->trackStart();
             GenTime trackEnd = clip->trackEnd();
@@ -3767,7 +3805,10 @@
                 m_clipMonitor->editPanel()->seek(clip->cropStartTime()
+ value - trackStart);
             }
         }
-        else activateWorkspaceMonitor();
+        else {
+        kdDebug() << "slotSetClipMonitorSourceAndSeek " << "[ none clip
]" << endl;
+        activateWorkspaceMonitor();
+    }
     }
 
     void KdenliveApp::loadLayout1() {
Index: /home/espinosa/src/kdenlive/kdenlive/kdenliveui.rc
===================================================================
--- /home/espinosa/src/kdenlive/kdenlive/kdenliveui.rc    (revision 1627)
+++ /home/espinosa/src/kdenlive/kdenlive/kdenliveui.rc    (working copy)
@@ -49,6 +49,7 @@
     <Action name="project_delete_clip"/>
     <Action name="project_clean"/>
         <Action name="edit_clip"/>
+    <Action name="play_clip"/>
     <Separator />
     <Action name="configure_project"/>
   </Menu>
@@ -170,6 +171,7 @@
     </Menu>
     <Action name="project_delete_clip"/>
         <Action name="edit_clip"/>
+    <Action name="play_clip"/>
     <Action name="project_extract_audio"/>
         <Separator />
         <Action name="project_clean"/>
@@ -187,6 +189,7 @@
     <Action name="project_duplicate_text_clip"/>
     <Action name="project_delete_clip"/>
         <Action name="edit_clip"/>
+    <Action name="play_clip"/>
         <Separator />
         <Action name="project_clean"/>
 </Menu>
@@ -203,6 +206,7 @@
     <Action name="show_virtual_zone"/>
     <Action name="project_delete_clip"/>
         <Action name="edit_clip"/>
+    <Action name="play_clip"/>
         <Separator />
         <Action name="project_clean"/>
 </Menu>
@@ -218,7 +222,9 @@
     </Menu>
     <Action name="external_audio"/>
     <Action name="project_delete_clip"/>
+    <Action name="play_clip"/>
         <Action name="edit_clip"/>
+    <Action name="play_clip"/>
         <Separator />
         <Action name="project_clean"/>
 </Menu>
Index: /home/espinosa/src/kdenlive/kdenlive/kdenlive.h
===================================================================
--- /home/espinosa/src/kdenlive/kdenlive/kdenlive.h    (revision 1627)
+++ /home/espinosa/src/kdenlive/kdenlive/kdenlive.h    (working copy)
@@ -294,6 +294,7 @@
     void slotProjectRenameFolder(QString message = QString());
     void slotProjectDeleteFolder();
 
+    void slotPlayClip();
     void slotProjectEditClip();
         void slotProjectEditParentClip();
     void slotSetClipDuration();





More information about the Kdenlive mailing list