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 a number of ux issues with the text properties docker.
Wolthera van Hövell tot Westerflier5120659ffd4c
diff --git a/HACKING b/HACKINGindex c5a8f0d4f2..6e90261df6 100644--- a/HACKING+++ b/HACKING@@ -318,3 +318,5 @@ QML Notes:will instantiate a delegate for every single item it could lay out upon the ListView itself be instantiated.It's better to set the default height of the ListView to something bounded, like the fontSize * 3, and thenensure it is resized later.+ - Comboboxes expect their delegates to be a ItemDelegate or AbstractButton. The Qt Docs imply this is because+ those call activated(), but Combobox.highlightedIndex being set on hover also only works together ItemDelegate.diff --git a/plugins/dockers/textproperties/FontAxesModel.cpp b/plugins/dockers/textproperties/FontAxesModel.cppindex d427b32d61..79d55eb80f 100644--- a/plugins/dockers/textproperties/FontAxesModel.cpp+++ b/plugins/dockers/textproperties/FontAxesModel.cpp@@ -216,12 +216,10 @@ void FontAxesModel::setAxisValues(const QVariantMap &newAxisValues)if (!d->blockAxesValuesUpdate) {emit axisValuesChanged();}- if (!d->axes.isEmpty()) {- QModelIndex idx1 = index(0, 0, QModelIndex());- QModelIndex idx2 = index(d->axes.size()-1, 0, QModelIndex());- if (idx1.isValid() && idx2.isValid()) {- emit dataChanged(idx1, idx2, {Qt::EditRole});- }- }+ QModelIndex idx1 = index(0, 0, QModelIndex());+ QModelIndex idx2 = index(rowCount(QModelIndex())-1, 0, QModelIndex());+ if (idx1.isValid() && idx2.isValid()) {+ emit dataChanged(idx1, idx2, {Qt::EditRole});+ }}diff --git a/plugins/dockers/textproperties/qml/Direction.qml b/plugins/dockers/textproperties/qml/Direction.qmlindex ec272f8003..ff6ff7af90 100644--- a/plugins/dockers/textproperties/qml/Direction.qml+++ b/plugins/dockers/textproperties/qml/Direction.qml@@ -35,11 +35,31 @@ TextPropertyBase {function onDirectionStateChanged() {updateVisibility();}+ function onUnicodeBidiStateChanged() {+ updateVisibility();+ }++ function onSpanSelectionChanged() {+ testEnabled();+ }}onPropertiesChanged: {updateDirection();updateUnicodeBidi();updateVisibility();+ testEnabled();+ }+ onParentPropertyTypeChanged: {+ unicodeBidiCmb.visible = parentPropertyType === TextPropertyConfigModel.Character;+ testEnabled();+ }++ function testEnabled() {+ if (parentPropertyType === TextPropertyConfigModel.Character) {+ enabled = properties.spanSelection;+ } else {+ enabled = properties.spanSelection? false: true;+ }}function updateDirection() {@@ -55,7 +75,6 @@ TextPropertyBase {}function updateVisibility() {- enabled = parentPropertyType === TextPropertyBase.Paragraph? !properties.spanSelection: properties.spanSelection;propertyState = [properties.directionState];setVisibleFromProperty();}@@ -116,7 +135,7 @@ TextPropertyBase {}RevertPropertyButton {- visible: parentPropertyType === TextPropertyBase.Character;+ visible: unicodeBidiCmb.visible;revertState: properties.unicodeBidiState;onClicked: properties.unicodeBidiState = KoSvgTextPropertiesModel.PropertyUnset;}@@ -125,14 +144,13 @@ TextPropertyBase {text: i18nc("@label:listbox", "Unicode-Bidi");elide: Text.ElideRight;Layout.fillWidth: true;- visible: parentPropertyType === TextPropertyBase.Character;+ visible: unicodeBidiCmb.visible;font.italic: properties.unicodeBidiState === KoSvgTextPropertiesModel.PropertyTriState;palette: unicodeBidiCmbPalette.palette;}ComboBox {- id: unicodeBidiCmb- visible: parentPropertyType === TextPropertyBase.Character;+ id: unicodeBidiCmb;Layout.fillWidth: true;model: [{text: i18nc("@label:inlistbox", "Normal"), value: KoSvgText.BidiNormal},diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qmlindex 0fc0ddc066..33f61d715b 100644--- a/plugins/dockers/textproperties/qml/FontStyle.qml+++ b/plugins/dockers/textproperties/qml/FontStyle.qml@@ -23,10 +23,10 @@ CollapsibleGroupProperty {property alias fontWidth: fontStretchSpn.value;property alias fontSlantSlope: fontSlantSpn.value;property int fontSlant: CssFontStyleModel.StyleNormal;+ property alias axisValues: axesModelId.axisValues;property FontAxesModel axesModel: FontAxesModel {- // TODO: handle locales.- onAxisValuesChanged: properties.axisValues = axisValues;+ id: axesModelId;}property FontStyleModel stylesModel: FontStyleModel {@@ -98,6 +98,7 @@ CollapsibleGroupProperty {}function onAxisValuesStateChanged() {+ updateAxisValues();updateVisibility();}}@@ -157,7 +158,7 @@ CollapsibleGroupProperty {function updateAxisValues() {blockSignals = true;- axesModel.axisValues = properties.axisValues;+ axisValues = properties.axisValues;blockSignals = false;}@@ -217,6 +218,12 @@ CollapsibleGroupProperty {}}+ onAxisValuesChanged: {+ if (!blockSignals) {+ properties.axisValues = axisValues;+ }+ }+onEnableProperty: {properties.fontWeightState = KoSvgTextPropertiesModel.PropertySet;}@@ -437,10 +444,13 @@ CollapsibleGroupProperty {required property bool axishidden;required property var model;+ // Somewhat complex, but data needs to be set on model.edit, and read from edit.+ required property double edit;+ onEditChanged: dValue = edit;+prefix: display + ": ";dFrom: axismin;dTo: axismax;- dValue: model.edit;onDValueChanged: model.edit = dValue;width: ListView.view.width;diff --git a/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qml b/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qmlindex f8a8b0fe29..0adb6cc978 100644--- a/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qml+++ b/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qml@@ -9,13 +9,12 @@ import QtQuick.Layouts 1.15import org.krita.flake.text 1.0import org.krita.components 1.0 as Kis-Control {+ItemDelegate {id: root;height: implicitHeight;- implicitHeight: layout.height + padding*2;clip: true;- required property string display;+ required property string name;required property string tag;required property string sample;required property string toolTip;@@ -34,16 +33,18 @@ Control {property bool enableMouseEvents: true;- property alias containsMouse: mouseArea.containsMouse;- property bool highlighted: false;+ hoverEnabled: enableMouseEvents;background: Rectangle {- color: highlighted? palette.highlight: "transparent";+ color: root.palette.highlight;+ visible: root.highlighted;}- signal featureClicked (QtObject mouse);+ onClicked: featureClicked();- RowLayout {+ signal featureClicked ();++ contentItem: RowLayout {id: layout;width: parent.availableWidth;@@ -71,7 +72,7 @@ Control {Layout.bottomMargin: layout.spacing;Label {id: displayLabel;- text: root.display;+ text: root.name;elide: Text.ElideRight;Layout.fillWidth: true;Layout.preferredHeight: implicitHeight@@ -86,7 +87,7 @@ Control {Layout.preferredHeight: displayLabel.height * 2;Layout.preferredWidth: (displayLabel.height * 2) * (implicitWidth/implicitHeight);Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter;- textColor: root.containsMouse? root.palette.highlightedText: root.palette.text;+ textColor: root.highlighted? root.palette.highlightedText: root.palette.text;fillColor: "transparent";fontFamilies: root.fontFamilies;fontSize: root.fontSize;@@ -109,17 +110,9 @@ Control {}}}- MouseArea {- id: mouseArea;- anchors.fill: parent;- hoverEnabled: root.enableMouseEvents;- enabled: root.enableMouseEvents;- onClicked: (mouse)=>{ featureClicked(mouse); }- Kis.ToolTipBase {- parent: mouseArea;- text: root.toolTip;- visible: mouseArea.containsMouse;- }+ Kis.ToolTipBase {+ parent: root;+ text: root.toolTip;+ visible: root.highlighted;}-}diff --git a/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml b/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qmlindex 7d2f9ea5c2..aa38313f71 100644--- a/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml+++ b/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml@@ -126,7 +126,7 @@ TextPropertyBase {currentIndex: activeFeatureDelegate.model.edit;contentItem: OpenTypeFeatureDelegate {- display: activeFeatureControl.currentText;+ name: activeFeatureControl.currentText;toolTip: activeFeatureDelegate.toolTip;sample: activeFeatureDelegate.sample;tag: activeFeatureDelegate.tag;@@ -148,8 +148,8 @@ TextPropertyBase {delegate: OpenTypeFeatureDelegate {width: ListView.view.width;required property var modelData;- display: modelData.display;- toolTip: display;+ name: modelData.display;+ toolTip: name;sample: activeFeatureDelegate.sample;tag: activeFeatureDelegate.tag;fontFamilies: properties.fontFamilies;@@ -204,7 +204,7 @@ TextPropertyBase {delegate: OpenTypeFeatureDelegate {required property var model;required property int index;- display: model.display;+ name: model.display;toolTip: model.toolTip;sample: model.sample;width: ListView.view.width;@@ -216,7 +216,7 @@ TextPropertyBase {fontWidth: properties.fontWidth;fontAxesValues: properties.axisValues;featureValue: 0;- onFeatureClicked: (mouse) => {+ onFeatureClicked: {cmbAvailableFeatures.currentIndex = index;fontFeatureModel.addFeature(tag);cmbAvailableFeatures.popup.close();@@ -302,7 +302,7 @@ TextPropertyBase {delegate: OpenTypeFeatureDelegate {required property var model;required property int index;- display: model.display;+ name: model.display;toolTip: model.toolTip;sample: model.sample;width: ListView.view.width;@@ -314,12 +314,12 @@ TextPropertyBase {fontWidth: properties.fontWidth;fontAxesValues: properties.axisValues;featureValue: 0;- onFeatureClicked: (mouse) => {+ onFeatureClicked: {fontFeatureModel.addFeature(tag);featureTxtEdit.finalize();}- onContainsMouseChanged: {- if (containsMouse) {+ onHoveredChanged: {+ if (hovered) {completerListView.currentIndex = index;}}diff --git a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qmlindex 3ff9882262..cf5fb2c70f 100644--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml@@ -12,7 +12,7 @@ import org.krita.components 1.0 as KisColumnLayout {id: propertyBaseList;- property int propertyType: TextPropertyConfigModel.Character;+ required property int propertyType;property TextPropertyConfigModel configModel;property double canvasDPI: 72.0;property KoSvgTextPropertiesModel propertiesModel;diff --git a/qmlmodules/components/qml/InformingTextInput.qml b/qmlmodules/components/qml/InformingTextInput.qmlindex 53aacf413d..6487b07d18 100644--- a/qmlmodules/components/qml/InformingTextInput.qml+++ b/qmlmodules/components/qml/InformingTextInput.qml@@ -93,6 +93,7 @@ TextField {Kis.Theme {id: theme;window.state: root.enabled? SystemPalette.Active: SystemPalette.Disabled;+ view.state: root.enabled? SystemPalette.Active: SystemPalette.Disabled;button.state: root.enabled? SystemPalette.Active: SystemPalette.Disabled;selection.state: root.enabled? SystemPalette.Active: SystemPalette.Disabled;}diff --git a/qmlmodules/widgets/KisQQuickWidget.cpp b/qmlmodules/widgets/KisQQuickWidget.cppindex 25ec2cbc6d..d799079adc 100644--- a/qmlmodules/widgets/KisQQuickWidget.cpp+++ b/qmlmodules/widgets/KisQQuickWidget.cpp@@ -16,6 +16,7 @@#include <KoResourcePaths.h>#include <KisSurfaceColorSpaceWrapper.h>+#include <kis_config_notifier.h>KisQQuickWidget::KisQQuickWidget(QWidget *parent): QQuickWidget(parent){@@ -43,6 +44,7 @@ KisQQuickWidget::KisQQuickWidget(QWidget *parent): QQuickWidget(parent)// Clear color is the 'default background color', which, in qwidget context is the window bg.setClearColor(palette().window().color());+ connect(KisConfigNotifier::instance(), SIGNAL(signalColorThemeChanged(QString)), this, SLOT(updatePaletteFromConfig()));// Default to fusion style unless the user forces another styleconst QString fusion = "Fusion";@@ -82,3 +84,8 @@ KisQQuickWidget::~KisQQuickWidget()/// * https://bugreports.qt.io/browse/QTBUG-81247setParent(nullptr);}++void KisQQuickWidget::updatePaletteFromConfig()+{+ setClearColor(palette().window().color());+}diff --git a/qmlmodules/widgets/KisQQuickWidget.h b/qmlmodules/widgets/KisQQuickWidget.hindex 53ac0ebec4..de00dc35e4 100644--- a/qmlmodules/widgets/KisQQuickWidget.h+++ b/qmlmodules/widgets/KisQQuickWidget.h@@ -24,6 +24,8 @@ public:KisQQuickWidget(QWidget *parent = nullptr);~KisQQuickWidget();+private Q_SLOTS:+ void updatePaletteFromConfig();};#endif // KISQQUICKWIDGET_H