From 67e9109c14bb914f31b6c8193bc391a954fad14c Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Tue, 10 Apr 2018 22:29:22 +0200 Subject: [PATCH] Implement 'rightIcon' and 'rightIconInactive' image properties for componenent StandardButton --- components/StandardButton.qml | 36 +++++++++++++++++++++++++++++++--- images/rightArrowInactive.png | Bin 0 -> 15343 bytes pages/Transfer.qml | 3 ++- qml.qrc | 1 + 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100755 images/rightArrowInactive.png 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 diff --git a/images/rightArrowInactive.png b/images/rightArrowInactive.png new file mode 100755 index 0000000000000000000000000000000000000000..09335c8ad6d05bd924fa208a4cbe9ffbf313858d GIT binary patch literal 15343 zcmeI3eQXnD9LJA<1BO%7MVArusL@d6dM|Ca_Uy{b%Gi+3x)s?LUv|5Dx*fE4wRfZ4 zbP8xplqhkDZ_J=ZFldk%{(uNf@dXV5UlU`3@`u5IAig9ZC}`$$ZP(tObx)S4@t^0C z_WFCi&+qqpp3n3Ap58zAc%*q*MR|2OMNt(^jiDBJue3fh%Ha2tkI$`ux0%Vtc7vj3 zU1NQwP@7+@qA33vHQHvjg;$8Oo^VNu-UVElL=yI#e02j!MlJKINr;0ewODLju&}O6gWD6 zIfCWzS0JUt#FkJ)J{`2`96hF)6j?T%PP@`>m!9fodB5M!asn#|4D7)eeVQp{7|pmb z7i2U}2pDooO`58%(N0Geq)Kfa`2vPU;{qeq`0WkH@WFG1Pr+e!=V{vnNziN*Tba zzdFZg0Tzz5!ii=1Wb0UzWb14T%2s&*CBTkpEe@;TnRipiFX!YCf4B_x6YBq4 zhT<-kdnBzJC_#2~1CKULZsl_8IkvJ!t95)O2CP3P5mqtWQBt;g_y9Yut(ZC2zs;(~ zcyG3Ut-!$xKEl8&?`oG(*LJ+CT}EAto+~xg3<~*dNVCn$`UlM&@2&7*4+LwxUbi>E zqRpsBM9qMBTS$fHuwk7i0-RUY2Ng;>wol|}6Y`F^rLsMiWot0k3LpC5^Cnw(;2c+; zg;VU`{860IzZn&YMUo&u@Fu~9=YyyO7Xk!t5?pvbh)QrFK=3BPh3A8)1Q!AXZxUR1 zK8Q+iAwcjZ!G-68s00@R1aA^tcs__qa3MhOCc%a0gQx@-0t9aoTzEc+N^l`S@Fu~9 z=YyyO7Xk!t5?pvbh)QrFK=3BPh3A8)1Q!AXZxUR1K8Q+iAwcjZ!G-68s00@R1aA^t zcs__qa3MhOCc%a0gQx@-0t9aoTzEc+N^l`S@Fu~9=YyyO7Xk!t5?pvbh)QrFK=3BP zh3A8)1Q!AXZ(?zk7hmB78hmdv4PVgQ2|P{k)`QwEwsi=&yNJDxeb`u#;wV#gHbdf!v6QwQ%~x8>yA3;n~t z#A_}M9a3&SrhR>G;NgchZksu;;ed19ao_i;x7SNm$9p@!*_}AN>(jtzmsWeK&-ZvX zKl_n*Y325r^R}#CarZLeg+F&hZ~6Tleecc(b|sIq{hpyY?`@#p+Wg6hLxbl}{qV)h zAGf>`nehniOWpJJ^_Q0&-hHI{lCz=e!_{YoH*L9M_R`3}^tOR&`D~)~*wr1I_TM)B l%$($~(0SpvX@6Ewq3SnYTEO%^XuXo#w6r<2b4llhzX9LZ)dK(k literal 0 HcmV?d00001 diff --git a/pages/Transfer.qml b/pages/Transfer.qml index d572e315..0a339f98 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -329,7 +329,8 @@ Rectangle { RowLayout { StandardButton { id: sendButton - rightIcon: "../images/rightIcon.png" + rightIcon: "../images/rightArrow.png" + rightIconInactive: "../images/rightArrowInactive.png" Layout.topMargin: 4 * scaleRatio text: qsTr("Send") + translationManager.emptyString // Send button is enabled when: diff --git a/qml.qrc b/qml.qrc index 8f00900f..42b868e6 100644 --- a/qml.qrc +++ b/qml.qrc @@ -205,5 +205,6 @@ js/TxUtils.js images/warning.png images/checkedBlackIcon.png + images/rightArrowInactive.png