diff --git a/app/src/toolbox.cpp b/app/src/toolbox.cpp index 9b515f480..18c171ff2 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 5c51c4206..e35e8a440 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 1a0426f15..d715afbc5 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 47d1a4116..eba83d521 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 14233ec79..05cf9dd1f 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 6ba1cd332..ed151363c 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 d02496cb4..be203f99f 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 533b59491..4be86bf5c 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 78be42526..6efee9c8a 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 e1b9b11ac..20aff72a2 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,