From 67e9109c14bb914f31b6c8193bc391a954fad14c Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Tue, 10 Apr 2018 22:29:22 +0200 Subject: Implement 'rightIcon' and 'rightIconInactive' image properties for componenent StandardButton --- components/StandardButton.qml | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'components/StandardButton.qml') diff --git a/components/StandardButton.qml b/components/StandardButton.qml index 39ddc061..8f552ac7 100644 --- a/components/StandardButton.qml +++ b/components/StandardButton.qml @@ -34,8 +34,10 @@ import "../components" as MoneroComponents Item { id: button property string rightIcon: "" + property string rightIconInactive: "" property string icon: "" property string textColor: button.enabled? MoneroComponents.Style.buttonTextColor: MoneroComponents.Style.buttonTextColorDisabled + property string textAlign: rightIcon !== "" ? "left" : "center" property bool small: false property alias text: label.text property int fontSize: { @@ -45,9 +47,21 @@ Item { signal clicked() // Dynamic height/width - Layout.minimumWidth: (label.contentWidth > 50)? label.contentWidth + 22 : 60 - height: small ? 30 * scaleRatio : 36 * scaleRatio + Layout.minimumWidth: { + var _padding = 22; + if(button.rightIcon !== ""){ + _padding += 60; + } + + var _width = label.contentWidth + _padding; + if(_width <= 50) { + return 60; + } + return _width; + } + + height: small ? 30 * scaleRatio : 36 * scaleRatio function doClick() { // Android workaround @@ -87,7 +101,8 @@ Item { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.right: parent.right - horizontalAlignment: Text.AlignHCenter + horizontalAlignment: textAlign === "center" ? Text.AlignHCenter : Text.AlignLeft + anchors.leftMargin: textAlign === "center" ? 0 : 11 font.family: MoneroComponents.Style.fontBold.name font.bold: true font.pixelSize: buttonArea.pressed ? button.fontSize - 1 : button.fontSize @@ -101,6 +116,21 @@ Item { source: parent.icon } + Image { + visible: parent.rightIcon !== "" + anchors.right: parent.right + anchors.rightMargin: 11 * scaleRatio + anchors.verticalCenter: parent.verticalCenter + width: parent.small ? 16 * scaleRatio : 20 * scaleRatio + height: parent.small ? 16 * scaleRatio : 20 * scaleRatio + source: { + if(parent.rightIconInactive !== "" && !parent.enabled){ + return parent.rightIconInactive; + } + return parent.rightIcon; + } + } + MouseArea { id: buttonArea anchors.fill: parent -- cgit v1.2.3