mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-09 21:36:13 +00:00
WIP: notif progress bar
This commit is contained in:
@@ -162,6 +162,34 @@ Variants {
|
||||
border.width: Math.max(1, Style.borderS * scaling)
|
||||
color: Color.mSurface
|
||||
|
||||
Rectangle {
|
||||
id: progressBar
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 3 * scaling
|
||||
color: "transparent"
|
||||
clip: true
|
||||
|
||||
Rectangle {
|
||||
width: parent.width * (model.progress || 0)
|
||||
height: parent.height
|
||||
color: {
|
||||
if (model.urgency === NotificationUrgency.Critical || model.urgency === 2)
|
||||
return Color.mError
|
||||
else if (model.urgency === NotificationUrgency.Low || model.urgency === 0)
|
||||
return Color.mOnSurface
|
||||
else
|
||||
return Color.mPrimary
|
||||
}
|
||||
|
||||
radius: parent.height / 2
|
||||
antialiasing: true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Animation properties
|
||||
property real scaleValue: 0.8
|
||||
property real opacityValue: 0.0
|
||||
|
||||
@@ -24,6 +24,7 @@ Singleton {
|
||||
// Internal state
|
||||
property var activeMap: ({})
|
||||
property var imageQueue: []
|
||||
property var progressTimers: ({})
|
||||
|
||||
// Simple image cacher
|
||||
PanelWindow {
|
||||
@@ -118,7 +119,9 @@ Singleton {
|
||||
"body": stripTags(n.body || ""),
|
||||
"appName": getAppName(n.appName),
|
||||
"urgency": n.urgency || 1,
|
||||
"expireTimeout": n.expireTimeout,
|
||||
"timestamp": time,
|
||||
"progress": 1.0,
|
||||
"originalImage": image,
|
||||
"cachedImage": imageId ? (Settings.cacheDirImagesNotifications + imageId + ".png") : image,
|
||||
"actionsJson": JSON.stringify((n.actions || []).map(a => ({
|
||||
@@ -160,7 +163,6 @@ Singleton {
|
||||
function updateModel(model, id, prop, value) {
|
||||
for (var i = 0; i < model.count; i++) {
|
||||
if (model.get(i).id === id) {
|
||||
model.setProperty(i, prop, "")
|
||||
model.setProperty(i, prop, value)
|
||||
break
|
||||
}
|
||||
@@ -172,6 +174,7 @@ Singleton {
|
||||
if (activeList.get(i).id === id) {
|
||||
activeList.remove(i)
|
||||
delete activeMap[id]
|
||||
delete progressTimers[id]
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -179,7 +182,7 @@ Singleton {
|
||||
|
||||
// Auto-hide timer
|
||||
Timer {
|
||||
interval: 1000
|
||||
interval: 10
|
||||
repeat: true
|
||||
running: activeList.count > 0
|
||||
onTriggered: {
|
||||
@@ -189,15 +192,22 @@ Singleton {
|
||||
for (var i = activeList.count - 1; i >= 0; i--) {
|
||||
const notif = activeList.get(i)
|
||||
const elapsed = now - notif.timestamp.getTime()
|
||||
const expire = notif.expireTimeout > 0 ? notif.expireTimeout : durations[notif.urgency]
|
||||
|
||||
if (elapsed >= durations[notif.urgency] || elapsed >= 8000) {
|
||||
const progress = Math.max(1.0 - (elapsed / expire), 0.0)
|
||||
updateModel(activeList, notif.id, "progress", progress)
|
||||
|
||||
if (elapsed >= expire) {
|
||||
animateAndRemove(notif.id, i)
|
||||
delete progressTimers[notif.id]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// History management
|
||||
function addToHistory(data) {
|
||||
historyList.insert(0, data)
|
||||
@@ -273,21 +283,23 @@ Singleton {
|
||||
}
|
||||
|
||||
historyList.append({
|
||||
"id": item.id || "",
|
||||
"summary": item.summary || "",
|
||||
"body": item.body || "",
|
||||
"appName": item.appName || "",
|
||||
"urgency": item.urgency || 1,
|
||||
"timestamp": time,
|
||||
"originalImage": item.originalImage || "",
|
||||
"cachedImage": cachedImage
|
||||
})
|
||||
"id": item.id || "",
|
||||
"summary": item.summary || "",
|
||||
"body": item.body || "",
|
||||
"appName": item.appName || "",
|
||||
"urgency": item.urgency || 1,
|
||||
"timestamp": time,
|
||||
"progress": 1.0,
|
||||
"originalImage": item.originalImage || "",
|
||||
"cachedImage": cachedImage
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.error("Notifications", "Load failed:", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Helpers
|
||||
function getAppName(name) {
|
||||
if (!name?.includes("."))
|
||||
|
||||
Reference in New Issue
Block a user