quickshell: wrap notifications in a card to match the other panes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-06-11 14:40:54 +01:00
parent 583b0588c2
commit d24a51b0af

View file

@ -2089,143 +2089,154 @@ in
}
}
// Notifications header
Item {
// Notifications card
Rectangle {
width: parent.width
height: 20
height: notifCardCol.height + 16
radius: 8
color: Theme.base01
Text {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
text: "Notifications"
color: Theme.base05
font.family: Theme.fontFamily
font.pixelSize: 13
font.weight: Font.Medium
}
Text {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: bar.notifServer.trackedNotifications.values.length > 0 ? "Clear all" : ""
color: Theme.base04
font.family: Theme.fontFamily
font.pixelSize: 11
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
let notifs = bar.notifServer.trackedNotifications.values;
for (let i = notifs.length - 1; i >= 0; i--) {
notifs[i].dismiss();
}
}
}
}
}
Column {
spacing: 4
width: parent.width
Text {
visible: bar.notifServer.trackedNotifications.values.length === 0
text: "No notifications"
color: Theme.base03
font.family: Theme.fontFamily
font.pixelSize: 11
Column {
id: notifCardCol
anchors.top: parent.top
anchors.topMargin: 8
anchors.horizontalCenter: parent.horizontalCenter
}
width: parent.width - 16
spacing: 6
Repeater {
model: bar.notifServer.trackedNotifications
Item {
width: parent.width
height: 20
Rectangle {
id: notifItem
required property var modelData
width: calRightCol.width
height: notifCol.height + 12
radius: 6
color: Theme.base01
Column {
id: notifCol
Text {
anchors.left: parent.left
anchors.right: dismissBtn.left
anchors.top: parent.top
anchors.margins: 6
spacing: 2
anchors.verticalCenter: parent.verticalCenter
text: "Notifications"
color: Theme.base05
font.family: Theme.fontFamily
font.pixelSize: 13
font.weight: Font.Medium
}
Text {
width: parent.width
text: notifItem.modelData.summary || notifItem.modelData.appName
color: Theme.base05
font.family: Theme.fontFamily
font.pixelSize: 11
font.weight: Font.Medium
elide: Text.ElideRight
}
Text {
width: parent.width
text: notifItem.modelData.body || ""
color: Theme.base04
font.family: Theme.fontFamily
font.pixelSize: 10
elide: Text.ElideRight
maximumLineCount: 2
wrapMode: Text.Wrap
visible: text !== ""
}
Row {
spacing: 4
visible: notifItem.modelData.actions.length > 0
Repeater {
model: notifItem.modelData.actions
Rectangle {
required property var modelData
width: actionText.width + 12
height: actionText.height + 4
radius: 4
color: actionMa.containsMouse ? Theme.base02 : Theme.base01
border.width: 1
border.color: Theme.base02
Text {
id: actionText
anchors.centerIn: parent
text: modelData.text
color: Theme.base05
font.family: Theme.fontFamily
font.pixelSize: 10
}
MouseArea {
id: actionMa
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: modelData.invoke()
}
Text {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: bar.notifServer.trackedNotifications.values.length > 0 ? "Clear all" : ""
color: Theme.base04
font.family: Theme.fontFamily
font.pixelSize: 11
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
let notifs = bar.notifServer.trackedNotifications.values;
for (let i = notifs.length - 1; i >= 0; i--) {
notifs[i].dismiss();
}
}
}
}
}
Text {
id: dismissBtn
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 6
text: "\u{f0156}"
color: dismissMa.containsMouse ? Theme.base05 : Theme.base03
font.family: Theme.fontFamily
font.pixelSize: 12
MouseArea {
id: dismissMa
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: notifItem.modelData.dismiss()
Text {
visible: bar.notifServer.trackedNotifications.values.length === 0
text: "No notifications"
color: Theme.base03
font.family: Theme.fontFamily
font.pixelSize: 11
anchors.horizontalCenter: parent.horizontalCenter
}
Repeater {
model: bar.notifServer.trackedNotifications
Rectangle {
id: notifItem
required property var modelData
width: notifCardCol.width
height: notifCol.height + 12
radius: 6
color: Theme.base02
Column {
id: notifCol
anchors.left: parent.left
anchors.right: dismissBtn.left
anchors.top: parent.top
anchors.margins: 6
spacing: 2
Text {
width: parent.width
text: notifItem.modelData.summary || notifItem.modelData.appName
color: Theme.base05
font.family: Theme.fontFamily
font.pixelSize: 11
font.weight: Font.Medium
elide: Text.ElideRight
}
Text {
width: parent.width
text: notifItem.modelData.body || ""
color: Theme.base04
font.family: Theme.fontFamily
font.pixelSize: 10
elide: Text.ElideRight
maximumLineCount: 2
wrapMode: Text.Wrap
visible: text !== ""
}
Row {
spacing: 4
visible: notifItem.modelData.actions.length > 0
Repeater {
model: notifItem.modelData.actions
Rectangle {
required property var modelData
width: actionText.width + 12
height: actionText.height + 4
radius: 4
color: actionMa.containsMouse ? Theme.base03 : Theme.base02
border.width: 1
border.color: Theme.base03
Text {
id: actionText
anchors.centerIn: parent
text: modelData.text
color: Theme.base05
font.family: Theme.fontFamily
font.pixelSize: 10
}
MouseArea {
id: actionMa
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: modelData.invoke()
}
}
}
}
}
Text {
id: dismissBtn
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 6
text: "\u{f0156}"
color: dismissMa.containsMouse ? Theme.base05 : Theme.base03
font.family: Theme.fontFamily
font.pixelSize: 12
MouseArea {
id: dismissMa
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: notifItem.modelData.dismiss()
}
}
}
}