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++
Fix layout of style preset editing window.
Wolthera van Hövell tot Westerfliera54461ecfa71
diff --git a/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp b/plugins/dockers/textproperties/CssStylePresetEditDialog.cppindex 0fe187a310..c3290fc765 100644--- a/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp+++ b/plugins/dockers/textproperties/CssStylePresetEditDialog.cpp@@ -25,7 +25,7 @@ CssStylePresetEditDialog::CssStylePresetEditDialog(QWidget *parent), m_model(new KoSvgTextPropertiesModel()){- setMinimumSize(300, 500);+ setMinimumSize(600, 400);setModal(true);m_quickWidget = new KisQQuickWidget(this);@@ -40,10 +40,6 @@ CssStylePresetEditDialog::CssStylePresetEditDialog(QWidget *parent)wellFormedBCPNames.append(langCode.split("_").join("-"));}- 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()));@@ -51,6 +47,9 @@ CssStylePresetEditDialog::CssStylePresetEditDialog(QWidget *parent)if (!m_quickWidget->errors().empty()) {qWarning() << "Errors in " << windowTitle() << ":" << m_quickWidget->errors();+ } else {+ m_quickWidget->rootObject()->setProperty("textProperties", QVariant::fromValue(m_model));+ m_quickWidget->rootObject()->setProperty("locales", QVariant::fromValue(wellFormedBCPNames));}}@@ -69,19 +68,19 @@ void CssStylePresetEditDialog::setCurrentResource(KoCssStylePresetSP resource)textData.inheritedProperties = KoSvgTextProperties();textData.commonProperties = properties;m_model->textData.set(textData);- m_quickWidget->rootObject()->setProperty("presetTitle", m_currentResource->name());- m_quickWidget->rootObject()->setProperty("presetDescription", m_currentResource->description());- m_quickWidget->rootObject()->setProperty("presetSample", m_currentResource->sampleSvg());- m_quickWidget->rootObject()->setProperty("presetSampleAlignment", variantFromAlignment(m_currentResource->alignSample()));- m_quickWidget->rootObject()->setProperty("styleType", m_currentResource->styleType());-- m_quickWidget->rootObject()->setProperty("beforeSample", m_currentResource->beforeText());- m_quickWidget->rootObject()->setProperty("sampleText", m_currentResource->sampleText());- m_quickWidget->rootObject()->setProperty("afterSample", m_currentResource->afterText());- const int storedPPI = m_currentResource->storedPPIResolution();- m_quickWidget->rootObject()->setProperty("makePixelRelative", storedPPI > 0);-- QMetaObject::invokeMethod(m_quickWidget->rootObject(), "setProperties");+ if (m_quickWidget->rootObject()) {+ m_quickWidget->rootObject()->setProperty("presetTitle", m_currentResource->name());+ m_quickWidget->rootObject()->setProperty("presetDescription", m_currentResource->description());+ m_quickWidget->rootObject()->setProperty("presetSample", m_currentResource->sampleSvg());+ m_quickWidget->rootObject()->setProperty("presetSampleAlignment", variantFromAlignment(m_currentResource->alignSample()));+ m_quickWidget->rootObject()->setProperty("styleType", m_currentResource->styleType());++ m_quickWidget->rootObject()->setProperty("beforeSample", m_currentResource->beforeText());+ m_quickWidget->rootObject()->setProperty("sampleText", m_currentResource->sampleText());+ m_quickWidget->rootObject()->setProperty("afterSample", m_currentResource->afterText());+ const int storedPPI = m_currentResource->storedPPIResolution();+ m_quickWidget->rootObject()->setProperty("makePixelRelative", storedPPI > 0);+ }m_blockUpdates = false;slotUpdateDirty();}@@ -100,7 +99,9 @@ KoCssStylePresetSP CssStylePresetEditDialog::currentResource()void CssStylePresetEditDialog::setDpi(const double dpi){- m_quickWidget->rootObject()->setProperty("canvasDPI", dpi);+ if (m_quickWidget->rootObject()) {+ m_quickWidget->rootObject()->setProperty("canvasDPI", dpi);+ }}void CssStylePresetEditDialog::slotUpdateTextProperties()@@ -126,7 +127,6 @@ void CssStylePresetEditDialog::slotUpdateTextProperties()m_currentResource->updateThumbnail();m_quickWidget->rootObject()->setProperty("presetSample", m_currentResource->sampleSvg());m_quickWidget->rootObject()->setProperty("presetSampleAlignment", variantFromAlignment(m_currentResource->alignSample()));- QMetaObject::invokeMethod(m_quickWidget->rootObject(), "setProperties");slotUpdateDirty();}}@@ -150,7 +150,7 @@ QString CssStylePresetEditDialog::wwsFontFamilyName(QString familyName)void CssStylePresetEditDialog::slotUpdateDirty() {bool isDirty = m_currentResource->isDirty();const QString title = m_quickWidget->rootObject()->property("presetTitle").toString();- if (!isDirty) {+ if (!isDirty && m_quickWidget->rootObject()) {const QString description = m_quickWidget->rootObject()->property("presetDescription").toString();if (title != m_currentResource->name() || description != m_currentResource->description()) {isDirty = true;@@ -162,6 +162,7 @@ void CssStylePresetEditDialog::slotUpdateDirty() {void CssStylePresetEditDialog::slotUpdateStoreDPI() {//Whenever we make it pixel relative, we'll set the resolution to 72 dpi.if (m_blockUpdates) return;+ if (!m_quickWidget->rootObject()) return;const bool makePixelRelative = m_quickWidget->rootObject()->property("makePixelRelative").toBool();const int storedPPI = m_currentResource->storedPPIResolution();const int canvasPPI = m_quickWidget->rootObject()->property("canvasDPI").toInt();diff --git a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qmlindex 3af6f6e84b..c65b8deae6 100644--- a/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml+++ b/plugins/dockers/textproperties/qml/CssStylePresetEdit.qml@@ -21,6 +21,11 @@ Control {property double canvasDPI: 72.0;property double pixelRelativeDPI: 72.0;property alias makePixelRelative: pixelRelativeCheck.checked;++ property var locales: [];+ property KoSvgTextPropertiesModel textProperties: KoSvgTextPropertiesModel{};++onMakePixelRelativeChanged: mainWindow.slotUpdateStoreDPI();property alias beforeSample: beforeSampleField.text;@@ -40,14 +45,12 @@ Control {color: palette.window;}- function setProperties() {- presetProperties.updateProperties();- }-- ColumnLayout {+ GridLayout {anchors.fill: parent;GridLayout {- Layout.fillWidth: true;+ Layout.minimumWidth: 250;+ Layout.maximumWidth: 300;+ Layout.fillHeight: true;Layout.preferredHeight: implicitHeight;columns: 2;@@ -145,27 +148,32 @@ Control {Layout.fillWidth: visible? true: false;Layout.preferredWidth: visible? implicitWidth: 0;placeholderText: i18nc("@info:placeholder", "Before...");- onFocusChanged: if (!activeFocus) mainWindow.slotUpdateTextProperties();+ onTextChanged: mainWindow.slotUpdateTextProperties();visible: styleType !== "paragraph";}TextField {id: sampleField;Layout.fillWidth: true;placeholderText: presetTitleField.text.length == 0? i18nc("@info:placeholder", "Sample..."): presetTitleField.text;- onFocusChanged: if (!activeFocus) mainWindow.slotUpdateTextProperties();+ onTextChanged: mainWindow.slotUpdateTextProperties();}TextField {id: afterSampleField;Layout.fillWidth: visible? true: false;Layout.preferredWidth: visible? implicitWidth: 0;placeholderText: i18nc("@info:placeholder", "... After");- onFocusChanged: if (!activeFocus) mainWindow.slotUpdateTextProperties();+ onTextChanged: mainWindow.slotUpdateTextProperties();visible: styleType !== "paragraph";}}+ Item {+ Layout.fillHeight: true;+ Layout.fillWidth: true;+ }}TextPropertyBaseList {- propertiesModel: textPropertiesModel;+ propertiesModel: styleEdit.textProperties;+ locales: styleEdit.locales;Layout.fillWidth: true;Layout.fillHeight: true;canvasDPI: styleEdit.makePixelRelative? styleEdit.pixelRelativeDPI: styleEdit.canvasDPI;