standard-button: fix layout

This commit is contained in:
xiphon 2018-12-08 21:26:33 +00:00
parent 71a1ff6677
commit e0796b24c9

View file

@ -46,22 +46,9 @@ Item {
} }
signal clicked() signal clicked()
// Dynamic height/width
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 height: small ? 30 * scaleRatio : 36 * scaleRatio
width: buttonLayout.width + 22 * scaleRatio
Component.onCompleted: width = width
function doClick() { function doClick() {
// Android workaround // Android workaround
@ -70,9 +57,7 @@ Item {
} }
Rectangle { Rectangle {
anchors.left: parent.left anchors.fill: parent
anchors.right: parent.right
height: parent.height - 1
radius: 3 radius: 3
color: parent.enabled ? MoneroComponents.Style.buttonBackgroundColor : MoneroComponents.Style.buttonBackgroundColorDisabled color: parent.enabled ? MoneroComponents.Style.buttonBackgroundColor : MoneroComponents.Style.buttonBackgroundColorDisabled
border.width: parent.focus ? 1 : 0 border.width: parent.focus ? 1 : 0
@ -96,38 +81,41 @@ Item {
} }
} }
Text { RowLayout {
id: label id: buttonLayout
anchors.verticalCenter: parent.verticalCenter height: button.height
anchors.left: parent.left spacing: 11 * scaleRatio
anchors.right: parent.right
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
color: parent.textColor
visible: parent.icon === ""
}
Image {
anchors.centerIn: parent anchors.centerIn: parent
visible: parent.icon !== ""
source: parent.icon
}
Image { Text {
visible: parent.rightIcon !== "" id: label
anchors.right: parent.right Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
anchors.rightMargin: 11 * scaleRatio horizontalAlignment: textAlign === "center" ? Text.AlignHCenter : Text.AlignLeft
anchors.verticalCenter: parent.verticalCenter font.family: MoneroComponents.Style.fontBold.name
width: parent.small ? 16 * scaleRatio : 20 * scaleRatio font.bold: true
height: parent.small ? 16 * scaleRatio : 20 * scaleRatio font.pixelSize: buttonArea.pressed ? button.fontSize - 1 : button.fontSize
source: { color: button.textColor
if(parent.rightIconInactive !== "" && !parent.enabled){ visible: button.icon === ""
return parent.rightIconInactive; }
Image {
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
visible: button.icon !== ""
source: button.icon
}
Image {
visible: button.rightIcon !== ""
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
width: button.small ? 16 * scaleRatio : 20 * scaleRatio
height: button.small ? 16 * scaleRatio : 20 * scaleRatio
source: {
if(button.rightIconInactive !== "" && !button.enabled) {
return button.rightIconInactive;
}
return button.rightIcon;
} }
return parent.rightIcon;
} }
} }