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

Improve usability add property combobox in text properties docker.

Wolthera van Hövell tot Westerflier0bad7c7403a8
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cpp
index d1bbaa47e9..627fbe29a3 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp
+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp
@@ -186,6 +186,11 @@ void TextPropertiesDock::setViewManager(KisViewManager *kisview)
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);
}
}
diff --git a/plugins/dockers/textproperties/TextPropertyConfigModel.cpp b/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
index a6adb79050..e550ba9634 100644
--- a/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
+++ b/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
@@ -165,6 +165,9 @@ int TextPropertyConfigModel::visibilityStateForName(const QString &name) const
TextPropertyConfigFilterModel::TextPropertyConfigFilterModel(QObject *parent)
: QSortFilterProxyModel(parent) {
+
+ connect(this, &QAbstractItemModel::rowsRemoved, this, &TextPropertyConfigFilterModel::filteredNamesChanged);
+ connect(this, &QAbstractItemModel::rowsInserted, this, &TextPropertyConfigFilterModel::filteredNamesChanged);
}
bool TextPropertyConfigFilterModel::showParagraphProperties() const {
@@ -184,6 +187,17 @@ void TextPropertyConfigFilterModel::setProxySourceModel(QAbstractItemModel *mode
emit proxySourceModelChanged();
}
+QStringList TextPropertyConfigFilterModel::filteredNames() const
+{
+ QStringList names;
+
+ for (int i = 0; i < rowCount(); i++) {
+ QModelIndex idx = index(i, 0);
+ names.append(data(idx, TextPropertyConfigModel::Name).toString());
+ }
+ return names;
+}
+
bool TextPropertyConfigFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
QModelIndex idx = sourceModel()->index(source_row, 0, source_parent);
diff --git a/plugins/dockers/textproperties/TextPropertyConfigModel.h b/plugins/dockers/textproperties/TextPropertyConfigModel.h
index 1ba5ee23a7..bb822b473c 100644
--- a/plugins/dockers/textproperties/TextPropertyConfigModel.h
+++ b/plugins/dockers/textproperties/TextPropertyConfigModel.h
@@ -82,6 +82,7 @@ class TextPropertyConfigFilterModel : public QSortFilterProxyModel
Q_OBJECT
Q_PROPERTY(bool showParagraphProperties READ showParagraphProperties WRITE setShowParagraphProperties NOTIFY showParagraphPropertiesChanged)
Q_PROPERTY(QAbstractItemModel *sourceModel READ sourceModel WRITE setProxySourceModel NOTIFY proxySourceModelChanged)
+ Q_PROPERTY(QStringList filteredNames READ filteredNames NOTIFY filteredNamesChanged)
public:
TextPropertyConfigFilterModel(QObject *parent = nullptr);
// QSortFilterProxyModel interface
@@ -92,9 +93,12 @@ public:
void setProxySourceModel(QAbstractItemModel *model);
+ QStringList filteredNames() const;
+
Q_SIGNALS:
void showParagraphPropertiesChanged();
void proxySourceModelChanged();
+ void filteredNamesChanged();
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
index 91e20c13e5..7e99183e16 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
@@ -207,8 +207,46 @@ ColumnLayout {
palette: cmbPalette.palette;
function enableProperty(name) {
+ propertySearch.blockSignals = true;
+ propertySearch.text = "";
propertyBaseList.enableProperty(name);
popup.close();
+ propertySearch.blockSignals = false;
+ }
+
+ 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;
+
+ 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);
+ }
+ text = "";
+ blockSignals = false;
+ }
}
delegate: ItemDelegate {
@@ -241,41 +279,7 @@ ColumnLayout {
onClicked: addPropertyCmb.enableProperty(name);
}
-
- popup: Popup {
- y: addPropertyCmb.height - 1;
- width: addPropertyCmb.width;
- height: contentHeight;
- padding: 2;
-
- palette: cmbPalette.palette;
-
- contentItem: ColumnLayout {
- clip: true;
- width: parent.width;
- ListView {
- clip: true;
- Layout.preferredHeight: contentHeight;
- Layout.maximumHeight: 300;
- Layout.fillWidth: true;
- model: addPropertyCmb.popup.visible ? addPropertyCmb.delegateModel : null
- currentIndex: addPropertyCmb.highlightedIndex;
-
- ScrollBar.vertical: ScrollBar {
- }
- }
- MenuSeparator {
- Layout.fillWidth: true;
- Layout.preferredHeight: implicitHeight;
- }
- TextField {
- id: propertySearch;
- placeholderText: i18nc("@info:placeholder", "Search...");
- Layout.fillWidth: true;
- Layout.preferredHeight: implicitHeight;
- onTextChanged: filteredConfigModel.setFilterRegularExpression(text);
- }
- }
- }
+ popup.y: addPropertyCmb.height - 1;
+ popup.palette: cmbPalette.palette;
}
}