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

Don't show filter bar in text properties docker when some properties can show contextually.

Wolthera van Hövell tot Westerflier22e52abae20e
diff --git a/plugins/dockers/textproperties/TextPropertyConfigModel.cpp b/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
index e550ba9634..4da3c4127c 100644
--- a/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
+++ b/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
@@ -51,6 +51,22 @@ void TextPropertyConfigModel::setDefaultVisibilityState(const VisibilityState st
return;
d->defaultVisibilityState = state;
emit defaultVisibilityStateChanged();
+ emit shouldFilterChanged();
+}
+
+bool TextPropertyConfigModel::shouldFilter() const
+{
+ bool shouldFilter = d->defaultVisibilityState == AlwaysVisible;
+ if (!shouldFilter) return false;
+
+ for (int i = 0; i < d->propertyData.size(); i++) {
+ VisibilityState state = d->propertyData.values().at(i).visibilityState;
+ if (state == WhenRelevant || state == WhenSet) {
+ return false;
+ break;
+ }
+ }
+ return shouldFilter;
}
int TextPropertyConfigModel::rowCount(const QModelIndex &parent) const
@@ -94,6 +110,7 @@ bool TextPropertyConfigModel::setData(const QModelIndex &index, const QVariant &
if (d->propertyData[name].visibilityState != newState) {
d->propertyData[name].visibilityState = VisibilityState(value.toInt());
emit dataChanged(index, index, {role});
+ emit shouldFilterChanged();
return true;
}
}
diff --git a/plugins/dockers/textproperties/TextPropertyConfigModel.h b/plugins/dockers/textproperties/TextPropertyConfigModel.h
index bb822b473c..40257c91c0 100644
--- a/plugins/dockers/textproperties/TextPropertyConfigModel.h
+++ b/plugins/dockers/textproperties/TextPropertyConfigModel.h
@@ -16,6 +16,7 @@ class TextPropertyConfigModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(VisibilityState defaultVisibilityState READ defaultVisibilityState WRITE setDefaultVisibilityState NOTIFY defaultVisibilityStateChanged)
+ Q_PROPERTY(bool shouldFilter READ shouldFilter NOTIFY shouldFilterChanged)
public:
enum VisibilityState {
@@ -47,6 +48,8 @@ public:
VisibilityState defaultVisibilityState() const;
void setDefaultVisibilityState(const VisibilityState state);
+ bool shouldFilter() const;
+
// Call this after adding all the properties.
Q_INVOKABLE void loadFromConfiguration();
@@ -70,6 +73,7 @@ public:
Q_SIGNALS:
void defaultVisibilityStateChanged();
+ void shouldFilterChanged();
private:
struct Private;
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
index e4329b102c..76c0871cd9 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
@@ -29,7 +29,7 @@ ColumnLayout {
onShowParagraphPropertiesChanged: fillPropertyList();
filterCaseSensitivity: Qt.CaseInsensitive;
- property bool isFiltering: configModel.defaultVisibilityState === TextPropertyConfigModel.AlwaysVisible;
+ property bool isFiltering: configModel.shouldFilter;
onFilteredNamesChanged: {
if (isFiltering) {