1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-17 19:22:04 -04:00

notifications: add configurable durations for do not disturb

fixes #1481
This commit is contained in:
bbedward
2026-04-16 16:51:05 -04:00
parent c6e8067a22
commit 7ced91ede1
18 changed files with 868 additions and 40 deletions

View File

@@ -0,0 +1,29 @@
import QtQuick
import qs.Common
import qs.Modules.ControlCenter.Widgets
CompoundPill {
id: root
iconName: SessionData.doNotDisturb ? "do_not_disturb_on" : "do_not_disturb_off"
iconColor: SessionData.doNotDisturb ? Theme.primary : Theme.surfaceText
primaryText: I18n.tr("Do Not Disturb")
isActive: SessionData.doNotDisturb
secondaryText: {
if (!SessionData.doNotDisturb)
return I18n.tr("Off");
if (SessionData.doNotDisturbUntil <= 0)
return I18n.tr("On");
const d = new Date(SessionData.doNotDisturbUntil);
const use24h = (typeof SettingsData !== "undefined") ? SettingsData.use24HourClock : true;
const pad = n => n < 10 ? "0" + n : "" + n;
if (use24h)
return I18n.tr("Until %1").arg(pad(d.getHours()) + ":" + pad(d.getMinutes()));
const suffix = d.getHours() >= 12 ? "PM" : "AM";
const h12 = ((d.getHours() + 11) % 12) + 1;
return I18n.tr("Until %1").arg(h12 + ":" + pad(d.getMinutes()) + " " + suffix);
}
onToggled: SessionData.setDoNotDisturb(!SessionData.doNotDisturb)
}