115 lines
3.1 KiB
QML
115 lines
3.1 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Wayland
|
|
import "." as M
|
|
import "../services" as S
|
|
import NovaStats as NS
|
|
|
|
PanelWindow {
|
|
id: root
|
|
|
|
visible: _winVisible
|
|
color: "transparent"
|
|
|
|
// Mirror of `screen` captured at construction. Reading `root.screen`
|
|
// directly in `_shown` couples it to visibility transitions (PanelWindow
|
|
// re-evaluates `screen` when mapped/unmapped), which feeds back into
|
|
// `_shown` via `_winVisible` and trips a binding loop.
|
|
property var assignedScreen: null
|
|
property bool _winVisible: false
|
|
property bool _shown: M.TooltipState.visible && M.TooltipState.screen === assignedScreen
|
|
|
|
on_ShownChanged: {
|
|
if (_shown) {
|
|
_winVisible = true;
|
|
hideAnim.stop();
|
|
if (S.ThemeUtil.reducedMotion) {
|
|
content.opacity = 1;
|
|
content.y = 0;
|
|
} else {
|
|
showAnim.start();
|
|
}
|
|
} else {
|
|
showAnim.stop();
|
|
if (S.ThemeUtil.reducedMotion) {
|
|
_winVisible = false;
|
|
} else {
|
|
hideAnim.start();
|
|
}
|
|
}
|
|
}
|
|
|
|
WlrLayershell.layer: WlrLayer.Overlay
|
|
WlrLayershell.exclusiveZone: 0
|
|
WlrLayershell.namespace: "nova-flyout"
|
|
|
|
anchors.top: true
|
|
anchors.left: true
|
|
|
|
margins.top: 0
|
|
margins.left: Math.max(0, Math.min(Math.round(M.TooltipState.itemX - implicitWidth / 2), screen.width - implicitWidth))
|
|
|
|
implicitWidth: label.implicitWidth + NS.ThemeService.barPadding * 2
|
|
implicitHeight: label.implicitHeight + NS.ThemeService.barPadding * 2
|
|
|
|
ParallelAnimation {
|
|
id: showAnim
|
|
NumberAnimation {
|
|
target: content
|
|
property: "opacity"
|
|
to: 1
|
|
duration: 120
|
|
easing.type: Easing.OutCubic
|
|
}
|
|
NumberAnimation {
|
|
target: content
|
|
property: "y"
|
|
to: 0
|
|
duration: 150
|
|
easing.type: Easing.OutCubic
|
|
}
|
|
}
|
|
|
|
ParallelAnimation {
|
|
id: hideAnim
|
|
NumberAnimation {
|
|
target: content
|
|
property: "opacity"
|
|
to: 0
|
|
duration: 150
|
|
easing.type: Easing.InCubic
|
|
}
|
|
NumberAnimation {
|
|
target: content
|
|
property: "y"
|
|
to: -content.height
|
|
duration: 150
|
|
easing.type: Easing.InCubic
|
|
}
|
|
onFinished: root._winVisible = false
|
|
}
|
|
|
|
Item {
|
|
id: content
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
height: root.implicitHeight
|
|
opacity: 0
|
|
y: -height
|
|
|
|
M.PopupBackground {
|
|
anchors.fill: parent
|
|
accentColor: M.TooltipState.accentColor
|
|
}
|
|
|
|
Text {
|
|
id: label
|
|
anchors.centerIn: parent
|
|
text: M.TooltipState.text.replace(/\n/g, "<br>")
|
|
textFormat: Text.RichText
|
|
color: NS.ThemeService.base05
|
|
font.pixelSize: NS.ThemeService.fontSize
|
|
font.family: NS.ThemeService.fontFamily
|
|
}
|
|
}
|
|
}
|