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:
29
quickshell/Modules/ControlCenter/Widgets/DndPill.qml
Normal file
29
quickshell/Modules/ControlCenter/Widgets/DndPill.qml
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user