Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix KoPencilTool preview not updating when changing color

Luna Lovecraftefc10992106b
diff --git a/libs/basicflakes/tools/KoPencilTool.cpp b/libs/basicflakes/tools/KoPencilTool.cpp
index 7132d5dc6b..9012f937f9 100644
--- a/libs/basicflakes/tools/KoPencilTool.cpp
+++ b/libs/basicflakes/tools/KoPencilTool.cpp
@@ -437,6 +437,7 @@ KoShapeStrokeSP KoPencilTool::createStroke()
KoShapeStrokeSP stroke;
if (m_strokeWidget) {
stroke = m_strokeWidget->createShapeStroke();
+ stroke->setColor(m_strokeColor);
}
return stroke;
}
@@ -573,6 +574,11 @@ qreal KoPencilTool::getFittingError()
return this->m_fittingError;
}
+void KoPencilTool::setStrokeColor(QColor color)
+{
+ m_strokeColor = color;
+}
+
void KoPencilTool::setFittingError(qreal fittingError)
{
this->m_fittingError = fittingError;
diff --git a/libs/basicflakes/tools/KoPencilTool.h b/libs/basicflakes/tools/KoPencilTool.h
index 724cbae167..68f2160223 100644
--- a/libs/basicflakes/tools/KoPencilTool.h
+++ b/libs/basicflakes/tools/KoPencilTool.h
@@ -10,6 +10,7 @@
#include "KoFlakeTypes.h"
#include "KoToolBase.h"
#include <kconfiggroup.h>
+#include <qcolor.h>
class KoPathShape;
class KoShapeStroke;
@@ -49,6 +50,7 @@ protected:
KoPathShape * path();
void setFittingError(qreal fittingError);
qreal getFittingError();
+ void setStrokeColor(QColor color);
private Q_SLOTS:
void selectMode(int mode);
@@ -78,6 +80,7 @@ private:
qreal m_combineAngle {15.0};
qreal m_fittingError {5.0};
bool m_close {false};
+ QColor m_strokeColor;
QList<QPointF> m_points; // the raw points
diff --git a/plugins/tools/basictools/kis_tool_pencil.cc b/plugins/tools/basictools/kis_tool_pencil.cc
index e798b09c5e..9114b08526 100644
--- a/plugins/tools/basictools/kis_tool_pencil.cc
+++ b/plugins/tools/basictools/kis_tool_pencil.cc
@@ -137,4 +137,14 @@ void __KisToolPencilLocalTool::slotUpdatePencilCursor()
{
KoShapeStrokeSP stroke = this->createStroke();
m_parentTool->updatePencilCursor(stroke && stroke->isVisible());
+
+ auto style = m_parentTool->strokeStyle();
+ if (style == KisToolShapeUtils::StrokeStyleForeground )
+ {
+ KoPencilTool::setStrokeColor(canvas()->resourceManager()->foregroundColor().toQColor());
+ }
+ else if ( style == KisToolShapeUtils::StrokeStyleBackground)
+ {
+ KoPencilTool::setStrokeColor(canvas()->resourceManager()->backgroundColor().toQColor());
+ }
}