Move notificationswapper to common, change defaul wrap mode
This commit is contained in:
@@ -4,9 +4,10 @@ import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Io
|
||||
import qs.Common
|
||||
|
||||
Singleton {
|
||||
id:root
|
||||
id: root
|
||||
|
||||
readonly property string hyprlandSignature: Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE")
|
||||
|
||||
@@ -93,32 +94,32 @@ Singleton {
|
||||
return workspaceDesktopEntries;
|
||||
}
|
||||
|
||||
Socket {
|
||||
path: `${Quickshell.env("XDG_RUNTIME_DIR")}/hypr/${Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE")}/.socket2.sock`
|
||||
connected: true
|
||||
Socket {
|
||||
path: `${Quickshell.env("XDG_RUNTIME_DIR")}/hypr/${Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE")}/.socket2.sock`
|
||||
connected: true
|
||||
|
||||
parser: SplitParser {
|
||||
property var fullscreenRegex: new RegExp("fullscreen>>.");
|
||||
parser: SplitParser {
|
||||
property var fullscreenRegex: new RegExp("fullscreen>>.")
|
||||
property var screencastRegex: new RegExp("screencast>>.*")
|
||||
|
||||
onRead: msg => {
|
||||
let match = fullscreenRegex.exec(msg);
|
||||
if (match != null) {
|
||||
if(msg.split(">>")[1] === "1") {
|
||||
root.hasFullscreen = true
|
||||
onRead: msg => {
|
||||
let match = fullscreenRegex.exec(msg);
|
||||
if (match != null) {
|
||||
if (msg.split(">>")[1] === "1") {
|
||||
root.hasFullscreen = true;
|
||||
} else {
|
||||
root.hasFullscreen = false
|
||||
root.hasFullscreen = false;
|
||||
}
|
||||
}
|
||||
match = screencastRegex.exec(msg);
|
||||
if (match != null) {
|
||||
if(msg.split(">>")[1].split(',')[0] === "1") {
|
||||
root.isScreencasting = true
|
||||
}
|
||||
match = screencastRegex.exec(msg);
|
||||
if (match != null) {
|
||||
if (msg.split(">>")[1].split(',')[0] === "1") {
|
||||
root.isScreencasting = true;
|
||||
} else {
|
||||
root.isScreencasting = false
|
||||
root.isScreencasting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Services.Notifications
|
||||
import qs.Widgets
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
|
||||
Singleton {
|
||||
@@ -27,21 +27,21 @@ Singleton {
|
||||
Connections {
|
||||
target: notificationServer
|
||||
function onNotification(notif) {
|
||||
if(notif.transient || notif.body === "MediaOngoingActivity")
|
||||
return;
|
||||
if (notif.transient || notif.body === "MediaOngoingActivity")
|
||||
return;
|
||||
|
||||
notif.tracked = true;
|
||||
root.addNotification(trackedNotifications, notif);
|
||||
|
||||
if (notif.lastGeneration)
|
||||
return;
|
||||
return;
|
||||
|
||||
// Use the refactored helper
|
||||
if(notificationList.count < root.maxShown && !root.receivingLock ) {
|
||||
root.addNotification(notificationList, notif)
|
||||
if (notificationList.count < root.maxShown && !root.receivingLock) {
|
||||
root.addNotification(notificationList, notif);
|
||||
} else {
|
||||
root.receivingLock = true
|
||||
root.addNotification(pendingList, notif)
|
||||
root.receivingLock = true;
|
||||
root.addNotification(pendingList, notif);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,6 @@ Singleton {
|
||||
* @param {var} targetNotif
|
||||
*/
|
||||
function removeNotification(model, targetNotif) {
|
||||
|
||||
if (!model || typeof model.remove !== "function") {
|
||||
console.warn("removeNotification(): invalid model");
|
||||
return;
|
||||
@@ -85,7 +84,7 @@ Singleton {
|
||||
// Avoid duplicates
|
||||
for (let i = 0; i < model.count; i++) {
|
||||
if (model.get(i).notif === notif)
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
model.append({
|
||||
@@ -98,48 +97,47 @@ Singleton {
|
||||
}
|
||||
|
||||
function notificationDismiss(notif) {
|
||||
let pendingIdx = -1
|
||||
let pendingIdx = -1;
|
||||
|
||||
for (let i = 0; i < pendingList.count; i++) {
|
||||
if (pendingList.get(i).notif === notif) {
|
||||
pendingIdx = i
|
||||
break
|
||||
pendingIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pendingIdx >= 0) {
|
||||
pendingList.remove(pendingIdx, 1)
|
||||
pendingList.remove(pendingIdx, 1);
|
||||
} else {
|
||||
removeNotification(notificationList, notif)
|
||||
removeNotification(notificationList, notif);
|
||||
}
|
||||
|
||||
removeNotification(trackedNotifications, notif)
|
||||
removeNotification(trackedNotifications, notif);
|
||||
|
||||
if (notif && typeof notif.dismiss === "function")
|
||||
notif.dismiss()
|
||||
notif.dismiss();
|
||||
|
||||
tryShowNext()
|
||||
tryShowNext();
|
||||
}
|
||||
|
||||
function timeoutNotification(notif) {
|
||||
removeNotification(notificationList, notif);
|
||||
|
||||
removeNotification(notificationList, notif)
|
||||
|
||||
tryShowNext()
|
||||
tryShowNext();
|
||||
}
|
||||
|
||||
function tryShowNext() {
|
||||
let filled = false
|
||||
let filled = false;
|
||||
|
||||
while (notificationList.count < root.maxShown && pendingList.count > 0) {
|
||||
const nextNotif = pendingList.get(0).notif
|
||||
pendingList.remove(0, 1)
|
||||
addNotification(notificationList, nextNotif)
|
||||
filled = true
|
||||
const nextNotif = pendingList.get(0).notif;
|
||||
pendingList.remove(0, 1);
|
||||
addNotification(notificationList, nextNotif);
|
||||
filled = true;
|
||||
}
|
||||
|
||||
// Only lock if there are still more pending than fit onscreen
|
||||
root.receivingLock = pendingList.count > 0
|
||||
root.receivingLock = pendingList.count > 0;
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
@@ -157,7 +155,9 @@ Singleton {
|
||||
implicitWidth: 400
|
||||
implicitHeight: screen.height
|
||||
color: "transparent"
|
||||
mask: Region { item: listView }
|
||||
mask: Region {
|
||||
item: listView
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: listView
|
||||
@@ -176,17 +176,16 @@ Singleton {
|
||||
notification: modelData
|
||||
implicitWidth: listView.width
|
||||
|
||||
|
||||
startTimer: NotificationUrgency.toString(notification?.urgency) === "Critical"? false: true
|
||||
startTimer: NotificationUrgency.toString(notification?.urgency) === "Critical" ? false : true
|
||||
timerDuration: 5000
|
||||
|
||||
onDismissed: {
|
||||
if (notification && typeof notification.dismiss === "function")
|
||||
root.notificationDismiss(notification);
|
||||
root.notificationDismiss(notification);
|
||||
}
|
||||
|
||||
onTimedout: {
|
||||
root.timeoutNotification(notification)
|
||||
root.timeoutNotification(notification);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user