diff --git a/core_lib/src/managers/toolmanager.cpp b/core_lib/src/managers/toolmanager.cpp index c80e5b6a75..a228ff78b1 100644 --- a/core_lib/src/managers/toolmanager.cpp +++ b/core_lib/src/managers/toolmanager.cpp @@ -153,7 +153,6 @@ void ToolManager::setWidth(float newWidth) } currentTool()->setWidth(static_cast(newWidth)); - emit penWidthValueChanged(newWidth); emit toolPropertyChanged(currentTool()->type(), WIDTH); } @@ -165,7 +164,6 @@ void ToolManager::setFeather(float newFeather) } currentTool()->setFeather(static_cast(newFeather)); - emit penFeatherValueChanged(newFeather); emit toolPropertyChanged(currentTool()->type(), FEATHER); } @@ -233,7 +231,6 @@ void ToolManager::setTolerance(int newTolerance) newTolerance = qMax(0, newTolerance); currentTool()->setTolerance(newTolerance); - emit toleranceValueChanged(newTolerance); emit toolPropertyChanged(currentTool()->type(), TOLERANCE); } diff --git a/core_lib/src/managers/toolmanager.h b/core_lib/src/managers/toolmanager.h index 6ba1cd3321..b01be3177b 100644 --- a/core_lib/src/managers/toolmanager.h +++ b/core_lib/src/managers/toolmanager.h @@ -53,10 +53,6 @@ class ToolManager : public BaseManager int propertySwitch(bool condition, int property); signals: - void penWidthValueChanged(float); - void penFeatherValueChanged(float); - void toleranceValueChanged(qreal); - void toolChanged(ToolType); void toolPropertyChanged(ToolType, ToolPropertyType); @@ -65,6 +61,7 @@ public slots: void setWidth(float); void setFeather(float); + void setUseFeather(bool); void setInvisibility(bool); void setPreserveAlpha(bool); diff --git a/core_lib/src/tool/basetool.h b/core_lib/src/tool/basetool.h index 2724354796..d3ef527218 100644 --- a/core_lib/src/tool/basetool.h +++ b/core_lib/src/tool/basetool.h @@ -107,6 +107,7 @@ class BaseTool : public QObject virtual void setWidth(const qreal width); virtual void setFeather(const qreal feather); + virtual void setInvisibility(const bool invisibility); virtual void setBezier(const bool bezier_state); virtual void setPressure(const bool pressure); diff --git a/core_lib/src/tool/stroketool.cpp b/core_lib/src/tool/stroketool.cpp index b3cfa6894c..4ff0c29e43 100644 --- a/core_lib/src/tool/stroketool.cpp +++ b/core_lib/src/tool/stroketool.cpp @@ -331,6 +331,10 @@ void StrokeTool::stopAdjusting() { msIsAdjusting = false; mAdjustPosition = QPointF(); + + mEditor->tools()->setWidth(properties.width); + mEditor->tools()->setFeather(properties.feather); + updateCanvasCursor(); } @@ -343,7 +347,7 @@ void StrokeTool::adjustCursor(Qt::KeyboardModifiers modifiers) // map it back to its original value, we can multiply by the factor we divided with const qreal newValue = QLineF(mAdjustPosition, getCurrentPoint()).length() * 2.0; - mEditor->tools()->setWidth(qBound(WIDTH_MIN, newValue, WIDTH_MAX)); + setTemporaryWidth(qBound(WIDTH_MIN, newValue, WIDTH_MAX)); break; } case FEATHER: { @@ -357,7 +361,7 @@ void StrokeTool::adjustCursor(Qt::KeyboardModifiers modifiers) // We flip min and max here in order to get the inverted value for the UI const qreal mappedValue = MathUtils::map(distance, inputMin, inputMax, outputMax, outputMin); - mEditor->tools()->setFeather(qBound(FEATHER_MIN, mappedValue, FEATHER_MAX)); + setTemporaryFeather(qBound(FEATHER_MIN, mappedValue, FEATHER_MAX)); break; } default: @@ -371,3 +375,25 @@ void StrokeTool::paint(QPainter& painter, const QRect& blitRect) { mCanvasCursorPainter.paint(painter, blitRect); } + +void StrokeTool::setTemporaryWidth(qreal width) +{ + if (std::isnan(width) || width < 0) + { + width = 1.f; + } + + properties.width = width; + emit mEditor->tools()->toolPropertyChanged(this->type(), WIDTH); +} + +void StrokeTool::setTemporaryFeather(qreal feather) +{ + if (std::isnan(feather) || feather < 0) + { + feather = 0.f; + } + + properties.feather = feather; + emit mEditor->tools()->toolPropertyChanged(this->type(), FEATHER); +} diff --git a/core_lib/src/tool/stroketool.h b/core_lib/src/tool/stroketool.h index 63ad63f0a2..8d21fa7090 100644 --- a/core_lib/src/tool/stroketool.h +++ b/core_lib/src/tool/stroketool.h @@ -110,6 +110,12 @@ public slots: CanvasCursorPainter mCanvasCursorPainter; StrokeInterpolator mInterpolator; + +private: + /// Sets the width value without calling settings to store the state + void setTemporaryWidth(qreal width); + /// Sets the feather value, without calling settings to store the state + void setTemporaryFeather(qreal feather); }; #endif // STROKETOOL_H