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

Proper implementation of go to next/previous and add keyframe shortcuts

parent b4768f86
Pipeline #64848 passed with stage
in 8 minutes and 24 seconds
......@@ -485,3 +485,24 @@ void AssetPanel::assetPanelWarning(const QString service, const QString /*id*/,
m_infoMessage->setMessageType(KMessageWidget::Warning);
m_infoMessage->animatedShow();
}
void AssetPanel::slotAddRemoveKeyframe()
{
if (m_effectStackWidget->isVisible()) {
m_effectStackWidget->addRemoveKeyframe();
}
}
void AssetPanel::slotNextKeyframe()
{
if (m_effectStackWidget->isVisible()) {
m_effectStackWidget->slotGoToKeyframe(true);
}
}
void AssetPanel::slotPreviousKeyframe()
{
if (m_effectStackWidget->isVisible()) {
m_effectStackWidget->slotGoToKeyframe(false);
}
}
......@@ -83,6 +83,9 @@ public slots:
/** @brief Collapse/expand current effect */
void collapseCurrentEffect();
void slotCheckWheelEventFilter();
void slotAddRemoveKeyframe();
void slotNextKeyframe();
void slotPreviousKeyframe();
protected:
/** @brief Return the stylesheet used to display the panel (based on current palette). */
......
......@@ -121,6 +121,9 @@ void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &mo
m_lay->addWidget(w);
if (type == ParamType::KeyframeParam || type == ParamType::AnimatedRect || type == ParamType::Roto_spline) {
m_mainKeyframeWidget = static_cast<KeyframeWidget *>(w);
connect(this, &AssetParameterView::nextKeyframe, m_mainKeyframeWidget, &KeyframeWidget::goToNext);
connect(this, &AssetParameterView::previousKeyframe, m_mainKeyframeWidget, &KeyframeWidget::goToPrevious);
connect(this, &AssetParameterView::addRemoveKeyframe, m_mainKeyframeWidget, &KeyframeWidget::addRemove);
} else {
minHeight += w->minimumHeight();
}
......
......@@ -112,6 +112,9 @@ signals:
void updatePresets(const QString &presetName = QString());
void updateHeight();
void activateEffect();
void nextKeyframe();
void previousKeyframe();
void addRemoveKeyframe();
};
#endif
......@@ -69,19 +69,30 @@ KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QMode
m_keyframes = m_model->getKeyframeModel();
m_keyframeview = new KeyframeView(m_keyframes, duration, in, this);
// Prepare keyframe actions
KActionCategory *kfActions = new KActionCategory(i18n("Effect Keyframes"), pCore->window()->actionCollection());
m_buttonAddDelete = new QAction(QIcon::fromTheme(QStringLiteral("keyframe-add")), i18n("Add keyframe"), pCore->window()->actionCollection());
kfActions->addAction(QStringLiteral("keyframe_add_remove"), m_buttonAddDelete);
connect(m_buttonAddDelete, &QAction::triggered, m_keyframeview, &KeyframeView::slotAddRemove);
QAction *buttonPrevious = new QAction(QIcon::fromTheme(QStringLiteral("keyframe-previous")), i18n("Go to previous keyframe"), pCore->window()->actionCollection());
kfActions->addAction(QStringLiteral("keyframe_previous"), buttonPrevious);
connect(buttonPrevious, &QAction::triggered, m_keyframeview, &KeyframeView::slotGoToPrev);
QAction *buttonNext = new QAction(QIcon::fromTheme(QStringLiteral("keyframe-next")), i18n("Go to next keyframe"), pCore->window()->actionCollection());
kfActions->addAction(QStringLiteral("keyframe_next"), buttonNext);
connect(buttonNext, &QAction::triggered, m_keyframeview, &KeyframeView::slotGoToNext);
m_buttonAddDelete = new QToolButton(this);
m_buttonAddDelete->setAutoRaise(true);
connect(m_buttonAddDelete, &QAbstractButton::pressed, m_keyframeview, &KeyframeView::slotAddRemove);
connect(this, &KeyframeWidget::addRemove, m_keyframeview, &KeyframeView::slotAddRemove);
m_buttonAddDelete->setIcon(QIcon::fromTheme(QStringLiteral("keyframe-add")));
m_buttonAddDelete->setToolTip(i18n("Add keyframe"));
QToolButton *buttonPrevious = new QToolButton(this);
buttonPrevious->setAutoRaise(true);
buttonPrevious->setIcon(QIcon::fromTheme(QStringLiteral("keyframe-previous")));
buttonPrevious->setToolTip(i18n("Go to previous keyframe"));
connect(buttonPrevious, &QAbstractButton::pressed, m_keyframeview, &KeyframeView::slotGoToPrev);
connect(this, &KeyframeWidget::goToPrevious, m_keyframeview, &KeyframeView::slotGoToPrev);
QToolButton *buttonNext = new QToolButton(this);
buttonNext->setAutoRaise(true);
buttonNext->setIcon(QIcon::fromTheme(QStringLiteral("keyframe-next")));
buttonNext->setToolTip(i18n("Go to next keyframe"));
connect(buttonNext, &QAbstractButton::pressed, m_keyframeview, &KeyframeView::slotGoToNext);
connect(this, &KeyframeWidget::goToNext, m_keyframeview, &KeyframeView::slotGoToNext);
// Move keyframe to cursor
m_buttonCenter = new QToolButton(this);
......@@ -132,9 +143,9 @@ KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QMode
m_time->setRange(0, duration - 1);
m_time->setOffset(in);
m_toolbar->addAction(buttonPrevious);
m_toolbar->addAction(m_buttonAddDelete);
m_toolbar->addAction(buttonNext);
m_toolbar->addWidget(buttonPrevious);
m_toolbar->addWidget(m_buttonAddDelete);
m_toolbar->addWidget(buttonNext);
m_toolbar->addWidget(m_buttonCenter);
m_toolbar->addWidget(m_buttonCopy);
m_toolbar->addWidget(m_buttonApply);
......@@ -318,6 +329,7 @@ KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QMode
KeyframeWidget::~KeyframeWidget()
{
delete m_keyframeview;
delete m_buttonAddDelete;
delete m_time;
}
......
......@@ -89,7 +89,7 @@ private:
std::shared_ptr<KeyframeModelList> m_keyframes;
KeyframeView *m_keyframeview;
KeyframeMonitorHelper *m_monitorHelper;
QAction *m_buttonAddDelete;
QToolButton *m_buttonAddDelete;
QToolButton *m_buttonCenter;
QToolButton *m_buttonCopy;
QToolButton *m_buttonApply;
......@@ -106,6 +106,9 @@ signals:
void addIndex(QPersistentModelIndex ix);
void setKeyframes(const QString &);
void updateEffectKeyframe(bool);
void goToNext();
void goToPrevious();
void addRemove();
};
#endif
......@@ -938,3 +938,18 @@ void CollapsibleEffectView::updateEffectZone()
m_model->setInOut(effectName, inOut, true, true);
}
void CollapsibleEffectView::slotNextKeyframe()
{
m_view->nextKeyframe();
}
void CollapsibleEffectView::slotPreviousKeyframe()
{
m_view->previousKeyframe();
}
void CollapsibleEffectView::addRemoveKeyframe()
{
m_view->addRemoveKeyframe();
}
......@@ -86,6 +86,9 @@ public:
/** @brief Update monitor scene depending on effect enabled state. */
void updateScene();
void updateInOut(QPair<int, int> inOut, bool withUndo);
void slotNextKeyframe();
void slotPreviousKeyframe();
void addRemoveKeyframe();
public slots:
void slotSyncEffectsPos(int pos);
......
......@@ -521,3 +521,31 @@ void EffectStackView::switchBuiltStack(bool show)
KdenliveSettings::setShowbuiltstack(show);
}
*/
void EffectStackView::slotGoToKeyframe(bool next)
{
int max = m_model->rowCount();
int currentActive = m_model->getActiveEffect();
if (currentActive < max && currentActive > -1) {
auto item = m_model->getEffectStackRow(currentActive);
QModelIndex ix = m_model->getIndexFromItem(item);
auto *w = static_cast<CollapsibleEffectView *>(m_effectsTree->indexWidget(ix));
if (next) {
w->slotNextKeyframe();
} else {
w->slotPreviousKeyframe();
}
}
}
void EffectStackView::addRemoveKeyframe()
{
int max = m_model->rowCount();
int currentActive = m_model->getActiveEffect();
if (currentActive < max && currentActive > -1) {
auto item = m_model->getEffectStackRow(currentActive);
QModelIndex ix = m_model->getIndexFromItem(item);
auto *w = static_cast<CollapsibleEffectView *>(m_effectsTree->indexWidget(ix));
w->addRemoveKeyframe();
}
}
......@@ -73,9 +73,13 @@ public:
*/
void enableStack(bool enable);
bool isStackEnabled() const;
/** @brief Collaps / expand current effect
/** @brief Collapse / expand current effect
*/
void switchCollapsed();
/** @brief Go to next keyframe in current effect
*/
void slotGoToKeyframe(bool next);
void addRemoveKeyframe();
protected:
void dragEnterEvent(QDragEnterEvent *event) override;
......
......@@ -382,7 +382,6 @@ void MainWindow::init(const QString &mltPath)
clipDockWidget->close();
m_onlineResourcesDock->close();
m_assetPanel = new AssetPanel(this);
m_effectStackDock = addDock(i18n("Effect/Composition Stack"), QStringLiteral("effect_stack"), m_assetPanel);
connect(m_assetPanel, &AssetPanel::doSplitEffect, m_projectMonitor, &Monitor::slotSwitchCompare);
connect(m_assetPanel, &AssetPanel::doSplitBinEffect, m_clipMonitor, &Monitor::slotSwitchCompare);
......@@ -1710,6 +1709,16 @@ void MainWindow::setupActions()
KStandardAction::paste(this, SLOT(slotPaste()), actionCollection());
// Keyframe actions
m_assetPanel = new AssetPanel(this);
KActionCategory *kfActions = new KActionCategory(i18n("Effect Keyframes"), actionCollection());
addAction(QStringLiteral("keyframe_add"), i18n("Add/Remove Keyframe"), m_assetPanel, SLOT(slotAddRemoveKeyframe()),
QIcon::fromTheme(QStringLiteral("keyframe-add")), QKeySequence(), kfActions);
addAction(QStringLiteral("keyframe_next"), i18n("Go to next keyframe"), m_assetPanel, SLOT(slotNextKeyframe()),
QIcon::fromTheme(QStringLiteral("keyframe-next")), QKeySequence(), kfActions);
addAction(QStringLiteral("keyframe_previous"), i18n("Go to previous keyframe"), m_assetPanel, SLOT(slotPreviousKeyframe()),
QIcon::fromTheme(QStringLiteral("keyframe-previous")), QKeySequence(), kfActions);
/*act = KStandardAction::copy(this, SLOT(slotCopy()), actionCollection());
clipActionCategory->addAction(KStandardAction::name(KStandardAction::Copy), act);
act->setEnabled(false);
......
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