nova-shell/modules/BarIcon.qml

55 lines
1.7 KiB
QML

import QtQuick
import QtQuick.Effects
import Quickshell
import "." as M
Text {
id: root
property string icon: ""
property string tooltip: ""
property bool _hovered: false
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 }
}
color: M.Theme.base05
font.pixelSize: M.Theme.fontSize + 1
font.family: M.Theme.iconFontFamily
verticalAlignment: Text.AlignVCenter
layer.enabled: _hovered && !(parent && parent._hovered === true)
layer.effect: MultiEffect {
shadowEnabled: true
shadowColor: M.Theme.base05
shadowBlur: 0.5
shadowVerticalOffset: 0
shadowHorizontalOffset: 0
}
HoverHandler {
onHoveredChanged: {
root._hovered = hovered;
if (hovered && root.tooltip !== "") {
M.FlyoutState.text = root.tooltip;
M.FlyoutState.itemX = root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0);
M.FlyoutState.screen = QsWindow.window?.screen ?? null;
M.FlyoutState.visible = true;
} else if (!hovered && root.tooltip !== "") {
M.FlyoutState.visible = false;
}
}
}
}