status-desktop/ui/app/AppLayouts/Wallet/controls/HeaderButton.qml

70 lines
1.7 KiB
QML
Raw Permalink Normal View History

import QtQuick 2.15
import QtGraphicalEffects 1.15
import StatusQ.Core.Theme 0.1
import utils 1.0
import shared 1.0
import shared.panels 1.0
2020-07-15 19:38:03 +00:00
Rectangle {
id: headerButton
2020-07-15 19:38:03 +00:00
property string text: ""
property url imageSource
property bool flipImage: false
property var onClicked: function () {}
property int margin: 8
2020-07-15 19:38:03 +00:00
width: buttonImage.width + buttonText.width + Theme.smallPadding * 2
+ (text === "" ? 0 : headerButton.margin)
height: buttonText.height + Theme.smallPadding * 2
2020-07-15 19:38:03 +00:00
border.width: 0
color: Theme.palette.transparent
radius: Theme.radius
2020-07-15 19:38:03 +00:00
SVGImage {
id: buttonImage
height: 18
anchors.left: parent.left
anchors.leftMargin: Theme.smallPadding
2020-07-15 19:38:03 +00:00
anchors.verticalCenter: parent.verticalCenter
fillMode: Image.PreserveAspectFit
source: imageSource
rotation: flipImage ? 180 : 0
ColorOverlay {
anchors.fill: parent
source: parent
color: Theme.palette.primaryColor1
}
2020-07-15 19:38:03 +00:00
}
StyledText {
id: buttonText
visible: !!headerButton.text
text: headerButton.text
anchors.left: buttonImage.right
anchors.leftMargin: headerButton.margin
2020-07-15 19:38:03 +00:00
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 13
font.weight: Font.Medium
color: Theme.palette.primaryColor1
2020-07-15 19:38:03 +00:00
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: {
parent.color = Theme.palette.secondaryBackground
2020-07-15 19:38:03 +00:00
}
onExited: {
parent.color = Theme.palette.transparent
2020-07-15 19:38:03 +00:00
}
onClicked: {
headerButton.onClicked()
}
cursorShape: Qt.PointingHandCursor
}
}