small component patches + code cleanup
This commit is contained in:
34
components/HoverButton.qml
Normal file
34
components/HoverButton.qml
Normal file
@@ -0,0 +1,34 @@
|
||||
import QtQuick
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property color idleColor: "transparent"
|
||||
property color hoverColor: "transparent"
|
||||
property color pressColor: "transparent"
|
||||
property color borderIdleColor: "transparent"
|
||||
property color borderHoverColor: "transparent"
|
||||
property real pressScale: 0.97
|
||||
property int animDuration: 150
|
||||
|
||||
readonly property bool hovered: _hover.hovered
|
||||
readonly property bool pressed: _tap.pressed
|
||||
|
||||
signal clicked()
|
||||
|
||||
color: pressed ? pressColor : (hovered ? hoverColor : idleColor)
|
||||
border.color: hovered ? borderHoverColor : borderIdleColor
|
||||
|
||||
scale: pressed ? pressScale : 1.0
|
||||
|
||||
Behavior on color { ColorAnimation { duration: root.animDuration } }
|
||||
Behavior on border.color { ColorAnimation { duration: root.animDuration } }
|
||||
Behavior on scale { NumberAnimation { duration: 100; easing.type: Easing.OutQuad } }
|
||||
|
||||
HoverHandler { id: _hover }
|
||||
TapHandler {
|
||||
id: _tap
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onTapped: root.clicked()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user