Something went wrong. Try again.
my over complex system configurations
Something went wrong. Try again.
6.7 kB · 191 lines
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192import QtQuickimport QtQuick.Layoutsimport Quickshellimport Quickshell.Widgetsimport Quickshell.Waylandimport Quickshell.Services.Notifications as QsNotificationsimport qs.data
Clickable { id: root
// a Quickshell Notification, or one of the shell's own from Notifications.notify required property var notification property bool elevated: false readonly property bool critical: notification?.urgency === QsNotifications.NotificationUrgency.Critical readonly property bool replyFocused: replyField.input.activeFocus readonly property bool cardHovered: hover.hovered
signal dismissed() signal replied() signal actionInvoked()
implicitHeight: column.implicitHeight + 24 radius: elevated ? Theme.sheetRadius : Theme.radiusMd color: elevated ? "transparent" : Theme.colors.surface border.color: critical ? Theme.colors.error : Theme.colors.border border.width: elevated && !critical ? 0 : 1
readonly property var defaultAction: notification?.actions.find(a => a.identifier === "default") ?? null readonly property var extraActions: (notification?.actions ?? []) .filter(a => a.identifier !== "default" && a.text !== "") .map(a => ({ kind: "action", text: a.text, action: a })) // clicking the card already views it, so the chip is only worth showing beside other actions readonly property var chips: extraActions.length > 0 ? [{ kind: "view", text: defaultAction?.text || "View" }, ...extraActions] : []
// as a toast it floats like the other popups CardSurface { visible: root.elevated; radius: root.radius; raised: true; z: -1 }
HoverHandler { id: hover }
onClicked: view()
function view(): void { const n = notification; if (!n) return; defaultAction?.invoke(); const entry = DesktopEntries.heuristicLookup(n.desktopEntry || n.appName); const ids = [n.desktopEntry, n.appName, entry?.id, entry?.startupClass].filter(s => s).map(s => s.toLowerCase()); ToplevelManager.toplevels.values.find(t => ids.includes(t.appId.toLowerCase()))?.activate(); Surfaces.closePopups(); n.dismiss(); root.actionInvoked(); }
function sendReply(): void { if (replyField.text.length === 0) return; notification.sendInlineReply(replyField.text); replyField.text = ""; root.replied(); }
ColumnLayout { id: column anchors { left: parent.left; right: parent.right; top: parent.top; margins: 12 } spacing: 10
RowLayout { Layout.fillWidth: true spacing: 12
ClippingWrapperRectangle { Layout.alignment: Qt.AlignTop implicitWidth: 36 implicitHeight: 36 radius: Theme.radiusSm color: "transparent"
Item { implicitWidth: 36 implicitHeight: 36
Image { id: image anchors.fill: parent source: root.notification?.image ?? "" sourceSize: Qt.size(72, 72) fillMode: Image.PreserveAspectCrop visible: status === Image.Ready asynchronous: true }
IconImage { asynchronous: true anchors.centerIn: parent visible: !image.visible implicitSize: 22 source: Quickshell.iconPath(Utils.getIcon(root.notification?.appIcon ?? ""), "application-x-executable") } } }
ColumnLayout { Layout.fillWidth: true spacing: 2
StyledText { Layout.fillWidth: true text: Utils.appName(root.notification?.appName ?? "") color: root.critical ? Theme.colors.error : Theme.colors.textMuted font.pixelSize: 11 font.weight: Font.Medium }
StyledText { Layout.fillWidth: true text: root.notification?.summary ?? "" font.pixelSize: 13 font.weight: Font.DemiBold visible: text !== "" }
StyledText { Layout.fillWidth: true text: root.notification?.body ?? "" color: Theme.colors.textMuted font.pixelSize: 12 textFormat: Text.PlainText wrapMode: Text.WordWrap maximumLineCount: 3 visible: text !== "" } }
IconButton { Layout.alignment: Qt.AlignTop icon: "window-close-symbolic" size: 12 color: Theme.colors.textMuted opacity: hover.hovered || root.elevated ? 1 : 0 Behavior on opacity { Anim { duration: Theme.animFast } } onClicked: { root.notification?.dismiss(); root.dismissed(); } } }
Flow { visible: root.chips.length > 0 Layout.fillWidth: true spacing: 6
Repeater { model: root.chips
BoxButton { required property var modelData implicitHeight: 28 fontSize: 11 text: modelData.text filled: modelData.kind === "view" onClicked: { if (modelData.kind === "view") return root.view(); modelData.action.invoke(); root.actionInvoked(); } } } }
InputField { id: replyField Layout.fillWidth: true visible: root.notification?.hasInlineReply ?? false implicitHeight: 34 fontSize: 12 placeholder: root.notification?.inlineReplyPlaceholder || "Reply…" onAccepted: root.sendReply()
IconButton { icon: "mail-send-symbolic" size: 13 color: replyField.text.length > 0 ? Theme.colors.accent : Theme.colors.textSubtle onClicked: root.sendReply() } } }}