reaction-trainer/qml/Components/FancyButton.qml

89 lines
1.9 KiB
QML
Raw Normal View History

2019-04-06 20:09:40 +02:00
import QtQuick 2.9
import QtQuick.Controls 2.4
import QtGraphicalEffects 1.0
Button {
id: control
property string image
property color backgroundColor: "white"
property color textColor: "black"
property real imageScale: 1
property double glowRadius: 0.001
property double glowSpread: 0.2
property bool glowVisible: true
property double glowScale: 0.75
property double glowOpacity: 1
scale: control.pressed ? 0.8:1
Behavior on scale {
PropertyAnimation {
duration: 100
}
}
Behavior on backgroundColor {
ColorAnimation {
duration: 200
}
}
contentItem: Text {
visible: false
}
Text {
id: conetntText
text: qsTr(control.text)
anchors.centerIn: parent
font: parent.font
color: control.textColor
opacity: control.enabled ? 1:0.4
}
background: Item {
id: controlBackgroundContainer
RectangularGlow {
id: effect
glowRadius: control.glowRadius
spread: control.glowSpread
color: "black"
visible: control.glowVisible
cornerRadius: controlBackground.radius
anchors.fill: controlBackground
scale: control.glowScale
opacity: control.glowOpacity
}
Rectangle {
id: controlBackground
anchors.fill: parent
radius: height * 0.5
color: control.backgroundColor
Image {
id: buttonIcon
source: control.image
anchors.centerIn: parent
height: parent.height * 0.5
width: height
mipmap: true
fillMode: Image.PreserveAspectFit
scale: control.imageScale
}
}
}
}