56 lines
1.5 KiB
QML
56 lines
1.5 KiB
QML
import QtQuick
|
|
import "../services" as S
|
|
import NovaStats as NS
|
|
|
|
// Icon element with crossfade animation on icon change.
|
|
// Pure visual component - tooltip handling lives in the parent BarModule.
|
|
Text {
|
|
id: root
|
|
property string icon: ""
|
|
property string minIcon: ""
|
|
property color accentColor: parent?.accentColor ?? NS.ThemeService.base05
|
|
property string _displayIcon: icon
|
|
property string _pendingIcon: ""
|
|
|
|
text: _displayIcon
|
|
|
|
onIconChanged: {
|
|
_pendingIcon = icon;
|
|
if (!_crossfade.running)
|
|
_crossfade.start();
|
|
}
|
|
|
|
SequentialAnimation {
|
|
id: _crossfade
|
|
NumberAnimation {
|
|
target: root
|
|
property: "opacity"
|
|
to: 0
|
|
duration: 60
|
|
easing.type: Easing.InQuad
|
|
}
|
|
ScriptAction {
|
|
script: root._displayIcon = root._pendingIcon
|
|
}
|
|
NumberAnimation {
|
|
target: root
|
|
property: "opacity"
|
|
to: 1
|
|
duration: 100
|
|
easing.type: Easing.OutQuad
|
|
}
|
|
}
|
|
width: minIcon ? Math.max(implicitWidth, _minIconMetrics.width) : implicitWidth
|
|
horizontalAlignment: minIcon ? Text.AlignHCenter : Text.AlignLeft
|
|
color: root.accentColor
|
|
font.pixelSize: NS.ThemeService.fontSize + 1
|
|
font.family: NS.ThemeService.iconFontFamily
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
TextMetrics {
|
|
id: _minIconMetrics
|
|
text: root.minIcon
|
|
font.pixelSize: root.font.pixelSize
|
|
font.family: root.font.family
|
|
}
|
|
}
|