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

Polish import buttons for QML resource view.

Wolthera van Hövell tot Westerflierf4dcd985ea84
diff --git a/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.cpp b/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.cpp
index df154a1f0b..70d7f423c4 100644
--- a/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.cpp
+++ b/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.cpp
@@ -94,6 +94,18 @@ void TagFilterProxyModelQmlWrapper::setResourceType(const QString &type)
emit currentResourceChanged();
}
+QString TagFilterProxyModelQmlWrapper::resourceTypeName() const
+{
+ if (d->resourceType.isEmpty()) return i18n("Resource");
+ // TODO: We should have separate translated entries for singular.
+ return ResourceName::resourceTypeToName(d->resourceType);
+}
+
+bool TagFilterProxyModelQmlWrapper::importEnabled() const
+{
+ return KisResourceLoaderRegistry::instance()->resourceTypes().contains(d->resourceType);
+}
+
void TagFilterProxyModelQmlWrapper::tagActivated(const int &row)
{
if (!d->tagModel || !d->tagFilterProxyModel) return;
diff --git a/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.h b/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.h
index eec292802e..4450eeee4a 100644
--- a/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.h
+++ b/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.h
@@ -23,6 +23,8 @@ class TagFilterProxyModelQmlWrapper : public QObject
Q_PROPERTY(QAbstractItemModel *tagModel READ tagModel NOTIFY tagModelChanged)
Q_PROPERTY(QString resourceType READ resourceType WRITE setResourceType NOTIFY resourceTypeChanged)
+ Q_PROPERTY(QString resourceTypeName READ resourceTypeName NOTIFY resourceTypeChanged)
+ Q_PROPERTY(bool importEnabled READ importEnabled NOTIFY resourceTypeChanged);
Q_PROPERTY(QString searchText READ searchText WRITE setSearchText NOTIFY searchTextChanged)
Q_PROPERTY(int currentTag READ currentTag WRITE tagActivated NOTIFY activeTagChanged)
@@ -52,6 +54,13 @@ public:
*/
void setResourceType(const QString &type);
+ /// The property translated name for the current resource type.
+ /// This might assert if there's no proper translated name.
+ QString resourceTypeName() const;
+
+ /// Returns whether the current resource has a ResourceLocator.
+ bool importEnabled() const;
+
/// Select tag at row in tag model.
void tagActivated(const int &row);
/// Return row of current tag in tag model.
diff --git a/plugins/dockers/textproperties/qml/ResourceView.qml b/plugins/dockers/textproperties/qml/ResourceView.qml
index 4603f3d707..d74a17ca9e 100644
--- a/plugins/dockers/textproperties/qml/ResourceView.qml
+++ b/plugins/dockers/textproperties/qml/ResourceView.qml
@@ -262,16 +262,24 @@ Control {
ToolButton {
id: importResource;
- palette: control.palette;
icon.source: "qrc:///light_document-import-16.svg";
icon.width: 16;
- icon.color: palette.text;
+ icon.color: palette.buttonText;
hoverEnabled: true;
- ToolTip.text: i18nc("@info:tooltip", "Import Resource");
+
display: AbstractButton.IconOnly;
- text: ToolTip.text;
- ToolTip.visible: hovered;
- ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval;
+ text: i18nc("@info:tooltip, %1 is resource type name", "Import %1", modelWrapper.resourceTypeName);
+ enabled: modelWrapper.importEnabled;
+
+ Kis.ThemedControl {
+ id: importPal;
+ }
+ palette: importPal.palette;
+
+ Kis.ToolTipBase {
+ text: importResource.text;
+ visible: importResource.hovered;
+ }
onClicked: modelWrapper.importResource();
@@ -283,11 +291,13 @@ Control {
icon.width: 16;
icon.color: palette.text;
hoverEnabled: true;
- ToolTip.text: i18nc("@info:tooltip", "Remove Resource");
display: AbstractButton.IconOnly;
- text: ToolTip.text;
- ToolTip.visible: hovered;
- ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval;
+ text: i18nc("@info:tooltip, %1 is resource type name", "Remove %1", modelWrapper.resourceTypeName);
+
+ Kis.ToolTipBase {
+ text: removeResource.text;
+ visible: removeResource.hovered;
+ }
onClicked: modelWrapper.removeResource();
}