From d4acad82cb756cafadc7a8461aab19ccec96168e Mon Sep 17 00:00:00 2001 From: Ed Rogalsky Date: Sun, 21 Oct 2012 21:09:21 +0200 Subject: [PATCH] move playhead to mouse curser position if p key is pressed 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 | 9 +++++++++ src/customtrackview.h | 2 ++ src/mainwindow.cpp | 9 +++++++++ src/mainwindow.h | 2 ++ 4 files changed, 22 insertions(+) diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index a0833a0d..cf3e3a13 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -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) diff --git a/src/customtrackview.h b/src/customtrackview.h index 74f9b9e3..328dcc43 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -304,6 +304,8 @@ public slots: /** @brief Get effect parameters ready for MLT*/ static void adjustEffectParameters(EffectsParameterList ¶meters, 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); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 31d181f5..347a8458 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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" diff --git a/src/mainwindow.h b/src/mainwindow.h index 4833d77b..3e8445f1 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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); -- 2.39.2