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++
Try to fix the font selection by fixing qml resource popups.
Wolthera van Hövell tot Westerflier4c24e9d9d949
diff --git a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml b/plugins/dockers/textproperties/qml/FontResourceDropdown.qmlindex da626cf3cc..a8355e2e4a 100644--- a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml+++ b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml@@ -14,7 +14,6 @@ Kis.ResourcePopup {addResourceRowVisible: false;resourceDelegate: Kis.FontFamilyDelegate {id: fontDelegate;- resourceView: resourceCmb.view;locales: resourceCmb.locales;onResourceLeftClicked: {resourceCmb.activated();diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qmlindex de114155b3..dc49471f31 100644--- a/plugins/dockers/textproperties/qml/TextProperties.qml+++ b/plugins/dockers/textproperties/qml/TextProperties.qml@@ -117,7 +117,6 @@ Control {Layout.fillWidth: true;resourceDelegate: Kis.CssStylePresetDelegate {- resourceView: presetView;onResourceDoubleClicked: {canvasObserver.applyPreset(presetView.modelWrapper.currentResource);}diff --git a/plugins/tools/svgtexttool/SvgTextToolOptions.qml b/plugins/tools/svgtexttool/SvgTextToolOptions.qmlindex 79ff0feb8f..53c960c2b2 100644--- a/plugins/tools/svgtexttool/SvgTextToolOptions.qml+++ b/plugins/tools/svgtexttool/SvgTextToolOptions.qml@@ -94,7 +94,6 @@ Control {resourceType: "css_styles";resourceDelegate: Kis.CssStylePresetDelegate {id: presetDelegate;- resourceView: btnSelectCssStylePreset.view;preferredHeight: minimumHeight;onResourceLeftClicked: {btnSelectCssStylePreset.activated();diff --git a/qmlmodules/components/qml/ResourcePopup.qml b/qmlmodules/components/qml/ResourcePopup.qmlindex cadab7008d..321b2c746e 100644--- a/qmlmodules/components/qml/ResourcePopup.qml+++ b/qmlmodules/components/qml/ResourcePopup.qml@@ -114,6 +114,7 @@ Button {modelWrapper.searchText = text;resourceView.showTagging = false;resourceView.showSearch = false;+ resourceView.highlightedIndex = 0;resourceCmbPopup.open();}diff --git a/qmlmodules/components/qml/ResourceView.qml b/qmlmodules/components/qml/ResourceView.qmlindex ddc4cc8936..4f554eee43 100644--- a/qmlmodules/components/qml/ResourceView.qml+++ b/qmlmodules/components/qml/ResourceView.qml@@ -44,7 +44,7 @@ Control {\qmlProperty highlightedIndexThe currently hovered index on the resource selector.*/- property alias highlightedIndex : view.currentIndex;+ property int highlightedIndex;/*\qmlProperty resourceDelegate@@ -106,10 +106,10 @@ Control {Keys.onDownPressed: downPress();Keys.onUpPressed: upPress();- function openContextMenu(x, y, resourceName, resourceIndex) {+ function openContextMenu(target, x, y, resourceName, resourceIndex) {tagActionsContextMenu.resourceName = resourceName;tagActionsContextMenu.resourceIndex = resourceIndex;- tagActionsContextMenu.popup(x, y);+ tagActionsContextMenu.popup(target, x, y);}contentItem: ColumnLayout {@@ -279,13 +279,23 @@ Control {clip: true;anchors.fill: parent;id: view;- currentIndex: 0;+ currentIndex: modelWrapper.currentIndex;Keys.onDownPressed: control.downPress();Keys.onUpPressed: control.upPress();ScrollBar.vertical: ScrollBar {}++ property alias highlightedIndex: control.highlightedIndex;++ function resourceLeftClicked(resourceIndex) {+ control.highlightedIndex = resourceIndex;+ control.applyHighlightedIndex();+ }+ function openContextMenu(target, x, y, resourceName, resourceIndex) {+ control.openContextMenu(target, x, y, resourceName, resourceIndex);+ }}}RowLayout {diff --git a/qmlmodules/components/qml/resourceDelegates/CssStylePresetDelegate.qml b/qmlmodules/components/qml/resourceDelegates/CssStylePresetDelegate.qmlindex b591e9eb8f..e408fbc7a2 100644--- a/qmlmodules/components/qml/resourceDelegates/CssStylePresetDelegate.qml+++ b/qmlmodules/components/qml/resourceDelegates/CssStylePresetDelegate.qml@@ -76,22 +76,19 @@ ResourceDelegateBase {acceptedButtons: Qt.RightButton | Qt.LeftButton;anchors.fill: parent;hoverEnabled: true;- onClicked: {+ onClicked: (mouse) => {if (mouse.button === Qt.RightButton) {- resourceView.openContextMenu(mouse.x, mouse.y, parent.model.name, parent.model.index);+ presetDelegate.resourceRightClicked(mouse.x, mouse.y, parent.model.name, parent.index);} else {- resourceView.applyHighlightedIndex();presetDelegate.resourceLeftClicked();}}onDoubleClicked: {- resourceView.applyHighlightedIndex();presetDelegate.resourceDoubleClicked();}+onContainsMouseChanged: {- if (containsMouse) {- resourceView.highlightedIndex = parent.model.index;- }+ presetDelegate.resourceHovered(containsMouse);}readonly property string missingFontName : i18nc("%1 is name of a font family", "Font Family \"%1\" is missing on this machine. This style preset may not work correctly.", presetDelegate.meta.primary_font_family);diff --git a/qmlmodules/components/qml/resourceDelegates/FontFamilyDelegate.qml b/qmlmodules/components/qml/resourceDelegates/FontFamilyDelegate.qmlindex d987bdb71d..9fb22ceee2 100644--- a/qmlmodules/components/qml/resourceDelegates/FontFamilyDelegate.qml+++ b/qmlmodules/components/qml/resourceDelegates/FontFamilyDelegate.qml@@ -23,7 +23,6 @@ ResourceDelegateBase {id: fontDelegateItem;property var locales: [];property string name: typeof model.name !== "undefined"? model.name: "";- property int index: model.index;property string fontName: name;property var metadata: model.metadata;// TODO: change this to use the text locale, if possible.@@ -217,11 +216,10 @@ ResourceDelegateBase {acceptedButtons: Qt.RightButton | Qt.LeftButton;anchors.fill: parent;hoverEnabled: true;- onClicked: {+ onClicked: (mouse) => {if (mouse.button === Qt.RightButton) {- resourceView.openContextMenu(mouse.x, mouse.y, parent.model.name, parent.index);+ fontDelegateItem.resourceRightClicked(mouse.x, mouse.y, parent.model.name, parent.index);} else {- resourceView.applyHighlightedIndex();fontDelegateItem.resourceLeftClicked();}}@@ -230,9 +228,7 @@ ResourceDelegateBase {}onContainsMouseChanged: {- if(containsMouse) {- resourceView.highlightedIndex = parent.index;- }+ fontDelegateItem.resourceHovered(containsMouse);}Kis.ToolTipBase {diff --git a/qmlmodules/components/qml/resourceDelegates/ResourceDelegateBase.qml b/qmlmodules/components/qml/resourceDelegates/ResourceDelegateBase.qmlindex e16756e911..8dc24da74b 100644--- a/qmlmodules/components/qml/resourceDelegates/ResourceDelegateBase.qml+++ b/qmlmodules/components/qml/resourceDelegates/ResourceDelegateBase.qml@@ -19,26 +19,35 @@ ItemDelegate {value automatically gained from the model and represents the model data.*/required property var model;+ property int index: model.index;property double preferredHeight;property double minimumHeight;- /*- \qmlProperty resourceView- the resource view this is set on.- */- property Kis.ResourceView resourceView;signal resourceLeftClicked();signal resourceDoubleClicked();- highlighted: resourceView.highlightedIndex === model.index;-/*\qmlProperty selectedWhether the current item is selected in the model wrapper.*/- property bool selected: resourceView.modelWrapper.currentIndex === model.index;+ property bool selected: ListView.view? ListView.isCurrentItem: false;+ highlighted: ListView.view.highlightedIndex === index;- palette: resourceView.palette;+ palette: ListView.view.palette;++ onResourceLeftClicked: {+ ListView.view.resourceLeftClicked(control.index);+ }++ function resourceRightClicked(x, y, resourceName, resourceIndex) {+ ListView.view.openContextMenu(control, x, y, resourceName, resourceIndex);+ }++ function resourceHovered(hovered) {+ if (hovered && ListView.view) {+ ListView.view.highlightedIndex = index;+ }+ }contentItem: Label {palette: control.palette;