From 2c49880b2d9a3571e0222dd998c3324ab0cb933d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Wed, 21 Aug 2024 00:42:09 +0200 Subject: [PATCH] Command Palette: add easing actions --- src/app/GUI/extraactions.cpp | 17 ++++++++++++++++- src/app/GUI/keysview.cpp | 11 ++++++++--- src/core/canvas.h | 6 ++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/app/GUI/extraactions.cpp b/src/app/GUI/extraactions.cpp index 08f1d5abe..f62892867 100644 --- a/src/app/GUI/extraactions.cpp +++ b/src/app/GUI/extraactions.cpp @@ -505,5 +505,20 @@ void MainWindow::setupMenuExtras() cmdAddAction(act); } } - // + // Easing + { + const QIcon easeIcon(QIcon::fromTheme("easing")); + const auto presets = AppSupport::getEasingPresets(); + for (const auto &preset : presets) { + const auto presetAct = new QAction(easeIcon, preset.second, this); + presetAct->setData(preset.first); + cmdAddAction(presetAct); + connect(presetAct, &QAction::triggered, + this, [this, presetAct]() { + const auto scene = *mDocument.fActiveScene; + if (!scene) { return; } + scene->setEasingAction(presetAct->text()); + }); + } + } } diff --git a/src/app/GUI/keysview.cpp b/src/app/GUI/keysview.cpp index 4efecac98..9077e1bdc 100644 --- a/src/app/GUI/keysview.cpp +++ b/src/app/GUI/keysview.cpp @@ -87,15 +87,20 @@ void KeysView::dragMoveEvent(QDragMoveEvent *event) { } } -void KeysView::setCurrentScene(Canvas * const scene) { - if(mCurrentScene) { +void KeysView::setCurrentScene(Canvas * const scene) +{ + if (mCurrentScene) { disconnect(mCurrentScene.data(), &Canvas::objectSelectionChanged, this, &KeysView::graphUpdateVisbile); + disconnect(mCurrentScene.data(), &Canvas::requestEasingAction, + this, &KeysView::graphEasingAction); } mCurrentScene = scene; - if(mCurrentScene) { + if (mCurrentScene) { connect(mCurrentScene.data(), &Canvas::objectSelectionChanged, this, &KeysView::graphUpdateVisbile); + connect(mCurrentScene.data(), &Canvas::requestEasingAction, + this, &KeysView::graphEasingAction); } graphUpdateVisbile(); } diff --git a/src/core/canvas.h b/src/core/canvas.h index 6dd125007..d5253274f 100644 --- a/src/core/canvas.h +++ b/src/core/canvas.h @@ -409,6 +409,11 @@ class CORE_EXPORT Canvas : public CanvasBase mPathEffectsVisible = bT; } + void setEasingAction(const QString &easing) + { + emit requestEasingAction(easing); + } + protected: void setCurrentSmartEndPoint(SmartNodePoint* const point); @@ -433,6 +438,7 @@ class CORE_EXPORT Canvas : public CanvasBase void gradientCreated(SceneBoundGradient*); void gradientRemoved(SceneBoundGradient*); void openTextEditor(); + void requestEasingAction(const QString &easing); public: void makePointCtrlsSymmetric();