quickshell-toki-night/custom/CustomText.qml

46 lines
1.2 KiB
QML

import QtQuick
import Quickshell
import qs.config
Text {
id: root
// Either boolean or function taking old and new text
property var animate: false
property string animateProp: "opacity"
property real animateFrom: 0
property real animateTo: 1
property int animateDuration: Config.anim.durations.normal
renderType: Text.NativeRendering
textFormat: Text.PlainText
color: Config.colors.primary
linkColor: Config.colors.highlight
font.family: Config.font.family.sans
font.pointSize: Config.font.size.smaller
Behavior on text {
enabled: typeof root.animate === "boolean"
? root.animate : root.animate(root.text, targetValue)
SequentialAnimation {
Anim {
to: root.animateFrom
easing.bezierCurve: Config.anim.curves.standardAccel
}
PropertyAction {}
Anim {
to: root.animateTo
easing.bezierCurve: Config.anim.curves.standardDecel
}
}
}
component Anim: NumberAnimation {
target: root
property: root.animateProp
duration: root.animateDuration / 2
easing.type: Easing.BezierSpline
}
}