notifications: disableable popups, configurable max popup count
This commit is contained in:
parent
ce62d8f9cd
commit
9358f8fe6e
5 changed files with 28 additions and 4 deletions
|
|
@ -21,7 +21,9 @@ QtObject {
|
||||||
})
|
})
|
||||||
property var notifications: ({
|
property var notifications: ({
|
||||||
enable: true,
|
enable: true,
|
||||||
timeout: 3000
|
timeout: 3000,
|
||||||
|
popups: true,
|
||||||
|
maxPopups: 4
|
||||||
})
|
})
|
||||||
property var mpris: ({
|
property var mpris: ({
|
||||||
enable: true
|
enable: true
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ PanelWindow {
|
||||||
property var _knownIds: ({})
|
property var _knownIds: ({})
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: M.NotifService.popups.slice(0, 4)
|
model: M.NotifService.popups.slice(0, M.Modules.notifications.maxPopups || 4)
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: popupItem
|
id: popupItem
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,15 @@ QtObject {
|
||||||
|
|
||||||
root.list = [data, ...root.list];
|
root.list = [data, ...root.list];
|
||||||
|
|
||||||
|
// Dismiss excess popups (keep in history, just hide popup)
|
||||||
|
const max = M.Modules.notifications.maxPopups || 4;
|
||||||
|
const currentPopups = root.list.filter(n => n.popup && !n.closed);
|
||||||
|
if (currentPopups.length > max) {
|
||||||
|
for (let i = max; i < currentPopups.length; i++)
|
||||||
|
currentPopups[i].popup = false;
|
||||||
|
root._changed();
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-expire popup
|
// Auto-expire popup
|
||||||
if (data.popup) {
|
if (data.popup) {
|
||||||
const timeout = notif.expireTimeout > 0 ? notif.expireTimeout : (M.Modules.notifications.timeout || 3000);
|
const timeout = notif.expireTimeout > 0 ? notif.expireTimeout : (M.Modules.notifications.timeout || 3000);
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,16 @@ in
|
||||||
default = 3000;
|
default = 3000;
|
||||||
description = "Notification popup timeout in milliseconds.";
|
description = "Notification popup timeout in milliseconds.";
|
||||||
};
|
};
|
||||||
|
popups = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "Show notification popups.";
|
||||||
|
};
|
||||||
|
maxPopups = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 4;
|
||||||
|
description = "Maximum number of notification popups shown simultaneously.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
bluetooth = moduleOpt "bluetooth" (intervalOpt 5000);
|
bluetooth = moduleOpt "bluetooth" (intervalOpt 5000);
|
||||||
network = moduleOpt "network" (intervalOpt 5000);
|
network = moduleOpt "network" (intervalOpt 5000);
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,11 @@ ShellRoot {
|
||||||
screen: scope.modelData
|
screen: scope.modelData
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifPopup {
|
LazyLoader {
|
||||||
screen: scope.modelData
|
active: Modules.notifications.popups
|
||||||
|
NotifPopup {
|
||||||
|
screen: scope.modelData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyLoader {
|
LazyLoader {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue