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++

Attempt to fix color palette switching for QML widgets.

Wolthera van Hövell tot Westerflierf9b991b20486
diff --git a/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp b/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
index b13ae3d014..562c4f32e9 100644
--- a/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
+++ b/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
@@ -124,7 +124,7 @@ void KoShapeQtQuickLabel::setForegroundColor(const QColor &newForegroundColor)
}
d->shape->setBackground(QSharedPointer<KoColorBackground>(new KoColorBackground(newForegroundColor)));
-
+ update(this->boundingRect().toAlignedRect());
emit foregroundColorChanged();
}
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cpp
index d2cf38e54b..8344b47784 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp
+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp
@@ -127,7 +127,6 @@ TextPropertiesDock::TextPropertiesDock()
m_quickWidget->engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib/qml/");
m_quickWidget->engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib64/qml/");
- m_quickWidget->setPalette(this->palette());
m_quickWidget->setMinimumHeight(100);
d->fontModel = new KisResourceModel(ResourceType::FontFamilies);
diff --git a/plugins/dockers/textproperties/qml/Direction.qml b/plugins/dockers/textproperties/qml/Direction.qml
index 0b0496048d..5d1cbde82b 100644
--- a/plugins/dockers/textproperties/qml/Direction.qml
+++ b/plugins/dockers/textproperties/qml/Direction.qml
@@ -61,6 +61,7 @@ TextPropertyBase {
elide: Text.ElideRight;
Layout.fillWidth: true;
font.italic: properties.directionState === KoSvgTextPropertiesModel.PropertyTriState;
+ palette: directionCmbPalette.palette;
}
ComboBox {
@@ -74,6 +75,11 @@ TextPropertyBase {
valueRole: "value";
onActivated: direction = currentValue;
wheelEnabled: true;
+ PaletteControl {
+ id: directionCmbPalette;
+ colorGroup: directionCmb.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+ palette: directionCmbPalette.palette;
}
RevertPropertyButton {
@@ -88,6 +94,7 @@ TextPropertyBase {
Layout.fillWidth: true;
visible: parentPropertyType === TextPropertyBase.Character;
font.italic: properties.unicodeBidiState === KoSvgTextPropertiesModel.PropertyTriState;
+ palette: unicodeBidiCmbPalette.palette;
}
ComboBox {
@@ -106,6 +113,12 @@ TextPropertyBase {
valueRole: "value";
onActivated: unicodeBidi = currentValue;
wheelEnabled: true;
+
+ PaletteControl {
+ id: unicodeBidiCmbPalette;
+ colorGroup: unicodeBidiCmb.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+ palette: unicodeBidiCmbPalette.palette;
}
}
}
diff --git a/plugins/dockers/textproperties/qml/FontFamily.qml b/plugins/dockers/textproperties/qml/FontFamily.qml
index e09c8550e8..7c5233663a 100644
--- a/plugins/dockers/textproperties/qml/FontFamily.qml
+++ b/plugins/dockers/textproperties/qml/FontFamily.qml
@@ -59,6 +59,11 @@ CollapsibleGroupProperty {
fontFamilies = [ text ];
}
}
+ PaletteControl {
+ id: mainCmbPalette;
+ colorGroup: parent.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+ palette: mainCmbPalette.palette;
function updateCurrentIndex() {
var name = mainWindow.wwsFontFamilyName(fontFamilies[0]);
if (name !== modelWrapper.resourceFilename) {
@@ -103,6 +108,11 @@ CollapsibleGroupProperty {
onActivated: {
fontFamilies[fontListDelegate.dIndex] = text;
}
+ PaletteControl {
+ id: fontCmbPalette;
+ colorGroup: parent.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+ palette: fontCmbPalette.palette;
Component.onCompleted: {
if (fontListDelegate.dIndex === 0) {
modelWrapper = mainFamilyCmb.modelWrapper;
diff --git a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
index 77e77c99f6..8b3fc6abc3 100644
--- a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
+++ b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
@@ -50,9 +50,13 @@ Button {
fontName = familyCmb.modelWrapper.localizedNameFromMetadata(meta, locales, model.name);
}
+ palette: familyCmb.palette;
+
contentItem: KoShapeQtQuickLabel {
id: fontFamilyDelegate;
property alias meta: fontDelegateItem.meta;
+ property alias highlighted: fontDelegateItem.highlighted;
+ property alias palette: fontDelegateItem.palette;
property bool colorBitmap : typeof meta.color_bitmap === 'boolean'? meta.color_bitmap: false;
property bool colorCLRV0 : typeof meta.color_clrv0 === 'boolean'? meta.color_clrv0: false;
property bool colorCLRV1 : typeof meta.color_clrv1 === 'boolean'? meta.color_clrv1: false;
@@ -65,14 +69,16 @@ Button {
imageScale: 3;
imagePadding: nameLabel.height;
svgData: fontDelegateItem.sample;
- foregroundColor: sysPalette.text;
+ foregroundColor: highlighted? palette.highlightedText: palette.text;
fullColor: colorBitmap || colorCLRV0 || colorCLRV1 || colorSVG;
Label {
id: nameLabel;
+ palette: fontDelegateItem.palette;
text: fontFamilyDelegate.fontName;
anchors.top: parent.top;
anchors.left: parent.left;
+ color: parent.highlighted? palette.highlightedText: palette.text;
}
Row {
@@ -89,7 +95,8 @@ Button {
property int type: fontFamilyDelegate.type;
icon.width: parent.imgHeight;
icon.height: parent.imgHeight;
- icon.color: sysPalette.text;
+ palette: fontDelegateItem.palette;
+ icon.color: nameLabel.color;
icon.source: type === KoSvgText.BDFFontType? "qrc:///font-type-bitmap.svg"
: type === KoSvgText.Type1FontType? "qrc:///font-type-postscript.svg"
: type === KoSvgText.OpenTypeFontType? "qrc:///font-type-opentype.svg":"qrc:///light_system-help.svg";
@@ -101,7 +108,8 @@ Button {
height: parent.imgHeight;
icon.width: parent.imgHeight;
icon.height: parent.imgHeight;
- icon.color: sysPalette.text;
+ palette: fontDelegateItem.palette;
+ icon.color: nameLabel.color;
visible: fontFamilyDelegate.isVariable;
icon.source: "qrc:///font-type-opentype-variable.svg"
}
@@ -149,7 +157,7 @@ Button {
}
}
background: Rectangle {
- color: highlighted? familyCmb.palette.highlight:"transparent";
+ color: highlighted? familyCmb.palette.highlight: "transparent";
}
MouseArea {
@@ -185,6 +193,8 @@ Button {
height: contentHeight;
padding: 2;
+ palette: familyCmb.palette;
+
contentItem:
ColumnLayout {
id: fontResourceView;
@@ -225,6 +235,8 @@ Button {
//--- Tag Setup ---//
Menu {
id: tagActionsContextMenu;
+
+ palette: familyCmb.palette;
property int resourceIndex: -1;
property alias resourceName: resourceLabel.text;
property var resourceTaggedModel : [];
@@ -352,7 +364,6 @@ Button {
}
}
}
- palette: familyCmb.palette;
}
}
diff --git a/plugins/dockers/textproperties/qml/PaletteControl.qml b/plugins/dockers/textproperties/qml/PaletteControl.qml
new file mode 100644
index 0000000000..80fc7c1196
--- /dev/null
+++ b/plugins/dockers/textproperties/qml/PaletteControl.qml
@@ -0,0 +1,45 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+
+/**
+ Dummy Control to work around QQuickPalette and QPalette being two completely different things.
+ */
+Control {
+ id: paletteControl;
+
+ property alias colorGroup: activePalette.colorGroup
+
+ SystemPalette {
+ id: activePalette;
+ colorGroup: SystemPalette.Active
+ }
+
+
+ palette.alternateBase: activePalette.alternateBase;
+ palette.base: activePalette.base;
+ palette.button: activePalette.button;
+ palette.buttonText: activePalette.buttonText;
+ palette.dark: activePalette.dark;
+ palette.highlight: activePalette.highlight;
+ palette.highlightedText: activePalette.highlightedText;
+ palette.light: activePalette.light;
+
+ palette.link: activePalette.link;
+ palette.linkVisited: activePalette.linkVisited;
+ palette.mid: activePalette.mid;
+ palette.midlight: activePalette.midlight;
+ palette.shadow: activePalette.shadow;
+ palette.text: activePalette.text;
+ palette.window: activePalette.window;
+ palette.windowText: activePalette.windowText;
+
+ palette.toolTipBase: activePalette.alternateBase;
+ palette.toolTipText: activePalette.text;
+ palette.brightText: Qt.lighter(activePalette.text);
+
+}
diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qml
index 446cc3e049..d3a0e28b1c 100644
--- a/plugins/dockers/textproperties/qml/TextProperties.qml
+++ b/plugins/dockers/textproperties/qml/TextProperties.qml
@@ -19,6 +19,11 @@ Rectangle {
colorGroup: SystemPalette.Active
}
+ PaletteControl {
+ id: paletteControl;
+ colorGroup: root.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+
function setProperties() {
characterPropertyList.updateProperties()
paragraphPropertyList.updateProperties()
@@ -29,6 +34,7 @@ Rectangle {
anchors.right: parent.right;
anchors.left: parent.left;
anchors.top: parent.top;
+ palette: paletteControl.palette;
TabButton {
text: i18nc("@title:tab", "Character")
}
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBase.qml b/plugins/dockers/textproperties/qml/TextPropertyBase.qml
index 48cc6631b0..7cdeb51035 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBase.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBase.qml
@@ -40,6 +40,10 @@ Column {
children.push(seperator);
}
+ property PaletteControl propertyBasePalette: PaletteControl {
+ colorGroup: enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+
MenuSeparator {
id: seperator;
width: parent.width;
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
index 3a8ccaa9f1..0a7e1928b5 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
@@ -76,6 +76,12 @@ ColumnLayout {
clip: true;
padding: 0;
+ PaletteControl {
+ id: paletteControl;
+ colorGroup: frame.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+ palette: paletteControl.palette;
+
ListView {
id: propertiesWidgetView
@@ -157,6 +163,12 @@ ColumnLayout {
signal searchChanged;
onSearchChanged: parent.filterChanged();
+ PaletteControl {
+ id: cmbPalette;
+ colorGroup: addPropertyCmb.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+ palette: cmbPalette.palette;
+
delegate: ItemDelegate {
id: addPropertyDelegate;
width: addPropertyCmb.width;
@@ -185,6 +197,8 @@ ColumnLayout {
height: contentHeight;
padding: 2;
+ palette: cmbPalette.palette;
+
contentItem: ColumnLayout {
clip: true;
width: parent.width;
diff --git a/plugins/dockers/textproperties/textproperties.qrc b/plugins/dockers/textproperties/textproperties.qrc
index 96766dfe7e..dc7e24cbfa 100644
--- a/plugins/dockers/textproperties/textproperties.qrc
+++ b/plugins/dockers/textproperties/textproperties.qrc
@@ -43,5 +43,6 @@
<file alias="font-type-opentype.svg">icons/font-type-opentype.svg</file>
<file alias="font-type-postscript.svg">icons/font-type-postscript.svg</file>
<file alias="font-type-opentype-variable.svg">icons/font-type-opentype-variable.svg</file>
+ <file alias="PaletteControl.qml">qml/PaletteControl.qml</file>
</qresource>
</RCC>