Horizontal media widget #16
+13
-6
@@ -205,6 +205,7 @@ Singleton {
|
|||||||
return {
|
return {
|
||||||
expire: notifs.expire,
|
expire: notifs.expire,
|
||||||
defaultExpireTimeout: notifs.defaultExpireTimeout,
|
defaultExpireTimeout: notifs.defaultExpireTimeout,
|
||||||
|
appNotifCooldown: notifs.appNotifCooldown,
|
||||||
clearThreshold: notifs.clearThreshold,
|
clearThreshold: notifs.clearThreshold,
|
||||||
expandThreshold: notifs.expandThreshold,
|
expandThreshold: notifs.expandThreshold,
|
||||||
actionOnClick: notifs.actionOnClick,
|
actionOnClick: notifs.actionOnClick,
|
||||||
@@ -306,7 +307,8 @@ Singleton {
|
|||||||
|
|
||||||
fileView.setText(JSON.stringify(config, null, 4));
|
fileView.setText(JSON.stringify(config, null, 4));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toaster.toast(qsTr("Failed to serialize config"), e.message, "settings_alert", Toast.Error);
|
Toaster.toast(qsTr("Failed to serialize config"), e.message,
|
||||||
|
"settings_alert", Toast.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -337,7 +339,8 @@ Singleton {
|
|||||||
}
|
}
|
||||||
onLoadFailed: err => {
|
onLoadFailed: err => {
|
||||||
if (err !== FileViewError.FileNotFound)
|
if (err !== FileViewError.FileNotFound)
|
||||||
Toaster.toast(qsTr("Failed to read config"), FileViewError.toString(err), "settings_alert", Toast.Warning);
|
Toaster.toast(qsTr("Failed to read config"), FileViewError.toString(err),
|
||||||
|
"settings_alert", Toast.Warning);
|
||||||
}
|
}
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
ModeScheduler.checkStartup();
|
ModeScheduler.checkStartup();
|
||||||
@@ -346,15 +349,19 @@ Singleton {
|
|||||||
const elapsed = timer.elapsedMs();
|
const elapsed = timer.elapsedMs();
|
||||||
|
|
||||||
if (adapter.utilities.toasts.configLoaded && !root.recentlySaved) {
|
if (adapter.utilities.toasts.configLoaded && !root.recentlySaved) {
|
||||||
Toaster.toast(qsTr("Config loaded"), qsTr("Config loaded in %1ms").arg(elapsed), "rule_settings");
|
Toaster.toast(qsTr("Config loaded"), qsTr("Config loaded in %1ms").arg(
|
||||||
|
elapsed), "rule_settings");
|
||||||
} else if (adapter.utilities.toasts.configLoaded && root.recentlySaved) {
|
} else if (adapter.utilities.toasts.configLoaded && root.recentlySaved) {
|
||||||
Toaster.toast(qsTr("Config saved"), qsTr("Config reloaded in %1ms").arg(elapsed), "settings_alert");
|
Toaster.toast(qsTr("Config saved"), qsTr("Config reloaded in %1ms").arg(
|
||||||
|
elapsed), "settings_alert");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toaster.toast(qsTr("Failed to load config"), e.message, "settings_alert", Toast.Error);
|
Toaster.toast(qsTr("Failed to load config"), e.message, "settings_alert",
|
||||||
|
Toast.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onSaveFailed: err => Toaster.toast(qsTr("Failed to save config"), FileViewError.toString(err), "settings_alert", Toast.Error)
|
onSaveFailed: err => Toaster.toast(qsTr("Failed to save config"),
|
||||||
|
FileViewError.toString(err), "settings_alert", Toast.Error)
|
||||||
|
|
||||||
JsonAdapter {
|
JsonAdapter {
|
||||||
id: adapter
|
id: adapter
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Quickshell.Io
|
|||||||
|
|
||||||
JsonObject {
|
JsonObject {
|
||||||
property bool actionOnClick: false
|
property bool actionOnClick: false
|
||||||
|
property int appNotifCooldown: 0
|
||||||
property real clearThreshold: 0.3
|
property real clearThreshold: 0.3
|
||||||
property int defaultExpireTimeout: 5000
|
property int defaultExpireTimeout: 5000
|
||||||
property int expandThreshold: 20
|
property int expandThreshold: 20
|
||||||
|
|||||||
+26
-1
@@ -23,6 +23,29 @@ Singleton {
|
|||||||
readonly property list<Notif> popups: list.filter(n => n.popup)
|
readonly property list<Notif> popups: list.filter(n => n.popup)
|
||||||
property alias server: server
|
property alias server: server
|
||||||
|
|
||||||
|
readonly property var appCooldownMap: new Map()
|
||||||
|
|
||||||
|
function shouldThrottle(appName: string): bool {
|
||||||
|
if ( props.dnd )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const key = ( appName || "unknown" ).trim().toLowerCase();
|
||||||
|
const cooldownSec = Config.notifs.appNotifCooldown;
|
||||||
|
const cooldownMs = Math.max(0, cooldownSec * 1000);
|
||||||
|
|
||||||
|
if ( cooldownMs <= 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
|
const until = appCooldownMap.get( key ) ?? 0;
|
||||||
|
|
||||||
|
if ( now < until )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
appCooldownMap.set( key, now + cooldownMs )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
onListChanged: {
|
onListChanged: {
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
saveTimer.restart();
|
saveTimer.restart();
|
||||||
@@ -77,8 +100,10 @@ Singleton {
|
|||||||
onNotification: notif => {
|
onNotification: notif => {
|
||||||
notif.tracked = true;
|
notif.tracked = true;
|
||||||
|
|
||||||
|
const is_popup = root.shouldThrottle(notif.appName);
|
||||||
|
|
||||||
const comp = notifComp.createObject(root, {
|
const comp = notifComp.createObject(root, {
|
||||||
popup: !props.dnd,
|
popup: is_popup,
|
||||||
notification: notif
|
notification: notif
|
||||||
});
|
});
|
||||||
root.list = [comp, ...root.list];
|
root.list = [comp, ...root.list];
|
||||||
|
|||||||
Reference in New Issue
Block a user