nova-shell/shell/modules/BarIcon.qml

55 lines
1.5 KiB
QML

import QtQuick
import "../services" as S
// 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 ?? S.Theme.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: S.Theme.fontSize + 1
font.family: S.Theme.iconFontFamily
verticalAlignment: Text.AlignVCenter
TextMetrics {
id: _minIconMetrics
text: root.minIcon
font.pixelSize: root.font.pixelSize
font.family: root.font.family
}
}