89 lines
2.4 KiB
QML
89 lines
2.4 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import "." as M
|
|
|
|
M.BarSection {
|
|
id: root
|
|
spacing: M.Theme.moduleSpacing
|
|
tooltip: {
|
|
const parts = [M.NotifService.count + " notification" + (M.NotifService.count !== 1 ? "s" : "")];
|
|
if (M.NotifService.dnd)
|
|
parts.push("Do not disturb");
|
|
return parts.join("\n");
|
|
}
|
|
|
|
required property var bar
|
|
|
|
M.BarIcon {
|
|
icon: {
|
|
if (M.NotifService.dnd)
|
|
return M.NotifService.count > 0 ? "\uDB80\uDCA0" : "\uDB82\uDE93";
|
|
return M.NotifService.count > 0 ? "\uDB84\uDD6B" : "\uDB80\uDC9C";
|
|
}
|
|
color: M.NotifService.dnd ? M.Theme.base04 : root.accentColor
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
M.BarLabel {
|
|
id: countLabel
|
|
label: M.NotifService.count > 0 ? String(M.NotifService.count) : ""
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
transform: Scale {
|
|
id: countScale
|
|
origin.x: countLabel.width / 2
|
|
origin.y: countLabel.height / 2
|
|
xScale: 1
|
|
yScale: 1
|
|
}
|
|
|
|
SequentialAnimation {
|
|
id: popAnim
|
|
NumberAnimation {
|
|
target: countScale
|
|
properties: "xScale,yScale"
|
|
to: 1.4
|
|
duration: 100
|
|
easing.type: Easing.OutQuad
|
|
}
|
|
NumberAnimation {
|
|
target: countScale
|
|
properties: "xScale,yScale"
|
|
to: 1.0
|
|
duration: 200
|
|
easing.type: Easing.OutElastic
|
|
}
|
|
}
|
|
}
|
|
|
|
Connections {
|
|
target: M.NotifService
|
|
function onCountChanged() {
|
|
if (M.NotifService.count > 0)
|
|
popAnim.start();
|
|
}
|
|
}
|
|
|
|
TapHandler {
|
|
acceptedButtons: Qt.LeftButton
|
|
cursorShape: Qt.PointingHandCursor
|
|
onTapped: {
|
|
centerLoader.active = !centerLoader.active;
|
|
M.FlyoutState.visible = false;
|
|
}
|
|
}
|
|
TapHandler {
|
|
acceptedButtons: Qt.RightButton
|
|
cursorShape: Qt.PointingHandCursor
|
|
onTapped: M.NotifService.toggleDnd()
|
|
}
|
|
|
|
Loader {
|
|
id: centerLoader
|
|
active: false
|
|
sourceComponent: M.NotifCenter {
|
|
screen: root.bar.screen
|
|
anchorX: root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0)
|
|
onDismissed: centerLoader.active = false
|
|
}
|
|
}
|
|
}
|