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++
Add canvas system palette to display converter and implement in text tool.
Wolthera van Hövell tot Westerflier8ca86adf089d
diff --git a/libs/flake/text/KoSvgTextShapeOutlineHelper.cpp b/libs/flake/text/KoSvgTextShapeOutlineHelper.cppindex 109b547ac7..4513ef1cb4 100644--- a/libs/flake/text/KoSvgTextShapeOutlineHelper.cpp+++ b/libs/flake/text/KoSvgTextShapeOutlineHelper.cpp@@ -35,6 +35,7 @@ struct KoSvgTextShapeOutlineHelper::Private {bool textWrappingAreasHovered = false;KisHandlePalette handlePalette;+ QPalette systemPalette;KoSvgTextShape *getTextModeShape() {return dynamic_cast<KoSvgTextShape*>(canvas->currentShapeManagerOwnerShape());@@ -119,7 +120,7 @@ QList<QLineF> getTextAreaOrderArrows(QList<QPainterPath> areas) {}void KoSvgTextShapeOutlineHelper::paintTextShape(QPainter *painter, const KoViewConverter &converter,- const QPalette &pal, KoSvgTextShape *text, bool contourModeActive) {+ KoSvgTextShape *text, bool contourModeActive) {painter->save();KisHandlePainterHelper helper =KoShape::createHandlePainterHelperView(painter, text, converter, d->handleRadius, d->decorationThickness);@@ -162,9 +163,9 @@ void KoSvgTextShapeOutlineHelper::paintTextShape(QPainter *painter, const KoViewpainter->save();QIcon icon = contourModeActive? KisIconUtils::loadIcon(ICON_EXIT): KisIconUtils::loadIcon(ICON_ENTER);QPixmap pm = icon.pixmap(BUTTON_ICON_SIZE, BUTTON_ICON_SIZE);- painter->setBrush(contourModeActive? pal.highlight(): pal.button());+ painter->setBrush(contourModeActive? d->systemPalette.highlight(): d->systemPalette.button());QPen pen;- pen.setColor(contourModeActive? pal.highlightedText().color(): pal.buttonText().color());+ pen.setColor(contourModeActive? d->systemPalette.highlightedText().color(): d->systemPalette.buttonText().color());pen.setCosmetic(true);pen.setWidthF(d->decorationThickness);painter->setPen(pen);@@ -176,15 +177,14 @@ void KoSvgTextShapeOutlineHelper::paintTextShape(QPainter *painter, const KoViewvoid KoSvgTextShapeOutlineHelper::paint(QPainter *painter, const KoViewConverter &converter){- const QPalette pal = qApp->palette();KoSvgTextShape *text = d->getTextModeShape();if (text) {- paintTextShape(painter, converter, pal, text, true);+ paintTextShape(painter, converter, text, true);} else {Q_FOREACH(KoShape* shape, d->canvas->shapeManager()->selection()->selectedEditableShapes()) {text = dynamic_cast<KoSvgTextShape*>(shape);if (d->drawButton(text)) {- paintTextShape(painter, converter, pal, text, false);+ paintTextShape(painter, converter, text, false);}}}@@ -251,6 +251,11 @@ void KoSvgTextShapeOutlineHelper::setHandlePalette(KisHandlePalette handlePalettd->handlePalette = handlePalette;}+void KoSvgTextShapeOutlineHelper::setSystemPalette(QPalette pal)+{+ d->systemPalette = pal;+}+KoSvgTextShape *KoSvgTextShapeOutlineHelper::contourModeButtonHovered(const QPointF &point){KoSvgTextShape *text = d->getTextModeShape();diff --git a/libs/flake/text/KoSvgTextShapeOutlineHelper.h b/libs/flake/text/KoSvgTextShapeOutlineHelper.hindex 603f66a5ee..7b923ff505 100644--- a/libs/flake/text/KoSvgTextShapeOutlineHelper.h+++ b/libs/flake/text/KoSvgTextShapeOutlineHelper.h@@ -64,6 +64,7 @@ public:void setDecorationThickness(int thickness);void setHandlePalette(KisHandlePalette handlePalette);+ void setSystemPalette(QPalette pal);KoSvgTextShape *contourModeButtonHovered(const QPointF &point);@@ -80,8 +81,7 @@ public:void setTextAreasHovered(bool enabled);private:- void paintTextShape(QPainter *painter, const KoViewConverter &converter,- const QPalette &pal, KoSvgTextShape *text,+ void paintTextShape(QPainter *painter, const KoViewConverter &converter, KoSvgTextShape *text,bool contourModeActive = false);struct Private;QScopedPointer<Private> d;diff --git a/libs/global/KisHandleStyle.h b/libs/global/KisHandleStyle.hindex 60c8229027..a0472932a8 100644--- a/libs/global/KisHandleStyle.h+++ b/libs/global/KisHandleStyle.h@@ -23,6 +23,7 @@ struct KRITAGLOBAL_EXPORT KisHandlePalette, highlightOutlineColor(QColor(155, 0, 0)), selectionColor(QColor(164, 227, 243)), white(Qt::white)+ , black(Qt::black){}@@ -33,6 +34,7 @@ struct KRITAGLOBAL_EXPORT KisHandlePaletteQColor highlightOutlineColor;QColor selectionColor;QColor white;+ QColor black;};/**diff --git a/libs/ui/canvas/kis_display_color_converter.cpp b/libs/ui/canvas/kis_display_color_converter.cppindex 759f4fdb25..238087dc27 100644--- a/libs/ui/canvas/kis_display_color_converter.cpp+++ b/libs/ui/canvas/kis_display_color_converter.cpp@@ -8,6 +8,7 @@#include <QGlobalStatic>#include <QPointer>+#include <QPalette>#include <KoColor.h>#include <KoColorDisplayRendererInterface.h>@@ -157,6 +158,7 @@ struct KisDisplayColorConverter::PrivateKisImageSP image;KisHandlePalette handlePalette;+ QPalette systemPalette;inline KoColor approximateFromQColor(const QColor &qcolor);inline QColor approximateToQColor(const KoColor &color);@@ -242,8 +244,8 @@ KisDisplayColorConverter::KisDisplayColorConverter(KoCanvasResourceProvider *resm_d->paintingColorSpace = KoColorSpaceRegistry::instance()->rgb8();m_d->setCurrentNode(0);setDisplayFilter(QSharedPointer<KisDisplayFilter>(0));- updateKisHandlePalette();- connect(this, SIGNAL(displayConfigurationChanged()), this, SLOT(updateKisHandlePalette()));+ updatePalettes();+ connect(this, SIGNAL(displayConfigurationChanged()), this, SLOT(updatePalettes()));}KisDisplayColorConverter::KisDisplayColorConverter()@@ -336,7 +338,7 @@ void KisDisplayColorConverter::Private::slotUpdateCurrentNodeColorSpace()setCurrentNode(connectedNode);}-void KisDisplayColorConverter::updateKisHandlePalette()+void KisDisplayColorConverter::updatePalettes(){KisHandlePalette palette;KoColor c;@@ -361,7 +363,19 @@ void KisDisplayColorConverter::updateKisHandlePalette()c.fromQColor(palette.white);palette.white = convertColorToDisplayColorSpace(c);+ c.fromQColor(palette.black);+ palette.black = convertColorToDisplayColorSpace(c);++ QPalette pal = qApp->palette();+ for (int r = 0; r < QPalette::NColorRoles; r++) {+ for (int cg = 0; cg < QPalette::NColorGroups; cg++) {+ c.fromQColor(pal.brush(QPalette::ColorGroup(cg), QPalette::ColorRole(r)).color());+ pal.setBrush(QPalette::ColorGroup(cg), QPalette::ColorRole(r), convertColorToDisplayColorSpace(c));+ }+ }+m_d->handlePalette = palette;+ m_d->systemPalette = pal;}inline KisPaintDeviceSP findValidDevice(KisNodeSP node) {@@ -689,6 +703,11 @@ KisHandlePalette KisDisplayColorConverter::handlePaletteForDisplayColorSpace() creturn m_d->handlePalette;}+QPalette KisDisplayColorConverter::systemPaletteForDisplayColorSpace() const+{+ return m_d->systemPalette;+}+KoColor KisDisplayColorConverter::Private::approximateFromQColor(const QColor &qcolor){if (!useOcio()) {diff --git a/libs/ui/canvas/kis_display_color_converter.h b/libs/ui/canvas/kis_display_color_converter.hindex 7bf1345a00..eedd456a6f 100644--- a/libs/ui/canvas/kis_display_color_converter.h+++ b/libs/ui/canvas/kis_display_color_converter.h@@ -22,6 +22,7 @@ class KoCanvasResourceProvider;class KisDisplayConfig;class KisMultiSurfaceDisplayConfig;class KoID;+class QPalette;/*** Special helper class that provides primitives for converting colors when@@ -81,6 +82,8 @@ public:KisHandlePalette handlePaletteForDisplayColorSpace() const;+ QPalette systemPaletteForDisplayColorSpace() const;+/*** Converts the exactBounds() (!) of the \p srcDevice into QImage* properly rendered into display RGB space. Please note that the@@ -124,7 +127,7 @@ private:Q_PRIVATE_SLOT(m_d, void slotCanvasResourceChanged(int key, const QVariant &v));Q_PRIVATE_SLOT(m_d, void selectPaintingColorSpace());Q_PRIVATE_SLOT(m_d, void slotUpdateCurrentNodeColorSpace());- Q_SLOT void updateKisHandlePalette();+ Q_SLOT void updatePalettes();private:struct Private;diff --git a/plugins/tools/svgtexttool/SvgTextTool.cpp b/plugins/tools/svgtexttool/SvgTextTool.cppindex daf578d250..a024b0df2c 100644--- a/plugins/tools/svgtexttool/SvgTextTool.cpp+++ b/plugins/tools/svgtexttool/SvgTextTool.cpp@@ -686,9 +686,11 @@ void SvgTextTool::paint(QPainter &gc, const KoViewConverter &converter)if (!isActivated()) return;KisHandlePalette handlePalette;+ QPalette systemPalette = qApp->palette();KisCanvas2* kisCanvas = dynamic_cast<KisCanvas2*>(canvas());if (kisCanvas) {handlePalette = kisCanvas->displayColorConverter()->handlePaletteForDisplayColorSpace();+ systemPalette = kisCanvas->displayColorConverter()->systemPaletteForDisplayColorSpace();}if (m_dragging == DragMode::Create || m_dragging == DragMode::InShapeOffset) {@@ -741,6 +743,7 @@ void SvgTextTool::paint(QPainter &gc, const KoViewConverter &converter)m_textOutlineHelper->setDecorationThickness(decorationThickness());m_textOutlineHelper->setHandleRadius(handleRadius());m_textOutlineHelper->setHandlePalette(handlePalette);+ m_textOutlineHelper->setSystemPalette(systemPalette);m_textOutlineHelper->paint(&gc, converter);m_textOnPathHelper.setDecorationThickness(decorationThickness());m_textOnPathHelper.setHandleRadius(handleRadius());@@ -756,7 +759,7 @@ void SvgTextTool::paint(QPainter &gc, const KoViewConverter &converter)}}if (shape) {- m_textCursor.paintDecorations(gc, qApp->palette().color(QPalette::Highlight), decorationThickness(), handleRadius(), handlePalette);+ m_textCursor.paintDecorations(gc, systemPalette.color(QPalette::Highlight), decorationThickness(), handleRadius(), handlePalette);}if (m_interactionStrategy) {gc.save();