sidebar/notifs: add link support

This commit is contained in:
2 * r + 2 * t 2025-09-21 14:24:35 +10:00
parent f9da00e6fb
commit 9523fdf0eb
6 changed files with 22 additions and 1 deletions

View file

@ -25,6 +25,7 @@ Item {
NotifDock { NotifDock {
props: root.props props: root.props
visibilities: root.visibilities
} }
} }

View file

@ -3,6 +3,7 @@ pragma ComponentBehavior: Bound
import qs.components import qs.components
import qs.services import qs.services
import qs.config import qs.config
import Quickshell
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
@ -12,7 +13,9 @@ StyledRect {
required property Notifs.Notif modelData required property Notifs.Notif modelData
required property Props props required property Props props
required property bool expanded required property bool expanded
required property var visibilities
readonly property StyledText body: expandedContent.item?.body ?? null
readonly property real nonAnimHeight: expanded ? summary.implicitHeight + expandedContent.implicitHeight + expandedContent.anchors.topMargin + Appearance.padding.normal * 2 : summaryHeightMetrics.height readonly property real nonAnimHeight: expanded ? summary.implicitHeight + expandedContent.implicitHeight + expandedContent.anchors.topMargin + Appearance.padding.normal * 2 : summaryHeightMetrics.height
implicitHeight: nonAnimHeight implicitHeight: nonAnimHeight
@ -116,14 +119,23 @@ StyledRect {
anchors.topMargin: Appearance.spacing.small / 2 anchors.topMargin: Appearance.spacing.small / 2
sourceComponent: ColumnLayout { sourceComponent: ColumnLayout {
readonly property alias body: body
spacing: Appearance.spacing.smaller spacing: Appearance.spacing.smaller
StyledText { StyledText {
id: body
Layout.fillWidth: true Layout.fillWidth: true
textFormat: Text.MarkdownText textFormat: Text.MarkdownText
text: root.modelData.body.replace(/(.)\n(?!\n)/g, "$1\n\n") || qsTr("No body here! :/") text: root.modelData.body.replace(/(.)\n(?!\n)/g, "$1\n\n") || qsTr("No body here! :/")
color: root.modelData.urgency === "critical" ? Colours.palette.m3secondary : Colours.palette.m3outline color: root.modelData.urgency === "critical" ? Colours.palette.m3secondary : Colours.palette.m3outline
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
onLinkActivated: link => {
Quickshell.execDetached(["app2unit", "-O", "--", link]);
root.visibilities.sidebar = false;
}
} }
NotifActionList { NotifActionList {

View file

@ -15,6 +15,7 @@ Item {
id: root id: root
required property Props props required property Props props
required property var visibilities
readonly property int notifCount: Notifs.list.reduce((acc, n) => n.closed ? acc : acc + 1, 0) readonly property int notifCount: Notifs.list.reduce((acc, n) => n.closed ? acc : acc + 1, 0)
anchors.fill: parent anchors.fill: parent
@ -140,6 +141,7 @@ Item {
id: notifList id: notifList
props: root.props props: root.props
visibilities: root.visibilities
container: view container: view
} }
} }

View file

@ -11,6 +11,7 @@ Item {
required property Props props required property Props props
required property Flickable container required property Flickable container
required property var visibilities
readonly property alias repeater: repeater readonly property alias repeater: repeater
readonly property int spacing: Appearance.spacing.small readonly property int spacing: Appearance.spacing.small
@ -145,6 +146,7 @@ Item {
modelData: notif.modelData modelData: notif.modelData
props: root.props props: root.props
container: root.container container: root.container
visibilities: root.visibilities
} }
Behavior on x { Behavior on x {

View file

@ -16,6 +16,7 @@ StyledRect {
required property string modelData required property string modelData
required property Props props required property Props props
required property Flickable container required property Flickable container
required property var visibilities
readonly property list<var> notifs: Notifs.list.filter(n => n.appName === modelData) readonly property list<var> notifs: Notifs.list.filter(n => n.appName === modelData)
readonly property int notifCount: notifs.reduce((acc, n) => n.closed ? acc : acc + 1, 0) readonly property int notifCount: notifs.reduce((acc, n) => n.closed ? acc : acc + 1, 0)
@ -234,6 +235,7 @@ StyledRect {
notifs: root.notifs notifs: root.notifs
expanded: root.expanded expanded: root.expanded
container: root.container container: root.container
visibilities: root.visibilities
onRequestToggleExpand: expand => root.toggleExpand(expand) onRequestToggleExpand: expand => root.toggleExpand(expand)
} }
} }

View file

@ -14,6 +14,7 @@ Item {
required property list<var> notifs required property list<var> notifs
required property bool expanded required property bool expanded
required property Flickable container required property Flickable container
required property var visibilities
readonly property real nonAnimHeight: { readonly property real nonAnimHeight: {
let h = -root.spacing; let h = -root.spacing;
@ -104,7 +105,7 @@ Item {
implicitHeight: notifInner.implicitHeight implicitHeight: notifInner.implicitHeight
hoverEnabled: true hoverEnabled: true
cursorShape: pressed ? Qt.ClosedHandCursor : undefined cursorShape: notifInner.body?.hoveredLink ? Qt.PointingHandCursor : pressed ? Qt.ClosedHandCursor : undefined
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
preventStealing: !root.expanded preventStealing: !root.expanded
enabled: !modelData.closed enabled: !modelData.closed
@ -176,6 +177,7 @@ Item {
modelData: notif.modelData modelData: notif.modelData
props: root.props props: root.props
expanded: root.expanded expanded: root.expanded
visibilities: root.visibilities
} }
Behavior on opacity { Behavior on opacity {