Implement 'rightIcon' and 'rightIconInactive' image properties for componenent StandardButton

This commit is contained in:
Sander Ferdinand 2018-04-10 22:29:22 +02:00
parent b4353a31ac
commit 67e9109c14
4 changed files with 36 additions and 4 deletions

View File

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

BIN
images/rightArrowInactive.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -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:

View File

@ -205,5 +205,6 @@
<file>js/TxUtils.js</file>
<file>images/warning.png</file>
<file>images/checkedBlackIcon.png</file>
<file>images/rightArrowInactive.png</file>
</qresource>
</RCC>