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

Make the Style Preset preview work and update accordingly.

Wolthera van Hövell tot Westerfliera04dfdb5afad
diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cpp
index 28c2129e9c..3a9ee34ead 100644
--- a/libs/flake/text/KoSvgTextShape.cpp
+++ b/libs/flake/text/KoSvgTextShape.cpp
@@ -1109,24 +1109,32 @@ KoSvgTextProperties KoSvgTextShape::propertiesForTreeIndex(const QVector<int> &t
bool KoSvgTextShape::setPropertiesAtTreeIndex(const QVector<int> treeIndex, const KoSvgTextProperties props)
{
QVector<int> idx = treeIndex;
- if (treeIndex.isEmpty()) return false;
+ bool success = false;
+ if (treeIndex.isEmpty()) return success;
idx.removeFirst();
for (auto it = d->textData.childBegin(); it != d->textData.childEnd(); it++) {
if (idx.isEmpty()) {
if (it != d->textData.childEnd()) {
it->properties = props;
- return true;
+ success = true;
+ break;
} else {
- return false;
+ success = false;
+ break;
}
}
auto child = d->iteratorForTreeIndex(idx, it);
if (child != d->textData.childEnd()) {
child->properties = props;
- return true;
+ success = true;
+ break;
}
}
- return false;
+ if (success) {
+ notifyChanged();
+ shapeChangedPriv(ContentChanged);
+ }
+ return success;
}
KoSvgTextProperties KoSvgTextShape::textProperties() const
diff --git a/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp b/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
index 61af1b3d59..b3c5bbd915 100644
--- a/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
+++ b/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
@@ -20,7 +20,7 @@ CssStylePresetEditDialog::CssStylePresetEditDialog(QWidget *parent)
, m_model(new KoSvgTextPropertiesModel())
{
- setMinimumSize(500, 300);
+ setMinimumSize(300, 500);
setModal(true);
m_quickWidget = new QQuickWidget(this);
@@ -82,6 +82,7 @@ void CssStylePresetEditDialog::setCurrentResource(KoCssStylePresetSP resource)
m_quickWidget->rootObject()->setProperty("presetDescription", m_currentResource->description());
m_quickWidget->rootObject()->setProperty("presetSample", m_currentResource->sampleSvg());
m_quickWidget->rootObject()->setProperty("styleType", m_currentResource->styleType());
+ QMetaObject::invokeMethod(m_quickWidget->rootObject(), "setProperties");
}
KoCssStylePresetSP CssStylePresetEditDialog::currentResource()
@@ -108,10 +109,12 @@ void CssStylePresetEditDialog::slotUpdateTextProperties()
{
if (m_currentResource) {
KoSvgTextPropertyData textData = m_model->textData.get();
- m_currentResource->setProperties(textData.commonProperties);
- m_quickWidget->rootObject()->setProperty("presetSample", m_currentResource->sampleSvg());
+ if (m_currentResource->properties() != textData.commonProperties) {
+ m_currentResource->setProperties(textData.commonProperties);
+ m_quickWidget->rootObject()->setProperty("presetSample", m_currentResource->sampleSvg());
+ QMetaObject::invokeMethod(m_quickWidget->rootObject(), "setProperties");
+ }
}
- QMetaObject::invokeMethod(m_quickWidget->rootObject(), "setProperties");
}
QColor CssStylePresetEditDialog::modalColorDialog(QColor oldColor)
diff --git a/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp b/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
index e695c4a34e..caac0ce0e7 100644
--- a/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
+++ b/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
@@ -234,8 +234,8 @@ void KoShapeQtQuickLabel::updateShapes()
for (int i = 0; i < d->shapes.size(); i++) {
d->shapes.at(i)->setBackground(bg);
}
- callUpdateIfComplete();
}
+ callUpdateIfComplete();
}
void KoShapeQtQuickLabel::callUpdateIfComplete()
diff --git a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
index 82abac30ac..cfbf0adef8 100644
--- a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
+++ b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
@@ -14,7 +14,7 @@ Control {
property TextPropertyConfigModel configModel: TextPropertyConfigModel {};
property alias presetTitle: presetTitleField.text;
property alias presetDescription: presetDescriptionArea.text;
- property alias presetSample: presetSample.svgData;
+ property alias presetSample: presetSampleLabel.svgData;
property string styleType: "paragraph";
property double canvasDPI: 72.0;
onStyleTypeChanged: {
@@ -46,15 +46,19 @@ Control {
columns: 2;
KoShapeQtQuickLabel {
- id: presetSample;
+ id: presetSampleLabel;
Layout.fillWidth: true;
Layout.columnSpan: 2;
foregroundColor: palette.text;
+ fullColor: false;
+ Layout.preferredHeight: presetTitleField.height*2;
}
Label {
Layout.minimumWidth: implicitWidth;
text: i18nc("label:title", "Title:");
+ Layout.alignment: Qt.AlignRight | Qt.AlignVCenter;
+ horizontalAlignment: Text.AlignRight;
}
TextField {
id: presetTitleField;
@@ -63,16 +67,33 @@ Control {
}
Label {
Layout.minimumWidth: implicitWidth;
- text: i18nc("label:title", "Description");
+ text: i18nc("label:title", "Description:");
+ Layout.alignment: Qt.AlignRight | Qt.AlignTop;
+ horizontalAlignment: Text.AlignRight;
}
- TextArea {
- id: presetDescriptionArea;
+ ScrollView {
+ id: descriptionScroll
Layout.fillWidth: true;
- placeholderText: i18nc("info:placeholder", "Style Description.");
+ Layout.preferredHeight: 3 * presetTitleField.height;
+
+ TextArea {
+ id: presetDescriptionArea;
+ wrapMode: TextInput.Wrap;
+
+ placeholderText: i18nc("info:placeholder", "Style Description.");
+ }
+
+ background: Rectangle {
+ border.color: presetDescriptionArea.focus? palette.highlight: palette.mid;
+ border.width: 1;
+ color: palette.base;
+ }
}
Label {
Layout.minimumWidth: implicitWidth;
text: i18nc("label:Title", "Style Type:");
+ Layout.alignment: Qt.AlignRight | Qt.AlignVCenter;
+ horizontalAlignment: Text.AlignRight;
}
ComboBox {
id: styleTypeCmb;
diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qml
index a93d68c8ef..03a7817f22 100644
--- a/plugins/dockers/textproperties/qml/TextProperties.qml
+++ b/plugins/dockers/textproperties/qml/TextProperties.qml
@@ -89,15 +89,13 @@ Rectangle {
resourceDelegate: ItemDelegate {
id: presetDelegate;
required property var model;
- property var meta: presetView.modelWrapper.metadataForIndex(model.index);
+ property var meta: model.metadata;
width: ListView.view.width;
highlighted: delegateMouseArea.containsMouse;
property bool selected: presetView.currentIndex === model.index;
contentItem: KoShapeQtQuickLabel {
- width: parent.width;
- height: nameLabel.height * 5;
- imageScale: 3;
- imagePadding: nameLabel.height;
+ implicitHeight: nameLabel.height * 4;
+ padding: nameLabel.height;
svgData: presetDelegate.meta.sample_svg;
foregroundColor: presetDelegate.highlighted? palette.highlightedText: palette.text;
@@ -108,8 +106,8 @@ Rectangle {
text: presetDelegate.model.name;
anchors.top: parent.top;
anchors.left: parent.left;
+ anchors.right: parent.right;
elide: Text.ElideRight;
- width: parent.width;
color: presetDelegate.highlighted? palette.highlightedText: palette.text;
}
}