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

Improve delegate for text style presets and fix tagging context menu.

Wolthera van Hövell tot Westerflier4b23dcd0ee73
diff --git a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
index d3630e04e7..2079b886ec 100644
--- a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
+++ b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
@@ -175,19 +175,13 @@ Button {
hoverEnabled: true;
onClicked: {
if (mouse.button === Qt.RightButton) {
- openContextMenu(mouse.x, mouse.y);
+ resourceView.openContextMenu(mouse.x, mouse.y, parent.model.name, parent.model.index);
} else {
- familyCmb.modelWrapper.currentIndex = fontDelegateItem.model.index;
+ familyCmb.modelWrapper.currentIndex = parent.model.index;
familyCmb.activated();
}
}
- onHoveredChanged: familyCmb.highlightedIndex = fontDelegateItem.model.index;
-
- function openContextMenu(x, y) {
- tagActionsContextMenu.resourceName = fontDelegateItem.model.name;
- tagActionsContextMenu.resourceIndex = fontDelegateItem.model.index;
- tagActionsContextMenu.popup()
- }
+ onHoveredChanged: familyCmb.highlightedIndex = parent.model.index;
ToolTip.text: fontDelegateItem.fontName;
ToolTip.visible: containsMouse;
diff --git a/plugins/dockers/textproperties/qml/ResourceView.qml b/plugins/dockers/textproperties/qml/ResourceView.qml
index 562c219427..ee22acfa2e 100644
--- a/plugins/dockers/textproperties/qml/ResourceView.qml
+++ b/plugins/dockers/textproperties/qml/ResourceView.qml
@@ -19,6 +19,11 @@ Control {
property alias resourceDelegate : view.delegate;
+ function openContextMenu(x, y, resourceName, resourceIndex) {
+ tagActionsContextMenu.resourceName = resourceName;
+ tagActionsContextMenu.resourceIndex = resourceIndex;
+ tagActionsContextMenu.popup(x, y);
+ }
contentItem: ColumnLayout {
id: resourceView;
@@ -50,7 +55,7 @@ Control {
palette: control.palette;
function hideShowMenu() {
if (!tagActionsContextMenu.visible) {
- tagActionsContextMenu.resourceIndex = familyCmb.highlightedIndex;
+ tagActionsContextMenu.resourceIndex = control.highlightedIndex;
tagActionsContextMenu.popup(tagMenuButton,
tagActionsContextMenu.width - tagMenuButton.width,
tagMenuButton.height - 1);
@@ -84,6 +89,7 @@ Control {
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
Label {
id: resourceLabel;
+ padding: parent.padding;
}
Menu {
@@ -127,23 +133,30 @@ Control {
}
}
MenuSeparator {}
- Action {
+ MenuItem {
enabled: modelWrapper.showResourceTagged(modelWrapper.currentTag, tagActionsContextMenu.resourceIndex);
id: removeFromThisTag;
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;
onTriggered: modelWrapper.untagResource(modelWrapper.currentTag, tagActionsContextMenu.resourceIndex);
}
Menu {
id: removeFromTag;
title: i18nc("@title:menu", "Remove from other tag");
+
ListView {
id: tagRemoveView;
model: tagActionsContextMenu.resourceTaggedModel;
height: contentHeight;
width: parent.width;
+
delegate: ItemDelegate {
width: tagRemoveView.width;
text: modelData.name;
@@ -186,7 +199,7 @@ Control {
palette: control.palette;
}
CheckBox {
- id: opticalSizeCbx
+ id: searchInTagCbx
text: i18nc("@option:check", "Search in tag")
onCheckedChanged: modelWrapper.searchInTag = checked;
checked: modelWrapper.searchInTag;
diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qml
index ad6b931def..d6b057db1f 100644
--- a/plugins/dockers/textproperties/qml/TextProperties.qml
+++ b/plugins/dockers/textproperties/qml/TextProperties.qml
@@ -85,11 +85,52 @@ Rectangle {
}
resourceDelegate: ItemDelegate {
+ id: presetDelegate;
required property var model;
+ property var meta: presetView.modelWrapper.metadataForIndex(model.index);
width: ListView.view.width;
- text: model.name;
+ highlighted: delegateMouseArea.containsMouse;
+ contentItem: KoShapeQtQuickLabel {
+ width: parent.width;
+ height: nameLabel.height * 5;
+ imageScale: 3;
+ imagePadding: nameLabel.height;
- onClicked: presetView.currentIndex = model.index;
+ svgData: presetDelegate.meta.sample_svg;
+ foregroundColor: presetDelegate.highlighted? palette.highlightedText: palette.text;
+
+ Label {
+ id: nameLabel;
+ palette: presetDelegate.palette;
+ text: presetDelegate.model.name;
+ anchors.top: parent.top;
+ anchors.left: parent.left;
+ elide: Text.ElideRight;
+ width: parent.width;
+ color: presetDelegate.highlighted? palette.highlightedText: palette.text;
+ }
+ }
+ background: Rectangle {
+ color: presetDelegate.highlighted? presetDelegate.palette.highlight: "transparent";
+ }
+
+ MouseArea {
+ id: delegateMouseArea;
+ acceptedButtons: Qt.RightButton | Qt.LeftButton;
+ anchors.fill: parent;
+ hoverEnabled: true;
+ onClicked: {
+ if (mouse.button === Qt.RightButton) {
+ presetView.openContextMenu(mouse.x, mouse.y, parent.model.name, parent.model.index);
+ } else {
+ presetView.modelWrapper.currentIndex = parent.model.index;
+ }
+ }
+ ToolTip.text: presetDelegate.model.name + "\n" + presetDelegate.meta.description;
+ ToolTip.visible: containsMouse;
+ ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval;
+
+ }
}
}
}