From ef9449db9cb9b913afc39c6d0ababb495ecfc727 Mon Sep 17 00:00:00 2001 From: shieldgenerator7 Date: Fri, 6 Oct 2023 15:07:30 -0400 Subject: [PATCH] #1792 Add option to toggle autoswitching --- app/src/toolbox.cpp | 9 ++++++--- app/src/tooloptionwidget.cpp | 10 ++++++++++ app/src/tooloptionwidget.h | 1 + app/ui/tooloptions.ui | 10 ++++++++++ core_lib/src/managers/toolmanager.cpp | 5 +++++ core_lib/src/managers/toolmanager.h | 1 + core_lib/src/tool/basetool.cpp | 5 +++++ core_lib/src/tool/basetool.h | 2 ++ core_lib/src/tool/selecttool.cpp | 2 ++ core_lib/src/util/pencildef.h | 1 + 10 files changed, 43 insertions(+), 3 deletions(-) diff --git a/app/src/toolbox.cpp b/app/src/toolbox.cpp index 9b515f4805..18c171ff26 100644 --- a/app/src/toolbox.cpp +++ b/app/src/toolbox.cpp @@ -313,10 +313,13 @@ void ToolBoxWidget::onSelectionChanged(){ BaseTool* currentTool = editor()->tools()->currentTool(); if (currentTool->type() == SELECT) { - SelectTool* selectTool = (SelectTool*) currentTool; - if (!selectTool->selectChanging() && editor()->select()->somethingSelected()) + if (editor()->select()->somethingSelected()) { - moveOn(); + SelectTool* selectTool = (SelectTool*) currentTool; + if (selectTool->properties.autoSwitchTool && !selectTool->selectChanging()) + { + moveOn(); + } } } } diff --git a/app/src/tooloptionwidget.cpp b/app/src/tooloptionwidget.cpp index 5c51c42065..e35e8a440f 100644 --- a/app/src/tooloptionwidget.cpp +++ b/app/src/tooloptionwidget.cpp @@ -114,6 +114,8 @@ void ToolOptionWidget::makeConnectionToEditor(Editor* editor) connect(ui->fillContourBox, &QCheckBox::clicked, toolManager, &ToolManager::setUseFillContour); + connect(ui->autoSwitchToolCheckBox, &QCheckBox::clicked, toolManager, &ToolManager::setAutoSwitchTool); + connect(ui->showInfoBox, &QCheckBox::clicked, toolManager, &ToolManager::setShowSelectionInfo); connect(toolManager, &ToolManager::toolChanged, this, &ToolOptionWidget::onToolChanged); @@ -136,6 +138,7 @@ void ToolOptionWidget::onToolPropertyChanged(ToolType, ToolPropertyType ePropert case ANTI_ALIASING: setAA(p.useAA); break; case STABILIZATION: setStabilizerLevel(p.stabilizerLevel); break; case FILLCONTOUR: setFillContour(p.useFillContour); break; + case AUTOSWITCHTOOL: setAutoSwitchTool(p.autoSwitchTool); break; case SHOWSELECTIONINFO: setShowSelectionInfo(p.showSelectionInfo); break; case BEZIER: setBezier(p.bezier_state); break; case CAMERAPATH: { break; } @@ -186,6 +189,7 @@ void ToolOptionWidget::setVisibility(BaseTool* tool) ui->stabilizerLabel->setVisible(tool->isPropertyEnabled(STABILIZATION)); ui->inpolLevelsCombo->setVisible(tool->isPropertyEnabled(STABILIZATION)); ui->fillContourBox->setVisible(tool->isPropertyEnabled(FILLCONTOUR)); + ui->autoSwitchToolCheckBox->setVisible(tool->isPropertyEnabled(AUTOSWITCHTOOL)); ui->showInfoBox->setVisible(tool->isPropertyEnabled(SHOWSELECTIONINFO)); auto currentLayerType = editor()->layers()->currentLayer()->type(); @@ -344,6 +348,12 @@ void ToolOptionWidget::setBezier(bool useBezier) ui->useBezierBox->setChecked(useBezier); } +void ToolOptionWidget::setAutoSwitchTool(bool autoSwitch) +{ + QSignalBlocker b(ui->autoSwitchToolCheckBox); + ui->autoSwitchToolCheckBox->setChecked(autoSwitch); +} + void ToolOptionWidget::setShowSelectionInfo(bool showSelectionInfo) { QSignalBlocker b(ui->showInfoBox); diff --git a/app/src/tooloptionwidget.h b/app/src/tooloptionwidget.h index 1a0426f159..d715afbc53 100644 --- a/app/src/tooloptionwidget.h +++ b/app/src/tooloptionwidget.h @@ -65,6 +65,7 @@ public slots: void setStabilizerLevel(int); void setFillContour(int); void setBezier(bool); + void setAutoSwitchTool(bool); void setShowSelectionInfo(bool); void disableAllOptions(); diff --git a/app/ui/tooloptions.ui b/app/ui/tooloptions.ui index 47d1a4116f..eba83d521f 100644 --- a/app/ui/tooloptions.ui +++ b/app/ui/tooloptions.ui @@ -130,6 +130,16 @@ + + + + Auto-Switch to Move Tool + + + true + + + diff --git a/core_lib/src/managers/toolmanager.cpp b/core_lib/src/managers/toolmanager.cpp index 14233ec79d..05cf9dd1fe 100644 --- a/core_lib/src/managers/toolmanager.cpp +++ b/core_lib/src/managers/toolmanager.cpp @@ -266,6 +266,11 @@ void ToolManager::setUseFillContour(bool useFillContour) emit toolPropertyChanged(currentTool()->type(), FILLCONTOUR); } +void ToolManager::setAutoSwitchTool(bool autoSwitch) +{ + currentTool()->setAutoSwitchTool(autoSwitch); +} + void ToolManager::setShowSelectionInfo(bool b) { currentTool()->setShowSelectionInfo(b); diff --git a/core_lib/src/managers/toolmanager.h b/core_lib/src/managers/toolmanager.h index 6ba1cd3321..ed151363cb 100644 --- a/core_lib/src/managers/toolmanager.h +++ b/core_lib/src/managers/toolmanager.h @@ -80,6 +80,7 @@ public slots: void setBucketFillReferenceMode(int referenceMode); void setBucketFillExpand(int); void setUseFillContour(bool); + void setAutoSwitchTool(bool autoSwitch); void setShowSelectionInfo(bool b); void setShowCameraPath(bool); void resetCameraPath(); diff --git a/core_lib/src/tool/basetool.cpp b/core_lib/src/tool/basetool.cpp index d02496cb46..be203f99ff 100644 --- a/core_lib/src/tool/basetool.cpp +++ b/core_lib/src/tool/basetool.cpp @@ -444,6 +444,11 @@ void BaseTool::setUseFillContour(const bool useFillContour) properties.useFillContour = useFillContour; } +void BaseTool::setAutoSwitchTool(const bool autoSwitch) +{ + properties.autoSwitchTool = autoSwitch; +} + void BaseTool::setShowSelectionInfo(const bool b) { properties.showSelectionInfo = b; diff --git a/core_lib/src/tool/basetool.h b/core_lib/src/tool/basetool.h index 533b59491f..4be86bf5c9 100644 --- a/core_lib/src/tool/basetool.h +++ b/core_lib/src/tool/basetool.h @@ -55,6 +55,7 @@ class Properties bool bucketFillExpandEnabled = 0; int bucketFillReferenceMode = 0; bool useFillContour = false; + bool autoSwitchTool = true; bool showSelectionInfo = true; bool cameraShowPath = true; DotColorType cameraPathDotColorType = DotColorType::RED; @@ -128,6 +129,7 @@ class BaseTool : public QObject virtual void setFillExpandEnabled(const bool enabled); virtual void setFillReferenceMode(int referenceMode); virtual void setUseFillContour(const bool useFillContour); + virtual void setAutoSwitchTool(const bool autoSwitch); virtual void setShowSelectionInfo(const bool b); virtual void setShowCameraPath(const bool showCameraPath); virtual void setPathDotColorType(const DotColorType dotColorType); diff --git a/core_lib/src/tool/selecttool.cpp b/core_lib/src/tool/selecttool.cpp index 78be42526b..6efee9c8ad 100644 --- a/core_lib/src/tool/selecttool.cpp +++ b/core_lib/src/tool/selecttool.cpp @@ -38,6 +38,8 @@ void SelectTool::loadSettings() QSettings settings(PENCIL2D, PENCIL2D); properties.showSelectionInfo = settings.value("ShowSelectionInfo").toBool(); mPropertyEnabled[SHOWSELECTIONINFO] = true; + properties.autoSwitchTool = true; + mPropertyEnabled[AUTOSWITCHTOOL] = true; } QCursor SelectTool::cursor() diff --git a/core_lib/src/util/pencildef.h b/core_lib/src/util/pencildef.h index e1b9b11ace..20aff72a20 100644 --- a/core_lib/src/util/pencildef.h +++ b/core_lib/src/util/pencildef.h @@ -60,6 +60,7 @@ enum ToolPropertyType STABILIZATION, TOLERANCE, FILLCONTOUR, + AUTOSWITCHTOOL, SHOWSELECTIONINFO, USETOLERANCE, BUCKETFILLEXPAND,