Browse Source

CURA-4354 fixed plugin injected tool icon path finding, example in PerObjectSettingsTool

ChrisTerBeke 7 years ago
parent
commit
11241642b3

+ 1 - 1
plugins/PerObjectSettingsTool/__init__.py

@@ -13,7 +13,7 @@ def getMetaData():
         "tool": {
             "name": i18n_catalog.i18nc("@label", "Per Model Settings"),
             "description": i18n_catalog.i18nc("@info:tooltip", "Configure Per Model Settings"),
-            "icon": "setting_per_object",
+            "icon": "tool_icon.svg",
             "tool_panel": "PerObjectSettingsPanel.qml",
             "weight": 3
         },

+ 3 - 0
plugins/PerObjectSettingsTool/tool_icon.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30">
+    <path d="M30 20L25.1 6.7 27.6 0H12.9l1.6 5H6.4l2.3 6H2.4l2.4 6.2L0 30h19.5l-1.7-4H26l-2.3-6H30zm-12.5 5l-2.8-7.5 2.4-6.5H9.6L7.7 6h14.7L20 12.4l2.9 7.6 2 5h-7.4z"/>
+</svg>

+ 9 - 19
resources/qml/Toolbar.qml

@@ -34,28 +34,18 @@ Item
             Button
             {
                 text: model.name
-                iconSource:
-                {
-                    var result = UM.Theme.getIcon(model.icon)
-                    if(result == "")
-                    {
-                        return model.location + "/" + model.icon
-                    }
-                    return result
-                }
-
-                checkable: true;
-                checked: model.active;
-                enabled: model.enabled && UM.Selection.hasSelection && UM.Controller.toolsEnabled;
-
-                style: UM.Theme.styles.tool_button;
-                onCheckedChanged:
-                {
-                    if(checked)
-                    {
+                iconSource: (UM.Theme.getIcon(model.icon) != "") ? UM.Theme.getIcon(model.icon) : "file:///" + model.location + "/" + model.icon
+                checkable: true
+                checked: model.active
+                enabled: model.enabled && UM.Selection.hasSelection && UM.Controller.toolsEnabled
+                style: UM.Theme.styles.tool_button
+
+                onCheckedChanged: {
+                    if (checked) {
                         base.activeY = y
                     }
                 }
+
                 //Workaround since using ToolButton"s onClicked would break the binding of the checked property, instead
                 //just catch the click so we do not trigger that behaviour.
                 MouseArea