From b2c6df289387453a39b1c356b05cdb05ab971b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sat, 3 Aug 2024 02:17:04 +0200 Subject: [PATCH] Support 'Add Key(s)' shortcut (Insert) --- src/app/GUI/mainwindow.cpp | 9 +++++++++ src/core/canvas.cpp | 10 ++++++++++ src/core/canvas.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/src/app/GUI/mainwindow.cpp b/src/app/GUI/mainwindow.cpp index cbf0cde40..d5b6fb98a 100644 --- a/src/app/GUI/mainwindow.cpp +++ b/src/app/GUI/mainwindow.cpp @@ -630,6 +630,15 @@ void MainWindow::setupMenuBar() &mActions, &Actions::clearSelectionAction, Qt::ALT + Qt::Key_A, mEditMenu)); mEditMenu->addSeparator(); + + const auto addKeyAct = mEditMenu->addAction(tr("Add Key(s)"), [this]() { + const auto scene = *mDocument.fActiveScene; + if (!scene) { return; } + scene->addKeySelectedProperties(); + }, QKeySequence(tr("Insert"))); + + mEditMenu->addSeparator(); + mEditMenu->addAction(tr("Clear Cache", "MenuBar_Edit"), [this]() { const auto m = MemoryHandler::sInstance; m->clearMemory(); diff --git a/src/core/canvas.cpp b/src/core/canvas.cpp index 645c716cc..3e2a27457 100644 --- a/src/core/canvas.cpp +++ b/src/core/canvas.cpp @@ -425,6 +425,16 @@ void Canvas::setFrameRange(const FrameRange &range) { emit newFrameRange(range); } +void Canvas::addKeySelectedProperties() +{ + for (const auto &prop : mSelectedProps.getList()) { + const auto asAnim = enve_cast(prop); + if (!asAnim) { continue; } + asAnim->anim_saveCurrentValueAsKey(); + } + mDocument.actionFinished(); +} + stdsptr Canvas::createRenderData() { return enve::make_shared(this); } diff --git a/src/core/canvas.h b/src/core/canvas.h index a9afcde45..604658f39 100644 --- a/src/core/canvas.h +++ b/src/core/canvas.h @@ -353,6 +353,8 @@ class CORE_EXPORT Canvas : public CanvasBase void setFrameRange(const FrameRange& range); + void addKeySelectedProperties(); + ColorAnimator *getBgColorAnimator() { return mBackgroundColor.get();