From 20cb306ad68a9193a11ff24b6070f8b7a177a2fa Mon Sep 17 00:00:00 2001 From: Damocles Date: Mon, 13 Apr 2026 17:01:04 +0200 Subject: [PATCH] C6: progress bar from hints.value, maxHistory default -1 (unlimited) --- modules/Modules.qml | 2 +- modules/NotifCenter.qml | 19 +++++++++++++++++++ modules/NotifPopup.qml | 22 ++++++++++++++++++++++ modules/NotifService.qml | 11 ++++++----- nix/hm-module.nix | 4 ++-- 5 files changed, 50 insertions(+), 8 deletions(-) diff --git a/modules/Modules.qml b/modules/Modules.qml index 2d0e128..efa1898 100644 --- a/modules/Modules.qml +++ b/modules/Modules.qml @@ -24,7 +24,7 @@ QtObject { timeout: 3000, maxPopups: 4, maxVisible: 10, - maxHistory: 50 + maxHistory: -1 }) property var mpris: ({ enable: true diff --git a/modules/NotifCenter.qml b/modules/NotifCenter.qml index 8a9045b..2c0bf61 100644 --- a/modules/NotifCenter.qml +++ b/modules/NotifCenter.qml @@ -300,6 +300,25 @@ M.PopupPanel { visible: text !== "" } + // Progress bar (hints.value) + Item { + width: parent.width + height: 3 + visible: (notifItem.modelData.hints?.value ?? -1) >= 0 + + Rectangle { + anchors.fill: parent + color: M.Theme.base02 + radius: 1 + } + Rectangle { + width: parent.width * Math.min(1, Math.max(0, (notifItem.modelData.hints?.value ?? 0) / 100)) + height: parent.height + radius: 1 + color: M.Theme.base0D + } + } + // Actions Row { spacing: 4 diff --git a/modules/NotifPopup.qml b/modules/NotifPopup.qml index d88f55c..356c370 100644 --- a/modules/NotifPopup.qml +++ b/modules/NotifPopup.qml @@ -213,6 +213,28 @@ PanelWindow { visible: text !== "" } + // Progress bar (hints.value) + Item { + width: parent.width + height: 4 + visible: (popupItem.modelData.hints?.value ?? -1) >= 0 + + Rectangle { + anchors.fill: parent + color: M.Theme.base02 + radius: 2 + } + Rectangle { + width: parent.width * Math.min(1, Math.max(0, (popupItem.modelData.hints?.value ?? 0) / 100)) + height: parent.height + radius: 2 + color: { + const u = popupItem.modelData.urgency; + return u === NotificationUrgency.Critical ? M.Theme.base08 : M.Theme.base0D; + } + } + } + // Actions Row { spacing: 6 diff --git a/modules/NotifService.qml b/modules/NotifService.qml index 6f57f45..b266f94 100644 --- a/modules/NotifService.qml +++ b/modules/NotifService.qml @@ -108,9 +108,9 @@ QtObject { item._expireTimer.running = true; } - // Trim history - const maxHistory = M.Modules.notifications.maxHistory || 50; - while (root.list.length > maxHistory) { + // Trim history (-1 = unlimited) + const maxHistory = M.Modules.notifications.maxHistory ?? -1; + while (maxHistory > 0 && root.list.length > maxHistory) { const old = root.list.pop(); old.finishDismiss(); delete root._byId[old.id]; @@ -146,8 +146,9 @@ QtObject { onLoaded: { try { const data = JSON.parse(text()); - const maxHistory = M.Modules.notifications.maxHistory || 50; - for (let i = 0; i < Math.min(data.length, maxHistory); i++) { + const maxHistory = M.Modules.notifications.maxHistory ?? -1; + const limit = maxHistory > 0 ? Math.min(data.length, maxHistory) : data.length; + for (let i = 0; i < limit; i++) { const n = data[i]; const item = _itemComp.createObject(root, { id: "p_" + (n.id ?? i) + "_" + n.time, diff --git a/nix/hm-module.nix b/nix/hm-module.nix index 50cd295..93ec3ce 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -110,8 +110,8 @@ in }; maxHistory = lib.mkOption { type = lib.types.int; - default = 50; - description = "Maximum notifications kept in history."; + default = -1; + description = "Maximum notifications kept in history (-1 for unlimited)."; }; }; bluetooth = moduleOpt "bluetooth" (intervalOpt 5000);