C6: progress bar from hints.value, maxHistory default -1 (unlimited)
This commit is contained in:
parent
3a9cd59243
commit
20cb306ad6
5 changed files with 50 additions and 8 deletions
|
|
@ -24,7 +24,7 @@ QtObject {
|
||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
maxPopups: 4,
|
maxPopups: 4,
|
||||||
maxVisible: 10,
|
maxVisible: 10,
|
||||||
maxHistory: 50
|
maxHistory: -1
|
||||||
})
|
})
|
||||||
property var mpris: ({
|
property var mpris: ({
|
||||||
enable: true
|
enable: true
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,25 @@ M.PopupPanel {
|
||||||
visible: text !== ""
|
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
|
// Actions
|
||||||
Row {
|
Row {
|
||||||
spacing: 4
|
spacing: 4
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,28 @@ PanelWindow {
|
||||||
visible: text !== ""
|
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
|
// Actions
|
||||||
Row {
|
Row {
|
||||||
spacing: 6
|
spacing: 6
|
||||||
|
|
|
||||||
|
|
@ -108,9 +108,9 @@ QtObject {
|
||||||
item._expireTimer.running = true;
|
item._expireTimer.running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trim history
|
// Trim history (-1 = unlimited)
|
||||||
const maxHistory = M.Modules.notifications.maxHistory || 50;
|
const maxHistory = M.Modules.notifications.maxHistory ?? -1;
|
||||||
while (root.list.length > maxHistory) {
|
while (maxHistory > 0 && root.list.length > maxHistory) {
|
||||||
const old = root.list.pop();
|
const old = root.list.pop();
|
||||||
old.finishDismiss();
|
old.finishDismiss();
|
||||||
delete root._byId[old.id];
|
delete root._byId[old.id];
|
||||||
|
|
@ -146,8 +146,9 @@ QtObject {
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(text());
|
const data = JSON.parse(text());
|
||||||
const maxHistory = M.Modules.notifications.maxHistory || 50;
|
const maxHistory = M.Modules.notifications.maxHistory ?? -1;
|
||||||
for (let i = 0; i < Math.min(data.length, maxHistory); i++) {
|
const limit = maxHistory > 0 ? Math.min(data.length, maxHistory) : data.length;
|
||||||
|
for (let i = 0; i < limit; i++) {
|
||||||
const n = data[i];
|
const n = data[i];
|
||||||
const item = _itemComp.createObject(root, {
|
const item = _itemComp.createObject(root, {
|
||||||
id: "p_" + (n.id ?? i) + "_" + n.time,
|
id: "p_" + (n.id ?? i) + "_" + n.time,
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,8 @@ in
|
||||||
};
|
};
|
||||||
maxHistory = lib.mkOption {
|
maxHistory = lib.mkOption {
|
||||||
type = lib.types.int;
|
type = lib.types.int;
|
||||||
default = 50;
|
default = -1;
|
||||||
description = "Maximum notifications kept in history.";
|
description = "Maximum notifications kept in history (-1 for unlimited).";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
bluetooth = moduleOpt "bluetooth" (intervalOpt 5000);
|
bluetooth = moduleOpt "bluetooth" (intervalOpt 5000);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue