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

Allow creating new text style presets as well as editing old ones.

Wolthera van Hövell tot Westerflierfd0bab165eae
diff --git a/libs/flake/resources/KoCssStylePreset.cpp b/libs/flake/resources/KoCssStylePreset.cpp
index 1f141b191d..d960edce5f 100644
--- a/libs/flake/resources/KoCssStylePreset.cpp
+++ b/libs/flake/resources/KoCssStylePreset.cpp
@@ -24,11 +24,15 @@ const QString DESC = "desc";
const QString SAMPLE_SVG = "sample_svg";
const QString STYLE_TYPE = "style_type";
+const QString STYLE_TYPE_PARAGRAPH = "paragraph";
+const QString STYLE_TYPE_CHARACTER = "character";
+
struct KoCssStylePreset::Private {
Private()
: shape(new KoSvgTextShape())
{
+ shape->insertText(0, i18nc("info:placeholder", "Style Sample"));
}
~Private() {}
@@ -51,7 +55,6 @@ KoCssStylePreset::KoCssStylePreset(const KoCssStylePreset &rhs)
, d(new Private())
{
d->shape.reset(dynamic_cast<KoSvgTextShape*>(rhs.d->shape.data()->cloneShape()));
- setTitle(rhs.title());
setDescription(rhs.description());
setValid(true);
}
@@ -64,36 +67,47 @@ KoCssStylePreset::~KoCssStylePreset()
KoSvgTextProperties KoCssStylePreset::properties()
{
const QVector<int> treeIndex = d->shape->findTreeIndexForPropertyId(KoSvgTextProperties::KraTextStyleType);
+ qDebug() << "searching properties" << treeIndex;
+ if (treeIndex.isEmpty()) return KoSvgTextProperties();
return d->shape->propertiesForTreeIndex(treeIndex);
}
void KoCssStylePreset::setProperties(const KoSvgTextProperties &properties)
{
const QVector<int> treeIndex = d->shape->findTreeIndexForPropertyId(KoSvgTextProperties::KraTextStyleType);
- if (d->shape->propertiesForTreeIndex(treeIndex) == properties) return;
- d->shape->setPropertiesAtTreeIndex(treeIndex, properties);
+ if (!treeIndex.isEmpty() && d->shape->propertiesForTreeIndex(treeIndex) == properties) return;
+ if (treeIndex.isEmpty()) {
+ KoSvgTextProperties modifiedProps = properties;
+ modifiedProps.setProperty(KoSvgTextProperties::KraTextStyleType, STYLE_TYPE_PARAGRAPH);
+ d->shape->setPropertiesAtPos(-1, modifiedProps);
+ } else {
+ d->shape->setPropertiesAtTreeIndex(treeIndex, properties);
+ }
+ updateThumbnail();
+ setValid(true);
}
-QString KoCssStylePreset::title() const
+QString KoCssStylePreset::description() const
{
- return d->shape->additionalAttribute(TITLE);
+ QMap<QString, QVariant> m = metadata();
+ return m[DESCRIPTION].toString();
}
-void KoCssStylePreset::setTitle(QString title)
+void KoCssStylePreset::setDescription(QString description)
{
- d->shape->setAdditionalAttribute(TITLE, title);
+ d->shape->setAdditionalAttribute(DESC, description);
+ addMetaData(DESCRIPTION, description);
}
-QString KoCssStylePreset::description() const
+QString KoCssStylePreset::styleType() const
{
QMap<QString, QVariant> m = metadata();
- return m[DESCRIPTION].toString();
+ return m[STYLE_TYPE].toString();
}
-void KoCssStylePreset::setDescription(QString description)
+void KoCssStylePreset::setStyleType(const QString &type)
{
- d->shape->setAdditionalAttribute(DESC, description);
- addMetaData(DESCRIPTION, description);
+ addMetaData(STYLE_TYPE, type);
}
KoResourceSP KoCssStylePreset::clone() const
@@ -135,7 +149,7 @@ bool KoCssStylePreset::loadFromDevice(QIODevice *dev, KisResourcesInterfaceSP re
addMetaData(DESCRIPTION, d->shape->additionalAttribute(DESC));
QVector<int> treeIndex = d->shape->findTreeIndexForPropertyId(KoSvgTextProperties::KraTextStyleType);
qDebug() << "style found at..." << treeIndex;
- QString styleType = "paragraph";
+ QString styleType = STYLE_TYPE_PARAGRAPH;
if (!treeIndex.isEmpty()) {
KoSvgTextProperties props = d->shape->propertiesForTreeIndex(treeIndex);
styleType = props.propertyOrDefault(KoSvgTextProperties::KraTextStyleType).toString();
@@ -157,6 +171,33 @@ bool KoCssStylePreset::loadFromDevice(QIODevice *dev, KisResourcesInterfaceSP re
bool KoCssStylePreset::saveToDevice(QIODevice *dev) const
{
if (!d->shape) return false;
+
+ QMap<QString, QVariant> m = metadata();
+ d->shape->setAdditionalAttribute(DESC, m[DESCRIPTION].toString());
+ d->shape->setAdditionalAttribute(TITLE, name());
+
+ const QVector<int> treeIndex = d->shape->findTreeIndexForPropertyId(KoSvgTextProperties::KraTextStyleType);
+ if (!treeIndex.isEmpty()) {
+ KoSvgTextProperties props = d->shape->propertiesForTreeIndex(treeIndex);
+ bool removeParagraph = styleType() == STYLE_TYPE_CHARACTER;
+
+ // Remove properties that cannot be edited.
+ Q_FOREACH(KoSvgTextProperties::PropertyId p, props.properties()) {
+ if (KoSvgTextProperties::propertyIsBlockOnly(p)) {
+ if (removeParagraph) {
+ props.removeProperty(p);
+ }
+ } else {
+ if (!removeParagraph) {
+ props.removeProperty(p);
+ }
+ }
+ }
+
+ props.setProperty(KoSvgTextProperties::KraTextStyleType, styleType());
+ d->shape->setPropertiesAtTreeIndex(treeIndex, props);
+ }
+
SvgWriter writer({d->shape.data()});
return writer.save(*dev, d->shape->boundingRect().size());
}
diff --git a/libs/flake/resources/KoCssStylePreset.h b/libs/flake/resources/KoCssStylePreset.h
index bd02517af0..56ffec3797 100644
--- a/libs/flake/resources/KoCssStylePreset.h
+++ b/libs/flake/resources/KoCssStylePreset.h
@@ -31,14 +31,13 @@ public:
KoSvgTextProperties properties();
void setProperties(const KoSvgTextProperties &properties);
- /// The proper title of the style.
- QString title() const;
- void setTitle(QString title);
-
/// The description associated with this style.
QString description() const;
void setDescription(QString description);
+ QString styleType() const;
+ void setStyleType(const QString &type);
+
// KoResource interface
public:
KoResourceSP clone() const override;
@@ -50,7 +49,6 @@ public:
private:
struct Private;
QScopedPointer<Private> d;
-
};
#endif // KOCSSSTYLEPRESET_H
diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cpp
index 88599b28ea..28c2129e9c 100644
--- a/libs/flake/text/KoSvgTextShape.cpp
+++ b/libs/flake/text/KoSvgTextShape.cpp
@@ -1076,7 +1076,9 @@ QVector<int> KoSvgTextShape::findTreeIndexForPropertyId(KoSvgTextProperties::Pro
return QVector<int>({0});
} else {
treeIndex = findTreeIndexForPropertyIdImpl(it, propertyId);
- treeIndex.insert(0, 0);
+ if (!treeIndex.isEmpty()) {
+ treeIndex.insert(0, 0);
+ }
}
}
@@ -1256,7 +1258,6 @@ bool KoSvgTextShape::saveSvg(SvgSavingContext &context)
}
if (it == d->textData.compositionBegin()) {
context.shapeWriter().startElement("text", false);
- SvgStyleWriter::saveMetadata(this, context);
if (!context.strippedTextMode()) {
context.shapeWriter().addAttribute("id", context.getID(this));
@@ -1295,6 +1296,9 @@ bool KoSvgTextShape::saveSvg(SvgSavingContext &context)
d->childCount(siblingCurrent(it)) == 0,
shapeSpecificStyles);
} else {
+ if (it == d->textData.compositionBegin()) {
+ SvgStyleWriter::saveMetadata(this, context);
+ }
context.shapeWriter().endElement();
}
}
diff --git a/plugins/dockers/textproperties/CMakeLists.txt b/plugins/dockers/textproperties/CMakeLists.txt
index e0272d5ccd..c1d1154aaf 100644
--- a/plugins/dockers/textproperties/CMakeLists.txt
+++ b/plugins/dockers/textproperties/CMakeLists.txt
@@ -10,6 +10,7 @@ set(KRITA_TEXTPROPERTIES_SOURCES
CssQmlUnitConverter.cpp
TextPropertyConfigModel.cpp
TextPropertyConfigDialog.cpp
+ CssStylePresetEditDialog.cpp
)
qt_add_resources(KRITA_TEXTPROPERTIES_SOURCES textproperties.qrc)
diff --git a/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp b/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
new file mode 100644
index 0000000000..46529a0a08
--- /dev/null
+++ b/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp
@@ -0,0 +1,130 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include "CssStylePresetEditDialog.h"
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QQuickItem>
+#include <QColorDialog>
+#include <KoResourcePaths.h>
+#include <KLocalizedContext>
+#include <KLocalizedString>
+#include "FontAxesModel.h"
+#include "FontStyleModel.h"
+
+CssStylePresetEditDialog::CssStylePresetEditDialog(QWidget *parent)
+ :KoDialog(parent)
+ , m_model(new KoSvgTextPropertiesModel())
+
+{
+ setMinimumSize(500, 300);
+ setModal(true);
+
+ m_quickWidget = new QQuickWidget(this);
+ this->setMainWidget(m_quickWidget);
+ m_quickWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ m_quickWidget->engine()->rootContext()->setContextProperty("mainWindow", this);
+ m_quickWidget->engine()->rootContext()->setContextObject(new KLocalizedContext(this));
+
+ m_quickWidget->engine()->addImportPath(KoResourcePaths::getApplicationRoot() + "/lib/qml/");
+ m_quickWidget->engine()->addImportPath(KoResourcePaths::getApplicationRoot() + "/lib64/qml/");
+
+ m_quickWidget->engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib/qml/");
+ m_quickWidget->engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib64/qml/");
+
+ m_quickWidget->setPalette(this->palette());
+ this->setWindowTitle(i18nc("@title:window", "Edit Style Preset"));
+
+ QList<QLocale> locales;
+ QStringList wellFormedBCPNames;
+ Q_FOREACH (const QString langCode, KLocalizedString::languages()) {
+ locales.append(QLocale(langCode));
+ wellFormedBCPNames.append(langCode.split("_").join("-"));
+ }
+
+ FontStyleModel stylesModel;
+ FontAxesModel axesModel;
+ m_quickWidget->rootContext()->setContextProperty("fontStylesModel", QVariant::fromValue(&stylesModel));
+ m_quickWidget->rootContext()->setContextProperty("fontAxesModel", QVariant::fromValue(&axesModel));
+ m_quickWidget->rootContext()->setContextProperty("textPropertiesModel", m_model);
+ m_quickWidget->rootContext()->setContextProperty("locales", QVariant::fromValue(wellFormedBCPNames));
+ m_quickWidget->rootContext()->setContextProperty("canvasDPI", QVariant::fromValue(72));
+
+ connect(m_model, SIGNAL(textPropertyChanged()),
+ this, SLOT(slotUpdateTextProperties()));
+
+ m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
+ m_quickWidget->setSource(QUrl("qrc:/CssStylePresetEdit.qml"));
+
+ if (!m_quickWidget->errors().empty()) {
+ qWarning() << "Errors in " << windowTitle() << ":" << m_quickWidget->errors();
+ }
+}
+
+CssStylePresetEditDialog::~CssStylePresetEditDialog()
+{
+ /// Prevent accessing destroyed objects in QML engine
+ /// See:
+ /// * https://invent.kde.org/graphics/krita/-/commit/d8676f4e9cac1a8728e73fec3ff1df1763c713b7
+ /// * https://bugreports.qt.io/browse/QTBUG-81247
+ m_quickWidget->setParent(nullptr);
+ delete m_quickWidget;
+
+}
+
+void CssStylePresetEditDialog::setCurrentResource(KoCssStylePresetSP resource)
+{
+ if (resource == m_currentResource) return;
+ m_currentResource = resource;
+ KoSvgTextProperties properties = m_currentResource->properties();
+ KoSvgTextPropertyData textData;
+ textData.inheritedProperties = KoSvgTextProperties();
+ textData.commonProperties = properties;
+ m_model->textData.set(textData);
+ m_quickWidget->rootObject()->setProperty("presetTitle", m_currentResource->name());
+ 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);
+ return m_currentResource;
+}
+
+void CssStylePresetEditDialog::slotUpdateStylesModel()
+{
+
+}
+
+void CssStylePresetEditDialog::slotUpdateAxesValues()
+{
+
+}
+
+void CssStylePresetEditDialog::slotUpdateTextProperties()
+{
+ QMetaObject::invokeMethod(m_quickWidget->rootObject(), "setProperties");
+}
+
+QColor CssStylePresetEditDialog::modalColorDialog(QColor oldColor)
+{
+ QColor c = QColorDialog::getColor(oldColor);
+ return c.isValid()? c: oldColor;
+}
+
+QString CssStylePresetEditDialog::wwsFontFamilyName(QString familyName)
+{
+ return familyName;
+}
+
+void CssStylePresetEditDialog::connectAutoEnabler(QObject *watched)
+{
+
+}
diff --git a/plugins/dockers/textproperties/CssStylePresetEditDialog.h b/plugins/dockers/textproperties/CssStylePresetEditDialog.h
new file mode 100644
index 0000000000..807b119db2
--- /dev/null
+++ b/plugins/dockers/textproperties/CssStylePresetEditDialog.h
@@ -0,0 +1,39 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef CSSSTYLEPRESETEDITDIALOG_H
+#define CSSSTYLEPRESETEDITDIALOG_H
+
+#include <QObject>
+#include <KoDialog.h>
+#include <resources/KoCssStylePreset.h>
+#include <QQuickWidget>
+#include <lager/KoSvgTextPropertiesModel.h>
+
+class CssStylePresetEditDialog : public KoDialog
+{
+ Q_OBJECT
+public:
+ CssStylePresetEditDialog(QWidget *parent = nullptr);
+ ~CssStylePresetEditDialog();
+
+ void setCurrentResource(KoCssStylePresetSP resource);
+ KoCssStylePresetSP currentResource();
+
+public Q_SLOTS:
+ void slotUpdateStylesModel();
+ void slotUpdateAxesValues();
+ void slotUpdateTextProperties();
+ QColor modalColorDialog(QColor oldColor);
+ QString wwsFontFamilyName(QString familyName);
+ void connectAutoEnabler(QObject *watched);
+
+private:
+ QQuickWidget *m_quickWidget {0};
+ KoSvgTextPropertiesModel *m_model;
+ KoCssStylePresetSP m_currentResource;
+};
+
+#endif // CSSSTYLEPRESETEDITDIALOG_H
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cpp
index a1ad71f11d..ce5545210a 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp
+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp
@@ -27,6 +27,7 @@
#include <KisResourceModelProvider.h>
#include <KisTagModel.h>
#include <kis_signal_compressor.h>
+#include <KisResourceUserOperations.h>
#include <KoCanvasResourcesIds.h>
#include <KoSvgTextPropertyData.h>
@@ -55,6 +56,7 @@
#include <KisSurfaceColorSpaceWrapper.h>
#include "TextPropertyConfigDialog.h"
+#include "CssStylePresetEditDialog.h"
/// Strange place to put this, do we have a better spot?
KIS_DECLARE_STATIC_INITIALIZER {
@@ -345,7 +347,37 @@ void TextPropertiesDock::applyPreset(KoResourceSP resource)
Q_FOREACH(KoSvgTextProperties::PropertyId p, properties.properties()) {
textData.commonProperties.setProperty(p, properties.property(p));
}
+ qDebug() << "applied preset" << resource->name();
d->textModel->textData.set(textData);
}
+bool TextPropertiesDock::createNewPresetFromSettings()
+{
+ KoCssStylePresetSP preset(new KoCssStylePreset(QString()));
+ KoSvgTextPropertyData textData = d->textModel->textData.get();
+ preset->setProperties(textData.commonProperties);
+
+ CssStylePresetEditDialog *dialog = new CssStylePresetEditDialog(this);
+ dialog->setCurrentResource(preset);
+
+ if (dialog->exec() == QDialog::Accepted) {
+ return KisResourceUserOperations::addResourceWithUserInput(this, dialog->currentResource());
+ }
+
+ return false;
+}
+
+void TextPropertiesDock::editPreset(KoResourceSP resource)
+{
+ KoCssStylePresetSP preset = resource.staticCast<KoCssStylePreset>();
+ if (!preset) return;
+
+ CssStylePresetEditDialog *dialog = new CssStylePresetEditDialog(this);
+ dialog->setCurrentResource(preset);
+
+ if (dialog->exec() == QDialog::Accepted) {
+ KisResourceUserOperations::updateResourceWithUserInput(this, dialog->currentResource());
+ }
+}
+
#include "TextPropertiesDock.moc"
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.h b/plugins/dockers/textproperties/TextPropertiesDock.h
index d9b72c784f..f14faa5ef2 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.h
+++ b/plugins/dockers/textproperties/TextPropertiesDock.h
@@ -42,6 +42,10 @@ public Q_SLOTS:
void applyPreset(KoResourceSP resource);
+ bool createNewPresetFromSettings();
+ void editPreset(KoResourceSP resource);
+
+
private:
QPointer<KisCanvas2> m_canvas;
QQuickWidget *m_quickWidget {0};
diff --git a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
new file mode 100644
index 0000000000..e409c0665d
--- /dev/null
+++ b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
@@ -0,0 +1,81 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+import QtQuick 2.15
+import QtQuick.Layouts 1.15
+import QtQuick.Controls 2.15
+import org.krita.flake.text 1.0;
+
+Control {
+ id: styleEdit;
+
+ property alias presetTitle: presetTitleField.text;
+ property string styleType: "paragraph";
+ onStyleTypeChanged: {
+ styleTypeCmb.currentIndex = styleTypeCmb.indexOfValue(styleType === "paragraph"? TextPropertyBase.Paragraph: TextPropertyBase.Character);
+ }
+
+ PaletteControl {
+ id: styleEditPalette;
+ }
+ SystemPalette {
+ id: sysPalette;
+ colorGroup: styleEditPalette.colorGroup;
+ }
+ palette: styleEditPalette.palette;
+
+ background: Rectangle {
+ color: palette.window;
+ }
+
+ function setProperties() {
+ presetProperties.updateProperties();
+ }
+
+ ColumnLayout {
+ anchors.fill: parent;
+ RowLayout {
+ Layout.fillWidth: true;
+ Layout.preferredHeight: implicitHeight;
+ Label {
+ Layout.minimumWidth: implicitWidth;
+ text: i18nc("label:Title", "Title:");
+ }
+ TextField {
+ id: presetTitleField;
+ Layout.fillWidth: true;
+ }
+ }
+ RowLayout {
+ Layout.fillWidth: true;
+ Layout.preferredHeight: implicitHeight;
+ Label {
+ Layout.minimumWidth: implicitWidth;
+ text: i18nc("label:Title", "Style Type:");
+ }
+ ComboBox {
+ id: styleTypeCmb;
+ Layout.fillWidth: true;
+ model: [
+ {text: i18nc("listbox", "Character"), value: TextPropertyBase.Character},
+ {text: i18nc("listbox", "Paragraph"), value: TextPropertyBase.Paragraph}
+ ];
+ valueRole: "value";
+ textRole: "text";
+ onActivated: styleEdit.styleType = currentValue === TextPropertyBase.Character? "character": "paragraph";
+ }
+ }
+ TextPropertyBaseList {
+ Layout.fillWidth: true;
+ Layout.fillHeight: true;
+ id: presetProperties;
+ propertyType: styleType == "character"? TextPropertyBase.Character: TextPropertyBase.Paragraph;
+ onPropertyTypeChanged: {
+ fillPropertyList();
+ updateProperties();
+ }
+ }
+ }
+}
diff --git a/plugins/dockers/textproperties/qml/PaletteControl.qml b/plugins/dockers/textproperties/qml/PaletteControl.qml
index 94061a4e0e..f8c02b1caf 100644
--- a/plugins/dockers/textproperties/qml/PaletteControl.qml
+++ b/plugins/dockers/textproperties/qml/PaletteControl.qml
@@ -17,7 +17,12 @@ import QtQuick.Controls 2.15
Control {
id: paletteControl;
- property alias colorGroup: activePalette.colorGroup
+ property alias colorGroup: activePalette.colorGroup;
+ colorGroup: parent && typeof parent != 'undefined'?
+ parent.enabled?
+ parent.activeFocus? SystemPalette.Active: SystemPalette.Inactive:
+ SystemPalette.Disabled:
+ SystemPalette.Active;
SystemPalette {
id: activePalette;
diff --git a/plugins/dockers/textproperties/qml/ResourceView.qml b/plugins/dockers/textproperties/qml/ResourceView.qml
index bd14af15f0..5fe1a7ab3e 100644
--- a/plugins/dockers/textproperties/qml/ResourceView.qml
+++ b/plugins/dockers/textproperties/qml/ResourceView.qml
@@ -20,6 +20,7 @@ Control {
property alias resourceDelegate : view.delegate;
property alias addResourceRow: addResourceRow;
+ property alias additionalAddResourceRow: addResourceRowExtra.data;
function openContextMenu(x, y, resourceName, resourceIndex) {
tagActionsContextMenu.resourceName = resourceName;
@@ -242,6 +243,12 @@ Control {
onClicked: modelWrapper.removeResource();
}
+
+ Item {
+ id: addResourceRowExtra;
+ Layout.fillWidth: true;
+ Layout.fillHeight: true;
+ }
}
}
}
diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qml
index 408b3dfac1..6668d90600 100644
--- a/plugins/dockers/textproperties/qml/TextProperties.qml
+++ b/plugins/dockers/textproperties/qml/TextProperties.qml
@@ -16,14 +16,12 @@ Rectangle {
property TextPropertyConfigModel configModel : textPropertyConfigModel;
- SystemPalette {
- id: sysPalette;
- colorGroup: SystemPalette.Active
- }
-
PaletteControl {
id: paletteControl;
- colorGroup: root.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+ SystemPalette {
+ id: sysPalette;
+ colorGroup: paletteControl.colorGroup;
}
function setProperties() {
@@ -81,7 +79,9 @@ Rectangle {
palette: paletteControl.palette;
signal applyPreset;
- onApplyPreset: mainWindow.applyPreset(currentResource);
+ onApplyPreset: {
+ mainWindow.applyPreset(currentResource);
+ }
resourceDelegate: ItemDelegate {
id: presetDelegate;
@@ -130,7 +130,7 @@ Rectangle {
}
onDoubleClicked: {
presetView.modelWrapper.currentIndex = parent.model.index;
- presetView.applyPreset;
+ presetView.applyPreset();
}
ToolTip.text: presetDelegate.model.name + "\n" + presetDelegate.meta.description;
@@ -139,6 +139,23 @@ Rectangle {
}
}
+ additionalAddResourceRow: RowLayout {
+ ToolButton {
+ text: i18nc("@label:button", "Add Style Preset");
+ icon.source: "qrc:///light_list-add.svg";
+ icon.color: palette.text;
+ icon.width: 16;
+ icon.height: 16;
+ onClicked: mainWindow.createNewPresetFromSettings();
+ }
+ ToolButton {
+ icon.source: "qrc:///16_light_edit-rename.svg";
+ icon.color: palette.text;
+ icon.width: 16;
+ icon.height: 16;
+ onClicked: mainWindow.editPreset(presetView.currentResource);
+ }
+ }
}
}
}
diff --git a/plugins/dockers/textproperties/textproperties.qrc b/plugins/dockers/textproperties/textproperties.qrc
index 86b316e6b6..ca48440441 100644
--- a/plugins/dockers/textproperties/textproperties.qrc
+++ b/plugins/dockers/textproperties/textproperties.qrc
@@ -61,5 +61,6 @@
<file alias="TextRendering.qml">qml/TextRendering.qml</file>
<file alias="TextPropertyConfigDialog.qml">qml/TextPropertyConfigDialog.qml</file>
<file alias="ResourceView.qml">qml/ResourceView.qml</file>
+ <file alias="CssStylePresetEdit.qml">qml/CssStylePresetEdit.qml</file>
</qresource>
</RCC>