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

Implement ability to configure text property visibility.

Wolthera van Hövell tot Westerflier1e14520d33c0
diff --git a/plugins/dockers/textproperties/CMakeLists.txt b/plugins/dockers/textproperties/CMakeLists.txt
index 335fe95359..e0272d5ccd 100644
--- a/plugins/dockers/textproperties/CMakeLists.txt
+++ b/plugins/dockers/textproperties/CMakeLists.txt
@@ -9,6 +9,7 @@ set(KRITA_TEXTPROPERTIES_SOURCES
LocaleHandler.cpp
CssQmlUnitConverter.cpp
TextPropertyConfigModel.cpp
+ TextPropertyConfigDialog.cpp
)
qt_add_resources(KRITA_TEXTPROPERTIES_SOURCES textproperties.qrc)
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cpp
index 64ac805bf5..d1bbaa47e9 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp
+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp
@@ -51,6 +51,8 @@
#include "CssQmlUnitConverter.h"
#include "TextPropertyConfigModel.h"
+#include "TextPropertyConfigDialog.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");
@@ -227,6 +229,16 @@ 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();
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.h b/plugins/dockers/textproperties/TextPropertiesDock.h
index 070741a994..8bf3d55648 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.h
+++ b/plugins/dockers/textproperties/TextPropertiesDock.h
@@ -37,6 +37,8 @@ public Q_SLOTS:
QColor modalColorDialog(QColor oldColor);
+ void callModalTextPropertyConfigDialog();
+
private:
QPointer<KisCanvas2> m_canvas;
QQuickWidget *m_quickWidget {0};
diff --git a/plugins/dockers/textproperties/TextPropertyConfigDialog.cpp b/plugins/dockers/textproperties/TextPropertyConfigDialog.cpp
new file mode 100644
index 0000000000..0d48651c9d
--- /dev/null
+++ b/plugins/dockers/textproperties/TextPropertyConfigDialog.cpp
@@ -0,0 +1,67 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <KLocalizedContext>
+#include <KLocalizedString>
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QQuickItem>
+#include <KoResourcePaths.h>
+
+#include "TextPropertyConfigDialog.h"
+
+TextPropertyConfigDialog::TextPropertyConfigDialog(QWidget *parent)
+ : KoDialog(parent)
+
+{
+ setMinimumSize(500, 300);
+ setModal(true);
+
+ m_quickWidget = new QQuickWidget(this);
+ this->setMainWidget(m_quickWidget);
+ m_quickWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ m_quickWidget->engine()->rootContext()->setContextProperty("mainWindow", this);
+ m_quickWidget->engine()->rootContext()->setContextObject(new KLocalizedContext(this));
+
+ m_quickWidget->engine()->addImportPath(KoResourcePaths::getApplicationRoot() + "/lib/qml/");
+ m_quickWidget->engine()->addImportPath(KoResourcePaths::getApplicationRoot() + "/lib64/qml/");
+
+ m_quickWidget->engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib/qml/");
+ m_quickWidget->engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib64/qml/");
+
+ m_quickWidget->setPalette(this->palette());
+ this->setWindowTitle(i18nc("@title:window", "Text Property Configuration"));
+
+ m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
+ m_quickWidget->setSource(QUrl("qrc:/TextPropertyConfigDialog.qml"));
+ if (!m_quickWidget->errors().empty()) {
+ qWarning() << "Errors in " << windowTitle() << ":" << m_quickWidget->errors();
+ }
+
+}
+
+TextPropertyConfigDialog::~TextPropertyConfigDialog()
+{
+ /// Prevent accessing destroyed objects in QML engine
+ /// See:
+ /// * https://invent.kde.org/graphics/krita/-/commit/d8676f4e9cac1a8728e73fec3ff1df1763c713b7
+ /// * https://bugreports.qt.io/browse/QTBUG-81247
+ m_quickWidget->setParent(nullptr);
+ delete m_quickWidget;
+}
+
+void TextPropertyConfigDialog::setTextPropertyConfigModel(TextPropertyConfigModel *model)
+{
+ if (m_quickWidget->rootObject() && model) {
+ m_model = model;
+ m_quickWidget->rootObject()->setProperty("configModel", QVariant::fromValue(m_model));
+ }
+}
+
+TextPropertyConfigModel *TextPropertyConfigDialog::model()
+{
+ return m_model;
+}
diff --git a/plugins/dockers/textproperties/TextPropertyConfigDialog.h b/plugins/dockers/textproperties/TextPropertyConfigDialog.h
new file mode 100644
index 0000000000..35000f0f6d
--- /dev/null
+++ b/plugins/dockers/textproperties/TextPropertyConfigDialog.h
@@ -0,0 +1,29 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef TEXTPROPERTYCONFIGDIALOG_H
+#define TEXTPROPERTYCONFIGDIALOG_H
+
+#include <QObject>
+#include <KoDialog.h>
+#include <QQuickWidget>
+
+#include "TextPropertyConfigModel.h"
+
+class TextPropertyConfigDialog : public KoDialog
+{
+ Q_OBJECT
+public:
+ TextPropertyConfigDialog(QWidget *parent = nullptr);
+ ~TextPropertyConfigDialog();
+
+ void setTextPropertyConfigModel(TextPropertyConfigModel *model);
+ TextPropertyConfigModel *model();
+private:
+ QQuickWidget *m_quickWidget {0};
+ TextPropertyConfigModel *m_model;
+};
+
+#endif // TEXTPROPERTYCONFIGDIALOG_H
diff --git a/plugins/dockers/textproperties/TextPropertyConfigModel.cpp b/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
index bfd6c23098..b93b2b8d7c 100644
--- a/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
+++ b/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
@@ -9,9 +9,9 @@
#include "TextPropertyConfigModel.h"
struct TextPropertyConfigModel::TextPropertyData {
- TextPropertyConfigModel::VisibilityState visibilityState;
- TextPropertyConfigModel::PropertyType propertyType;
- bool collapsed;
+ TextPropertyConfigModel::VisibilityState visibilityState = TextPropertyConfigModel::FollowDefault;
+ TextPropertyConfigModel::PropertyType propertyType = TextPropertyConfigModel::Mixed;
+ bool collapsed = false;
QStringList searchTerms;
QString toolTip;
QString title;
@@ -25,10 +25,12 @@ const QMap<TextPropertyConfigModel::VisibilityState, QString> visibilityConfigNa
{TextPropertyConfigModel::WhenSet, "whenSet"},
};
+const QString DEFAULT_VISIBILITY_STATE = "defaultVisibilityState";
+
struct TextPropertyConfigModel::Private {
QStringList propertyNames;
QMap<QString, TextPropertyConfigModel::TextPropertyData> propertyData;
- TextPropertyConfigModel::VisibilityState defaultVisibilityState: TextPropertyConfigModel::WhenRelevant;
+ TextPropertyConfigModel::VisibilityState defaultVisibilityState = TextPropertyConfigModel::WhenRelevant;
};
TextPropertyConfigModel::TextPropertyConfigModel(QObject *parent)
@@ -41,14 +43,14 @@ TextPropertyConfigModel::~TextPropertyConfigModel()
{
}
-int TextPropertyConfigModel::defaultVisibilityState() const {
- return int(d->defaultVisibilityState);
+TextPropertyConfigModel::VisibilityState TextPropertyConfigModel::defaultVisibilityState() const {
+ return d->defaultVisibilityState;
}
-void TextPropertyConfigModel::setDefaultVisibilityState(const int state) {
- if (state == int(d->defaultVisibilityState))
+void TextPropertyConfigModel::setDefaultVisibilityState(const VisibilityState state) {
+ if (state == d->defaultVisibilityState)
return;
- d->defaultVisibilityState = VisibilityState(state);
+ d->defaultVisibilityState = state;
emit defaultVisibilityStateChanged();
}
@@ -73,7 +75,7 @@ QVariant TextPropertyConfigModel::data(const QModelIndex &index, int role) const
} else if (role == Qt::ToolTipRole) {
return data.toolTip;
} else if (role == Visibility) {
- return int(data.visibilityState);
+ return data.visibilityState;
} else if (role == Collapsed) {
return data.collapsed;
} else if (role == SearchTerms) {
@@ -86,14 +88,17 @@ QVariant TextPropertyConfigModel::data(const QModelIndex &index, int role) const
bool TextPropertyConfigModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
- if (!index.isValid()) return false;
+ if (!index.isValid() || !value.isValid()) return false;
if (index.row() < 0 || index.row() >= d->propertyNames.size()) return false;
if (role == Visibility) {
+ VisibilityState newState = VisibilityState(value.toInt());
const QString name = d->propertyNames.at(index.row());
- d->propertyData[name].visibilityState = VisibilityState(value.toInt());
- emit dataChanged(index, index, {role});
- return true;
+ if (d->propertyData[name].visibilityState != newState) {
+ d->propertyData[name].visibilityState = VisibilityState(value.toInt());
+ emit dataChanged(index, index, {role});
+ return true;
+ }
} else if (role == Collapsed) {
const QString name = d->propertyNames.at(index.row());
d->propertyData[name].collapsed = value.toBool();
@@ -117,7 +122,7 @@ bool TextPropertyConfigModel::moveRows(const QModelIndex &sourceParent, int sour
QHash<int, QByteArray> TextPropertyConfigModel::roleNames() const
{
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
- roles[Visibility] = "visibilityState";
+ roles[Visibility] = "visibility";
roles[SearchTerms] = "searchTerms";
roles[Collapsed] = "collapsed";
roles[Type] = "type";
@@ -128,7 +133,8 @@ QHash<int, QByteArray> TextPropertyConfigModel::roleNames() const
void TextPropertyConfigModel::saveConfiguration()
{
- KConfigGroup configGroup = KSharedConfig::openConfig()->group("TextPropertiesDock");
+ KConfigGroup configGroup = KSharedConfig::openConfig()->group("TextProperties");
+ configGroup.writeEntry(DEFAULT_VISIBILITY_STATE, visibilityConfigNames.value(d->defaultVisibilityState));
Q_FOREACH (const QString name, d->propertyNames) {
const TextPropertyData data = d->propertyData.value(name);
configGroup.writeEntry(name, visibilityConfigNames.value(data.visibilityState));
@@ -136,13 +142,14 @@ void TextPropertyConfigModel::saveConfiguration()
}
void TextPropertyConfigModel::loadFromConfiguration() {
- KConfigGroup configGroup = KSharedConfig::openConfig()->group("TextPropertiesDock");
+ KConfigGroup configGroup = KSharedConfig::openConfig()->group("TextProperties");
+ d->defaultVisibilityState = visibilityConfigNames.key(configGroup.readEntry(DEFAULT_VISIBILITY_STATE, visibilityConfigNames.value(d->defaultVisibilityState)));
Q_FOREACH (const QString name, d->propertyNames) {
- d->propertyData[name].visibilityState = visibilityConfigNames.key(configGroup.readEntry(name));
+ d->propertyData[name].visibilityState = visibilityConfigNames.key(configGroup.readEntry(name, visibilityConfigNames.value(d->propertyData[name].visibilityState)));
}
}
-void TextPropertyConfigModel::addProperty(const QString name, const int propertyType, const QString title, const QString toolTip, const QString searchTerms, const int visibilityState, const bool collapsed)
+void TextPropertyConfigModel::addProperty(const QString &name, const int propertyType, const QString title, const QString toolTip, const QString searchTerms, const int visibilityState, const bool collapsed)
{
if (d->propertyNames.contains(name)) return;
beginInsertRows(QModelIndex(), d->propertyNames.size(), d->propertyNames.size());
@@ -151,13 +158,20 @@ void TextPropertyConfigModel::addProperty(const QString name, const int property
data.propertyType = PropertyType(propertyType);
data.toolTip = toolTip;
data.searchTerms = searchTerms.split(",");
- data.visibilityState = visibilityState < 0? FollowDefault: VisibilityState(visibilityState);
+
+ data.visibilityState = VisibilityState(qMax(visibilityState, 0));
data.collapsed = collapsed;
d->propertyData.insert(name, data);
d->propertyNames.append(name);
endInsertRows();
}
+int TextPropertyConfigModel::visibilityStateForName(const QString &name) const
+{
+ TextPropertyData data = d->propertyData.value(name, TextPropertyData());
+ return int(data.visibilityState);
+}
+
TextPropertyConfigFilterModel::TextPropertyConfigFilterModel(QObject *parent)
: QSortFilterProxyModel(parent) {
setFilterCaseSensitivity(Qt::CaseInsensitive);
@@ -188,6 +202,8 @@ bool TextPropertyConfigFilterModel::filterAcceptsRow(int source_row, const QMode
const QString name = sourceModel()->data(idx, Qt::DisplayRole).toString();
const QStringList searchTerms = sourceModel()->data(idx, TextPropertyConfigModel::SearchTerms).toStringList();
const TextPropertyConfigModel::PropertyType type = TextPropertyConfigModel::PropertyType(sourceModel()->data(idx, TextPropertyConfigModel::Type).toInt());
+ const TextPropertyConfigModel::VisibilityState state = TextPropertyConfigModel::VisibilityState(sourceModel()->data(idx, TextPropertyConfigModel::Visibility).toInt());
+ if (state == TextPropertyConfigModel::NeverVisible) return false;
if (type == TextPropertyConfigModel::Paragraph && !m_showParagraphProperties) {
return false;
} else if (type == TextPropertyConfigModel::Character && m_showParagraphProperties) {
diff --git a/plugins/dockers/textproperties/TextPropertyConfigModel.h b/plugins/dockers/textproperties/TextPropertyConfigModel.h
index 02ac4a3663..3767b7c26a 100644
--- a/plugins/dockers/textproperties/TextPropertyConfigModel.h
+++ b/plugins/dockers/textproperties/TextPropertyConfigModel.h
@@ -15,15 +15,15 @@
class TextPropertyConfigModel : public QAbstractListModel
{
Q_OBJECT
- Q_PROPERTY(int defaultVisibilityState READ defaultVisibilityState WRITE setDefaultVisibilityState NOTIFY defaultVisibilityStateChanged)
+ Q_PROPERTY(VisibilityState defaultVisibilityState READ defaultVisibilityState WRITE setDefaultVisibilityState NOTIFY defaultVisibilityStateChanged)
public:
enum VisibilityState {
FollowDefault = 0, ///< Follow the default property.
- WhenRelevant, ///< Show when either set or inherited.
- WhenSet, ///< Show only when set.
- AlwaysVisible, ///< Always show property.
- NeverVisible, ///< Never show property.
+ WhenRelevant = 1, ///< Show when either set or inherited.
+ WhenSet = 2, ///< Show only when set.
+ AlwaysVisible = 3, ///< Always show property.
+ NeverVisible = 4, ///< Never show property.
};
Q_ENUM(VisibilityState)
@@ -45,13 +45,13 @@ public:
explicit TextPropertyConfigModel(QObject *parent = nullptr);
~TextPropertyConfigModel();
- int defaultVisibilityState() const;
- void setDefaultVisibilityState(const int state);
+ VisibilityState defaultVisibilityState() const;
+ void setDefaultVisibilityState(const VisibilityState state);
// Call this after adding all the properties.
Q_INVOKABLE void loadFromConfiguration();
- Q_INVOKABLE void addProperty(const QString name,
+ Q_INVOKABLE void addProperty(const QString &name,
const int propertyType = 0,
const QString title = QString(),
const QString toolTip = QString(),
@@ -59,6 +59,9 @@ public:
const int visibilityState = -1,
const bool collapsed = false);
+ Q_INVOKABLE int visibilityStateForName(const QString &name) const;
+
+ void saveConfiguration();
// QAbstractItemModel interface
public:
int rowCount(const QModelIndex &parent) const override;
@@ -69,8 +72,6 @@ public:
Q_SIGNALS:
void defaultVisibilityStateChanged();
-private Q_SLOTS:
- void saveConfiguration();
private:
struct Private;
diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qml
index 777b0827e1..3469c17eca 100644
--- a/plugins/dockers/textproperties/qml/TextProperties.qml
+++ b/plugins/dockers/textproperties/qml/TextProperties.qml
@@ -14,6 +14,8 @@ Rectangle {
color: sysPalette.window;
anchors.fill: parent;
+ property TextPropertyConfigModel configModel : textPropertyConfigModel;
+
SystemPalette {
id: sysPalette;
colorGroup: SystemPalette.Active
@@ -29,11 +31,40 @@ Rectangle {
paragraphPropertyList.updateProperties()
}
+ function updatePropertyVisibilityState() {
+ configModel.loadFromConfiguration();
+ characterPropertyList.updatePropertyVisibilityState();
+ paragraphPropertyList.updatePropertyVisibilityState();
+ }
+
+ RowLayout {
+ id: configLayout;
+ height: implicitHeight;
+ anchors.right: parent.right;
+ anchors.left: parent.left;
+ anchors.top: parent.top;
+ Item {
+ Layout.fillWidth: true;
+ }
+ ToolButton {
+ id: configButton;
+ icon.source: "qrc:///light_configure.svg"
+ icon.color: palette.text;
+ icon.width: 16;
+ icon.height: 16;
+ text: i18nc("@label:button", "Configure");
+
+ palette: paletteControl.palette;
+
+ onClicked: mainWindow.callModalTextPropertyConfigDialog();
+ }
+ }
+
TabBar {
id: tabs
anchors.right: parent.right;
anchors.left: parent.left;
- anchors.top: parent.top;
+ anchors.top: configLayout.bottom;
palette: paletteControl.palette;
TabButton {
text: i18nc("@title:tab", "Character")
@@ -53,11 +84,13 @@ Rectangle {
TextPropertyBaseList {
id: characterPropertyList;
propertyType: TextPropertyConfigModel.Character;
+ configModel: root.configModel;
}
TextPropertyBaseList {
id: paragraphPropertyList;
propertyType: TextPropertyConfigModel.Paragraph;
+ configModel: root.configModel;
}
}
}
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBase.qml b/plugins/dockers/textproperties/qml/TextPropertyBase.qml
index 159085727c..affd89ebd6 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBase.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBase.qml
@@ -16,6 +16,7 @@ Column {
height: visible? childrenRect.height: 0;
property KoSvgTextPropertiesModel properties : textPropertiesModel;
+ property int defaultVisibilityState : TextPropertyConfigModel.FollowDefault;
property double dpi: canvasDPI;
signal propertiesUpdated; ///< Used by each text property panel to update the data on the controls.
signal enableProperty; ///< Set the property to a default value.
@@ -32,7 +33,7 @@ Column {
property var propertyState: []; /// All property states related to the current property.
function setVisibleFromProperty() {
- let visibleState = visibilityState === TextPropertyConfigModel.FollowDefault? textPropertyConfigModel.defaultVisibilityState: visibilityState;
+ let visibleState = visibilityState === TextPropertyConfigModel.FollowDefault? defaultVisibilityState: visibilityState;
if (visibleState === TextPropertyConfigModel.AlwaysVisible) {
visible = true;
} else if (visibleState === TextPropertyConfigModel.NeverVisible) {
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
index f60a37f176..91e20c13e5 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
@@ -12,6 +12,7 @@ import org.krita.flake.text 1.0
ColumnLayout {
id: propertyBaseList;
property int propertyType: TextPropertyConfigModel.Character;
+ property TextPropertyConfigModel configModel;
ListModel {
id: propertyList;
@@ -23,36 +24,47 @@ ColumnLayout {
TextPropertyConfigFilterModel {
id : filteredConfigModel;
- sourceModel: textPropertyConfigModel;
+ sourceModel: configModel;
showParagraphProperties: propertyBaseList.propertyType === TextPropertyConfigModel.Paragraph;
onShowParagraphPropertiesChanged: fillPropertyList();
filterCaseSensitivity: Qt.CaseInsensitive;
}
- Component.onCompleted: fillPropertyList();
+ onConfigModelChanged: {if (configModel != null) fillPropertyList();}
function fillPropertyList() {
for (var i = 0; i < propertyWidgetModel.count; i++) {
let prop = propertyWidgetModel.get(i);
- textPropertyConfigModel.addProperty(prop.propertyName,
- prop.propertyType,
- prop.propertyTitle,
- prop.toolTip,
- prop.searchTerms,
- );
- textPropertyConfigModel.loadFromConfiguration();
- if (filteredConfigModel.showParagraphProperties && prop.propertyType === TextPropertyConfigModel.Character) {
- propertyWidgetModel.get(i).visible = false;
- } else if (!filteredConfigModel.showParagraphProperties && prop.propertyType === TextPropertyConfigModel.Paragraph) {
- propertyWidgetModel.get(i).visible = false;
+ configModel.addProperty(prop.propertyName,
+ prop.propertyType,
+ prop.propertyTitle,
+ prop.toolTip,
+ prop.searchTerms,
+ prop.visibilityState
+ );
+
+ if (testShowProperty(prop.propertyType)) {
+ prop.setVisibleFromProperty();
+ } else {
+ prop.visible = false;
}
}
+ textPropertyConfigModel.loadFromConfiguration();
+ updatePropertyVisibilityState();
+ }
+
+ function testShowProperty(propertyType) {
+ if (filteredConfigModel.showParagraphProperties && propertyType === TextPropertyConfigModel.Character) {
+ return false;
+ } else if (!filteredConfigModel.showParagraphProperties && propertyType === TextPropertyConfigModel.Paragraph) {
+ return false;
+ }
+ return true;
}
function updateProperties() {
for (var i = 0; i < propertyWidgetModel.count; i++) {
- if (propertyWidgetModel.get(i).propertyType === propertyType ||
- propertyWidgetModel.get(i).propertyType === TextPropertyBase.Mixed) {
+ if (testShowProperty(propertyWidgetModel.get(i).propertyType)) {
propertyWidgetModel.get(i).propertiesUpdated();
} else {
propertyWidgetModel.get(i).visible = false;
@@ -60,6 +72,19 @@ ColumnLayout {
}
}
+ function updatePropertyVisibilityState() {
+ for (var i = 0; i < propertyWidgetModel.count; i++) {
+ let name = propertyWidgetModel.get(i).propertyName;
+ propertyWidgetModel.get(i).defaultVisibilityState = configModel.defaultVisibilityState;
+ propertyWidgetModel.get(i).visibilityState = configModel.visibilityStateForName(name);
+ if (testShowProperty(propertyWidgetModel.get(i).propertyType)) {
+ propertyWidgetModel.get(i).setVisibleFromProperty();
+ } else {
+ propertyWidgetModel.get(i).visible = false;
+ }
+ }
+ }
+
function isVisible(name) {
for (var i = 0; i < propertyWidgetModel.count; i++) {
let prop = propertyWidgetModel.get(i);
diff --git a/plugins/dockers/textproperties/qml/TextPropertyConfigDialog.qml b/plugins/dockers/textproperties/qml/TextPropertyConfigDialog.qml
new file mode 100644
index 0000000000..3d474d815d
--- /dev/null
+++ b/plugins/dockers/textproperties/qml/TextPropertyConfigDialog.qml
@@ -0,0 +1,114 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Layouts 1.15
+import org.krita.flake.text 1.0
+
+/**
+ This should be a dialog, but because qml doesn't get proper dialog handling till 6.8,
+ it only is an item that we put inside a kodialog.
+ **/
+
+Control {
+ id: control;
+ property TextPropertyConfigModel configModel;
+ onConfigModelChanged: {
+ defaultVisibilityCmb.currentIndex = defaultVisibilityCmb.indexOfValue(configModel.defaultVisibilityState);
+ }
+
+ PaletteControl {
+ id: paletteControl;
+ colorGroup: control.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+
+ palette: paletteControl.palette;
+
+ background: Rectangle {
+ color: palette.window;
+ anchors.fill: parent;
+ }
+
+ ColumnLayout {
+
+ anchors.fill: parent;
+
+ RowLayout {
+ Layout.fillWidth: true;
+ Label {
+ text: i18nc("@label:listbox", "Default Visibility:");
+ Layout.fillWidth: true;
+ }
+
+ ComboBox {
+ id: defaultVisibilityCmb;
+ model: [
+ {text: i18nc("@label:inlistbox", "When Relevant"), value: TextPropertyConfigModel.WhenRelevant},
+ {text: i18nc("@label:inlistbox", "When Set"), value: TextPropertyConfigModel.WhenSet},
+ {text: i18nc("@label:inlistbox", "Always Show"), value: TextPropertyConfigModel.AlwaysVisible}
+ ]
+
+ textRole: "text";
+ valueRole: "value";
+ Layout.preferredWidth: implicitWidth;
+ onActivated: {
+ if (control.configModel) {
+ control.configModel.defaultVisibilityState = currentValue;
+ }
+ }
+ }
+
+ }
+
+ ListView {
+ id: configListView;
+ model: configModel;
+ Layout.fillWidth: true;
+ Layout.fillHeight: true;
+ clip: true;
+
+ ScrollBar.vertical: ScrollBar {
+ }
+
+ delegate: ItemDelegate {
+ id: configDelegate;
+ width: configListView.width;
+ height: implicitHeight;
+ required property var model;
+ required property int index;
+
+ palette: control.palette;
+ contentItem: RowLayout {
+ Label {
+ text: configDelegate.model.title;
+ Layout.fillWidth: true;
+ palette: control.palette;
+ }
+ ComboBox {
+ id: visibilityCmb;
+ Layout.preferredWidth: implicitWidth;
+ model: [
+ {text: i18nc("@label:inlistbox", "Follow Default"), value: TextPropertyConfigModel.FollowDefault},
+ {text: i18nc("@label:inlistbox", "When Relevant"), value: TextPropertyConfigModel.WhenRelevant},
+ {text: i18nc("@label:inlistbox", "When Set"), value: TextPropertyConfigModel.WhenSet},
+ {text: i18nc("@label:inlistbox", "Always Show"), value: TextPropertyConfigModel.AlwaysVisible},
+ {text: i18nc("@label:inlistbox", "Never Show"), value: TextPropertyConfigModel.NeverVisible}
+ ]
+
+ palette: control.palette;
+ textRole: "text";
+ valueRole: "value";
+ Component.onCompleted: {
+ currentIndex = indexOfValue(configDelegate.model.visibility);
+ }
+
+ onActivated: configDelegate.model.visibility = currentValue;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/dockers/textproperties/textproperties.qrc b/plugins/dockers/textproperties/textproperties.qrc
index d48cbeea0c..a1c36a2f28 100644
--- a/plugins/dockers/textproperties/textproperties.qrc
+++ b/plugins/dockers/textproperties/textproperties.qrc
@@ -59,5 +59,6 @@
<file alias="16_light_format-text-overline.svg">icons/16_light_format-text-overline.svg</file>
<file alias="FontSizeAdjust.qml">qml/FontSizeAdjust.qml</file>
<file alias="TextRendering.qml">qml/TextRendering.qml</file>
+ <file alias="TextPropertyConfigDialog.qml">qml/TextPropertyConfigDialog.qml</file>
</qresource>
</RCC>