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

Add description data and shape preview to style edit.

Wolthera van Hövell tot Westerfliere45bafac4fd6
diff --git a/libs/flake/resources/KoCssStylePreset.cpp b/libs/flake/resources/KoCssStylePreset.cpp
index d960edce5f..1b84482959 100644
--- a/libs/flake/resources/KoCssStylePreset.cpp
+++ b/libs/flake/resources/KoCssStylePreset.cpp
@@ -110,6 +110,12 @@ void KoCssStylePreset::setStyleType(const QString &type)
addMetaData(STYLE_TYPE, type);
}
+QString KoCssStylePreset::sampleSvg() const
+{
+ QMap<QString, QVariant> m = metadata();
+ return m[SAMPLE_SVG].toString();
+}
+
KoResourceSP KoCssStylePreset::clone() const
{
return KoResourceSP(new KoCssStylePreset(*this));
diff --git a/libs/flake/resources/KoCssStylePreset.h b/libs/flake/resources/KoCssStylePreset.h
index 56ffec3797..74b7120695 100644
--- a/libs/flake/resources/KoCssStylePreset.h
+++ b/libs/flake/resources/KoCssStylePreset.h
@@ -38,6 +38,9 @@ public:
QString styleType() const;
void setStyleType(const QString &type);
+ /// Returns the sample svg metadata. Use updateThumbnail to update it.
+ QString sampleSvg() const;
+
// KoResource interface
public:
KoResourceSP clone() const override;
diff --git a/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp b/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
index 2e4d0c91e7..61af1b3d59 100644
--- a/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
+++ b/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
@@ -79,17 +79,23 @@ void CssStylePresetEditDialog::setCurrentResource(KoCssStylePresetSP resource)
textData.commonProperties = properties;
m_model->textData.set(textData);
m_quickWidget->rootObject()->setProperty("presetTitle", m_currentResource->name());
+ m_quickWidget->rootObject()->setProperty("presetDescription", m_currentResource->description());
+ m_quickWidget->rootObject()->setProperty("presetSample", m_currentResource->sampleSvg());
m_quickWidget->rootObject()->setProperty("styleType", m_currentResource->styleType());
}
KoCssStylePresetSP CssStylePresetEditDialog::currentResource()
{
- KoSvgTextPropertyData textData = m_model->textData.get();
- m_currentResource->setProperties(textData.commonProperties);
- const QString title = m_quickWidget->rootObject()->property("presetTitle").toString();
- const QString styleType = m_quickWidget->rootObject()->property("styleType").toString();
- m_currentResource->setName(title);
- m_currentResource->setStyleType(styleType);
+ if (m_currentResource) {
+ KoSvgTextPropertyData textData = m_model->textData.get();
+ m_currentResource->setProperties(textData.commonProperties);
+ const QString title = m_quickWidget->rootObject()->property("presetTitle").toString();
+ const QString description = m_quickWidget->rootObject()->property("presetDescription").toString();
+ const QString styleType = m_quickWidget->rootObject()->property("styleType").toString();
+ m_currentResource->setName(title);
+ m_currentResource->setDescription(description);
+ m_currentResource->setStyleType(styleType);
+ }
return m_currentResource;
}
@@ -100,6 +106,11 @@ void CssStylePresetEditDialog::setDpi(const double dpi)
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());
+ }
QMetaObject::invokeMethod(m_quickWidget->rootObject(), "setProperties");
}
diff --git a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
index 471dda927b..82abac30ac 100644
--- a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
+++ b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
@@ -13,6 +13,8 @@ Control {
property TextPropertyConfigModel configModel: TextPropertyConfigModel {};
property alias presetTitle: presetTitleField.text;
+ property alias presetDescription: presetDescriptionArea.text;
+ property alias presetSample: presetSample.svgData;
property string styleType: "paragraph";
property double canvasDPI: 72.0;
onStyleTypeChanged: {
@@ -38,21 +40,36 @@ Control {
ColumnLayout {
anchors.fill: parent;
- RowLayout {
+ GridLayout {
Layout.fillWidth: true;
Layout.preferredHeight: implicitHeight;
+ columns: 2;
+
+ KoShapeQtQuickLabel {
+ id: presetSample;
+ Layout.fillWidth: true;
+ Layout.columnSpan: 2;
+ foregroundColor: palette.text;
+ }
+
Label {
Layout.minimumWidth: implicitWidth;
- text: i18nc("label:Title", "Title:");
+ text: i18nc("label:title", "Title:");
}
TextField {
id: presetTitleField;
Layout.fillWidth: true;
+ placeholderText: i18nc("info:placeholder", "Style Name");
+ }
+ Label {
+ Layout.minimumWidth: implicitWidth;
+ text: i18nc("label:title", "Description");
+ }
+ TextArea {
+ id: presetDescriptionArea;
+ Layout.fillWidth: true;
+ placeholderText: i18nc("info:placeholder", "Style Description.");
}
- }
- RowLayout {
- Layout.fillWidth: true;
- Layout.preferredHeight: implicitHeight;
Label {
Layout.minimumWidth: implicitWidth;
text: i18nc("label:Title", "Style Type:");