]> git.sesse.net Git - kdenlive/commitdiff
move playhead to mouse curser position if p key is pressed
authorEd Rogalsky <ed.rogalsky@googlemail.com>
Sun, 21 Oct 2012 19:09:21 +0000 (21:09 +0200)
committerEd Rogalsky <ed.rogalsky@googlemail.com>
Sun, 21 Oct 2012 19:09:21 +0000 (21:09 +0200)
when dealing with multitracks and different tools it is handy beeing
able to align the playhead to mouse position by pressing a key.

hopefully now all kde scm/qm rules are satisfied for pushing

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

index a0833a0d00710c94f32faf2b8f228cd104ce6fc5..cf3e3a135218eb9c111263ebd00ecd9cf167d177 100644 (file)
@@ -404,6 +404,15 @@ void CustomTrackView::slotCheckPositionScrolling()
     }
 }
 
+void CustomTrackView::slotOnPlayheadKeyPressed()
+{
+       /* get curser point ref in screen coord */
+       QPoint ps = QCursor::pos();
+       /* get xPos in scene coord */
+       int mappedXPos = qMax((int)(mapToScene(mapFromGlobal(ps)).x() + 0.5), 0);
+       /* move playhead to new xPos*/
+       seekCursorPos(mappedXPos);
+}
 
 // virtual
 void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
index 74f9b9e3349ffabcc59f3fc281e109007daa355d..328dcc43ac8425884ac8c6d2eb5285e9b78de8fa 100644 (file)
@@ -304,6 +304,8 @@ public slots:
 
     /** @brief Get effect parameters ready for MLT*/
     static void adjustEffectParameters(EffectsParameterList &parameters, QDomNodeList params, MltVideoProfile profile, const QString &prefix = QString());
+       /** @brief Move playhead to mouse curser position if p key is pressed */
+    void slotOnPlayheadKeyPressed();
 
 protected:
     virtual void drawBackground(QPainter * painter, const QRectF & rect);
index 31d181f574f657b5509222c9b5bfdc26345af20f..347a84581da29b0f4ec15263780972a27423855d 100644 (file)
@@ -1402,6 +1402,11 @@ void MainWindow::setupActions()
     collection.addAction("delete_timeline_clip", deleteItem);
     connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
 
+    KAction* movePlayhead = new KAction(i18n("Move Playhead"), this);
+    movePlayhead->setShortcut(Qt::Key_P);
+    collection.addAction("move_playhead", movePlayhead);
+    connect(movePlayhead, SIGNAL(triggered(bool)), this, SLOT(slotOnPlayheadKeyPressed()));
+
     /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
     collection.addAction("change_clip_speed", editTimelineClipSpeed);
     editTimelineClipSpeed->setData("change_speed");
@@ -4579,6 +4584,10 @@ void MainWindow::slotProcessImportKeyframes(GRAPHICSRECTITEM type, const QString
     }
 }
 
+void MainWindow::slotOnPlayheadKeyPressed()
+{
+       m_activeTimeline->projectView()->slotOnPlayheadKeyPressed();
+}
 
 #include "mainwindow.moc"
 
index 4833d77b85657129fd46b99aeec88e3fe5591cf7..3e8445f196346904c26c9c4f52ff0649a609a1f4 100644 (file)
@@ -568,6 +568,8 @@ private slots:
     void slotSaveTimelineClip();
     /** @brief Process keyframe data sent from a clip to effect / transition stack. */
     void slotProcessImportKeyframes(GRAPHICSRECTITEM type, const QString& data);
+    /** @brief Move playhead to mouse curser position if p key is pressed */
+    void slotOnPlayheadKeyPressed();
 
 signals:
     Q_SCRIPTABLE void abortRenderJob(const QString &url);