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++
Implement KisTheme to wrap around KColorScheme and use it in the QML widgets.
Wolthera van Hövell tot Westerfliered5af94e98ef
diff --git a/libs/global/kis_config_notifier.cpp b/libs/global/kis_config_notifier.cppindex e97f7c8935..34cfcf6428 100644--- a/libs/global/kis_config_notifier.cpp+++ b/libs/global/kis_config_notifier.cpp@@ -54,3 +54,8 @@ void KisConfigNotifier::notifyColorHistoryModeChanged(){Q_EMIT colorHistoryModeChanged();}++void KisConfigNotifier::notifyColorThemeChanged(const QString &filename)+{+ Q_EMIT signalColorThemeChanged(filename);+}diff --git a/libs/global/kis_config_notifier.h b/libs/global/kis_config_notifier.hindex 1fe5db2b46..79da4dcb9b 100644--- a/libs/global/kis_config_notifier.h+++ b/libs/global/kis_config_notifier.h@@ -37,6 +37,8 @@ public:void notifyPixelGridModeChanged();void notifyColorHistoryModeChanged();+ void notifyColorThemeChanged(const QString &filename);+Q_SIGNALS:/*** This signal is emitted whenever notifyConfigChanged() is called.@@ -45,6 +47,7 @@ Q_SIGNALS:void dropFramesModeChanged();void pixelGridModeChanged();void colorHistoryModeChanged();+ void signalColorThemeChanged(const QString &filename);private:KisConfigNotifier(const KisConfigNotifier&);KisConfigNotifier operator=(const KisConfigNotifier&);diff --git a/libs/ui/thememanager.cpp b/libs/ui/thememanager.cppindex 94461e1427..9a2584a5b3 100644--- a/libs/ui/thememanager.cpp+++ b/libs/ui/thememanager.cpp@@ -46,6 +46,7 @@// Calligra#include <kis_icon.h>+#include <kis_config_notifier.h>#ifdef __APPLE__#include <QStyle>@@ -188,6 +189,7 @@ void ThemeManager::slotChangePalette()// hint for the style to synchronize the color scheme with the window manager/compositorqApp->setProperty("KDE_COLOR_SCHEME_PATH", filename);qApp->setPalette(palette);+ KisConfigNotifier::instance()->notifyColorThemeChanged(filename);Q_EMIT signalThemeChanged();}diff --git a/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp b/plugins/dockers/textproperties/KoShapeQtQuickLabel.cppindex 15de3172e2..ebcc709be1 100644--- a/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp+++ b/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp@@ -241,7 +241,7 @@ void KoShapeQtQuickLabel::updateShapes()void KoShapeQtQuickLabel::callUpdateIfComplete(){- if (isComponentComplete() && isVisible()) {+ if (isComponentComplete()) {update(boundingRect().toAlignedRect());}}diff --git a/plugins/dockers/textproperties/TextPropertyConfigDialog.cpp b/plugins/dockers/textproperties/TextPropertyConfigDialog.cppindex 0d48651c9d..87ca4ea4cd 100644--- a/plugins/dockers/textproperties/TextPropertyConfigDialog.cpp+++ b/plugins/dockers/textproperties/TextPropertyConfigDialog.cpp@@ -20,36 +20,20 @@ TextPropertyConfigDialog::TextPropertyConfigDialog(QWidget *parent)setMinimumSize(500, 300);setModal(true);- m_quickWidget = new QQuickWidget(this);+ m_quickWidget = new KisQQuickWidget(this);this->setMainWidget(m_quickWidget);- m_quickWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);- m_quickWidget->engine()->rootContext()->setContextProperty("mainWindow", this);- m_quickWidget->engine()->rootContext()->setContextObject(new KLocalizedContext(this));- m_quickWidget->engine()->addImportPath(KoResourcePaths::getApplicationRoot() + "/lib/qml/");- m_quickWidget->engine()->addImportPath(KoResourcePaths::getApplicationRoot() + "/lib64/qml/");-- m_quickWidget->engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib/qml/");- m_quickWidget->engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib64/qml/");-- m_quickWidget->setPalette(this->palette());this->setWindowTitle(i18nc("@title:window", "Text Property Configuration"));- m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);m_quickWidget->setSource(QUrl("qrc:/TextPropertyConfigDialog.qml"));if (!m_quickWidget->errors().empty()) {qWarning() << "Errors in " << windowTitle() << ":" << m_quickWidget->errors();}-+ m_quickWidget->setPalette(this->palette());}TextPropertyConfigDialog::~TextPropertyConfigDialog(){- /// Prevent accessing destroyed objects in QML engine- /// See:- /// * https://invent.kde.org/graphics/krita/-/commit/d8676f4e9cac1a8728e73fec3ff1df1763c713b7- /// * https://bugreports.qt.io/browse/QTBUG-81247- m_quickWidget->setParent(nullptr);delete m_quickWidget;}diff --git a/plugins/dockers/textproperties/TextPropertyConfigDialog.h b/plugins/dockers/textproperties/TextPropertyConfigDialog.hindex 35000f0f6d..9d2eee7d19 100644--- a/plugins/dockers/textproperties/TextPropertyConfigDialog.h+++ b/plugins/dockers/textproperties/TextPropertyConfigDialog.h@@ -8,7 +8,7 @@#include <QObject>#include <KoDialog.h>-#include <QQuickWidget>+#include <KisQQuickWidget.h>#include "TextPropertyConfigModel.h"@@ -22,7 +22,7 @@ public:void setTextPropertyConfigModel(TextPropertyConfigModel *model);TextPropertyConfigModel *model();private:- QQuickWidget *m_quickWidget {0};+ KisQQuickWidget *m_quickWidget {0};TextPropertyConfigModel *m_model;};diff --git a/plugins/dockers/textproperties/qml/BaselineShift.qml b/plugins/dockers/textproperties/qml/BaselineShift.qmlindex f18ed131b0..b72764fcda 100644--- a/plugins/dockers/textproperties/qml/BaselineShift.qml+++ b/plugins/dockers/textproperties/qml/BaselineShift.qml@@ -115,7 +115,7 @@ TextPropertyBase {onDValueChanged: if (enabled) baselineShiftUnitCmb.userValue = dValue;palette: baselinePalette.palette;blockUpdateSignalOnDrag: true;- PaletteControl {+ Kis.ThemedControl {id: baselinePalette;}}diff --git a/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml b/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qmlindex 50e29fd1f1..2b999f68ba 100644--- a/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml+++ b/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml@@ -13,9 +13,6 @@ TextPropertyBase {property alias titleItem: titleItemContainer.data;spacing: columnSpacing;- SystemPalette {- id: sysPalette;- }GridLayout {id: grid;@@ -33,7 +30,7 @@ TextPropertyBase {id: collapse;display: AbstractButton.IconOnlyicon.source: contentItemContainer.visible? "qrc:///light_groupOpened.svg" : "qrc:///light_groupClosed.svg";- icon.color: sysPalette.text;+ icon.color: palette.text;icon.width: 12;icon.height: 12;onClicked: contentItemContainer.visible = !contentItemContainer.visible;diff --git a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qmlindex 246a89d6b7..ad06d37bc8 100644--- a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml+++ b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml@@ -7,6 +7,7 @@ import QtQuick 2.15import QtQuick.Layouts 1.15import QtQuick.Controls 2.15import org.krita.flake.text 1.0;+import org.krita.components 1.0 as KisControl {id: styleEdit;@@ -30,14 +31,10 @@ Control {styleTypeCmb.currentIndex = styleTypeCmb.indexOfValue(styleType === "paragraph"? TextPropertyConfigModel.Paragraph: TextPropertyConfigModel.Character);}- PaletteControl {- id: styleEditPalette;+ Kis.ThemedControl {+ id: pal;}- SystemPalette {- id: sysPalette;- colorGroup: styleEditPalette.colorGroup;- }- palette: styleEditPalette.palette;+ palette: pal.palette;background: Rectangle {color: palette.window;diff --git a/plugins/dockers/textproperties/qml/Direction.qml b/plugins/dockers/textproperties/qml/Direction.qmlindex b778c1a71e..73ee056b7a 100644--- a/plugins/dockers/textproperties/qml/Direction.qml+++ b/plugins/dockers/textproperties/qml/Direction.qml@@ -7,6 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.components 1.0 as KisTextPropertyBase {propertyTitle: i18nc("@label:listbox", "Direction");@@ -81,9 +82,8 @@ TextPropertyBase {iconSize: 16;onActivated: direction = currentValue;wheelEnabled: true;- PaletteControl {+ Kis.ThemedControl {id: directionCmbPalette;- colorGroup: directionCmb.enabled? SystemPalette.Active: SystemPalette.Disabled;}palette: directionCmbPalette.palette;}@@ -120,9 +120,8 @@ TextPropertyBase {onActivated: unicodeBidi = currentValue;wheelEnabled: true;- PaletteControl {+ Kis.ThemedControl {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.qmlindex 96c4e0276d..0d178bea07 100644--- a/plugins/dockers/textproperties/qml/FontFamily.qml+++ b/plugins/dockers/textproperties/qml/FontFamily.qml@@ -7,6 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.15import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.components 1.0 as KisCollapsibleGroupProperty {propertyTitle: i18nc("@label", "Font Family");@@ -45,8 +46,7 @@ CollapsibleGroupProperty {Label {id: propertyTitleLabel;text: propertyTitle;- verticalAlignment: Text.AlignVCenter- color: sysPalette.text;+ verticalAlignment: Text.AlignVCenter;elide: Text.ElideRight;Layout.maximumWidth: contentWidth;@@ -61,9 +61,8 @@ CollapsibleGroupProperty {fontFamilies = [ text ];}}- PaletteControl {+ Kis.ThemedControl {id: mainCmbPalette;- colorGroup: parent.enabled? SystemPalette.Active: SystemPalette.Disabled;}palette: mainCmbPalette.palette;function updateCurrentIndex() {@@ -110,9 +109,8 @@ CollapsibleGroupProperty {onActivated: {fontFamilies[fontListDelegate.dIndex] = text;}- PaletteControl {+ Kis.ThemedControl {id: fontCmbPalette;- colorGroup: parent.enabled? SystemPalette.Active: SystemPalette.Disabled;}palette: fontCmbPalette.palette;Component.onCompleted: {diff --git a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml b/plugins/dockers/textproperties/qml/FontResourceDropdown.qmlindex 3d53838731..abc434e204 100644--- a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml+++ b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml@@ -8,6 +8,7 @@ import QtQuick.Controls 2.15import QtQuick.Layouts 1.12import QtQuick.Window 2.15import org.krita.flake.text 1.0+import org.krita.components 1.0 as KisButton {id: familyCmb;@@ -20,6 +21,11 @@ Button {resourceType: "fontfamilies";};+ Kis.ThemedControl {+ id: palControl;+ }+ palette: palControl.palette;+/// Ideally we'd have the max popup height be Window-height - y-pos-of-item-to-window./// But that's pretty hard to calculate (map to global is screen relative, but there's/// no way to get window.y relative to screen), so we'll just use 300 as the maximum.diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qmlindex 68e8a4775a..070090312f 100644--- a/plugins/dockers/textproperties/qml/FontStyle.qml+++ b/plugins/dockers/textproperties/qml/FontStyle.qml@@ -111,8 +111,7 @@ CollapsibleGroupProperty {Label {id: propertyTitleLabel;text: propertyTitle;- verticalAlignment: Text.AlignVCenter- color: sysPalette.text;+ verticalAlignment: Text.AlignVCenter;elide: Text.ElideRight;Layout.maximumWidth: contentWidth;Layout.preferredHeight: implicitHeight;@@ -236,11 +235,11 @@ CollapsibleGroupProperty {Layout.preferredHeight: fontSlantSpn.implicitHeight;Kis.IntSliderSpinBox {id: fontSlantSpn;- suffix: i18nc("@item:valuesuffix", "%")+ suffix: i18nc("@item:valuesuffix", "°")from: -90;to: 90;enabled: fontSlant == CssFontStyleModel.StyleOblique;- PaletteControl {+ Kis.ThemedControl {id: slantSpnPal;}blockUpdateSignalOnDrag: true;diff --git a/plugins/dockers/textproperties/qml/Language.qml b/plugins/dockers/textproperties/qml/Language.qmlindex b02f805491..c8332829b3 100644--- a/plugins/dockers/textproperties/qml/Language.qml+++ b/plugins/dockers/textproperties/qml/Language.qml@@ -8,6 +8,7 @@ import QtQuick.Controls 2.15import QtQuick.Layouts 1.12import QtQuick.Window 2.15import org.krita.flake.text 1.0+import org.krita.components 1.0 as KisTextPropertyBase {propertyTitle: i18nc("@title:group", "Language");@@ -218,9 +219,8 @@ TextPropertyBase {editable: true;- PaletteControl {+ Kis.ThemedControl {id: scriptPalette;- colorGroup: scriptCmb.enabled? SystemPalette.Active: SystemPalette.Disabled;}palette: scriptPalette.palette;diff --git a/plugins/dockers/textproperties/qml/LineHeight.qml b/plugins/dockers/textproperties/qml/LineHeight.qmlindex 642a3db4b8..1f7e99767e 100644--- a/plugins/dockers/textproperties/qml/LineHeight.qml+++ b/plugins/dockers/textproperties/qml/LineHeight.qml@@ -152,7 +152,7 @@ TextPropertyBase {Layout.preferredWidth: symbolWidth.width+leftPadding+rightPadding+spacing+indicator.width;Layout.maximumWidth: implicitWidth;- PaletteControl {+ Kis.ThemedControl {id: lineHeightPalette;}palette: lineHeightPalette.palette;diff --git a/plugins/dockers/textproperties/qml/PaletteControl.qml b/plugins/dockers/textproperties/qml/PaletteControl.qmldeleted file mode 100644index f8c02b1caf..0000000000--- a/plugins/dockers/textproperties/qml/PaletteControl.qml+++ /dev/null@@ -1,64 +0,0 @@-/*- * 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.- This could probably be replaced with Kirigami.Theme if we start using Kirigami.-- You will need to manually setup this control and its color group for each control that can be disabled,- to ensure that the correct palette is retrieved. Qt6 has something more complex for this, where the- active/inactive(unfocused)/disabled palettes can all be set, but in Qt5 this is the best we've got.- */-Control {- id: paletteControl;-- property alias colorGroup: activePalette.colorGroup;- colorGroup: parent && typeof parent != 'undefined'?- parent.enabled?- parent.activeFocus? SystemPalette.Active: SystemPalette.Inactive:- SystemPalette.Disabled:- SystemPalette.Active;-- SystemPalette {- id: activePalette;- colorGroup: SystemPalette.Active;-- onButtonTextChanged: paletteControl.palette.buttonText = buttonText;- }-- 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;-- //Link and LinkVisited are both disabled because they cannot be retrieved from the system palette.- //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;-- // None of the following are available from SystemPalette either...- palette.toolTipBase: activePalette.alternateBase;- palette.toolTipText: activePalette.text;- palette.brightText: Qt.lighter(activePalette.text);-- Component.onCompleted: {- // For some bizare reason, system palette doesn't change properly for button text on load.- // Therefore, we manually need to setup the connection inside this control.- palette.buttonText = activePalette.buttonText;- }--}diff --git a/plugins/dockers/textproperties/qml/ResourceView.qml b/plugins/dockers/textproperties/qml/ResourceView.qmlindex af58d3f896..c28dbaebe5 100644--- a/plugins/dockers/textproperties/qml/ResourceView.qml+++ b/plugins/dockers/textproperties/qml/ResourceView.qml@@ -7,6 +7,7 @@ import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Layouts 1.15import org.krita.flake.text 1.0+import org.krita.components 1.0 as KisControl {id: control;@@ -99,6 +100,7 @@ Control {id: assignToTag;title: i18nc("@title:menu", "Assign to Tag");height: contentChildren.height;+ palette: control.palette;ListView {id: tagAddView;model: tagActionsContextMenu.resourceTaggedModel;@@ -142,17 +144,14 @@ Control {text: i18nc("@action:inmenu", "Remove from this tag");icon.source: "qrc:///16_light_list-remove.svg";icon.color: palette.text;- PaletteControl {- id: pal;- colorGroup: parent.enabled? SystemPalette.Active: SystemPalette.Disabled;- }- palette: pal.palette;+ palette: control.palette;onTriggered: modelWrapper.untagResource(modelWrapper.currentTag, tagActionsContextMenu.resourceIndex);}Menu {id: removeFromTag;title: i18nc("@title:menu", "Remove from other tag");+ palette: control.palette;ListView {id: tagRemoveView;diff --git a/plugins/dockers/textproperties/qml/RevertPropertyButton.qml b/plugins/dockers/textproperties/qml/RevertPropertyButton.qmlindex 13754c2c5d..e45d756069 100644--- a/plugins/dockers/textproperties/qml/RevertPropertyButton.qml+++ b/plugins/dockers/textproperties/qml/RevertPropertyButton.qml@@ -6,6 +6,7 @@import QtQuick 2.15import QtQuick.Controls 2.0import org.krita.flake.text 1.0+import org.krita.components 1.0 as KisItem {width: firstColumnWidth;@@ -23,13 +24,17 @@ Item {id: revert;icon.width: 22;icon.height: 22;- icon.color: sysPalette.text;+ icon.color: palette.text;enabled: revertState !== KoSvgTextPropertiesModel.PropertyUnset && revertState !== KoSvgTextPropertiesModel.PropertyInherited;- opacity: enabled? 1.0: 0.3;display: AbstractButton.IconOnly;icon.source: revertState === KoSvgTextPropertiesModel.PropertyTriState? "qrc:///light_edit-undo-tristate.svg": "qrc:///light_edit-undo.svg";onClicked: parent.clicked();+ Kis.ThemedControl {+ id: buttonPalette;+ }+ palette: buttonPalette.palette;+ToolTip.text: revertState === KoSvgTextPropertiesModel.PropertyTriState? tristateText: setText;ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval;ToolTip.visible: hovered;diff --git a/plugins/dockers/textproperties/qml/SqueezedComboBox.qml b/plugins/dockers/textproperties/qml/SqueezedComboBox.qmlindex 4f6d4fb677..3426593874 100644--- a/plugins/dockers/textproperties/qml/SqueezedComboBox.qml+++ b/plugins/dockers/textproperties/qml/SqueezedComboBox.qml@@ -6,6 +6,7 @@import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Layouts 1.15+import org.krita.components 1.0 as Kis/**This is a QML Interpretation of KisSqueezedComboBox, where the main combobox button is resized and elided,but the pop-up is scaled so all items fit inside.diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qmlindex d33365b0b2..38dd3a942e 100644--- a/plugins/dockers/textproperties/qml/TextProperties.qml+++ b/plugins/dockers/textproperties/qml/TextProperties.qml@@ -7,22 +7,20 @@ import QtQuick 2.0import QtQuick.Controls 2.5import QtQuick.Layouts 1.12import org.krita.flake.text 1.0+import org.krita.components 1.0 as Kis--Rectangle {+Control {id: root;- color: sysPalette.window;anchors.fill: parent;property TextPropertyConfigModel configModel : textPropertyConfigModel;property double canvasDPI: 72.0;-- PaletteControl {- id: paletteControl;+ Kis.ThemedControl {+ id: pal;}- SystemPalette {- id: sysPalette;- colorGroup: paletteControl.colorGroup;+ palette: pal.palette;+ background: Rectangle {+ color: palette.window;}function setProperties() {@@ -41,7 +39,6 @@ Rectangle {anchors.right: parent.right;anchors.left: parent.left;anchors.top: parent.top;- palette: paletteControl.palette;TabButton {text: i18nc("@title:tab", "Character")}@@ -79,7 +76,6 @@ Rectangle {resourceType: "css_styles";Layout.fillHeight: true;Layout.fillWidth: true;- palette: paletteControl.palette;signal applyPreset;onApplyPreset: {@@ -93,6 +89,7 @@ Rectangle {width: ListView.view.width;highlighted: delegateMouseArea.containsMouse;property bool selected: presetView.currentIndex === model.index;+ palette: presetView.palette;contentItem: KoShapeQtQuickLabel {implicitHeight: nameLabel.height * 4;padding: nameLabel.height;@@ -130,7 +127,7 @@ Rectangle {}background: Rectangle {color: presetDelegate.highlighted? presetDelegate.palette.highlight: "transparent";- border.color: presetDelegate.selected? presetDelegate.palette.highlight: presetDelegate.palette.base;+ border.color: presetDelegate.selected? presetDelegate.palette.highlight: presetDelegate.palette.mid;border.width: presetDelegate.selected? 2: 1;}@@ -189,7 +186,7 @@ Rectangle {icon.height: 16;onClicked: mainWindow.editPreset(presetView.currentResource);hoverEnabled: true;- PaletteControl {+ Kis.ThemedControl {id: editPalette;}palette: editPalette.palette;@@ -208,7 +205,7 @@ Rectangle {icon.height: 16;onClicked: mainWindow.cloneAndEditPreset(presetView.currentResource);hoverEnabled: true;- PaletteControl {+ Kis.ThemedControl {id: cloneButtonPalette;}palette: cloneButtonPalette.palette;diff --git a/plugins/dockers/textproperties/qml/TextPropertyBase.qml b/plugins/dockers/textproperties/qml/TextPropertyBase.qmlindex d4afbe2627..d062b95532 100644--- a/plugins/dockers/textproperties/qml/TextPropertyBase.qml+++ b/plugins/dockers/textproperties/qml/TextPropertyBase.qml@@ -6,6 +6,7 @@import QtQuick 2.15import QtQuick.Controls 2.15import org.krita.flake.text 1.0+import org.krita.components 1.0 as KisColumn {id: root;@@ -61,8 +62,7 @@ Column {children.push(seperator);}- property PaletteControl propertyBasePalette: PaletteControl {- colorGroup: enabled? SystemPalette.Active: SystemPalette.Disabled;+ property Kis.ThemedControl propertyBasePalette: Kis.ThemedControl {}MenuSeparator {diff --git a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qmlindex 9be69cc8cb..58ef2f9af5 100644--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml@@ -8,6 +8,7 @@ import QtQuick.Controls 2.15import QtQuick.Layouts 1.15import QtQml.Models 2.1import org.krita.flake.text 1.0+import org.krita.components 1.0 as KisColumnLayout {id: propertyBaseList;@@ -146,9 +147,8 @@ ColumnLayout {clip: true;padding: 0;- PaletteControl {+ Kis.ThemedControl {id: paletteControl;- colorGroup: frame.enabled? SystemPalette.Active: SystemPalette.Disabled;}palette: paletteControl.palette;@@ -297,9 +297,8 @@ ColumnLayout {displayText: i18nc("@label:listbox", "Add Property");onPopupChanged: if (!addPropertyCmb.popup.visible) { propertySearch.text = ""; }- PaletteControl {+ Kis.ThemedControl {id: cmbPalette;- colorGroup: addPropertyCmb.enabled? SystemPalette.Active: SystemPalette.Disabled;}palette: cmbPalette.palette;@@ -356,9 +355,8 @@ ColumnLayout {required property string toolTip;contentItem: Label {enabled: addPropertyDelegate.enabled;- PaletteControl {+ Kis.ThemedControl {id: addPropertyPalette;- colorGroup: parent.enabled? SystemPalette.Active: SystemPalette.Disabled;}palette: addPropertyPalette.palette;color: addPropertyDelegate.highlighted? palette.highlightedText: palette.text;diff --git a/plugins/dockers/textproperties/qml/TextPropertyConfigDialog.qml b/plugins/dockers/textproperties/qml/TextPropertyConfigDialog.qmlindex b617c48f85..1e73fac7a9 100644--- a/plugins/dockers/textproperties/qml/TextPropertyConfigDialog.qml+++ b/plugins/dockers/textproperties/qml/TextPropertyConfigDialog.qml@@ -7,6 +7,7 @@ import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Layouts 1.15import org.krita.flake.text 1.0+import org.krita.components 1.0 as Kis/**This should be a dialog, but because qml doesn't get proper dialog handling till 6.8,@@ -20,16 +21,12 @@ Control {defaultVisibilityCmb.currentIndex = defaultVisibilityCmb.indexOfValue(configModel.defaultVisibilityState);}- PaletteControl {- id: paletteControl;- colorGroup: control.enabled? SystemPalette.Active: SystemPalette.Disabled;+ Kis.ThemedControl {+ id: pal;}-- palette: paletteControl.palette;-+ palette: pal.palette;background: Rectangle {color: palette.window;- anchors.fill: parent;}ColumnLayout {@@ -53,6 +50,7 @@ Control {textRole: "text";valueRole: "value";+ palette: control.palette;Layout.preferredWidth: implicitWidth;onActivated: {if (control.configModel) {@@ -68,7 +66,7 @@ Control {Layout.fillHeight: true;padding: 0;background: Rectangle {- color: palette.base;+ color: control.palette.base;}ListView {@@ -90,7 +88,7 @@ Control {palette: control.palette;background: Rectangle {- color: "transparent";+ visible: false;}contentItem: RowLayout {diff --git a/plugins/dockers/textproperties/textproperties.qrc b/plugins/dockers/textproperties/textproperties.qrcindex ca48440441..c8a760c865 100644--- a/plugins/dockers/textproperties/textproperties.qrc+++ b/plugins/dockers/textproperties/textproperties.qrc@@ -42,7 +42,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><file alias="SqueezedComboBox.qml">qml/SqueezedComboBox.qml</file><file alias="OpenTypeFeatureSettings.qml">qml/OpenTypeFeatureSettings.qml</file><file alias="OpenTypeFeatureDelegate.qml">qml/OpenTypeFeatureDelegate.qml</file>diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml b/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qmlindex f29c691781..3a26fbf12f 100644--- a/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphDelegate.qml@@ -6,70 +6,96 @@import QtQuick 2.15import QtQuick.Controls 2.5import org.krita.tools.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as Kis-SvgTextLabel {- id: glyphLabel;- openTypeFeatures: model.openType;- text: model.display;- padding: height/8;- clip: true;-- property alias hovered: glyphMouseArea.containsMouse;+Control {+ id: root;width: GridView.view.cellWidth;height: GridView.view.cellHeight;- property bool currentItem: GridView.isCurrentItem;+ property alias fontFamilies: glyphLabel.fontFamilies;+ property alias fontSize: glyphLabel.fontSize;+ property alias fontStyle: glyphLabel.fontStyle;+ property alias fontWeight: glyphLabel.fontWeight;+ property alias fontWidth: glyphLabel.fontWidth;+ property alias fontSlant: glyphLabel.fontSlant;+ property alias fontAxesValues: glyphLabel.fontAxesValues;+ property alias language: glyphLabel.language;+ property alias fillColor: glyphLabel.fillColor;+ property alias textColor: glyphLabel.textColor;++ required property var model;+ required property int index;++ Kis.ThemedControl {+ id: pal;+ }+ palette: pal.palette;++ background: Rectangle {+ color: hovered? root.palette.highlight: root.palette.base;+ }signal glyphClicked(int index, QtObject mouse);signal glyphDoubleClicked(int index, QtObject mouse);+ property bool currentItem: GridView.isCurrentItem;- Rectangle {+ Kis.SvgTextLabel {+ id: glyphLabel;+ openTypeFeatures: model.openType;+ text: model.display;+ padding: height/8;anchors.fill: parent;- color: "transparent";- border.color: parent.currentItem? sysPalette.highlight: sysPalette.alternateBase;- border.width: parent.currentItem? 2: 1;- }- Rectangle {- anchors.top: parent.top;- anchors.left: parent.left;- color: sysPalette.text;- opacity: 0.6;- layer.enabled: true- width: childrenRect.width;- height: childrenRect.height;- Text {- padding: 2;- text: model.glyphLabel;- color: sysPalette.base;- font.pointSize: 9;+ clip: true;+ textColor: hovered? root.palette.highlightedText: root.palette.text;++++ Rectangle {+ anchors.fill: parent;+ color: "transparent";+ border.color: parent.currentItem? root.palette.highlight: root.palette.mid;+ border.width: parent.currentItem? 2: 1;+ }+ Rectangle {+ anchors.top: parent.top;+ anchors.left: parent.left;+ color: root.palette.highlightedText;+ opacity: 0.6;+ layer.enabled: true+ width: childrenRect.width;+ height: childrenRect.height;+ Text {+ padding: 2;+ text: model.glyphLabel;+ color: root.palette.highlight;+ font.pointSize: 9;+ }+ visible: root.hovered;+ }+ Rectangle {+ anchors.top: parent.top;+ anchors.right: parent.right;+ width: 8;+ height: 8;+ radius: 4;+ color: parent.textColor;+ opacity: 0.3;+ visible: model.childCount > 1;}- visible: parent.hovered;- }- Rectangle {- anchors.top: parent.top;- anchors.right: parent.right;- width: 8;- height: 8;- radius: 4;- color: parent.textColor;- opacity: 0.3;- visible: model.childCount > 1;}-MouseArea {anchors.fill: parent;id: glyphMouseAreaonClicked: (mouse)=>{- parent.GridView.view.currentIndex = index;- glyphClicked(index, mouse);- }+ root.GridView.view.currentIndex = index;+ glyphClicked(index, mouse);+ }onDoubleClicked: (mouse)=>{- parent.GridView.view.currentIndex = index;- glyphDoubleClicked(index, mouse);- }- hoverEnabled: true;+ root.GridView.view.currentIndex = index;+ glyphDoubleClicked(index, mouse);+ }ToolTip.text: model.toolTip;ToolTip.visible: containsMouse;ToolTip.delay: 1000;diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml b/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qmlindex 9ad62c0194..5ba34c515c 100644--- a/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphPalette.qml@@ -8,8 +8,9 @@ import QtQml.Models 2.15import QtQuick.Controls 2.5import QtQuick.Layouts 1.15import org.krita.tools.text 1.0+import org.krita.components 1.0 as Kis-Rectangle {+Control {id: root;anchors.fill: parent;property QtObject model: glyphModel;@@ -24,11 +25,14 @@ Rectangle {property double fontSlant: 0.0;property var fontAxesValues: ({});property string language: "";- SystemPalette {- id: sysPalette;- colorGroup: SystemPalette.Active++ Kis.ThemedControl {+ id: pal;+ }+ palette: pal.palette;+ background: Rectangle {+ color: root.palette.window;}- color: sysPalette.windowTabBar {id: tabs;@@ -76,28 +80,36 @@ Rectangle {Layout.fillHeight: true;Layout.fillWidth: true;spacing: 1;- ListView {- id: charMapFilter- model: root.charMapModel.blockLabels;++ Frame {Layout.minimumWidth: 100;Layout.maximumWidth: 200;Layout.fillHeight: true;Layout.fillWidth: true;-- onCurrentIndexChanged: {- root.charMapModel.blockFilter = currentIndex;+ background: Rectangle {+ color: root.palette.base;}+ ListView {+ id: charMapFilter+ model: root.charMapModel.blockLabels;+ anchors.fill: parent;- clip: true;- delegate: ItemDelegate {- width: charMapFilter !== undefined? charMapFilter.width: 0;- text: modelData.name;- highlighted: ListView.isCurrentItem;- onClicked: {- charMapFilter.currentIndex = modelData.value;+ onCurrentIndexChanged: {+ root.charMapModel.blockFilter = currentIndex;+ }++ clip: true;+ delegate: ItemDelegate {+ width: charMapFilter !== undefined? charMapFilter.width: 0;+ text: modelData.name;+ highlighted: ListView.isCurrentItem;+ onClicked: {+ charMapFilter.currentIndex = modelData.value;+ }+ palette: root.palette;+ }+ ScrollBar.vertical: ScrollBar {}- }- ScrollBar.vertical: ScrollBar {}}@@ -107,8 +119,6 @@ Rectangle {Layout.fillHeight: true;Layout.fillWidth: true;--TextField {id: searchInput;onTextEdited: {@@ -126,41 +136,48 @@ Rectangle {ToolTip.visible: hovered;}- GridView {- id: charMap;- model: root.charMapModel;- focus: true;- clip: true;+ Frame {Layout.fillHeight: true;Layout.fillWidth: true;-- cellWidth: (width - charMapScroll.implicitBackgroundWidth)/8;- cellHeight: cellWidth;-- delegate: GlyphDelegate {- textColor: hovered? sysPalette.highlightedText: sysPalette.text;- fillColor: hovered? sysPalette.highlight: sysPalette.base;- fontFamilies: root.fontFamilies;- fontSize: root.fontSize;- fontStyle: root.fontStyle;- fontWeight: root.fontWeight;- language: root.language;- fontWidth: root.fontWidth;- fontSlant: root.fontSlant;- fontAxesValues: root.fontAxesValues === undefined? {}: root.fontAxesValues;- onGlyphDoubleClicked: (index, mouse)=> {- mainWindow.slotInsertRichText(index, -1, false, true)- };- onGlyphClicked: (index, mouse)=> {- if (model.childCount > 1){- var entryPos = mapToItem(root, 0+width, 0);- mainWindow.slotShowPopupPalette(index, entryPos.x, entryPos.y, width, height)- }- }+ background: Rectangle {+ color: root.palette.base;}+ padding:0;+ GridView {+ id: charMap;+ model: root.charMapModel;+ focus: true;+ clip: true;+ anchors.fill: parent;+++ cellWidth: (width - charMapScroll.implicitBackgroundWidth)/8;+ cellHeight: cellWidth;++ delegate: GlyphDelegate {+ fillColor: "transparent";+ fontFamilies: root.fontFamilies;+ fontSize: root.fontSize;+ fontStyle: root.fontStyle;+ fontWeight: root.fontWeight;+ language: root.language;+ fontWidth: root.fontWidth;+ fontSlant: root.fontSlant;+ fontAxesValues: root.fontAxesValues === undefined? {}: root.fontAxesValues;+ onGlyphDoubleClicked: (index, mouse)=> {+ mainWindow.slotInsertRichText(index, -1, false, true)+ };+ onGlyphClicked: (index, mouse)=> {+ if (model.childCount > 1){+ var entryPos = mapToItem(root, 0+width, 0);+ mainWindow.slotShowPopupPalette(index, entryPos.x, entryPos.y, width, height)+ }+ }+ }- ScrollBar.vertical: ScrollBar {- id: charMapScroll;+ ScrollBar.vertical: ScrollBar {+ id: charMapScroll;+ }}}}diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAltPopup.cpp b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAltPopup.cppindex 7c2625236f..3d27c97bb7 100644--- a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAltPopup.cpp+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAltPopup.cpp@@ -30,14 +30,13 @@ GlyphPaletteAltPopup::GlyphPaletteAltPopup(QWidget *parent)m_quickWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);- m_quickWidget->setPalette(this->palette());-m_quickWidget->setSource(QUrl("qrc:/GlyphPaletteAlts.qml"));if (!m_quickWidget->errors().empty()) {qWarning() << "Errors in " << windowTitle() << ":" << m_quickWidget->errors();} else if (m_quickWidget->rootObject()){m_quickWidget->rootObject()->setProperty("columns", QVariant::fromValue(3));}+ m_quickWidget->setPalette(this->palette());}GlyphPaletteAltPopup::~GlyphPaletteAltPopup()diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAlts.qml b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAlts.qmlindex ef4fe3e473..4a7b6e62c2 100644--- a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAlts.qml+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteAlts.qml@@ -7,8 +7,9 @@ import QtQuick 2.15import QtQuick.Controls 2.5import QtQml.Models 2.15import org.krita.tools.text 1.0+import org.krita.components 1.0 as Kis-Rectangle {+Control {id: root;property QtObject glyphModel;property int parentIndex: 0;@@ -24,12 +25,15 @@ Rectangle {property double fontSlant: 0.0;property var fontAxesValues;property string language: "";- SystemPalette {- id: sysPalette;- colorGroup: SystemPalette.Active++ Kis.ThemedControl {+ id: pal;}+ palette: pal.palette;- color: sysPalette.base;+ background: Rectangle {+ color: root.palette.base;+ }GridView {anchors.fill: parent;@@ -46,8 +50,7 @@ Rectangle {}delegate: GlyphDelegate {- textColor: hovered? sysPalette.highlightedText: sysPalette.text;- fillColor: hovered? sysPalette.highlight: sysPalette.base;+ fillColor: "transparent";fontFamilies: root.fontFamilies;fontSize: root.fontSize;fontStyle: root.fontStyle;diff --git a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cppindex e4d80ea058..a729b6b8c4 100644--- a/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp+++ b/plugins/tools/svgtexttool/glyphpalette/GlyphPaletteDialog.cpp@@ -29,7 +29,6 @@ GlyphPaletteDialog::GlyphPaletteDialog(QWidget *parent)this->setMainWidget(m_quickWidget);m_quickWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);- m_quickWidget->setPalette(this->palette());this->setWindowTitle(i18nc("@title:window", "Glyph Palette"));m_charMapModel->setSourceModel(m_model);@@ -44,6 +43,7 @@ GlyphPaletteDialog::GlyphPaletteDialog(QWidget *parent)qWarning() << "Errors in " << windowTitle() << ":" << m_quickWidget->errors();}connect(m_altPopup, SIGNAL(sigInsertRichText(int,int,bool,bool)), this, SLOT(slotInsertRichText(int,int,bool,bool)));+ m_quickWidget->setPalette(this->palette());}GlyphPaletteDialog::~GlyphPaletteDialog()diff --git a/qmlmodules/components/CMakeLists.txt b/qmlmodules/components/CMakeLists.txtindex 62bb66c489..34aa9508df 100644--- a/qmlmodules/components/CMakeLists.txt+++ b/qmlmodules/components/CMakeLists.txt@@ -17,6 +17,8 @@ if (QT_MAJOR_VERSION STREQUAL "6")KisNumParser.hKisCubicCurveQMLWrapper.cppKisCubicCurveQMLWrapper.h+ KisTheme.cpp+ KisTheme.h)else ()@@ -36,6 +38,8 @@ else ()KisNumParser.hKisCubicCurveQMLWrapper.cppKisCubicCurveQMLWrapper.h+ KisTheme.cpp+ KisTheme.h)endif ()@@ -69,6 +73,7 @@ ecm_target_qml_sources(kritaqmlcomponents SOURCESqml/button/GroupButton.qmlqml/button/OptionButtonStrip.qml+ qml/ThemedControl.qmlqml/IntParseSpinBox.qmlqml/DoubleSpinBox.qmlqml/DoubleParseSpinBox.qmldiff --git a/qmlmodules/components/KisTheme.cpp b/qmlmodules/components/KisTheme.cppnew file mode 100644index 0000000000..6ef36905c5--- /dev/null+++ b/qmlmodules/components/KisTheme.cpp@@ -0,0 +1,169 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+#include "KisTheme.h"+#include <QApplication>+#include <kis_config_notifier.h>+#include <lager/state.hpp>++namespace {+auto getForeground = [](KColorScheme::ForegroundRole id) { return lager::lenses::getset(+ [id](const KColorScheme &value) -> QColor {+ return value.foreground(id).color();+ }, [id](KColorScheme value, const QColor &color) -> KColorScheme {return value;}+ );+};++auto getBackground = [](KColorScheme::BackgroundRole id) { return lager::lenses::getset(+ [id](const KColorScheme &value) -> QColor {+ return value.background(id).color();+ }, [id](KColorScheme value, const QColor &color) -> KColorScheme {return value;}+ );+};++auto getDecorations = [](KColorScheme::DecorationRole id) { return lager::lenses::getset(+ [id](const KColorScheme &value) -> QColor {+ return value.decoration(id).color();+ }, [id](KColorScheme value, const QColor &color) -> KColorScheme {return value;}+ );+};++auto getShade = [](KColorScheme::ShadeRole id) { return lager::lenses::getset(+ [id](const KColorScheme &value) -> QColor {+ return value.shade(id);+ }, [id](KColorScheme value, const QColor &color) -> KColorScheme {return value;}+ );+};+}+++KisThemeColorGroup::KisThemeColorGroup(KColorScheme::ColorSet _set, QObject *parent)+ : QObject(parent)+ , m_set(_set)+ , m_active(KColorScheme(QPalette::Active, m_set))+ , m_inactive(KColorScheme(QPalette::Inactive, m_set))+ , m_disabled(KColorScheme(QPalette::Disabled, m_set))+ , scheme(lager::make_state(KColorScheme(QPalette::Active, _set), lager::automatic_tag{}))+ , LAGER_QT(textColor) {scheme.zoom(getForeground(KColorScheme::NormalText))}+ , LAGER_QT(disabledTextColor) {scheme.zoom(getForeground(KColorScheme::InactiveText))}+ , LAGER_QT(activeTextColor) {scheme.zoom(getForeground(KColorScheme::ActiveText))}+ , LAGER_QT(linkColor) {scheme.zoom(getForeground(KColorScheme::LinkText))}+ , LAGER_QT(visitedLinkColor) {scheme.zoom(getForeground(KColorScheme::VisitedText))}+ , LAGER_QT(negativeTextColor) {scheme.zoom(getForeground(KColorScheme::NegativeText))}+ , LAGER_QT(neutralTextColor) {scheme.zoom(getForeground(KColorScheme::NeutralText))}+ , LAGER_QT(positiveTextColor) {scheme.zoom(getForeground(KColorScheme::PositiveText))}+ , LAGER_QT(backgroundColor) {scheme.zoom(getBackground(KColorScheme::NormalBackground))}+ , LAGER_QT(activeBackgroundColor) {scheme.zoom(getBackground(KColorScheme::ActiveBackground))}+ , LAGER_QT(linkBackgroundColor) {scheme.zoom(getBackground(KColorScheme::LinkBackground))}+ , LAGER_QT(visitedLinkBackgroundColor) {scheme.zoom(getBackground(KColorScheme::VisitedBackground))}+ , LAGER_QT(negativeBackgroundColor) {scheme.zoom(getBackground(KColorScheme::NegativeBackground))}+ , LAGER_QT(neutralBackgroundColor) {scheme.zoom(getBackground(KColorScheme::NeutralBackground))}+ , LAGER_QT(positiveBackgroundColor) {scheme.zoom(getBackground(KColorScheme::PositiveBackground))}+ , LAGER_QT(alternateBackgroundColor) {scheme.zoom(getBackground(KColorScheme::AlternateBackground))}+ , LAGER_QT(focusColor) {scheme.zoom(getDecorations(KColorScheme::FocusColor))}+ , LAGER_QT(hoverColor) {scheme.zoom(getDecorations(KColorScheme::HoverColor))}+ , LAGER_QT(lightShadeColor) {scheme.zoom(getShade(KColorScheme::LightShade))}+ , LAGER_QT(midLightShadeColor) {scheme.zoom(getShade(KColorScheme::MidlightShade))}+ , LAGER_QT(midShadeColor) {scheme.zoom(getShade(KColorScheme::MidShade))}+ , LAGER_QT(darkShadeColor) {scheme.zoom(getShade(KColorScheme::DarkShade))}+ , LAGER_QT(shadowShadeColor) {scheme.zoom(getShade(KColorScheme::ShadowShade))}+{+ connect(this, SIGNAL(stateChanged()), this, SLOT(updateState()));+ lager::watch(scheme, std::bind(&KisThemeColorGroup::schemeChanged, this));+}++KisThemeColorGroup::~KisThemeColorGroup()+{+}++void KisThemeColorGroup::updateColorScheme(const QString filename)+{+ KSharedConfigPtr config = KSharedConfig::openConfig(filename);+ m_active = KColorScheme(QPalette::Active, m_set, config);+ m_inactive = KColorScheme(QPalette::Inactive, m_set, config);+ m_disabled = KColorScheme(QPalette::Disabled, m_set, config);++ updateState();+}++void KisThemeColorGroup::setState(int newState)+{+ if (m_state == QPalette::ColorGroup(newState)) return;+ m_state = QPalette::ColorGroup(newState);+ Q_EMIT stateChanged();+}++int KisThemeColorGroup::state()+{+ return int(m_state);+}++void KisThemeColorGroup::updateState()+{+ if (m_state == QPalette::Inactive) {+ scheme.set(m_inactive);+ } else if (m_state == QPalette::Disabled) {+ scheme.set(m_disabled);+ } else {+ scheme.set(m_active);+ }+}++KisTheme::KisTheme(QObject *parent)+ : QObject(parent)+ , viewModel(KisThemeColorGroup(KColorScheme::View, this))+ , windowModel(KisThemeColorGroup(KColorScheme::Window, this))+ , buttonModel(KisThemeColorGroup(KColorScheme::Button, this))+ , selectionModel(KisThemeColorGroup(KColorScheme::Selection, this))+ , tooltipModel(KisThemeColorGroup(KColorScheme::Tooltip, this))+{+ slotUpdateThemes();++ connect(KisConfigNotifier::instance(), SIGNAL(signalColorThemeChanged(QString)), this, SLOT(slotUpdateThemes()));++ connect(&viewModel, SIGNAL(schemeChanged()), this, SIGNAL(viewChanged()));+ connect(&windowModel, SIGNAL(schemeChanged()), this, SIGNAL(windowChanged()));+ connect(&buttonModel, SIGNAL(schemeChanged()), this, SIGNAL(buttonChanged()));+ connect(&selectionModel, SIGNAL(schemeChanged()), this, SIGNAL(selectionChanged()));+ connect(&tooltipModel, SIGNAL(schemeChanged()), this, SIGNAL(tooltipChanged()));+}++KisThemeColorGroup *KisTheme::view()+{+ return &this->viewModel;+}++KisThemeColorGroup *KisTheme::window()+{+ return &this->windowModel;+}++KisThemeColorGroup *KisTheme::button()+{+ return &this->buttonModel;+}++KisThemeColorGroup *KisTheme::selection()+{+ return &this->selectionModel;+}++KisThemeColorGroup *KisTheme::tooltip()+{+ return &this->tooltipModel;+}++void KisTheme::slotUpdateThemes()+{+ const QString filename = qApp->property("KDE_COLOR_SCHEME_PATH").toString();++ viewModel.updateColorScheme(filename);+ windowModel.updateColorScheme(filename);+ buttonModel.updateColorScheme(filename);+ selectionModel.updateColorScheme(filename);+ tooltipModel.updateColorScheme(filename);+}++diff --git a/qmlmodules/components/KisTheme.h b/qmlmodules/components/KisTheme.hnew file mode 100644index 0000000000..37c2223c87--- /dev/null+++ b/qmlmodules/components/KisTheme.h@@ -0,0 +1,124 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+#ifndef KISTHEME_H+#define KISTHEME_H++#include <QObject>+#include <QQmlEngine>+#include <lager/cursor.hpp>+#include <lager/extra/qt.hpp>+#include <kcolorscheme.h>++class KisThemeColorGroup : public QObject+{+ Q_OBJECT+ QML_UNCREATABLE("Use Theme instead")+ Q_PROPERTY(int state READ state WRITE setState NOTIFY stateChanged)+public:+ KisThemeColorGroup(KColorScheme::ColorSet _set = KColorScheme::View, QObject *parent = nullptr);+ ~KisThemeColorGroup();++ lager::cursor<KColorScheme> scheme;+ LAGER_QT_READER(int, colorSet);++ // Foreground roles: used for text.+ LAGER_QT_READER(QColor, textColor);+ LAGER_QT_READER(QColor, disabledTextColor);+ LAGER_QT_READER(QColor, activeTextColor);++ LAGER_QT_READER(QColor, linkColor);+ LAGER_QT_READER(QColor, visitedLinkColor);++ LAGER_QT_READER(QColor, negativeTextColor);+ LAGER_QT_READER(QColor, neutralTextColor);+ LAGER_QT_READER(QColor, positiveTextColor);++ // Background roles: used for backgrounds.+ LAGER_QT_READER(QColor, backgroundColor);+ LAGER_QT_READER(QColor, activeBackgroundColor);++ LAGER_QT_READER(QColor, linkBackgroundColor);+ LAGER_QT_READER(QColor, visitedLinkBackgroundColor);++ LAGER_QT_READER(QColor, negativeBackgroundColor);+ LAGER_QT_READER(QColor, neutralBackgroundColor);+ LAGER_QT_READER(QColor, positiveBackgroundColor);++ LAGER_QT_READER(QColor, alternateBackgroundColor);++ // Decoration roles: used for borders.+ LAGER_QT_READER(QColor, focusColor);+ LAGER_QT_READER(QColor, hoverColor);++ // Shade roles: used for 3d elements like bevels.++ LAGER_QT_READER(QColor, lightShadeColor);+ LAGER_QT_READER(QColor, midLightShadeColor);+ LAGER_QT_READER(QColor, midShadeColor);+ LAGER_QT_READER(QColor, darkShadeColor);+ LAGER_QT_READER(QColor, shadowShadeColor);++ void updateColorScheme(const QString filename);+ void setState(int newState);+ int state();+private Q_SLOTS:+ void updateState();++Q_SIGNALS:+ void schemeChanged();+ void stateChanged();+private:+ KColorScheme::ColorSet m_set = KColorScheme::Window;+ QPalette::ColorGroup m_state = QPalette::Active;++ KColorScheme m_active;+ KColorScheme m_inactive;+ KColorScheme m_disabled;+};++/**+ * @brief The KisTheme class+ *+ * This class both handles retrieving colors from KColorScheme, as well+ * as listening to theme changes, simplifying theme updates.+ */++class KisTheme : public QObject+{+ Q_OBJECT++ Q_PROPERTY(KisThemeColorGroup *view READ view() NOTIFY viewChanged())+ Q_PROPERTY(KisThemeColorGroup *window READ window() NOTIFY windowChanged())+ Q_PROPERTY(KisThemeColorGroup *button READ button() NOTIFY buttonChanged())+ Q_PROPERTY(KisThemeColorGroup *selection READ selection() NOTIFY selectionChanged())+ Q_PROPERTY(KisThemeColorGroup *tooltip READ tooltip() NOTIFY tooltipChanged())++ QML_NAMED_ELEMENT(Theme)+public:+ KisTheme(QObject *parent = nullptr);++ KisThemeColorGroup viewModel;+ KisThemeColorGroup windowModel;+ KisThemeColorGroup buttonModel;+ KisThemeColorGroup selectionModel;+ KisThemeColorGroup tooltipModel;++ KisThemeColorGroup *view();+ KisThemeColorGroup *window();+ KisThemeColorGroup *button();+ KisThemeColorGroup *selection();+ KisThemeColorGroup *tooltip();+private Q_SLOTS:+ void slotUpdateThemes();+Q_SIGNALS:+ void viewChanged();+ void windowChanged();+ void buttonChanged();+ void selectionChanged();+ void tooltipChanged();+};++#endif // KISTHEME_Hdiff --git a/qmlmodules/components/KritaQmlComponentsPlugin.cpp b/qmlmodules/components/KritaQmlComponentsPlugin.cppindex a4384dcdbd..de9e4b191f 100644--- a/qmlmodules/components/KritaQmlComponentsPlugin.cpp+++ b/qmlmodules/components/KritaQmlComponentsPlugin.cpp@@ -12,6 +12,7 @@#include <SvgTextLabel.h>#include <KisNumParser.h>#include <KisCubicCurveQMLWrapper.h>+#include <KisTheme.h>#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)#error "This plugin implementation is to be used with Qt5 only!\n"@@ -38,6 +39,8 @@ void KritaQmlComponentsPlugin::registerTypes(const char *uri)qmlRegisterType<SvgTextLabel>(uri, 1, 0, "SvgTextLabel");qmlRegisterType<KisNumParser>(uri, 1, 0, "KisNumParser");qmlRegisterType<KisCubicCurveQml>(uri, 1, 0, "KisCubicCurve");+ qmlRegisterType<KisTheme>(uri, 1, 0, "Theme");+ qmlRegisterUncreatableType<KisThemeColorGroup>(uri, 1, 0, "ThemeColorGroup", "Use Theme instead");}#include "KritaQmlComponentsPlugin.moc"diff --git a/qmlmodules/components/SvgTextLabel.cpp b/qmlmodules/components/SvgTextLabel.cppindex c82519f024..c79dff88f5 100644--- a/qmlmodules/components/SvgTextLabel.cpp+++ b/qmlmodules/components/SvgTextLabel.cpp@@ -240,7 +240,7 @@ void SvgTextLabel::setTextColor(QColor textColor)d->shape->setBackground(QSharedPointer<KoColorBackground>(new KoColorBackground(textColor)));d->props.setProperty(KoSvgTextProperties::FillId, d->shape->textProperties().property(KoSvgTextProperties::FillId));emit textColorChanged(textColor);- if (!opaquePainting() && isComponentComplete() && isVisible()) {+ if (!opaquePainting() && isComponentComplete()) {update(boundingRect().toAlignedRect());}}@@ -300,7 +300,6 @@ void SvgTextLabel::componentComplete()d->shape->setResolution(pixelRatio*72, pixelRatio*72);}setOpaquePainting(fillColor().alpha() == 255);- updateShape();if (!d->shapePainter) {d->shapePainter.reset(new KoShapePainter());if (!d->shape->boundingRect().isEmpty()) {@@ -308,6 +307,7 @@ void SvgTextLabel::componentComplete()d->addedShapeToPainter = true;}}+ updateShape();}QRectF SvgTextLabel::minimumRect() constdiff --git a/qmlmodules/components/qml/ThemedControl.qml b/qmlmodules/components/qml/ThemedControl.qmlnew file mode 100644index 0000000000..508720d0f0--- /dev/null+++ b/qmlmodules/components/qml/ThemedControl.qml@@ -0,0 +1,55 @@+/*+ * 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+import org.krita.components 1.0 as Kis++/**+ Dummy Control to work around QQuickPalette and QPalette being two completely different things.+ This could probably be replaced with Kirigami.Theme if we start using Kirigami.++ You will need to manually setup this control and its color group for each control that can be disabled,+ to ensure that the correct palette is retrieved. Qt6 has something more complex for this, where the+ active/inactive(unfocused)/disabled palettes can all be set, but in Qt5 this is the best we've got.+ */+Control {+ id: themedControl;++ // There doesn't seem to be any relevant difference between inactive and active, so we don't bother distinguishing between them.+ property int colorGroup: enabled? SystemPalette.Active: SystemPalette.Disabled;++ property Kis.Theme theme: Kis.Theme {+ window.state: colorGroup;+ view.state: colorGroup;+ button.state: colorGroup;+ selection.state: colorGroup;+ tooltip.state: colorGroup;+ }++ palette.alternateBase: theme.view.alternateBackgroundColor;+ palette.base: theme.view.backgroundColor;+ palette.button: theme.button.backgroundColor;+ palette.buttonText: theme.button.textColor;+ palette.dark: theme.window.darkShadeColor;+ palette.highlight: theme.selection.backgroundColor;+ palette.highlightedText: theme.selection.textColor;+ palette.light: theme.window.lightShadeColor;+++ palette.mid: theme.window.midShadeColor;+ palette.midlight: theme.window.midlightShadeColor;+ palette.shadow: theme.window.shadowShadeColor;+ palette.text: theme.view.textColor;+ palette.window: theme.window.backgroundColor;+ palette.windowText: theme.window.textColor;++ palette.link: theme.view.linkColor;+ palette.linkVisited: theme.view.linkVisitedColor;+ palette.toolTipBase: theme.tooltip.backgroundColor;+ palette.toolTipText: theme.tooltip.textColor;+ palette.brightText: Qt.lighter(theme.view.textColor);++}diff --git a/qmlmodules/components/qml/button/GroupButton.qml b/qmlmodules/components/qml/button/GroupButton.qmlindex acec104f1a..9340b29eb4 100644--- a/qmlmodules/components/qml/button/GroupButton.qml+++ b/qmlmodules/components/qml/button/GroupButton.qml@@ -5,7 +5,7 @@*/import QtQuick 2.15import QtQuick.Controls 2.15-+import org.krita.components 1.0 as Kis/*\qmltype GroupButton@@ -59,11 +59,9 @@ Button {GroupCenter //!< The button is on the center of the group, so it would have separators on both sides}- SystemPalette {- id: sysPalette;- colorGroup: root.enabled?- root.activeFocus? SystemPalette.Active:- SystemPalette.Inactive: SystemPalette.Disabled;+ Kis.Theme {+ id: theme;+ button.state: root.enabled? root.activeFocus? SystemPalette.Active: SystemPalette.Inactive: SystemPalette.Disabled;}/*@@ -72,9 +70,9 @@ Button {/sa GroupPosition*/- property int groupPosition: GroupButton.GroupPosition.NoGroup- palette.button: checked? sysPalette.highlight: sysPalette.button;- palette.buttonText: checked? sysPalette.highlightedText: sysPalette.buttonText+ property int groupPosition: GroupButton.GroupPosition.NoGroup;+ palette.button: checked? theme.selection.backgroundColor: theme.button.backgroundColor;+ palette.buttonText: checked? theme.selection.textColor: theme.button.textColor;text: "Button"clip: true@@ -89,7 +87,7 @@ Button {width: 1height: root.background.heightanchors.right: parent.right- color: root.palette.buttonText;+ color: palette.buttonText;opacity: 0.1;visible: root.groupPosition === GroupButton.GroupPosition.GroupLeft ||root.groupPosition === GroupButton.GroupPosition.GroupCenterdiff --git a/qmlmodules/components/qml/overlays/WarningOverlay.qml b/qmlmodules/components/qml/overlays/WarningOverlay.qmlindex c928c3d835..74db7acd48 100644--- a/qmlmodules/components/qml/overlays/WarningOverlay.qml+++ b/qmlmodules/components/qml/overlays/WarningOverlay.qml@@ -4,6 +4,7 @@* SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuick 2.15+import org.krita.components 1.0 as Kis/*\qmltype WarningOverlay@@ -141,8 +142,12 @@ Item {Rectangle {id: backgroundanchors.fill: parent- color: Qt.rgba(1, 0.2, 0, 1)+ color: theme.view.negativeBackgroundColor;opacity: 0++ Kis.Theme {+ id: theme;+ }}Item {diff --git a/qmlmodules/widgets/KisQQuickWidget.cpp b/qmlmodules/widgets/KisQQuickWidget.cppindex 9f20c4057e..840ef37471 100644--- a/qmlmodules/widgets/KisQQuickWidget.cpp+++ b/qmlmodules/widgets/KisQQuickWidget.cpp@@ -39,6 +39,9 @@ KisQQuickWidget::KisQQuickWidget(QWidget *parent): QQuickWidget(parent)engine()->rootContext()->setContextProperty("mainWindow", parent);engine()->rootContext()->setContextObject(new KLocalizedContext(parent));+ // Clear color is the 'default background color', which, in qwidget context is the window bg.+ setClearColor(palette().window().color());+// Default to fusion style unless the user forces another styleconst QString fusion = "Fusion";if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE") && QQuickStyle::name() != fusion) {