Browse Source

Add icons on left and right side of text

For this I had to implement functionality in ActionButton to be able to display the icon on either side.

Contributes to issue CURA-5876.
Ghostkeeper 6 years ago
parent
commit
d42ddad606

+ 20 - 4
resources/qml/ActionButton.qml

@@ -11,7 +11,8 @@ Button
 {
     id: button
     property alias cursorShape: mouseArea.cursorShape
-    property alias iconSource: buttonIcon.source
+    property alias iconSource: buttonIconLeft.source
+    property var iconOnRightSide: false
     property alias textFont: buttonText.font
     property alias cornerRadius: backgroundRect.radius
     property alias tooltip: tooltip.text
@@ -35,16 +36,17 @@ Button
 
     contentItem: Row
     {
+        //Icon if displayed on the left side.
         UM.RecolorImage
         {
-            id: buttonIcon
+            id: buttonIconLeft
             source: ""
             height: Math.round(0.6 * parent.height)
-            width: height
+            width: visible ? height : 0
             sourceSize.width: width
             sourceSize.height: height
             color: button.hovered ? button.textHoverColor : button.textColor
-            visible: source != ""
+            visible: source != "" && !button.iconOnRightSide
             anchors.verticalCenter: parent.verticalCenter
         }
 
@@ -61,6 +63,20 @@ Button
             horizontalAlignment: Text.AlignHCenter
             elide: Text.ElideRight
         }
+
+        //Icon if displayed on the right side.
+        UM.RecolorImage
+        {
+            id: buttonIconRight
+            source: buttonIconLeft.source
+            height: Math.round(0.6 * parent.height)
+            width: visible ? height : 0
+            sourceSize.width: width
+            sourceSize.height: height
+            color: button.hovered ? button.textHoverColor : button.textColor
+            visible: source != "" && button.iconOnRightSide
+            anchors.verticalCenter: parent.verticalCenter
+        }
     }
 
     background: Rectangle

+ 5 - 0
resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml

@@ -172,6 +172,9 @@ Cura.ExpandableComponent
                 textColor: UM.Theme.getColor("primary")
                 textHoverColor: UM.Theme.getColor("text")
 
+                iconSource: UM.Theme.icons.arrow_right
+                iconOnRightSide: true
+
                 onClicked: popupItem.configuration_method = "custom"
             }
 
@@ -192,6 +195,8 @@ Cura.ExpandableComponent
                 textColor: UM.Theme.getColor("primary")
                 textHoverColor: UM.Theme.getColor("text")
 
+                iconSource: UM.Theme.icons.arrow_left
+
                 onClicked: popupItem.configuration_method = "auto"
             }
         }