* Add option to remove keyframes after cursor position

* Fix dropping dragged keyframe info on transition / clip
parent 29a56701
......@@ -164,6 +164,9 @@ AnimationWidget::AnimationWidget(EffectMetaInfo *info, int clipPos, int min, int
QAction *paste = new QAction(i18n("Import keyframes from clipboard"), this);
connect(paste, &QAction::triggered, this, &AnimationWidget::slotImportKeyframes);
QAction *removeNext = new QAction(i18n("Remove all keyframes after cursor"), this);
connect(removeNext, &QAction::triggered, this, &AnimationWidget::slotRemoveNext);
// save preset
QAction *savePreset = new QAction(KoIconUtils::themedIcon(QStringLiteral("document-save")), i18n("Save preset"), this);
connect(savePreset, &QAction::triggered, this, &AnimationWidget::savePreset);
......@@ -178,6 +181,7 @@ AnimationWidget::AnimationWidget(EffectMetaInfo *info, int clipPos, int min, int
container->addSeparator();
container->addAction(copy);
container->addAction(paste);
container->addAction(removeNext);
container->addSeparator();
container->addAction(savePreset);
container->addAction(delPreset);
......@@ -355,6 +359,34 @@ void AnimationWidget::slotAddDeleteKeyframe(bool add, int pos)
emit parameterChanged();
}
void AnimationWidget::slotRemoveNext()
{
int pos = m_timePos->getValue();
// Delete keyframe in all animations at current pos
QStringList paramNames = m_doubleWidgets.keys();
if (!m_rectParameter.isEmpty())
paramNames << m_rectParameter;
int kfrPos;
for (int i = 0; i < paramNames.count(); i++) {
m_animController = m_animProperties.get_animation(paramNames.at(i).toUtf8().constData());
int j = 0;
while (j < m_animController.key_count()) {
kfrPos = m_animController.key_get_frame(j);
if (kfrPos > (pos - m_offset)) {
m_animController.remove(kfrPos);
} else j++;
}
}
m_selectType->setEnabled(false);
m_addKeyframe->setActive(false);
slotPositionChanged(-1, false);
// Restore default controller
m_animController = m_animProperties.get_animation(m_inTimeline.toUtf8().constData());
// Rebuild
rebuildKeyframes();
emit parameterChanged();
}
void AnimationWidget::slotSyncPosition(int relTimelinePos)
{
// do only sync if this effect is keyframable
......
......@@ -144,7 +144,9 @@ private slots:
void slotAdjustToFrameSize();
void slotFitToWidth();
void slotFitToHeight();
/** @brief Delete all keyframes after current cursor pos. */
void slotRemoveNext();
/** @brief Moves the rect to the left frame border (x position = 0). */
void slotMoveLeft();
/** @brief Centers the rect horizontally. */
......
......@@ -1627,9 +1627,19 @@ void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event)
// Transition drop
effects = QString::fromUtf8(event->mimeData()->data(QStringLiteral("kdenlive/transitionslist")));
transitionDrop = true;
} else {
} else if (event->mimeData()->hasFormat(QStringLiteral("kdenlive/effectslist"))) {
// Effect drop
effects = QString::fromUtf8(event->mimeData()->data(QStringLiteral("kdenlive/effectslist")));
} else if (event->mimeData()->hasFormat(QStringLiteral("kdenlive/geometry"))) {
if (m_selectionTimer.isActive())
m_selectionTimer.stop();
event->acceptProposedAction();
CustomTrackView *view = static_cast<CustomTrackView*>(scene()->views().first());
if (view) {
QString geometry = QString::fromUtf8(event->mimeData()->data(QStringLiteral("kdenlive/geometry")));
view->dropClipGeometry(this, geometry);
}
return;
}
event->acceptProposedAction();
QDomDocument doc;
......
......@@ -8443,18 +8443,39 @@ void CustomTrackView::updateTransitionWidget(Transition *tr, ItemInfo info)
void CustomTrackView::dropTransitionGeometry(Transition *trans, const QString &geometry)
{
if (m_dragItem && m_dragItem != trans) {
if (!m_dragItem || m_dragItem != trans) {
clearSelection(false);
m_dragItem = trans;
m_dragItem->setMainSelectedClip(true);
trans->setSelected(true);
updateTimelineSelection();
}
emit transitionItemSelected(trans);
QMap <QString, QString> data;
data.insert(i18n("Dropped Geometry"), geometry);
slotImportClipKeyframes(TransitionWidget, trans->info(), trans->toXML(), data);
}
void CustomTrackView::dropClipGeometry(ClipItem *clip, const QString &geometry)
{
if (!m_dragItem || m_dragItem != clip) {
clearSelection(false);
m_dragItem = clip;
m_dragItem->setMainSelectedClip(true);
clip->setSelected(true);
updateTimelineSelection();
}
emit clipItemSelected(clip);
QMap <QString, QString> data;
data.insert(i18n("Dropped Geometry"), geometry);
QDomElement currentEffect = clip->getEffectAtIndex(clip->selectedEffectIndex());
if (currentEffect.isNull()) {
emit displayMessage(i18n("No effect to import keyframes"), InformationMessage);
return;
}
slotImportClipKeyframes(AVWidget, clip->info(), currentEffect.cloneNode().toElement(), data);
}
void CustomTrackView::breakLockedGroups(QList<ItemInfo> clipsToMove, QList<ItemInfo> transitionsToMove, QUndoCommand *masterCommand, bool doIt)
{
QList <AbstractGroupItem *> processedGroups;
......
......@@ -258,7 +258,10 @@ public:
/** @brief Creates an overlay track with filtered clip */
bool createSplitOverlay(Mlt::Filter *filter);
void removeSplitOverlay();
/** @brief Geometry keyframes dropped on a transition, start import */
void dropTransitionGeometry(Transition *trans, const QString &geometry);
/** @brief Geometry keyframes dropped on a clip, start import */
void dropClipGeometry(ClipItem *trans, const QString &geometry);
/** @brief Switch current track lock state */
void switchTrackLock();
void switchAllTrackLock();
......
......@@ -76,7 +76,7 @@ Transition::Transition(const ItemInfo &info, int transitiontrack, double fps, co
for (int i = 0; i < namenode.count() ; ++i) {
QDomElement pa = namenode.item(i).toElement();
QString paramType = pa.attribute(QStringLiteral("type"));
if (paramType == QLatin1String("geometry") || paramType == QLatin1String("animated")) {
if (paramType == QLatin1String("geometry") || paramType == QLatin1String("animated") || paramType == QLatin1String("animatedrect")) {
setAcceptDrops(true);
break;
}
......@@ -502,7 +502,7 @@ void Transition::dropEvent(QGraphicsSceneDragDropEvent * event)
{
if (scene() && !scene()->views().isEmpty()) {
if (m_selectionTimer.isActive())
m_selectionTimer.stop();
m_selectionTimer.stop();
QString geometry = QString::fromUtf8(event->mimeData()->data(QStringLiteral("kdenlive/geometry")));
event->acceptProposedAction();
CustomTrackView *view = static_cast<CustomTrackView*>(scene()->views().first());
......
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