fixed weird mpris and notification state issues

This commit is contained in:
2026-06-26 21:05:35 +01:00
parent 07ec781b68
commit 33cfb4b539

View File

@@ -22,7 +22,6 @@ Container {
defaultItem: time defaultItem: time
exclusiveMonitor: root.monitor exclusiveMonitor: root.monitor
exclusiveToScreen: true exclusiveToScreen: true
state: ""
states: [ states: [
State { State {
@@ -50,18 +49,30 @@ Container {
PropertyChanges { PropertyChanges {
root.boxHeight: 35 root.boxHeight: 35
root.boxRadius: 15 root.boxRadius: 15
root.boxWidth: MprisManager.getPlaying() == true ? 350 : 110 root.boxWidth: 110
root.visibleTopMargin: 0 root.visibleTopMargin: 0
} }
StateChangeScript { StateChangeScript {
script: { script: {
if (MprisManager.getPlaying()) { root.previousState = "hovered";
root.previousState = "mpris"; }
root.stack.replace(mpris); }
} else { },
root.previousState = "hovered"; State {
} name: "mprisToast"
PropertyChanges {
root.boxHeight: 35
root.boxRadius: 15
root.boxWidth: 350
root.visibleTopMargin: 0
}
StateChangeScript {
script: {
root.previousState = "mpris";
root.stack.replace(mpris);
} }
} }
}, },
@@ -112,8 +123,18 @@ Container {
] ]
hover.onHoveredChanged: { hover.onHoveredChanged: {
hover.hovered == true ? root.state == "notified" ? root.state = "notified" : root.state = "hovered" : if (hover.hovered == true) {
root.state = ""; if (root.state == "notified") {
root.state = "notified";
notificationViewTimer.stop();
} else if (MprisManager.getPlaying() == true) {
root.state = "mprisToast";
} else {
root.state = "hovered";
}
} else {
root.state = "";
}
} }
onLatestNotificationChanged: { onLatestNotificationChanged: {
if (latestNotification != null && Hyprland.focusedMonitor == monitor) { if (latestNotification != null && Hyprland.focusedMonitor == monitor) {
@@ -130,8 +151,10 @@ Container {
Connections { Connections {
function onTrackChanged() { function onTrackChanged() {
if (Hyprland.focusedMonitor == root.monitor) { if (Hyprland.focusedMonitor == root.monitor) {
musicToastTimer.start(); musicToastTimer.restart();
root.state = "hovered"; if (root.state == "") {
root.state = "mprisToast";
}
} }
} }
@@ -143,7 +166,7 @@ Container {
interval: 3000 interval: 3000
repeat: false repeat: false
running: false || !root.hover.hovered running: false
onTriggered: { onTriggered: {
root.state = ""; root.state = "";
@@ -153,12 +176,15 @@ Container {
Timer { Timer {
id: musicToastTimer id: musicToastTimer
interval: 2000 interval: 3000
repeat: false repeat: false
running: false running: false
onTriggered: { onTriggered: {
root.state = ""; if (!root.hover.hovered) {
console.log("some");
root.state = "";
}
} }
} }