From 5df58992cfa272509dc1de5b1c4020ae66aedcfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 30 Aug 2024 15:13:58 +0200 Subject: [PATCH] Update boxsinglewidget.cpp Middle-click to rename layer. Ref: #233 --- src/app/GUI/BoxesList/boxsinglewidget.cpp | 28 +++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/app/GUI/BoxesList/boxsinglewidget.cpp b/src/app/GUI/BoxesList/boxsinglewidget.cpp index 96a7a6e4e..1fa2a1127 100644 --- a/src/app/GUI/BoxesList/boxsinglewidget.cpp +++ b/src/app/GUI/BoxesList/boxsinglewidget.cpp @@ -48,7 +48,7 @@ #include "BlendEffects/blendeffectcollection.h" #include "BlendEffects/blendeffectboxshadow.h" #include "Sound/eindependentsound.h" - +#include "GUI/propertynamedialog.h" #include "Animators/SmartPath/smartpathcollection.h" #include "typemenu.h" @@ -707,19 +707,29 @@ void BoxSingleWidget::mouseMoveEvent(QMouseEvent *event) { drag->exec(Qt::CopyAction | Qt::MoveAction); } -void BoxSingleWidget::mouseReleaseEvent(QMouseEvent *event) { - if(!mTarget) return; - if(event->x() < mFillWidget->x() || - event->x() > mFillWidget->x() + mFillWidget->width()) return; +void BoxSingleWidget::mouseReleaseEvent(QMouseEvent *event) +{ + if (!mTarget) { return; } + const auto target = mTarget->getTarget(); + + const auto bbox = enve_cast(target); + if (event->button() == Qt::MidButton && bbox) { + PropertyNameDialog::sRenameBox(bbox, this); + return; + } + + if (event->x() < mFillWidget->x() || + event->x() > mFillWidget->x() + mFillWidget->width()) { return; } setSelected(false); - if(pointToLen(event->pos() - mDragStartPos) > eSizesUI::widget/2) return; + + if (pointToLen(event->pos() - mDragStartPos) > eSizesUI::widget/2) { return; } + const bool shiftPressed = event->modifiers() & Qt::ShiftModifier; - const auto target = mTarget->getTarget(); - if(enve_cast(target) || enve_cast(target)) { + if (enve_cast(target) || enve_cast(target)) { const auto boxTarget = static_cast(target); boxTarget->selectionChangeTriggered(shiftPressed); Document::sInstance->actionFinished(); - } else if(const auto pTarget = enve_cast(target)) { + } else if (const auto pTarget = enve_cast(target)) { pTarget->prp_selectionChangeTriggered(shiftPressed); } }