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

Split the canvas observer from the text properties docker into a qml object.

Wolthera van Hövell tot Westerflier19110686cc46
diff --git a/plugins/dockers/textproperties/CMakeLists.txt b/plugins/dockers/textproperties/CMakeLists.txt
index 2db43cf7c6..537132a735 100644
--- a/plugins/dockers/textproperties/CMakeLists.txt
+++ b/plugins/dockers/textproperties/CMakeLists.txt
@@ -11,6 +11,7 @@ set(KRITA_TEXTPROPERTIES_SOURCES
TextPropertyConfigModel.cpp
TextPropertyConfigDialog.cpp
CssStylePresetEditDialog.cpp
+ TextPropertiesCanvasObserver.cpp
)
qt_add_resources(KRITA_TEXTPROPERTIES_SOURCES textproperties.qrc)
diff --git a/plugins/dockers/textproperties/TextPropertiesCanvasObserver.cpp b/plugins/dockers/textproperties/TextPropertiesCanvasObserver.cpp
new file mode 100644
index 0000000000..be5c2d50a2
--- /dev/null
+++ b/plugins/dockers/textproperties/TextPropertiesCanvasObserver.cpp
@@ -0,0 +1,214 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include "TextPropertiesCanvasObserver.h"
+
+#include <KLocalizedContext>
+
+#include <KisViewManager.h>
+#include <kis_canvas_resource_provider.h>
+#include <kis_signal_compressor.h>
+
+#include <KisResourceModel.h>
+#include <KisResourceUserOperations.h>
+
+#include <lager/state.hpp>
+#include <QApplication>
+
+#include "TextPropertyConfigDialog.h"
+#include "CssStylePresetEditDialog.h"
+
+struct TextPropertiesCanvasObserver::Private {
+
+ Private(QObject *parent = nullptr)
+ : modelToProviderCompressor(KisSignalCompressor(200, KisSignalCompressor::FIRST_ACTIVE, parent)) {
+
+ }
+
+ KisSignalCompressor modelToProviderCompressor;
+
+ KoSvgTextPropertiesModel *textModel {new KoSvgTextPropertiesModel()};
+ KisCanvasResourceProvider *provider{nullptr};
+ TextPropertyConfigModel *textPropertyConfigModel {nullptr};
+ qreal currentDpi{72.0};
+ QStringList locales;
+};
+
+TextPropertiesCanvasObserver::TextPropertiesCanvasObserver(QObject *parent)
+ : QObject(parent)
+ , d(new Private(this))
+{
+ d->textPropertyConfigModel = new TextPropertyConfigModel(this);
+ QList<QLocale> locales;
+ QStringList wellFormedBCPNames;
+ Q_FOREACH (const QString langCode, KLocalizedString::languages()) {
+ locales.append(QLocale(langCode));
+ wellFormedBCPNames.append(langCode.split("_").join("-"));
+ }
+ d->locales = wellFormedBCPNames;
+
+ connect(d->textModel, SIGNAL(textPropertyChanged()),
+ &d->modelToProviderCompressor, SLOT(start()));
+ connect(&d->modelToProviderCompressor, SIGNAL(timeout()), this, SLOT(slotTextPropertiesChanged()));
+ connect(d->textModel, SIGNAL(textPropertyChanged()),
+ this, SIGNAL(textPropertiesChanged()));
+}
+
+TextPropertiesCanvasObserver::~TextPropertiesCanvasObserver()
+{
+
+}
+
+void TextPropertiesCanvasObserver::setViewManager(KisViewManager *kisview)
+{
+ d->provider = kisview->canvasResourceProvider();
+ if (d->provider) {
+ connect(d->provider, SIGNAL(sigTextPropertiesChanged()),
+ this, SLOT(slotCanvasTextPropertiesChanged()));
+
+ // This initializes the docker to an empty entry;
+ KoSvgTextPropertyData textData;
+ textData.inheritedProperties = KoSvgTextProperties();
+ d->provider->setTextPropertyData(textData);
+ }
+}
+
+void TextPropertiesCanvasObserver::setCanvas(KoCanvasBase *canvas)
+{
+ //setEnabled(true);
+
+ if (m_canvas == canvas) {
+ return;
+ }
+
+ if (m_canvas) {
+ m_canvas->disconnectCanvasObserver(this);
+ }
+
+ KIS_ASSERT(canvas);
+
+ m_canvas = dynamic_cast<KisCanvas2*>(canvas);
+ if (m_canvas && m_canvas->currentImage()) {
+ d->currentDpi = m_canvas->currentImage()->xRes() * 72.0;
+ Q_EMIT dpiChanged();
+ }
+}
+
+void TextPropertiesCanvasObserver::unsetCanvas()
+{
+ m_canvas = 0;
+}
+
+qreal TextPropertiesCanvasObserver::dpi() const
+{
+ return d->currentDpi;
+}
+
+QStringList TextPropertiesCanvasObserver::locales() const
+{
+ return d->locales;
+}
+
+KoSvgTextPropertiesModel *TextPropertiesCanvasObserver::textProperties() const
+{
+ return d->textModel;
+}
+
+TextPropertyConfigModel *TextPropertiesCanvasObserver::textPropertyConfig() const
+{
+ return d->textPropertyConfigModel;
+}
+
+void TextPropertiesCanvasObserver::slotCanvasTextPropertiesChanged()
+{
+ KoSvgTextPropertyData data = d->provider->textPropertyData();
+ if (d->textModel->textData.get() != data) {
+ d->textModel->textData.set(data);
+ Q_EMIT textPropertiesChanged();
+ }
+}
+
+void TextPropertiesCanvasObserver::slotTextPropertiesChanged()
+{
+ KoSvgTextPropertyData textData = d->textModel->textData.get();
+ debugFlake << Q_FUNC_INFO << textData;
+ if (d->provider && d->provider->textPropertyData() != textData) {
+ d->provider->setTextPropertyData(textData);
+ }
+}
+
+void TextPropertiesCanvasObserver::callModalTextPropertyConfigDialog()
+{
+ TextPropertyConfigDialog dialog(qApp->activeWindow());
+ dialog.setTextPropertyConfigModel(d->textPropertyConfigModel);
+ if (dialog.exec() == QDialog::Accepted) {
+ dialog.model()->saveConfiguration();
+ Q_EMIT textPropertyConfigChanged();
+ }
+}
+
+void TextPropertiesCanvasObserver::applyPreset(KoResourceSP resource)
+{
+ KoCssStylePresetSP preset = resource.staticCast<KoCssStylePreset>();
+ if (!preset) return;
+ KoSvgTextPropertyData textData = d->textModel->textData.get();
+ KoSvgTextProperties properties = preset->properties(d->currentDpi, true);
+ Q_FOREACH(KoSvgTextProperties::PropertyId p, properties.properties()) {
+ textData.commonProperties.setProperty(p, properties.property(p));
+ }
+ d->textModel->textData.set(textData);
+}
+
+bool TextPropertiesCanvasObserver::createNewPresetFromSettings()
+{
+ KoCssStylePresetSP preset(new KoCssStylePreset(QString()));
+ KoSvgTextPropertyData textData = d->textModel->textData.get();
+ preset->setProperties(textData.commonProperties);
+ preset->setName(i18nc("@info:placeholder", "New Style Preset"));
+ preset->setStyleType("character");
+ preset->updateThumbnail();
+
+ CssStylePresetEditDialog *dialog = new CssStylePresetEditDialog(qApp->activeWindow());
+ dialog->setDpi(d->currentDpi);
+ dialog->setCurrentResource(preset);
+
+ if (dialog->exec() == QDialog::Accepted) {
+ return KisResourceUserOperations::addResourceWithUserInput(qApp->activeWindow(), dialog->currentResource());
+ }
+
+ return false;
+}
+
+void TextPropertiesCanvasObserver::editPreset(KoResourceSP resource)
+{
+ KoCssStylePresetSP preset = resource.staticCast<KoCssStylePreset>();
+ if (!preset) return;
+
+ CssStylePresetEditDialog *dialog = new CssStylePresetEditDialog(qApp->activeWindow());
+ dialog->setCurrentResource(preset);
+
+ if (dialog->exec() == QDialog::Accepted) {
+ KisResourceUserOperations::updateResourceWithUserInput(qApp->activeWindow(), dialog->currentResource());
+ } else {
+ KisResourceModel model = KisResourceModel(ResourceType::CssStyles, qApp->activeWindow());
+ model.reloadResource(preset);
+ }
+}
+
+void TextPropertiesCanvasObserver::cloneAndEditPreset(KoResourceSP resource)
+{
+ KoResourceSP newResource = resource->clone();
+ KoCssStylePresetSP preset = newResource.staticCast<KoCssStylePreset>();
+ if (!preset) return;
+
+ CssStylePresetEditDialog *dialog = new CssStylePresetEditDialog(qApp->activeWindow());
+ dialog->setCurrentResource(preset);
+
+ if (dialog->exec() == QDialog::Accepted) {
+ preset = dialog->currentResource();
+ preset->setFilename(preset->name().replace(' ', '_').replace('.', '_') + preset->defaultFileExtension());
+ KisResourceUserOperations::addResourceWithUserInput(qApp->activeWindow(), preset);
+ }
+}
diff --git a/plugins/dockers/textproperties/TextPropertiesCanvasObserver.h b/plugins/dockers/textproperties/TextPropertiesCanvasObserver.h
new file mode 100644
index 0000000000..64294a15b4
--- /dev/null
+++ b/plugins/dockers/textproperties/TextPropertiesCanvasObserver.h
@@ -0,0 +1,70 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef TEXTPROPERTIESMANAGER_H
+#define TEXTPROPERTIESMANAGER_H
+
+#include <QObject>
+#include <kis_mainwindow_observer.h>
+
+#include <kis_canvas2.h>
+#include <KoResource.h>
+#include <lager/KoSvgTextPropertiesModel.h>
+#include "TextPropertyConfigModel.h"
+
+/**
+ * @brief The TextPropertiesCanvasObserver class
+ *
+ * This splits out the canvas observer tasks from the docker into
+ * it's own QObject, so that it may be instantiated inside QML.
+ *
+ * The benefit of this is that we'll have to do way less manipulating
+ * of the rootobject on the quickwidget if we want to communicate
+ * properties between qml and cpp. Given that the rootobject only exists when
+ * the qml successfully loads, this should require way less checks.
+ */
+class TextPropertiesCanvasObserver : public QObject, public KisMainwindowObserver
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal dpi READ dpi() NOTIFY dpiChanged)
+ Q_PROPERTY(QStringList locales READ locales() NOTIFY localesChanged)
+ Q_PROPERTY(KoSvgTextPropertiesModel *textProperties READ textProperties NOTIFY textPropertiesChanged)
+ Q_PROPERTY(TextPropertyConfigModel *textPropertyConfig READ textPropertyConfig NOTIFY textPropertyConfigChanged)
+public:
+ explicit TextPropertiesCanvasObserver(QObject *parent = nullptr);
+ ~TextPropertiesCanvasObserver();
+
+ QString observerName() override { return "TextPropertiesCanvasObserver"; }
+ void setViewManager(KisViewManager *kisview) override;
+ void setCanvas(KoCanvasBase *canvas) override;
+ void unsetCanvas() override;
+
+ qreal dpi() const;
+ QStringList locales() const;
+ KoSvgTextPropertiesModel *textProperties() const;
+ TextPropertyConfigModel *textPropertyConfig() const;
+
+public Q_SLOTS:
+ void slotCanvasTextPropertiesChanged();
+ void slotTextPropertiesChanged();
+
+ void callModalTextPropertyConfigDialog();
+
+ void applyPreset(KoResourceSP resource);
+ bool createNewPresetFromSettings();
+ void editPreset(KoResourceSP resource);
+ void cloneAndEditPreset(KoResourceSP resource);
+Q_SIGNALS:
+ void dpiChanged();
+ void localesChanged();
+ void textPropertiesChanged();
+ void textPropertyConfigChanged();
+private:
+ struct Private;
+ const QScopedPointer<Private> d;
+ QPointer<KisCanvas2> m_canvas;
+};
+
+#endif // TEXTPROPERTIESMANAGER_H
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cpp
index ef18834c67..45b20536fe 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp
+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp
@@ -6,8 +6,6 @@
#include "TextPropertiesDock.h"
-#include <lager/state.hpp>
-
#include <QQuickWidget>
#include <QQmlEngine>
#include <QQmlContext>
@@ -20,90 +18,23 @@
#include <KisViewManager.h>
#include <kis_canvas_resource_provider.h>
-#include <KisStaticInitializer.h>
#include <KLocalizedContext>
-
-#include <KisResourceModel.h>
-#include <KisResourceModelProvider.h>
-#include <KisTagModel.h>
-#include <kis_signal_compressor.h>
-#include <KisResourceUserOperations.h>
-
-#include <KoCanvasResourcesIds.h>
-#include <KoSvgTextPropertyData.h>
-#include <text/lager/KoSvgTextPropertiesModel.h>
-#include <text/lager/CssLengthPercentageModel.h>
-#include <text/lager/LineHeightModel.h>
-#include <text/lager/TextIndentModel.h>
-#include <text/lager/TabSizeModel.h>
-#include <text/lager/TextTransformModel.h>
-#include <text/lager/CssFontStyleModel.h>
-#include <text/lager/FontVariantLigaturesModel.h>
-#include <text/lager/FontVariantNumericModel.h>
-#include <text/lager/FontVariantEastAsianModel.h>
-#include <resources/KoFontFamily.h>
-#include <resources/KoCssStylePreset.h>
-#include <lager/state.hpp>
-
-#include "FontStyleModel.h"
-#include "FontAxesModel.h"
-#include "KoShapeQtQuickLabel.h"
-#include "OpenTypeFeatureModel.h"
-#include "TagFilterProxyModelQmlWrapper.h"
-#include "LocaleHandler.h"
-#include "CssQmlUnitConverter.h"
-#include "TextPropertyConfigModel.h"
-
-#include "TextPropertyConfigDialog.h"
-#include "CssStylePresetEditDialog.h"
-
-/// Strange place to put this, do we have a better spot?
-KIS_DECLARE_STATIC_INITIALIZER {
- qmlRegisterType<KoSvgTextPropertiesModel>("org.krita.flake.text", 1, 0, "KoSvgTextPropertiesModel");
- qmlRegisterType<CssLengthPercentageModel>("org.krita.flake.text", 1, 0, "CssLengthPercentageModel");
- qmlRegisterType<LineHeightModel>("org.krita.flake.text", 1, 0, "LineHeightModel");
- qmlRegisterType<TextIndentModel>("org.krita.flake.text", 1, 0, "TextIndentModel");
- qmlRegisterType<TabSizeModel>("org.krita.flake.text", 1, 0, "TabSizeModel");
- qmlRegisterType<TextTransformModel>("org.krita.flake.text", 1, 0, "TextTransformModel");
- qmlRegisterType<CssFontStyleModel>("org.krita.flake.text", 1, 0, "CssFontStyleModel");
- qmlRegisterType<FontVariantLigaturesModel>("org.krita.flake.text", 1, 0, "FontVariantLigaturesModel");
- qmlRegisterType<FontVariantNumericModel>("org.krita.flake.text", 1, 0, "FontVariantNumericModel");
- qmlRegisterType<FontVariantEastAsianModel>("org.krita.flake.text", 1, 0, "FontVariantEastAsianModel");
- qmlRegisterUncreatableMetaObject(KoSvgText::staticMetaObject, "org.krita.flake.text", 1, 0, "KoSvgText", "Error: Namespace with enums");
-
- qmlRegisterType<FontStyleModel>("org.krita.flake.text", 1, 0, "FontStyleModel");
- qmlRegisterType<FontAxesModel>("org.krita.flake.text", 1, 0, "FontAxesModel");
- qmlRegisterType<OpenTypeFeatureFilterModel>("org.krita.flake.text", 1, 0, "OpenTypeFeatureFilterModel");
- qmlRegisterType<OpenTypeFeatureModel>("org.krita.flake.text", 1, 0, "OpenTypeFeatureModel");
- qmlRegisterType<KoShapeQtQuickLabel>("org.krita.flake.text", 1, 0, "KoShapeQtQuickLabel");
- qmlRegisterType<CssQmlUnitConverter>("org.krita.flake.text", 1, 0, "CssQmlUnitConverter");
- qmlRegisterType<TagFilterProxyModelQmlWrapper>("org.krita.flake.text", 1, 0, "TagFilterProxyModelQmlWrapper");
- qmlRegisterType<LocaleHandler>("org.krita.flake.text", 1, 0, "LocaleHandler");
- qmlRegisterType<TextPropertyConfigModel>("org.krita.flake.text", 1, 0, "TextPropertyConfigModel");
- qmlRegisterType<TextPropertyConfigFilterModel>("org.krita.flake.text", 1, 0, "TextPropertyConfigFilterModel");
-}
+#include "TextPropertiesCanvasObserver.h"
struct TextPropertiesDock::Private
{
Private(QObject *parent = nullptr)
- : modelToProviderCompressor(KisSignalCompressor(200, KisSignalCompressor::FIRST_ACTIVE, parent))
- , providerToModelCompressor(KisSignalCompressor(200, KisSignalCompressor::FIRST_ACTIVE, parent)){
+ : canvasObserver(new TextPropertiesCanvasObserver(parent)) {
}
- KoSvgTextPropertiesModel *textModel {new KoSvgTextPropertiesModel()};
- KisCanvasResourceProvider *provider{nullptr};
- TextPropertyConfigModel *textPropertyConfigModel {nullptr};
- qreal currentDpi{72.0};
-
- KisSignalCompressor modelToProviderCompressor;
- KisSignalCompressor providerToModelCompressor;
+ TextPropertiesCanvasObserver *canvasObserver{nullptr};
};
TextPropertiesDock::TextPropertiesDock()
: QDockWidget(i18n("Text Properties"))
- , d(new Private(this))
+ , d(new Private)
{
m_quickWidget = new KisQQuickWidget(this);
@@ -112,24 +43,14 @@ TextPropertiesDock::TextPropertiesDock()
m_quickWidget->setMinimumHeight(100);
- d->textPropertyConfigModel = new TextPropertyConfigModel(this);
+ m_quickWidget->setSource(QUrl("qrc:/TextProperties.qml"));
- QList<QLocale> locales;
- QStringList wellFormedBCPNames;
- Q_FOREACH (const QString langCode, KLocalizedString::languages()) {
- locales.append(QLocale(langCode));
- wellFormedBCPNames.append(langCode.split("_").join("-"));
+ if (!m_quickWidget->errors().empty()) {
+ qWarning() << "Errors in " << windowTitle() << ":" << m_quickWidget->errors();
+ } else {
+ m_quickWidget->rootObject()->setProperty("canvasObserver", QVariant::fromValue(d->canvasObserver));
}
-
- m_quickWidget->rootContext()->setContextProperty("textPropertiesModel", d->textModel);
- m_quickWidget->rootContext()->setContextProperty("textPropertyConfigModel", QVariant::fromValue(d->textPropertyConfigModel));
- m_quickWidget->rootContext()->setContextProperty("locales", QVariant::fromValue(wellFormedBCPNames));
- connect(d->textModel, SIGNAL(textPropertyChanged()),
- &d->modelToProviderCompressor, SLOT(start()));
- connect(&d->modelToProviderCompressor, SIGNAL(timeout()), this, SLOT(slotTextPropertiesChanged()));
- m_quickWidget->setSource(QUrl("qrc:/TextProperties.qml"));
-
m_quickWidget->setPalette(this->palette());
}
@@ -138,45 +59,24 @@ TextPropertiesDock::~TextPropertiesDock()
delete m_quickWidget;
}
-void TextPropertiesDock::setViewManager(KisViewManager *kisview)
+QString TextPropertiesDock::observerName()
{
- d->provider = kisview->canvasResourceProvider();
- if (d->provider) {
- connect(d->provider, SIGNAL(sigTextPropertiesChanged()),
- this, SLOT(slotCanvasTextPropertiesChanged()));
+ return d->canvasObserver->observerName();
+}
- // This initializes the docker to an empty entry;
- KoSvgTextPropertyData textData;
- textData.inheritedProperties = KoSvgTextProperties();
- d->provider->setTextPropertyData(textData);
- }
+void TextPropertiesDock::setViewManager(KisViewManager *kisview)
+{
+ d->canvasObserver->setViewManager(kisview);
}
void TextPropertiesDock::setCanvas(KoCanvasBase *canvas)
{
- setEnabled(true);
-
- if (m_canvas == canvas) {
- return;
- }
-
- if (m_canvas) {
- m_canvas->disconnectCanvasObserver(this);
- }
-
- KIS_ASSERT(canvas);
-
- m_canvas = dynamic_cast<KisCanvas2*>(canvas);
- if (m_canvas && m_canvas->currentImage()) {
- d->currentDpi = m_canvas->currentImage()->xRes() * 72.0;
- m_quickWidget->rootObject()->setProperty("canvasDPI", QVariant::fromValue(d->currentDpi));
- }
+ d->canvasObserver->setCanvas(canvas);
}
void TextPropertiesDock::unsetCanvas()
{
- setEnabled(false);
- m_canvas = 0;
+ d->canvasObserver->unsetCanvas();
}
QColor TextPropertiesDock::modalColorDialog(QColor oldColor)
@@ -185,34 +85,6 @@ QColor TextPropertiesDock::modalColorDialog(QColor oldColor)
return c.isValid()? c: oldColor;
}
-void TextPropertiesDock::callModalTextPropertyConfigDialog()
-{
- TextPropertyConfigDialog dialog(this);
- dialog.setTextPropertyConfigModel(d->textPropertyConfigModel);
- if (dialog.exec() == QDialog::Accepted) {
- dialog.model()->saveConfiguration();
- QMetaObject::invokeMethod(m_quickWidget->rootObject(), "updatePropertyVisibilityState");
- }
-}
-
-void TextPropertiesDock::slotCanvasTextPropertiesChanged()
-{
- KoSvgTextPropertyData data = d->provider->textPropertyData();
- if (d->textModel->textData.get() != data) {
- d->textModel->textData.set(data);
- }
-}
-
-void TextPropertiesDock::slotTextPropertiesChanged()
-{
- KoSvgTextPropertyData textData = d->textModel->textData.get();
- debugFlake << Q_FUNC_INFO << textData;
- if (d->provider && d->provider->textPropertyData() != textData) {
- d->provider->setTextPropertyData(textData);
- }
- QMetaObject::invokeMethod(m_quickWidget->rootObject(), "setProperties");
-}
-
#include <KoFontRegistry.h>
QString TextPropertiesDock::wwsFontFamilyName(QString familyName, bool returnEmptyWhenMissing)
{
@@ -222,67 +94,3 @@ QString TextPropertiesDock::wwsFontFamilyName(QString familyName, bool returnEmp
}
return name.value();
}
-
-void TextPropertiesDock::applyPreset(KoResourceSP resource)
-{
- KoCssStylePresetSP preset = resource.staticCast<KoCssStylePreset>();
- if (!preset) return;
- KoSvgTextPropertyData textData = d->textModel->textData.get();
- KoSvgTextProperties properties = preset->properties(d->currentDpi, true);
- Q_FOREACH(KoSvgTextProperties::PropertyId p, properties.properties()) {
- textData.commonProperties.setProperty(p, properties.property(p));
- }
- d->textModel->textData.set(textData);
-}
-
-bool TextPropertiesDock::createNewPresetFromSettings()
-{
- KoCssStylePresetSP preset(new KoCssStylePreset(QString()));
- KoSvgTextPropertyData textData = d->textModel->textData.get();
- preset->setProperties(textData.commonProperties);
- preset->setName(i18nc("@info:placeholder", "New Style Preset"));
- preset->setStyleType("character");
- preset->updateThumbnail();
-
- CssStylePresetEditDialog *dialog = new CssStylePresetEditDialog(this);
- dialog->setDpi(d->currentDpi);
- 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());
- } else {
- KisResourceModel model = KisResourceModel(ResourceType::CssStyles, this);
- model.reloadResource(preset);
- }
-}
-
-void TextPropertiesDock::cloneAndEditPreset(KoResourceSP resource)
-{
- KoResourceSP newResource = resource->clone();
- KoCssStylePresetSP preset = newResource.staticCast<KoCssStylePreset>();
- if (!preset) return;
-
- CssStylePresetEditDialog *dialog = new CssStylePresetEditDialog(this);
- dialog->setCurrentResource(preset);
-
- if (dialog->exec() == QDialog::Accepted) {
- preset = dialog->currentResource();
- preset->setFilename(preset->name().replace(' ', '_').replace('.', '_') + preset->defaultFileExtension());
- KisResourceUserOperations::addResourceWithUserInput(this, preset);
- }
-}
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.h b/plugins/dockers/textproperties/TextPropertiesDock.h
index f4bfbcaf09..28b13162bc 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.h
+++ b/plugins/dockers/textproperties/TextPropertiesDock.h
@@ -23,25 +23,17 @@ class TextPropertiesDock : public QDockWidget, public KisMainwindowObserver {
public:
TextPropertiesDock();
~TextPropertiesDock();
- QString observerName() override { return "TextPropertiesDock"; }
+
+ QString observerName() override;
void setViewManager(KisViewManager *kisview) override;
void setCanvas(KoCanvasBase *canvas) override;
void unsetCanvas() override;
public Q_SLOTS:
- void slotCanvasTextPropertiesChanged();
- void slotTextPropertiesChanged();
QString wwsFontFamilyName(QString familyName, bool returnEmptyWhenMissing = false);
QColor modalColorDialog(QColor oldColor);
- void callModalTextPropertyConfigDialog();
-
- void applyPreset(KoResourceSP resource);
-
- bool createNewPresetFromSettings();
- void editPreset(KoResourceSP resource);
- void cloneAndEditPreset(KoResourceSP resource);
private:
diff --git a/plugins/dockers/textproperties/TextPropertiesPlugin.cpp b/plugins/dockers/textproperties/TextPropertiesPlugin.cpp
index ce2427484e..8693d46681 100644
--- a/plugins/dockers/textproperties/TextPropertiesPlugin.cpp
+++ b/plugins/dockers/textproperties/TextPropertiesPlugin.cpp
@@ -9,6 +9,7 @@
#include <kpluginfactory.h>
#include <klocalizedstring.h>
#include <KoDockFactoryBase.h>
+#include <KisStaticInitializer.h>
#include "kis_config.h"
#include "kis_types.h"
@@ -17,8 +18,55 @@
#include "TextPropertiesDock.h"
#include <KoDockRegistry.h>
+#include <text/lager/KoSvgTextPropertiesModel.h>
+#include <text/lager/CssLengthPercentageModel.h>
+#include <text/lager/LineHeightModel.h>
+#include <text/lager/TextIndentModel.h>
+#include <text/lager/TabSizeModel.h>
+#include <text/lager/TextTransformModel.h>
+#include <text/lager/CssFontStyleModel.h>
+#include <text/lager/FontVariantLigaturesModel.h>
+#include <text/lager/FontVariantNumericModel.h>
+#include <text/lager/FontVariantEastAsianModel.h>
+
+#include "FontStyleModel.h"
+#include "FontAxesModel.h"
+#include "KoShapeQtQuickLabel.h"
+#include "OpenTypeFeatureModel.h"
+#include "TagFilterProxyModelQmlWrapper.h"
+#include "LocaleHandler.h"
+#include "CssQmlUnitConverter.h"
+#include "TextPropertyConfigModel.h"
+#include "TextPropertiesCanvasObserver.h"
+
K_PLUGIN_FACTORY_WITH_JSON(TextPropertiesPluginFactory, "krita_textproperties.json", registerPlugin<TextPropertiesPlugin>();)
+KIS_DECLARE_STATIC_INITIALIZER {
+ qmlRegisterType<TextPropertiesCanvasObserver>("org.krita.flake.text", 1, 0, "TextPropertiesCanvasObserver");
+ qmlRegisterType<KoSvgTextPropertiesModel>("org.krita.flake.text", 1, 0, "KoSvgTextPropertiesModel");
+ qmlRegisterType<CssLengthPercentageModel>("org.krita.flake.text", 1, 0, "CssLengthPercentageModel");
+ qmlRegisterType<LineHeightModel>("org.krita.flake.text", 1, 0, "LineHeightModel");
+ qmlRegisterType<TextIndentModel>("org.krita.flake.text", 1, 0, "TextIndentModel");
+ qmlRegisterType<TabSizeModel>("org.krita.flake.text", 1, 0, "TabSizeModel");
+ qmlRegisterType<TextTransformModel>("org.krita.flake.text", 1, 0, "TextTransformModel");
+ qmlRegisterType<CssFontStyleModel>("org.krita.flake.text", 1, 0, "CssFontStyleModel");
+ qmlRegisterType<FontVariantLigaturesModel>("org.krita.flake.text", 1, 0, "FontVariantLigaturesModel");
+ qmlRegisterType<FontVariantNumericModel>("org.krita.flake.text", 1, 0, "FontVariantNumericModel");
+ qmlRegisterType<FontVariantEastAsianModel>("org.krita.flake.text", 1, 0, "FontVariantEastAsianModel");
+ qmlRegisterUncreatableMetaObject(KoSvgText::staticMetaObject, "org.krita.flake.text", 1, 0, "KoSvgText", "Error: Namespace with enums");
+
+ qmlRegisterType<FontStyleModel>("org.krita.flake.text", 1, 0, "FontStyleModel");
+ qmlRegisterType<FontAxesModel>("org.krita.flake.text", 1, 0, "FontAxesModel");
+ qmlRegisterType<OpenTypeFeatureFilterModel>("org.krita.flake.text", 1, 0, "OpenTypeFeatureFilterModel");
+ qmlRegisterType<OpenTypeFeatureModel>("org.krita.flake.text", 1, 0, "OpenTypeFeatureModel");
+ qmlRegisterType<KoShapeQtQuickLabel>("org.krita.flake.text", 1, 0, "KoShapeQtQuickLabel");
+ qmlRegisterType<CssQmlUnitConverter>("org.krita.flake.text", 1, 0, "CssQmlUnitConverter");
+ qmlRegisterType<TagFilterProxyModelQmlWrapper>("org.krita.flake.text", 1, 0, "TagFilterProxyModelQmlWrapper");
+ qmlRegisterType<LocaleHandler>("org.krita.flake.text", 1, 0, "LocaleHandler");
+ qmlRegisterType<TextPropertyConfigModel>("org.krita.flake.text", 1, 0, "TextPropertyConfigModel");
+ qmlRegisterType<TextPropertyConfigFilterModel>("org.krita.flake.text", 1, 0, "TextPropertyConfigFilterModel");
+}
+
class TextPropertiesDockFactory : public KoDockFactoryBase {
public:
TextPropertiesDockFactory()
diff --git a/plugins/dockers/textproperties/qml/AlignmentBaseline.qml b/plugins/dockers/textproperties/qml/AlignmentBaseline.qml
index 8e4f9da231..ec2a279166 100644
--- a/plugins/dockers/textproperties/qml/AlignmentBaseline.qml
+++ b/plugins/dockers/textproperties/qml/AlignmentBaseline.qml
@@ -18,12 +18,30 @@ TextPropertyBase {
"alignment-baseline, mojisoroe");
property int baselineSelection;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onAlignmentBaselineChanged() {
+ updateAlignmentBaseline();
+ updateVisibility();
+ }
+
+ function onAlignmentBaselineStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateAlignmentBaseline();
+ updateVisibility();
+ }
+ function updateAlignmentBaseline() {
blockSignals = true;
baselineSelection = properties.alignmentBaseline;
+ blockSignals = false;
+ }
+
+ function updateVisibility() {
propertyState = [properties.alignmentBaselineState];
setVisibleFromProperty();
- blockSignals = false;
}
onBaselineSelectionChanged: {
diff --git a/plugins/dockers/textproperties/qml/BaselineShift.qml b/plugins/dockers/textproperties/qml/BaselineShift.qml
index b72764fcda..6fb625e7e2 100644
--- a/plugins/dockers/textproperties/qml/BaselineShift.qml
+++ b/plugins/dockers/textproperties/qml/BaselineShift.qml
@@ -23,14 +23,59 @@ TextPropertyBase {
property alias baselineShiftUnit: baselineShiftUnitCmb.dataUnit;
property int baselineShiftMode;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onBaselineShiftModeChanged() {
+ updateBaselineShiftMode();
+ updateVisibility();
+ }
+ function onBaselineShiftValueChanged() {
+ updateBaselineShiftValue();
+ updateVisibility();
+ }
+
+ // Fontsize and lineheight affect the metrics.
+ function onFontSizeChanged() {
+ updateUnits();
+ }
+ function onFontFamiliesChanged() {
+ updateUnits();
+ }
+ function onLineHeightChanged() {
+ updateUnits();
+ }
+
+ function onBaselineShiftStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateUnits();
+ updateBaselineShiftMode();
+ updateBaselineShiftValue();
+ updateVisibility();
+ }
+
+ function updateUnits() {
blockSignals = true;
- baselineShiftMode = properties.baselineShiftMode;
baselineShiftUnitCmb.setTextProperties(properties);
- baselineShiftUnitCmb.setDataValueAndUnit(properties.baselineShiftValue.value, properties.baselineShiftValue.unitType)
+ blockSignals = false;
+ }
+
+ function updateBaselineShiftMode() {
+ blockSignals = true;
+ baselineShiftMode = properties.baselineShiftMode;
+ blockSignals = false;
+ }
+ function updateBaselineShiftValue() {
+ blockSignals = true;
+ baselineShiftUnitCmb.setDataValueAndUnit(properties.baselineShiftValue.value, properties.baselineShiftValue.unitType);
+ blockSignals = false;
+ }
+
+ function updateVisibility() {
propertyState = [properties.baselineShiftState];
setVisibleFromProperty();
- blockSignals = false;
}
onBaselineShiftValueChanged: {
diff --git a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
index ad06d37bc8..3af6f6e84b 100644
--- a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
+++ b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml
@@ -165,6 +165,7 @@ Control {
}
}
TextPropertyBaseList {
+ propertiesModel: textPropertiesModel;
Layout.fillWidth: true;
Layout.fillHeight: true;
canvasDPI: styleEdit.makePixelRelative? styleEdit.pixelRelativeDPI: styleEdit.canvasDPI;
diff --git a/plugins/dockers/textproperties/qml/Direction.qml b/plugins/dockers/textproperties/qml/Direction.qml
index 73ee056b7a..ec272f8003 100644
--- a/plugins/dockers/textproperties/qml/Direction.qml
+++ b/plugins/dockers/textproperties/qml/Direction.qml
@@ -21,16 +21,43 @@ TextPropertyBase {
property int direction;
property int unicodeBidi;
+ Connections {
+ target: properties;
+ function onDirectionChanged() {
+ updateDirection();
+ updateVisibility();
+ }
+ function onUnicodeBidiChanged() {
+ updateUnicodeBidi();
+ updateVisibility();
+ }
+ function onDirectionStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateDirection();
+ updateUnicodeBidi();
+ updateVisibility();
+ }
- onPropertiesUpdated: {
+ function updateDirection() {
blockSignals = true;
direction = properties.direction;
+ blockSignals = false;
+ }
+
+ function updateUnicodeBidi() {
+ blockSignals = true;
unicodeBidi = properties.unicodeBidi;
+ blockSignals = false;
+ }
+
+ function updateVisibility() {
enabled = parentPropertyType === TextPropertyBase.Paragraph? !properties.spanSelection: properties.spanSelection;
propertyState = [properties.directionState];
setVisibleFromProperty();
- blockSignals = false;
}
onDirectionChanged: {
diff --git a/plugins/dockers/textproperties/qml/DominantBaseline.qml b/plugins/dockers/textproperties/qml/DominantBaseline.qml
index 32da514bfd..ff874eea52 100644
--- a/plugins/dockers/textproperties/qml/DominantBaseline.qml
+++ b/plugins/dockers/textproperties/qml/DominantBaseline.qml
@@ -18,12 +18,30 @@ TextPropertyBase {
"dominant-baseline, mojisoroe");
property int baselineSelection
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onDominantBaselineChanged() {
+ updateDominantBaseline();
+ updateVisibility();
+ }
+
+ function onDominantBaselineStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateDominantBaseline();
+ updateVisibility();
+ }
+ function updateDominantBaseline() {
blockSignals = true;
baselineSelection = properties.dominantBaseline;
+ blockSignals = false;
+ }
+
+ function updateVisibility() {
propertyState = [properties.dominantBaselineState];
setVisibleFromProperty();
- blockSignals = false;
}
onBaselineSelectionChanged: {
diff --git a/plugins/dockers/textproperties/qml/FontFamily.qml b/plugins/dockers/textproperties/qml/FontFamily.qml
index 0d178bea07..1a678068f7 100644
--- a/plugins/dockers/textproperties/qml/FontFamily.qml
+++ b/plugins/dockers/textproperties/qml/FontFamily.qml
@@ -10,6 +10,7 @@ import org.krita.flake.text 1.0
import org.krita.components 1.0 as Kis
CollapsibleGroupProperty {
+ id: root;
propertyTitle: i18nc("@label", "Font Family");
propertyName: "font-family";
propertyType: TextPropertyConfigModel.Character;
@@ -20,13 +21,33 @@ CollapsibleGroupProperty {
"font-family, typeface, font, fallback");
property var fontFamilies: [];
+ property var locales: [];
- onPropertiesUpdated: {
- blockSignals = true;
- fontFamilies = properties.fontFamilies;
+ Connections {
+ target: properties;
+ function onFontFamiliesChanged() {
+ updateFontFamilies();
+ updateFontFamilies();
+ }
+
+ function onFontFamiliesStateChanged() {
+ updateFontFamilies();
+ }
+ }
+ onPropertiesChanged: {
+ updateFontFamilies();
+ setVisibleFromProperty();
+ }
+
+ function updateFontFamilies() {
+ blockSignals = true;
+ fontFamilies = properties.fontFamilies;
+ blockSignals = false;
+ }
+
+ function updateVisibility() {
propertyState = [properties.fontFamiliesState];
setVisibleFromProperty();
- blockSignals = false;
}
onFontFamiliesChanged: {
@@ -54,6 +75,7 @@ CollapsibleGroupProperty {
FontResourceDropdown {
id: mainFamilyCmb;
Layout.fillWidth: true;
+ locales: root.locales;
onActivated: {
if (fontFamilies.length >0) {
fontFamilies[0] = text;
@@ -106,6 +128,7 @@ CollapsibleGroupProperty {
FontResourceDropdown {
id: fontCmb;
Layout.fillWidth: true;
+ locales: root.locales;
onActivated: {
fontFamilies[fontListDelegate.dIndex] = text;
}
diff --git a/plugins/dockers/textproperties/qml/FontKerning.qml b/plugins/dockers/textproperties/qml/FontKerning.qml
index 08f6c042f5..e893879e64 100644
--- a/plugins/dockers/textproperties/qml/FontKerning.qml
+++ b/plugins/dockers/textproperties/qml/FontKerning.qml
@@ -22,12 +22,32 @@ TextPropertyBase {
"font-kerning, tracking");
property alias kerning: fontKerningCbx.checked;
- onPropertiesUpdated: {
+
+ Connections {
+ target: properties;
+ function onFontKerningChanged() {
+ updateKerning();
+ updateVisibility();
+ }
+
+ function onFontKerningStateChanged() {
+ updateVisibility();
+ }
+ }
+
+ onPropertiesChanged: {
+ updateKerning();
+ updateVisibility();
+ }
+
+ function updateKerning() {
blockSignals = true;
kerning = properties.fontKerning;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.fontKerningState];
setVisibleFromProperty();
- blockSignals = false;
}
onKerningChanged: {
diff --git a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
index abc434e204..f7b44d1a45 100644
--- a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
+++ b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
@@ -20,6 +20,7 @@ Button {
id: modelWrapperId;
resourceType: "fontfamilies";
};
+ property var locales: [];
Kis.ThemedControl {
id: palControl;
@@ -57,8 +58,8 @@ Button {
property string sample: "";
Component.onCompleted: {
- fontName = modelWrapper.localizedNameFromMetadata(meta, locales, model.name);
- sample = modelWrapper.localizedSampleFromMetadata(meta, locales, "");
+ fontName = modelWrapper.localizedNameFromMetadata(meta, familyCmb.locales, model.name);
+ sample = modelWrapper.localizedSampleFromMetadata(meta, familyCmb.locales, "");
}
/// When updating the model wrapper, the "model" doesn't always update on the delegate, so we need to manually load
diff --git a/plugins/dockers/textproperties/qml/FontSize.qml b/plugins/dockers/textproperties/qml/FontSize.qml
index 43642590b3..a9fa8f12d5 100644
--- a/plugins/dockers/textproperties/qml/FontSize.qml
+++ b/plugins/dockers/textproperties/qml/FontSize.qml
@@ -23,14 +23,49 @@ TextPropertyBase {
property alias fontSize: fontSizeUnitCmb.dataValue;
property alias fontSizeUnit: fontSizeUnitCmb.dataUnit;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onFontSizeChanged() {
+ updateFontSize();
+ updateVisibility();
+ }
+
+ function onFontFamiliesChanged() {
+ updateUnits();
+ }
+ function onLineHeightChanged() {
+ updateUnits();
+ }
+
+ function onFontSizeStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateUnits();
+ updateFontSize();
+ updateVisibility();
+ }
+
+ function updateUnits() {
blockSignals = true;
fontSizeUnitCmb.setTextProperties(properties);
- fontSizeUnitCmb.setDataValueAndUnit(properties.fontSize.value, properties.fontSize.unitType);
+ blockSignals = false;
+ }
+
+ function updateFontSize() {
+ if (!fontSizeSpn.isDragging) {
+ blockSignals = true;
+ fontSizeUnitCmb.setDataValueAndUnit(properties.fontSize.value, properties.fontSize.unitType);
+ blockSignals = false;
+ }
+ }
+
+ function updateVisibility() {
propertyState = [properties.fontSizeState];
setVisibleFromProperty();
- blockSignals = false;
}
+
onFontSizeChanged: {
if (!blockSignals) {
properties.fontSize.value = fontSize;
@@ -63,7 +98,7 @@ TextPropertyBase {
softDFrom: 0;
softDTo: 72;
softRangeActive: true;
- blockUpdateSignalOnDrag: true;
+ //blockUpdateSignalOnDrag: true;
onDValueChanged: fontSizeUnitCmb.userValue = dValue;
}
diff --git a/plugins/dockers/textproperties/qml/FontSizeAdjust.qml b/plugins/dockers/textproperties/qml/FontSizeAdjust.qml
index 8a267e624a..d013e1b0a5 100644
--- a/plugins/dockers/textproperties/qml/FontSizeAdjust.qml
+++ b/plugins/dockers/textproperties/qml/FontSizeAdjust.qml
@@ -20,13 +20,34 @@ TextPropertyBase {
property alias fontSizeAdjust: fontSizeAdjustSpn.dValue;
- onPropertiesUpdated: {
- blockSignals = true;
- fontSizeAdjust = properties.fontSizeAdjust;
+ Connections {
+ target: properties;
+ function onFontSizeAdjustChanged() {
+ updateFontSizeAdjust();
+ updateVisibility();
+ }
+
+ function onFontSizeAdjustStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateFontSizeAdjust();
+ setVisibleFromProperty();
+ }
+
+ function updateFontSizeAdjust() {
+ if (!fontSizeAdjustSpn.isDragging) {
+ blockSignals = true;
+ fontSizeAdjust = properties.fontSizeAdjust;
+ blockSignals = false;
+ }
+ }
+ function updateVisibility() {
propertyState = [properties.fontSizeAdjustState];
setVisibleFromProperty();
- blockSignals = false;
}
+
onFontSizeAdjustChanged: {
if (!blockSignals) {
properties.fontSizeAdjust = fontSizeAdjust;
@@ -56,7 +77,7 @@ TextPropertyBase {
dStepSize: 0.1;
Layout.preferredWidth: implicitWidth;
Layout.fillWidth: true;
- blockUpdateSignalOnDrag: true;
+ //blockUpdateSignalOnDrag: true;
}
Button {
diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qml
index 070090312f..9e38fdb52a 100644
--- a/plugins/dockers/textproperties/qml/FontStyle.qml
+++ b/plugins/dockers/textproperties/qml/FontStyle.qml
@@ -42,28 +42,123 @@ CollapsibleGroupProperty {
property alias fontSynthesizeWeight: synthesizeWeightCbx.checked;
property alias fontSynthesizeSlant: synthesizeSlantCbx.checked;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onFontWeightChanged() {
+ updateWeight();
+ updateVisibility();
+ }
+ function onFontStyleChanged() {
+ updateSlant();
+ updateVisibility();
+ }
+ function onFontWidthChanged() {
+ updateWidth();
+ updateVisibility();
+ }
+ function onFontOpticalSizeLinkChanged() {
+ updateWeight();
+ updateVisibility();
+ }
+ function onFontSynthesisStyleChanged() {
+ updateFontSynthesizeSlant();
+ updateVisibility();
+ }
+ function onFontSynthesisWeightChanged() {
+ updateFontSynthesizeWeight();
+ updateVisibility();
+ }
+
+ function onAxisValuesChanged() {
+ updateAxisValues();
+ updateVisibility();
+ }
+
+ function onFontFamiliesChanged() {
+ updateAxisAndStyle();
+ }
+ }
+ onPropertiesChanged: {
+ updateWeight();
+ updateSlant();
+ updateWidth();
+ updateOptical();
+ updateFontSynthesizeSlant();
+ updateFontSynthesizeWeight();
+ updateAxisAndStyle();
+ updateVisibility();
+ }
+
+ function updateWeight() {
+ if (!fontWeightSpn.isDragging) {
+ blockSignals = true;
+ fontWeight = properties.fontWeight;
+ blockSignals = false;
+ }
+ }
+
+ function updateSlant() {
+ if (!fontSlantSpn.isDragging) {
+ blockSignals = true;
+ fontSlant = properties.fontStyle.style;
+ fontSlantSlope = properties.fontStyle.value;
+ blockSignals = false;
+ }
+ }
+
+ function updateWidth() {
+ if (!fontStretchSpn.isDragging) {
+ blockSignals = true;
+ fontWidth = properties.fontWidth;
+ blockSignals = false;
+ }
+ }
+
+ function updateOptical() {
blockSignals = true;
- fontWeight = properties.fontWeight;
- fontWidth = properties.fontWidth;
fontOptical = properties.fontOpticalSizeLink;
- fontSlant = properties.fontStyle.style;
- fontSlantSlope = properties.fontStyle.value;
+ blockSignals = false;
+ }
+
+ function updateFontSynthesizeSlant() {
+ blockSignals = true;
fontSynthesizeSlant = properties.fontSynthesisStyle;
+ blockSignals = false;
+ }
+
+ function updateFontSynthesizeWeight() {
+ blockSignals = true;
fontSynthesizeWeight = properties.fontSynthesisWeight;
+ blockSignals = false;
+ }
+
+ function updateAxisValues() {
+ blockSignals = true;
+ axesModel.axisValues = properties.axisValues;
+ blockSignals = false;
+ }
+
+ function updateAxisAndStyle() {
+ blockSignals = true;
axesModel.setFromTextPropertiesModel(properties);
stylesModel.setFromTextPropertiesModel(properties);
styleCmb.currentIndex = stylesModel.rowForStyle(properties.fontWeight, properties.fontWidth, properties.fontStyle.style, properties.fontStyle.value);
- visible = properties.fontWeightState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.fontStyleState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.fontWidthState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.fontOpticalSizeLinkState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.axisValueState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.fontSynthesisStyleState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.fontSynthesisWeightState !== KoSvgTextPropertiesModel.PropertyUnset;
- setVisibleFromProperty();
blockSignals = false;
}
+
+ function updateVisibility() {
+ propertyState = [properties.fontWeightState,
+ properties.fontStyleState,
+ properties.fontWidthState,
+ properties.fontOpticalSizeLinkState,
+ properties.axisValueState,
+ properties.fontSynthesisStyleState,
+ properties.fontSynthesisWeightState,
+ properties.axisValueState
+ ];
+ setVisibleFromProperty();
+ }
+
onFontWeightChanged: {
if (!blockSignals) {
properties.fontWeight = fontWeight;
@@ -160,7 +255,6 @@ CollapsibleGroupProperty {
prefix: i18nc("@label:slider", "Weight: ");
from: 0;
to: 1000;
- blockUpdateSignalOnDrag: true;
Layout.fillWidth: true;
Layout.columnSpan: 2;
@@ -191,7 +285,6 @@ CollapsibleGroupProperty {
prefix: i18nc("@label:slider", "Width: ")
from: 0;
to: 200;
- blockUpdateSignalOnDrag: true;
Layout.fillWidth: true;
Layout.columnSpan: 2;
}
@@ -242,7 +335,6 @@ CollapsibleGroupProperty {
Kis.ThemedControl {
id: slantSpnPal;
}
- blockUpdateSignalOnDrag: true;
anchors.fill: parent;
palette: slantSpnPal.palette;
@@ -325,7 +417,6 @@ CollapsibleGroupProperty {
dFrom: axismin;
dTo: axismax;
dValue: model.edit;
- blockUpdateSignalOnDrag: true;
onDValueChanged: model.edit = dValue;
width: ListView.view.width;
diff --git a/plugins/dockers/textproperties/qml/HangingPunctuation.qml b/plugins/dockers/textproperties/qml/HangingPunctuation.qml
index 6965ea1fb3..f7c41fb5f1 100644
--- a/plugins/dockers/textproperties/qml/HangingPunctuation.qml
+++ b/plugins/dockers/textproperties/qml/HangingPunctuation.qml
@@ -20,14 +20,53 @@ TextPropertyBase {
property alias hangEnd: paragraphEndCbx.checked;
property int hangComma: KoSvgTextPropertiesModel.NoHang;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onHangingPunctuationFirstChanged() {
+ updateHangStart();
+ updateVisibility();
+ }
+ function onHangingPunctuationLastChanged() {
+ updateHangEnd();
+ updateVisibility();
+ }
+ function onHangingPunctuationCommaChanged() {
+ updateHangComma();
+ updateVisibility();
+ }
+
+ function onHangingPunctuationStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateHangStart();
+ updateHangEnd();
+ updateHangComma();
+ updateVisibility();
+ }
+
+ function updateHangStart() {
blockSignals = true;
hangStart = properties.hangingPunctuationFirst;
+ blockSignals = false;
+ }
+
+ function updateHangEnd() {
+ blockSignals = true;
hangEnd = properties.hangingPunctuationLast;
+ blockSignals = false;
+ }
+
+ function updateHangComma() {
+ blockSignals = true;
hangComma = properties.hangingPunctuationComma;
+ blockSignals = false;
+ }
+
+ function updateVisibility() {
propertyState = [properties.hangingPunctuationState];
setVisibleFromProperty();
- blockSignals = false;
}
onHangStartChanged: {
diff --git a/plugins/dockers/textproperties/qml/Language.qml b/plugins/dockers/textproperties/qml/Language.qml
index c8332829b3..70ef71b27f 100644
--- a/plugins/dockers/textproperties/qml/Language.qml
+++ b/plugins/dockers/textproperties/qml/Language.qml
@@ -31,12 +31,31 @@ TextPropertyBase {
onLanguageChanged: languageCmb.currentIndex = languageCmb.indexOfValue(language);
}
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onLanguageChanged() {
+ updateBcpTags();
+ updateVisibility();
+ }
+
+ function onLanguageStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateBcpTags();
+ updateVisibility();
+ }
+
+ function updateBcpTags() {
blockSignals = true;
- localeHandler.bcp47Tag = properties.language;
+ localeHandler.bcp47Tag = properties.language
+ blockSignals = false;
+ }
+
+ function updateVisibility() {
propertyState = [properties.languageState];
setVisibleFromProperty();
- blockSignals = false;
}
onEnableProperty: properties.languageState = KoSvgTextPropertiesModel.PropertySet;
diff --git a/plugins/dockers/textproperties/qml/LetterSpacing.qml b/plugins/dockers/textproperties/qml/LetterSpacing.qml
index fd65c455ae..f2464d74c7 100644
--- a/plugins/dockers/textproperties/qml/LetterSpacing.qml
+++ b/plugins/dockers/textproperties/qml/LetterSpacing.qml
@@ -21,15 +21,52 @@ TextPropertyBase {
property alias letterSpacing: letterSpacingUnitCmb.dataValue;
property alias letterSpacingUnit: letterSpacingUnitCmb.dataUnit;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onLetterSpacingChanged() {
+ updateLetterSpacing();
+ updateVisibility();
+ }
+ // Fontsize and lineheight affect the metrics.
+ function onFontSizeChanged() {
+ updateUnits();
+ }
+ function onFontFamiliesChanged() {
+ updateUnits();
+ }
+ function onLineHeightChanged() {
+ updateUnits();
+ }
+
+ function onLetterSpacingStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateUnits();
+ updateLetterSpacing();
+ updateVisibility();
+ }
+
+ function updateUnits() {
blockSignals = true;
letterSpacingUnitCmb.setTextProperties(properties);
- letterSpacingUnitCmb.setDataValueAndUnit(properties.letterSpacing.value, properties.letterSpacing.unitType);
+ blockSignals = false;
+ }
+ function updateLetterSpacing() {
+ if (!letterSpacingSpn.isDragging) {
+ blockSignals = true;
+ letterSpacingUnitCmb.setDataValueAndUnit(properties.letterSpacing.value, properties.letterSpacing.unitType);
+ blockSignals = false;
+ }
+ }
+
+ function updateVisibility() {
propertyState = [properties.letterSpacingState];
setVisibleFromProperty();
- blockSignals = false;
}
+
onLetterSpacingChanged: {
if (!blockSignals) {
properties.letterSpacing.value = letterSpacing;
@@ -63,13 +100,11 @@ TextPropertyBase {
dTo: 99;
softDFrom: -10;
softDTo: 10;
- softRangeActive: true;
dStepSize: 0.1;
-
- blockUpdateSignalOnDrag: true;
+ softRangeActive: true;
onDValueChanged: letterSpacingUnitCmb.userValue = dValue;
-
+ blockUpdateSignalOnDrag: true;
}
UnitComboBox {
diff --git a/plugins/dockers/textproperties/qml/LineBreak.qml b/plugins/dockers/textproperties/qml/LineBreak.qml
index 5b256d76d7..e87dee7fbe 100644
--- a/plugins/dockers/textproperties/qml/LineBreak.qml
+++ b/plugins/dockers/textproperties/qml/LineBreak.qml
@@ -19,12 +19,30 @@ TextPropertyBase {
"line-break, line breaking, strictness, kinsoku");
propertyType: TextPropertyConfigModel.Character;
- onPropertiesUpdated: {
- blockSignals = true;
- breakType = properties.lineBreak;
+ Connections {
+ target: properties;
+ function onLineBreakChanged() {
+ updateLineBreak();
+ updateVisibility();
+ }
+ function onLineBreakStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateLineBreak();
+ updateVisibility();
+ }
+
+ function updateVisibility() {
propertyState = [properties.lineBreakState];
setVisibleFromProperty();
+ }
+
+ function updateLineBreak() {
+ blockSignals = true;
+ breakType = properties.lineBreak;
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/LineHeight.qml b/plugins/dockers/textproperties/qml/LineHeight.qml
index 1f7e99767e..7e1564bd02 100644
--- a/plugins/dockers/textproperties/qml/LineHeight.qml
+++ b/plugins/dockers/textproperties/qml/LineHeight.qml
@@ -41,16 +41,48 @@ TextPropertyBase {
onUserUnitChanged: lineHeightUnitCmb.currentIndex = lineHeightUnitCmb.indexOfValue(userUnit);
}
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onLineHeightChanged() {
+ updateLineHeight();
+ updateVisibility();
+ }
+
+ // Fontsize and lineheight affect the metrics.
+ function onFontSizeChanged() {
+ updateUnits();
+ }
+ function onFontFamiliesChanged() {
+ updateUnits();
+ }
+
+ function onLineHeightStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateUnits();
+ updateLineHeight();
+ updateVisibility();
+ }
+
+ function updateUnits() {
blockSignals = true;
- isNormal = properties.lineHeight.isNormal;
converter.setFontMetricsFromTextPropertiesModel(properties, false, true);
+ blockSignals = false;
+ }
+
+ function updateLineHeight() {
+ blockSignals = true;
+ isNormal = properties.lineHeight.isNormal;
converter.percentageReference = properties.resolvedFontSize(false);
converter.setDataValueAndUnit(properties.lineHeight.value, properties.lineHeight.unit);
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.lineHeightState];
setVisibleFromProperty();
- blockSignals = false;
}
onLineHeightUnitChanged: {
diff --git a/plugins/dockers/textproperties/qml/OTCaps.qml b/plugins/dockers/textproperties/qml/OTCaps.qml
index 8f0d0aa927..f8917ebb99 100644
--- a/plugins/dockers/textproperties/qml/OTCaps.qml
+++ b/plugins/dockers/textproperties/qml/OTCaps.qml
@@ -19,14 +19,30 @@ TextPropertyBase {
property int capsType;
+ Connections {
+ target: properties;
+ function onFontVariantCapsChanged() {
+ updateOTCaps();
+ updateVisibility();
+ }
- onPropertiesUpdated: {
+ function onFontVariantCapsStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateOTCaps();
+ updateVisibility();
+ }
+ function updateOTCaps() {
blockSignals = true;
capsType = properties.fontVariantCaps;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.fontVariantCapsState];
setVisibleFromProperty();
- blockSignals = false;
}
onCapsTypeChanged: {
diff --git a/plugins/dockers/textproperties/qml/OTEastAsian.qml b/plugins/dockers/textproperties/qml/OTEastAsian.qml
index a645a11f7d..f03810d47f 100644
--- a/plugins/dockers/textproperties/qml/OTEastAsian.qml
+++ b/plugins/dockers/textproperties/qml/OTEastAsian.qml
@@ -21,15 +21,33 @@ TextPropertyBase {
property int widthType;
property alias ruby: rubyCbx.checked;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onFontVariantEastAsianChanged() {
+ updateOTEastAsian();
+ updateVisibility();
+ }
+
+ function onFontVariantEastAsianStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateOTEastAsian();
+ updateVisibility();
+ }
+
+ function updateOTEastAsian() {
blockSignals = true;
ruby = properties.fontVariantEastAsian.ruby;
variantType = properties.fontVariantEastAsian.variant;
widthType = properties.fontVariantEastAsian.width;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.fontVariantEastAsianState];
setVisibleFromProperty();
- blockSignals = false;
}
onVariantTypeChanged: {
diff --git a/plugins/dockers/textproperties/qml/OTLigatures.qml b/plugins/dockers/textproperties/qml/OTLigatures.qml
index 0174be780b..39e3b4ab51 100644
--- a/plugins/dockers/textproperties/qml/OTLigatures.qml
+++ b/plugins/dockers/textproperties/qml/OTLigatures.qml
@@ -22,17 +22,33 @@ TextPropertyBase {
property alias historicalLigatures: historicalLigaCbx.checked;
property alias contextualAlternates: contextualLigaCbx.checked;
+ Connections {
+ target: properties;
+ function onFontVariantLigaturesChanged() {
+ updateOTLigatures();
+ updateVisibility();
+ }
- onPropertiesUpdated: {
+ function onFontVariantLigaturesStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateOTLigatures();
+ updateVisibility();
+ }
+ function updateOTLigatures() {
blockSignals = true;
commonLigatures = properties.fontVariantLigatures.commonLigatures;
discretionaryLigatures = properties.fontVariantLigatures.discretionaryLigatures;
historicalLigatures = properties.fontVariantLigatures.historicalLigatures;
contextualAlternates = properties.fontVariantLigatures.contextualAlternates;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.fontVariantLigaturesState];
setVisibleFromProperty();
- blockSignals = false;
}
onCommonLigaturesChanged: {
diff --git a/plugins/dockers/textproperties/qml/OTNumeric.qml b/plugins/dockers/textproperties/qml/OTNumeric.qml
index 0033cef5e7..8ad9809d4f 100644
--- a/plugins/dockers/textproperties/qml/OTNumeric.qml
+++ b/plugins/dockers/textproperties/qml/OTNumeric.qml
@@ -23,17 +23,34 @@ TextPropertyBase {
property alias ordinals: ordinalsCbx.checked;
property alias slashedZero: slashedZeroCbx.checked;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onFontVariantNumericChanged() {
+ updateOTNumeric();
+ updateVisibility();
+ }
+
+ function onFontVariantNumericStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateOTNumeric();
+ updateVisibility();
+ }
+ function updateOTNumeric() {
blockSignals = true;
figureStyleType = properties.fontVariantNumeric.figureStyle;
figureSpacingType = properties.fontVariantNumeric.figureSpacing;
fractionType = properties.fontVariantNumeric.fractions;
ordinals = properties.fontVariantNumeric.ordinals;
slashedZero = properties.fontVariantNumeric.slashedZero;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.fontVariantNumericState];
setVisibleFromProperty();
- blockSignals = false;
}
onFigureStyleTypeChanged: {
diff --git a/plugins/dockers/textproperties/qml/OTPosition.qml b/plugins/dockers/textproperties/qml/OTPosition.qml
index 615ffcbcc4..4152453179 100644
--- a/plugins/dockers/textproperties/qml/OTPosition.qml
+++ b/plugins/dockers/textproperties/qml/OTPosition.qml
@@ -19,14 +19,30 @@ TextPropertyBase {
property int positionType;
+ Connections {
+ target: properties;
+ function onFontVariantPositionChanged() {
+ updateOTPosition();
+ updateVisibility();
+ }
- onPropertiesUpdated: {
+ function onFontVariantPositionStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateOTPosition();
+ updateVisibility();
+ }
+ function updateOTPosition() {
blockSignals = true;
positionType = properties.fontVariantPosition;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.fontVariantPositionState];
setVisibleFromProperty();
- blockSignals = false;
}
onPositionTypeChanged: {
diff --git a/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml b/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml
index 61bc367586..8f10f9be2b 100644
--- a/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml
+++ b/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml
@@ -27,14 +27,41 @@ TextPropertyBase {
}
}
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onFontFeatureSettingsChanged() {
+ updateFontFeatures();
+ updateVisibility();
+ }
+ function onFontFamiliesChanged() {
+ updateFontFeatureModel();
+ updateVisibility();
+ }
+ function onFontFeatureSettingsStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateFontFeatureModel();
+ updateVisibility();
+ }
+
+ function updateFontFeatureModel() {
blockSignals = true;
// Setting text properties model will also set the opentype features.
fontFeatureModel.setFromTextPropertiesModel(properties);
+ blockSignals = false;
+ }
+
+ function updateFontFeatures() {
+ blockSignals = true;
+ fontFeatureModel.openTypeFeatures = properties.fontFeatureSettings;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.fontFeatureSettingsState];
setVisibleFromProperty();
- blockSignals = false;
}
onEnableProperty: properties.fontFeatureSettingsState = KoSvgTextPropertiesModel.PropertySet;
diff --git a/plugins/dockers/textproperties/qml/TabSize.qml b/plugins/dockers/textproperties/qml/TabSize.qml
index 7ddd6e74be..7e6c0338aa 100644
--- a/plugins/dockers/textproperties/qml/TabSize.qml
+++ b/plugins/dockers/textproperties/qml/TabSize.qml
@@ -40,14 +40,49 @@ TextPropertyBase {
onUserUnitChanged: tabSizeUnitCmb.currentIndex = tabSizeUnitCmb.indexOfValue(userUnit);
}
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onTabSizeChanged() {
+ updateTabSize();
+ updateVisibility();
+ }
+
+ // Fontsize and lineheight affect the metrics.
+ function onFontSizeChanged() {
+ updateUnits();
+ }
+ function onFontFamiliesChanged() {
+ updateUnits();
+ }
+ function onLineHeightChanged() {
+ updateUnits();
+ }
+
+ function onTabSizeStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateUnits();
+ updateTabSize();
+ updateVisibility();
+ }
+
+ function updateUnits() {
blockSignals = true;
converter.setFontMetricsFromTextPropertiesModel(properties);
+ blockSignals = false;
+ }
+
+ function updateTabSize() {
+ blockSignals = true;
converter.setDataValueAndUnit(properties.tabSize.value, properties.tabSize.unit);
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.tabSizeState];
setVisibleFromProperty();
- blockSignals = false;
}
onTabSizeChanged: {
diff --git a/plugins/dockers/textproperties/qml/TextAlign.qml b/plugins/dockers/textproperties/qml/TextAlign.qml
index 854536984d..2b16646629 100644
--- a/plugins/dockers/textproperties/qml/TextAlign.qml
+++ b/plugins/dockers/textproperties/qml/TextAlign.qml
@@ -23,20 +23,69 @@ CollapsibleGroupProperty {
property int textAlignLast: 0;
property int textAnchor: 0;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onTextAlignAllChanged() {
+ updateTextAlignAll();
+ setButtonsChecked();
+ updateVisibility();
+ }
+
+ function onTextAlignLastChanged() {
+ updateTextAlignLast();
+ setButtonsChecked();
+ updateVisibility();
+ }
+
+ function onTextAnchorChanged() {
+ updateTextAnchor();
+ setButtonsChecked();
+ updateVisibility();
+ }
+
+ function onTextAlignAllStateChanged() {
+ updateVisibility();
+ }
+ function onTextAlignLastStateChanged() {
+ updateVisibility();
+ }
+ function onTextAnchorStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateTextAlignAll();
+ updateTextAlignLast();
+ updateTextAnchor();
+ setButtonsChecked();
+ updateVisibility();
+ }
+
+ function updateTextAlignAll() {
blockSignals = true;
textAlignAll = properties.textAlignAll;
+ blockSignals = false;
+ }
+
+ function updateTextAlignLast() {
+ blockSignals = true;
textAlignLast = properties.textAlignLast;
+ blockSignals = false;
+ }
+
+ function updateTextAnchor() {
+ blockSignals = true;
textAnchor = properties.textAnchor;
- setButtonsChecked();
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [
properties.textAlignAllState,
properties.textAlignLastState,
properties.textAnchorState
];
setVisibleFromProperty();
- blockSignals = false;
}
onTextAlignAllChanged: {
diff --git a/plugins/dockers/textproperties/qml/TextDecoration.qml b/plugins/dockers/textproperties/qml/TextDecoration.qml
index f2a927573b..a47538c86f 100644
--- a/plugins/dockers/textproperties/qml/TextDecoration.qml
+++ b/plugins/dockers/textproperties/qml/TextDecoration.qml
@@ -23,21 +23,85 @@ TextPropertyBase {
property int lineStyle;
property color lineColor;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onTextDecorationLineThroughChanged() {
+ updateTextDecorThrough();
+ updateVisibility();
+ }
+ function onTextDecorationUnderlineChanged() {
+ updateTextDecorUnder();
+ updateVisibility();
+ }
+ function onTextDecorationOverlineChanged() {
+ updateTextDecorOver();
+ updateVisibility();
+ }
+
+ function onTextDecorationStyleChanged() {
+ updateTextDecorStyle();
+ updateVisibility();
+ }
+
+ function onTextDecorationColorChanged() {
+ updateTextDecorColor();
+ updateVisibility();
+ }
+
+ function onTextDecorationLineStateChanged() {
+ updateVisibility();
+ }
+ function onTextDecorationStyleStateChanged() {
+ updateVisibility();
+ }
+ function onTextDecorationColorStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateTextDecorThrough();
+ updateTextDecorUnder();
+ updateTextDecorOver();
+ updateTextDecorStyle();
+ updateTextDecorColor();
+ updateVisibility();
+ }
+
+ function updateTextDecorOver() {
blockSignals = true;
- underline = properties.textDecorationUnderline;
overline = properties.textDecorationOverline;
+ blockSignals = false;
+ }
+ function updateTextDecorThrough() {
+ blockSignals = true;
linethrough = properties.textDecorationLineThrough;
+ blockSignals = false;
+ }
+ function updateTextDecorUnder() {
+ blockSignals = true;
+ underline = properties.textDecorationUnderline;
+ blockSignals = false;
+ }
+
+ function updateTextDecorStyle() {
+ blockSignals = true;
lineStyle = properties.textDecorationStyle;
+ blockSignals = false;
+ }
+
+ function updateTextDecorColor() {
+ blockSignals = true;
lineColor = properties.textDecorationColor;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [
properties.textDecorationLineState,
properties.textDecorationStyleState,
properties.textDecorationColorState
];
setVisibleFromProperty();
- blockSignals = false;
}
onLineStyleChanged: {
diff --git a/plugins/dockers/textproperties/qml/TextIndent.qml b/plugins/dockers/textproperties/qml/TextIndent.qml
index c856c2ec43..8be8bd50b6 100644
--- a/plugins/dockers/textproperties/qml/TextIndent.qml
+++ b/plugins/dockers/textproperties/qml/TextIndent.qml
@@ -24,16 +24,51 @@ CollapsibleGroupProperty {
property alias eachLine: eachLineCkb.checked;
property alias textIndentUnit: textIndentUnitCmb.dataUnit;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onTextIndentChanged() {
+ updateTextIndentValue();
+ updateVisibility();
+ }
+
+ // Fontsize and lineheight affect the metrics.
+ function onFontSizeChanged() {
+ updateUnits();
+ }
+ function onFontFamiliesChanged() {
+ updateUnits();
+ }
+ function onLineHeightChanged() {
+ updateUnits();
+ }
+
+ function onTextIndentStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateUnits();
+ updateTextIndentValue();
+ updateVisibility();
+ }
+
+ function updateUnits() {
blockSignals = true;
textIndentUnitCmb.setTextProperties(properties);
+ blockSignals = false;
+ }
+
+ function updateTextIndentValue() {
+ blockSignals = true;
textIndentUnitCmb.setDataValueAndUnit(properties.textIndent.length.value, properties.textIndent.length.unitType);
hanging = properties.textIndent.hanging;
eachLine = properties.textIndent.eachLine;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.textIndentState];
setVisibleFromProperty();
- blockSignals = false;
}
onTextIndentValueChanged: {
diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qml
index 38dd3a942e..19c2761b7d 100644
--- a/plugins/dockers/textproperties/qml/TextProperties.qml
+++ b/plugins/dockers/textproperties/qml/TextProperties.qml
@@ -13,8 +13,18 @@ Control {
id: root;
anchors.fill: parent;
- property TextPropertyConfigModel configModel : textPropertyConfigModel;
- property double canvasDPI: 72.0;
+ property TextPropertiesCanvasObserver canvasObserver: TextPropertiesCanvasObserver {
+ };
+
+ Connections {
+ target: canvasObserver;
+ function onTextPropertyConfigChanged() {updatePropertyVisibilityState()}
+ function onTextPropertiesChanged() {setProperties()}
+ }
+
+
+ property TextPropertyConfigModel configModel : canvasObserver.textPropertyConfig;
+ property double canvasDPI: canvasObserver.dpi;
Kis.ThemedControl {
id: pal;
}
@@ -34,6 +44,12 @@ Control {
paragraphPropertyList.updatePropertyVisibilityState();
}
+ onCanvasObserverChanged: updatePropertyVisibilityState();
+ Component.onCompleted: {
+ updatePropertyVisibilityState();
+ setProperties();
+ }
+
TabBar {
id: tabs
anchors.right: parent.right;
@@ -62,6 +78,10 @@ Control {
propertyType: TextPropertyConfigModel.Character;
configModel: root.configModel;
canvasDPI: root.canvasDPI;
+ locales: canvasObserver.locales;
+ propertiesModel: canvasObserver.textProperties;
+
+ onCallPropertyVisibilityConfig: canvasObserver.callModalTextPropertyConfigDialog();
}
TextPropertyBaseList {
@@ -69,6 +89,10 @@ Control {
propertyType: TextPropertyConfigModel.Paragraph;
configModel: root.configModel;
canvasDPI: root.canvasDPI;
+ locales: canvasObserver.locales;
+ propertiesModel: canvasObserver.textProperties;
+
+ onCallPropertyVisibilityConfig: canvasObserver.callModalTextPropertyConfigDialog();
}
ResourceView {
@@ -79,7 +103,7 @@ Control {
signal applyPreset;
onApplyPreset: {
- mainWindow.applyPreset(currentResource);
+ canvasObserver.applyPreset(currentResource);
}
resourceDelegate: ItemDelegate {
@@ -171,7 +195,7 @@ Control {
icon.color: palette.text;
icon.width: 16;
icon.height: 16;
- onClicked: mainWindow.createNewPresetFromSettings();
+ onClicked: canvasObserver.createNewPresetFromSettings();
hoverEnabled: true;
ToolTip.text: text;
ToolTip.visible: hovered;
@@ -184,7 +208,7 @@ Control {
icon.color: palette.text;
icon.width: 16;
icon.height: 16;
- onClicked: mainWindow.editPreset(presetView.currentResource);
+ onClicked: canvasObserver.editPreset(presetView.currentResource);
hoverEnabled: true;
Kis.ThemedControl {
id: editPalette;
@@ -203,7 +227,7 @@ Control {
icon.color: palette.text;
icon.width: 16;
icon.height: 16;
- onClicked: mainWindow.cloneAndEditPreset(presetView.currentResource);
+ onClicked: canvasObserver.cloneAndEditPreset(presetView.currentResource);
hoverEnabled: true;
Kis.ThemedControl {
id: cloneButtonPalette;
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBase.qml b/plugins/dockers/textproperties/qml/TextPropertyBase.qml
index d062b95532..da9e64c791 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBase.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBase.qml
@@ -16,10 +16,9 @@ Column {
width: ListView.view? ListView.view.width - (padding * 2): 100;
height: visible? implicitHeight: 0;
- property KoSvgTextPropertiesModel properties : textPropertiesModel;
+ property KoSvgTextPropertiesModel properties: KoSvgTextPropertiesModel{};
property int defaultVisibilityState : TextPropertyConfigModel.FollowDefault;
property double dpi: 72.0;
- signal propertiesUpdated; ///< Used by each text property panel to update the data on the controls.
signal enableProperty; ///< Set the property to a default value.
property bool blockSignals; ///< When setting the data on the controls, this needs to be enabled and checked while returning data from the controls.
@@ -34,6 +33,11 @@ Column {
property var propertyState: []; /// All property states related to the current property.
function setVisibleFromProperty() {
+ if (propertyType !== parentPropertyType && propertyType !== TextPropertyConfigModel.Mixed) {
+ visible = false;
+ return;
+ }
+
let visibleState = visibilityState === TextPropertyConfigModel.FollowDefault? defaultVisibilityState: visibilityState;
if (visibleState === TextPropertyConfigModel.AlwaysVisible) {
visible = true;
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
index 58ef2f9af5..a9de10ea99 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
@@ -15,6 +15,8 @@ ColumnLayout {
property int propertyType: TextPropertyConfigModel.Character;
property TextPropertyConfigModel configModel;
property double canvasDPI: 72.0;
+ property KoSvgTextPropertiesModel propertiesModel;
+ property var locales: [];
ListModel {
id: propertyList;
@@ -54,7 +56,8 @@ ColumnLayout {
prop.visibilityState
);
- if (testShowProperty(prop.propertyType) && !shouldFilter(prop.propertyName)) {
+ prop.parentPropertyType = propertyBaseList.propertyType;
+ if (!shouldFilter(prop.propertyName)) {
prop.setVisibleFromProperty();
} else {
prop.visible = false;
@@ -64,28 +67,14 @@ ColumnLayout {
updatePropertyVisibilityState();
}
- /// Test if the current propertyType is the same as the one for this list.
- /// Used to filter out paragraph-properties from character property list and vice-versa.
- function testShowProperty(propertyType) {
- if (filteredConfigModel.showParagraphProperties && propertyType === TextPropertyConfigModel.Character) {
- return false;
- } else if (!filteredConfigModel.showParagraphProperties && propertyType === TextPropertyConfigModel.Paragraph) {
- return false;
- }
- return true;
- }
-
/// Update properties on the list or hide them.
function updateProperties() {
for (var i = 0; i < propertyWidgetModel.count; i++) {
let prop = propertyWidgetModel.get(i);
- if (testShowProperty(prop.propertyType)) {
- prop.propertiesUpdated();
- if (shouldFilter(prop.propertyName)) {
- prop.visible = false;
- }
- } else {
+ if (shouldFilter(prop.propertyName)) {
prop.visible = false;
+ } else {
+ prop.setVisibleFromProperty();
}
}
}
@@ -108,14 +97,10 @@ ColumnLayout {
prop.defaultVisibilityState = configModel.defaultVisibilityState;
prop.visibilityState = configModel.visibilityStateForName(name);
- if (testShowProperty(prop.propertyType)) {
- if (shouldFilter(name)) {
- prop.visible = false;
- } else {
- prop.setVisibleFromProperty();
- }
- } else {
+ if (shouldFilter(name)) {
prop.visible = false;
+ } else {
+ prop.setVisibleFromProperty();
}
}
}
@@ -140,6 +125,8 @@ ColumnLayout {
}
}
+ signal callPropertyVisibilityConfig;
+
Frame {
id: frame;
Layout.fillHeight: true;
@@ -163,97 +150,129 @@ ColumnLayout {
id: propertyWidgetModel;
WritingMode {
dpi: canvasDPI;
+ properties: propertiesModel;
}
Direction {
dpi: canvasDPI;
+ properties: propertiesModel;
}
TextIndent{
dpi: canvasDPI;
+ properties: propertiesModel;
}
TextAlign{
dpi: canvasDPI;
+ properties: propertiesModel;
}
DominantBaseline {
dpi: canvasDPI;
+ properties: propertiesModel;
}
WhiteSpace {
dpi: canvasDPI;
+ properties: propertiesModel;
}
UnderlinePosition {
dpi: canvasDPI;
+ properties: propertiesModel;
}
HangingPunctuation {
dpi: canvasDPI;
+ properties: propertiesModel;
}
TabSize {
dpi: canvasDPI;
+ properties: propertiesModel;
}
TextRendering {
dpi: canvasDPI;
+ properties: propertiesModel;
}
FontSize {
dpi: canvasDPI;
+ properties: propertiesModel;
}
FontSizeAdjust {
dpi: canvasDPI;
+ properties: propertiesModel;
}
FontFamily {
dpi: canvasDPI;
+ properties: propertiesModel;
+ locales: propertyBaseList.locales;
}
FontStyle {
dpi: canvasDPI;
+ properties: propertiesModel;
}
LetterSpacing {
dpi: canvasDPI;
+ properties: propertiesModel;
}
WordSpacing {
dpi: canvasDPI;
+ properties: propertiesModel;
}
LineHeight {
dpi: canvasDPI;
+ properties: propertiesModel;
}
LineBreak {
dpi: canvasDPI;
+ properties: propertiesModel;
}
WordBreak {
dpi: canvasDPI;
+ properties: propertiesModel;
}
TextTransform {
dpi: canvasDPI;
+ properties: propertiesModel;
}
TextDecoration {
dpi: canvasDPI;
+ properties: propertiesModel;
}
OTLigatures {
dpi: canvasDPI;
+ properties: propertiesModel;
}
OTPosition {
dpi: canvasDPI;
+ properties: propertiesModel;
}
OTNumeric {
dpi: canvasDPI;
+ properties: propertiesModel;
}
OTCaps {
dpi: canvasDPI;
+ properties: propertiesModel;
}
OTEastAsian {
dpi: canvasDPI;
+ properties: propertiesModel;
}
OpenTypeFeatureSettings {
dpi: canvasDPI;
+ properties: propertiesModel;
}
FontKerning {
dpi: canvasDPI;
+ properties: propertiesModel;
}
BaselineShift {
dpi: canvasDPI;
+ properties: propertiesModel;
}
AlignmentBaseline {
dpi: canvasDPI;
+ properties: propertiesModel;
}
Language {
dpi: canvasDPI;
+ properties: propertiesModel;
}
}
}
@@ -261,123 +280,125 @@ ColumnLayout {
RowLayout {
Layout.fillWidth: true;
- TextField {
- id: filterPropertyLn;
+ StackLayout {
Layout.fillWidth: true;
- Layout.minimumHeight: implicitHeight;
- placeholderText: i18nc("@info:placeholder", "Filter...");
-
- visible: filteredConfigModel.isFiltering;
- onVisibleChanged: {
- if (visible) {
- text = "";
+ Layout.maximumHeight: Math.max(addPropertyCmb.implicitHeight, filterPropertyLn.implicitHeight);
+
+ currentIndex: filteredConfigModel.isFiltering? 0: 1;
+ TextField {
+ id: filterPropertyLn;
+ Layout.fillWidth: true;
+ Layout.maximumHeight: implicitHeight;
+ placeholderText: i18nc("@info:placeholder", "Filter...");
+
+ onVisibleChanged: {
+ if (visible) {
+ text = "";
+ }
}
- }
- onTextChanged: {
- if (visible) {
- filteredConfigModel.setFilterRegularExpression(text);
+ onTextChanged: {
+ if (visible) {
+ filteredConfigModel.setFilterRegularExpression(text);
+ }
}
}
- }
- ComboBox {
- id: addPropertyCmb;
- visible: !filteredConfigModel.isFiltering;
- onVisibleChanged: {
- if (visible) {
- filteredConfigModel.setFilterRegularExpression("");
+ ComboBox {
+ id: addPropertyCmb;
+ Layout.fillWidth: true;
+ Layout.maximumHeight: implicitHeight;
+ onVisibleChanged: {
+ if (visible) {
+ filteredConfigModel.setFilterRegularExpression("");
+ }
}
- }
-
- Layout.fillWidth: true;
- Layout.minimumHeight: implicitHeight;
- model: filteredConfigModel;
- textRole: "display";
- displayText: i18nc("@label:listbox", "Add Property");
- onPopupChanged: if (!addPropertyCmb.popup.visible) { propertySearch.text = ""; }
-
- Kis.ThemedControl {
- id: cmbPalette;
- }
- palette: cmbPalette.palette;
-
- function enableProperty(name) {
- propertySearch.blockSignals = true;
- propertySearch.text = "";
- propertyBaseList.enableProperty(name);
- popup.close();
- propertySearch.blockSignals = false;
- }
+ model: filteredConfigModel;
+ textRole: "display";
+ displayText: i18nc("@label:listbox", "Add Property");
+ onPopupChanged: if (!addPropertyCmb.popup.visible) { propertySearch.text = ""; }
- contentItem: TextField {
- id: propertySearch;
- placeholderText: i18nc("@info:placeholder", "Add Property...");
-
- verticalAlignment: Text.AlignVCenter
- font: addPropertyCmb.font
- color: addPropertyCmb.palette.text
- selectionColor: addPropertyCmb.palette.highlight
- selectedTextColor: addPropertyCmb.palette.highlightedText;
+ Kis.ThemedControl {
+ id: cmbPalette;
+ }
+ palette: cmbPalette.palette;
- property bool blockSignals: false;
+ function enableProperty(name) {
+ propertySearch.blockSignals = true;
+ propertySearch.text = "";
+ propertyBaseList.enableProperty(name);
+ popup.close();
+ propertySearch.blockSignals = false;
+ }
- selectByMouse: true;
+ contentItem: TextField {
+ id: propertySearch;
+ placeholderText: i18nc("@info:placeholder", "Add Property...");
- onTextChanged: {
- if (text !== "") {
- filteredConfigModel.setFilterRegularExpression(text);
- addPropertyCmb.popup.open();
- } else {
- addPropertyCmb.popup.close();
- filteredConfigModel.setFilterRegularExpression(text);
+ verticalAlignment: Text.AlignVCenter
+ font: addPropertyCmb.font
+ color: addPropertyCmb.palette.text
+ selectionColor: addPropertyCmb.palette.highlight
+ selectedTextColor: addPropertyCmb.palette.highlightedText;
+
+ property bool blockSignals: false;
+
+ selectByMouse: true;
+
+ onTextChanged: {
+ if (text !== "") {
+ filteredConfigModel.setFilterRegularExpression(text);
+ addPropertyCmb.popup.open();
+ } else {
+ addPropertyCmb.popup.close();
+ filteredConfigModel.setFilterRegularExpression(text);
+ }
}
- }
- onAccepted: {
- blockSignals = true;
- let name = filteredConfigModel.filteredNames[addPropertyCmb.highlightedIndex]
- if (typeof name != 'undefined') {
- addPropertyCmb.enableProperty(name);
+ onAccepted: {
+ blockSignals = true;
+ let name = filteredConfigModel.filteredNames[addPropertyCmb.highlightedIndex]
+ if (typeof name != 'undefined') {
+ addPropertyCmb.enableProperty(name);
+ }
+ text = "";
+ blockSignals = false;
}
- text = "";
- blockSignals = false;
}
- }
- delegate: ItemDelegate {
- id: addPropertyDelegate;
- width: addPropertyCmb.width;
- required property var model;
- required property string title;
- required property string name;
- required property int index;
- required property string toolTip;
- contentItem: Label {
- enabled: addPropertyDelegate.enabled;
- Kis.ThemedControl {
- id: addPropertyPalette;
+ delegate: ItemDelegate {
+ id: addPropertyDelegate;
+ width: addPropertyCmb.width;
+ required property var model;
+ required property string title;
+ required property string name;
+ required property int index;
+ required property string toolTip;
+ contentItem: Label {
+ enabled: addPropertyDelegate.enabled;
+ Kis.ThemedControl {
+ id: addPropertyPalette;
+ }
+ palette: addPropertyPalette.palette;
+ color: addPropertyDelegate.highlighted? palette.highlightedText: palette.text;
+ text: addPropertyDelegate.title;
+ elide: Text.ElideRight;
+ verticalAlignment: Text.AlignVCenter
}
- palette: addPropertyPalette.palette;
- color: addPropertyDelegate.highlighted? palette.highlightedText: palette.text;
- text: addPropertyDelegate.title;
- elide: Text.ElideRight;
- verticalAlignment: Text.AlignVCenter
- }
- enabled: !isVisible(name);
- highlighted: addPropertyCmb.highlightedIndex === index;
- background: Rectangle { color: highlighted? parent.palette.highlight:"transparent"; }
+ enabled: !isVisible(name);
+ highlighted: addPropertyCmb.highlightedIndex === index;
+ background: Rectangle { color: highlighted? parent.palette.highlight:"transparent"; }
- ToolTip.text: toolTip;
- ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
- ToolTip.visible: highlighted;
+ ToolTip.text: toolTip;
+ ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
+ ToolTip.visible: highlighted;
- onClicked: addPropertyCmb.enableProperty(name);
+ onClicked: addPropertyCmb.enableProperty(name);
+ }
+ popup.y: addPropertyCmb.height - 1;
+ popup.palette: cmbPalette.palette;
}
- popup.y: addPropertyCmb.height - 1;
- popup.palette: cmbPalette.palette;
}
-
ToolButton {
id: configButton;
icon.source: "qrc:///light_configure.svg"
@@ -392,7 +413,8 @@ ColumnLayout {
palette: paletteControl.palette;
- onClicked: mainWindow.callModalTextPropertyConfigDialog();
+ onClicked: callPropertyVisibilityConfig();
}
+
}
}
diff --git a/plugins/dockers/textproperties/qml/TextRendering.qml b/plugins/dockers/textproperties/qml/TextRendering.qml
index 2e677b1e4f..37d16dadf3 100644
--- a/plugins/dockers/textproperties/qml/TextRendering.qml
+++ b/plugins/dockers/textproperties/qml/TextRendering.qml
@@ -18,12 +18,30 @@ TextPropertyBase {
"text-rendering, hinting, anti-aliasing");
property int textRendering;
- onPropertiesUpdated: {
- blockSignals = true;
- textRendering = properties.textRendering;
+ Connections {
+ target: properties;
+ function onTextRenderingChanged() {
+ updateRendering();
+ updateVisibility();
+ }
+ function onTextRenderingStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateRendering();
+ updateVisibility();
+ }
+
+ function updateVisibility() {
propertyState = [properties.textRenderingState];
setVisibleFromProperty();
+ }
+
+ function updateRendering() {
+ blockSignals = true;
+ textRendering = properties.textRendering;
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/TextTransform.qml b/plugins/dockers/textproperties/qml/TextTransform.qml
index 64579e7312..a09a840c07 100644
--- a/plugins/dockers/textproperties/qml/TextTransform.qml
+++ b/plugins/dockers/textproperties/qml/TextTransform.qml
@@ -20,14 +20,32 @@ TextPropertyBase {
property alias fullSizeKana: fullSizeKanaChk.checked;
property int capitals;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+ function onTextTransformChanged() {
+ updateTextTransform();
+ updateVisibility();
+ }
+
+ function onTextTransformStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateTextTransform();
+ updateVisibility();
+ }
+
+ function updateVisibility() {
+ propertyState = [properties.textTransformState];
+ setVisibleFromProperty();
+ }
+
+ function updateTextTransform() {
blockSignals = true;
fullWidth = properties.textTransform.fullWidth;
fullSizeKana = properties.textTransform.fullSizeKana;
capitals = properties.textTransform.capitals;
-
- propertyState = [properties.textTransformState];
- setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/UnderlinePosition.qml b/plugins/dockers/textproperties/qml/UnderlinePosition.qml
index ac80574411..16d96c5b19 100644
--- a/plugins/dockers/textproperties/qml/UnderlinePosition.qml
+++ b/plugins/dockers/textproperties/qml/UnderlinePosition.qml
@@ -17,17 +17,39 @@ TextPropertyBase {
"text-decoration-position, underline, left, right, under");
propertyType: TextPropertyConfigModel.Mixed;
-
property int horizontalPos: 0;
property int verticalPos: 0;
- onPropertiesUpdated: {
+
+ Connections {
+ target: properties;
+ function onTextDecorationUnderlinePosHorizontalChanged() {
+ updateUnderlinePos();
+ updateVisibility();
+ }
+ function onTextDecorationUnderlinePosVerticalChanged() {
+ updateUnderlinePos();
+ updateVisibility();
+ }
+
+ function onTextDecorationUnderlinePositionStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateUnderlinePos();
+ updateVisibility();
+ }
+
+ function updateUnderlinePos() {
blockSignals = true;
horizontalPos = properties.textDecorationUnderlinePosHorizontal;
verticalPos = properties.textDecorationUnderlinePosVertical;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.textDecorationUnderlinePositionState];
setVisibleFromProperty();
- blockSignals = false;
}
onHorizontalPosChanged: {
diff --git a/plugins/dockers/textproperties/qml/WhiteSpace.qml b/plugins/dockers/textproperties/qml/WhiteSpace.qml
index 878ffaf545..45c01e439f 100644
--- a/plugins/dockers/textproperties/qml/WhiteSpace.qml
+++ b/plugins/dockers/textproperties/qml/WhiteSpace.qml
@@ -27,7 +27,27 @@ TextPropertyBase {
readonly property int wsBreakSpace: 4;
readonly property int wsPreLine: 5;
- onPropertiesUpdated: {
+ Connections {
+ target: properties;
+
+ function onTextCollapseChanged() {
+ updateWhiteSpace();
+ updateVisibility();
+ }
+ function onTextWrapChanged() {
+ updateWhiteSpace();
+ updateVisibility();
+ }
+
+ function onTextCollapseStateChanged() {
+ updateVisibility();
+ }
+ function onTextWrapStateChanged() {
+ updateVisibility();
+ }
+ }
+
+ function updateWhiteSpace() {
blockSignals = true;
if (properties.textWrap !== KoSvgText.NoWrap) {
if (properties.textCollapse === KoSvgText.Preserve) {
@@ -46,10 +66,12 @@ TextPropertyBase {
whiteSpace = wsNoWrap;
}
}
+ blockSignals = false;
+ }
- propertyState = [properties.textCollapseState, properties.textWrap];
+ function updateVisibility() {
+ propertyState = [properties.textCollapseState, properties.textWrapState];
setVisibleFromProperty();
- blockSignals = false;
}
onWhiteSpaceChanged: {
diff --git a/plugins/dockers/textproperties/qml/WordBreak.qml b/plugins/dockers/textproperties/qml/WordBreak.qml
index 6fa070295e..69305edaa3 100644
--- a/plugins/dockers/textproperties/qml/WordBreak.qml
+++ b/plugins/dockers/textproperties/qml/WordBreak.qml
@@ -18,13 +18,30 @@ TextPropertyBase {
"word-break, line breaking");
property int breakType;
+ Connections {
+ target: properties;
+ function onWordBreakChanged() {
+ updateWordBreak();
+ updateVisibility();
+ }
- onPropertiesUpdated: {
- blockSignals = true;
- breakType = properties.wordBreak;
+ function onWordBreakStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateWordBreak();
+ updateVisibility();
+ }
+ function updateVisibility() {
propertyState = [properties.wordBreakState];
setVisibleFromProperty();
+ }
+
+ function updateWordBreak() {
+ blockSignals = true;
+ breakType = properties.wordBreak;
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/WordSpacing.qml b/plugins/dockers/textproperties/qml/WordSpacing.qml
index 94159a551b..79d76767ed 100644
--- a/plugins/dockers/textproperties/qml/WordSpacing.qml
+++ b/plugins/dockers/textproperties/qml/WordSpacing.qml
@@ -21,16 +21,52 @@ TextPropertyBase {
property alias wordSpacing: wordSpacingUnitCmb.dataValue;
property alias wordSpacingUnit: wordSpacingUnitCmb.dataUnit;
+ Connections {
+ target: properties;
+ function onWordSpacingChanged() {
+ updateWordSpacing();
+ updateVisibility();
+ }
+ // Fontsize and lineheight affect the metrics.
+ function onFontSizeChanged() {
+ updateUnits();
+ }
+ function onFontFamiliesChanged() {
+ updateUnits();
+ }
+ function onLineHeightChanged() {
+ updateUnits();
+ }
+
+ function onWordSpacingStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateUnits();
+ updateWordSpacing();
+ updateVisibility();
+ }
- onPropertiesUpdated: {
+ function updateUnits() {
blockSignals = true;
wordSpacingUnitCmb.setTextProperties(properties);
- wordSpacingUnitCmb.setDataValueAndUnit(properties.wordSpacing.value, properties.wordSpacing.unitType);
+ blockSignals = false;
+ }
+ function updateWordSpacing() {
+ if (!wordSpacingSpn.isDragging) {
+ blockSignals = true;
+ wordSpacingUnitCmb.setDataValueAndUnit(properties.wordSpacing.value, properties.wordSpacing.unitType);
+ blockSignals = false;
+ }
+ }
+
+ function updateVisibility() {
propertyState = [properties.wordSpacingState];
setVisibleFromProperty();
- blockSignals = false;
}
+
onWordSpacingChanged: {
if (!blockSignals) {
properties.wordSpacing.value = wordSpacing;
diff --git a/plugins/dockers/textproperties/qml/WritingMode.qml b/plugins/dockers/textproperties/qml/WritingMode.qml
index 9df1a343d0..84d2d4cf1b 100644
--- a/plugins/dockers/textproperties/qml/WritingMode.qml
+++ b/plugins/dockers/textproperties/qml/WritingMode.qml
@@ -18,15 +18,31 @@ TextPropertyBase {
"writing-mode, horizontal, vertical, top-to-bottom");
property int writingMode;
+ Connections {
+ target: properties;
+ function onWritingModeChanged() {
+ updateWritingMode();
+ updateVisibility();
+ }
+ function onWritingModeStateChanged() {
+ updateVisibility();
+ }
+ }
+ onPropertiesChanged: {
+ updateWritingMode();
+ updateVisibility();
+ }
- onPropertiesUpdated: {
+ function updateWritingMode() {
blockSignals = true;
writingMode = properties.writingMode;
+ blockSignals = false;
+ }
+ function updateVisibility() {
propertyState = [properties.writingModeState];
setVisibleFromProperty();
- blockSignals = false;
}
onWritingModeChanged: {