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 button-text being initialized, and assign appropriate palette for disabled item.

Wolthera van Hövell tot Westerflier6229c6eb969e
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cpp
index 8344b47784..1145a4653a 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp
+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp
@@ -152,6 +152,8 @@ TextPropertiesDock::TextPropertiesDock()
m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
m_quickWidget->setSource(QUrl("qrc:/TextProperties.qml"));
+ m_quickWidget->setPalette(this->palette());
+
}
TextPropertiesDock::~TextPropertiesDock()
diff --git a/plugins/dockers/textproperties/qml/PaletteControl.qml b/plugins/dockers/textproperties/qml/PaletteControl.qml
index 80fc7c1196..94061a4e0e 100644
--- a/plugins/dockers/textproperties/qml/PaletteControl.qml
+++ b/plugins/dockers/textproperties/qml/PaletteControl.qml
@@ -8,6 +8,11 @@ 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;
@@ -16,9 +21,10 @@ Control {
SystemPalette {
id: activePalette;
- colorGroup: SystemPalette.Active
- }
+ colorGroup: SystemPalette.Active;
+ onButtonTextChanged: paletteControl.palette.buttonText = buttonText;
+ }
palette.alternateBase: activePalette.alternateBase;
palette.base: activePalette.base;
@@ -29,8 +35,9 @@ Control {
palette.highlightedText: activePalette.highlightedText;
palette.light: activePalette.light;
- palette.link: activePalette.link;
- palette.linkVisited: activePalette.linkVisited;
+ //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;
@@ -38,8 +45,15 @@ Control {
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/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
index 0a7e1928b5..0109e2f045 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
@@ -178,8 +178,14 @@ ColumnLayout {
required property string toolTip;
contentItem: Label {
enabled: addPropertyDelegate.enabled;
+ PaletteControl {
+ id: addPropertyPalette;
+ colorGroup: parent.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+ palette: addPropertyPalette.palette;
+ color: addPropertyDelegate.highlighted? palette.highlightedText: palette.text;
text: addPropertyDelegate.name;
- elide: Text.ElideRight
+ elide: Text.ElideRight;
verticalAlignment: Text.AlignVCenter
}
enabled: !item.visible;