The bar-null-shell-null-typeof-function ternary guarded against our own shell missing a method it always defines. bar?.shell?.firstPartyServiceFor() handles the only real case, delayed bar injection, in one line. The typeof checks that probe genuinely third-party plugin objects stay. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
23 lines
581 B
QML
23 lines
581 B
QML
import QtQuick
|
|
import qs.Commons
|
|
import qs.Ui
|
|
|
|
BarIndicator {
|
|
id: root
|
|
|
|
readonly property var notificationService: bar?.shell?.firstPartyServiceFor("omarchy.notifications")
|
|
readonly property bool dnd: notificationService ? notificationService.doNotDisturb : false
|
|
|
|
active: dnd
|
|
activeText: ""
|
|
inactiveText: ""
|
|
activeTooltipText: "Allow Notifications"
|
|
inactiveTooltipText: "Silence Notifications"
|
|
|
|
onPressed: function() {
|
|
if (root.notificationService) {
|
|
root.notificationService.setDoNotDisturb(!root.notificationService.doNotDisturb)
|
|
}
|
|
}
|
|
}
|