This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
app/resources/qml/components/FancyButton.qml

100 lines
2.5 KiB
QML
Raw Permalink Normal View History

2019-03-08 15:36:32 +01:00
import QtQuick 2.9
2020-04-02 17:40:22 +02:00
import QtQuick.Controls 2.2
2019-03-08 15:36:32 +01:00
import QtGraphicalEffects 1.0
import de.itsblue.ScStw.Styling 2.0
import de.itsblue.ScStw.Styling.Components 1.0
2019-03-08 15:36:32 +01:00
Button {
id: control
property string image
2020-05-19 12:43:32 +02:00
property color backgroundColor: appTheme.theme.colors.button
2019-03-08 15:36:32 +01:00
property real imageScale: 1
property double glowRadius: 0.001
property double glowSpread: 0.2
property bool glowVisible: true
property double glowScale: 0.75
2019-05-19 14:06:05 +02:00
property double glowOpacity: Math.pow( control.opacity, 100 )
2019-03-08 15:36:32 +01:00
Behavior on text {
//animate a text change
enabled: true
FadeAnimation {
target: text
2019-03-08 15:36:32 +01:00
}
}
contentItem: Item {}
2019-03-08 15:36:32 +01:00
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
2019-03-08 15:36:32 +01:00
anchors.fill: parent
radius: height * 0.5
color: control.down ? Qt.darker(control.backgroundColor, 1.2) : control.backgroundColor
Behavior on color {
ColorAnimation {
duration: 200
}
}
2019-03-08 15:36:32 +01:00
Text {
id: text
anchors.centerIn: parent
anchors.verticalCenterOffset: -height * 0.05
height: parent.height * 0.6
width: parent.width * 0.6
fontSizeMode: Text.Fit
font.pixelSize: Math.max(parent.height * 0.16, parent.width * 0.16)
font.family: "Helvetica"
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: control.text
color: enabled ? appTheme.theme.colors.text:appTheme.theme.colors.disabledText
}
2019-03-08 15:36:32 +01:00
Image {
id: buttonIcon
source: control.image
anchors.centerIn: parent
height: parent.height * 0.5
width: height
mipmap: true
fillMode: Image.PreserveAspectFit
scale: control.imageScale
}
}
}
}