Commit 3db37117 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix "go to previous keyframe" not going to clip start if no keyframe at start

Disable next / previous keyframe buttons when irrelevant
Always focus project monitor when clicking in timeline
parent d5fcba99
......@@ -93,7 +93,7 @@ AnimationWidget::AnimationWidget(EffectMetaInfo *info, int clipPos, int min, int
connect(m_timePos, SIGNAL(timeCodeEditingFinished()), this, SLOT(slotPositionChanged()));
// seek to previous
tb->addAction(KoIconUtils::themedIcon(QStringLiteral("media-skip-backward")), i18n("Previous keyframe"), this, SLOT(slotPrevious()));
m_previous = tb->addAction(KoIconUtils::themedIcon(QStringLiteral("media-skip-backward")), i18n("Previous keyframe"), this, SLOT(slotPrevious()));
// Add/remove keyframe
m_addKeyframe = new KDualAction(i18n("Add keyframe"), i18n("Remove keyframe"), this);
......@@ -102,8 +102,8 @@ AnimationWidget::AnimationWidget(EffectMetaInfo *info, int clipPos, int min, int
connect(m_addKeyframe, SIGNAL(activeChangedByUser(bool)), this, SLOT(slotAddDeleteKeyframe(bool)));
tb->addAction(m_addKeyframe);
// seek to previous
tb->addAction(KoIconUtils::themedIcon(QStringLiteral("media-skip-forward")), i18n("Next keyframe"), this, SLOT(slotNext()));
// seek to next
m_next = tb->addAction(KoIconUtils::themedIcon(QStringLiteral("media-skip-forward")), i18n("Next keyframe"), this, SLOT(slotNext()));
// Preset combo
m_presetCombo = new QComboBox(this);
......@@ -262,6 +262,10 @@ void AnimationWidget::updateTimecodeFormat()
void AnimationWidget::slotPrevious()
{
int previous = qMax(-m_offset, m_animController.previous_key(m_timePos->getValue() - m_offset - 1)) + m_offset;
if (previous == m_timePos->getValue() && previous > 0) {
// Make sure we can seek to effect start even if there is no keyframe
previous = 0;
}
m_ruler->setActiveKeyframe(previous);
slotPositionChanged(previous, true);
}
......@@ -494,6 +498,8 @@ void AnimationWidget::slotPositionChanged(int pos, bool seek)
updateRect(pos - m_offset);
}
updateSlider(pos - m_offset);
m_previous->setEnabled(pos > 0);
m_next->setEnabled(pos < (m_outPoint - m_inPoint - 1));
if (seek)
emit seekToPos(pos);
}
......
......@@ -70,6 +70,8 @@ private:
TimecodeDisplay *m_timePos;
KDualAction* m_addKeyframe;
QComboBox *m_presetCombo;
QAction *m_previous;
QAction *m_next;
/** @brief True if effect is currently selected in stack */
bool m_active;
int m_clipPos;
......
......@@ -1966,7 +1966,7 @@ void MainWindow::connectDocument()
connect(m_effectStack->transitionConfig(), SIGNAL(transitionUpdated(Transition*,QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition*,QDomElement)));
connect(m_effectStack->transitionConfig(), SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(seekCursorPos(int)));
connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()), Qt::DirectConnection);
connect(project, &KdenliveDoc::updateFps, trackView, &Timeline::updateProfile, Qt::DirectConnection);
connect(trackView, SIGNAL(zoneMoved(int,int)), this, SLOT(slotZoneMoved(int,int)));
trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu*>(factory()->container(QStringLiteral("marker_menu"), this)));
......
......@@ -801,6 +801,7 @@ void CustomTrackView::updateTimelineSelection()
// virtual
void CustomTrackView::mousePressEvent(QMouseEvent * event)
{
emit activateDocumentMonitor();
setFocus(Qt::MouseFocusReason);
m_menuPosition = QPoint();
if (m_moveOpMode == MoveOperation) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment