Show notifications by widening the notch in notch mode

The collapsed notch grows sideways for a new notification: the clock and
media stay at the left end and the banner fills the right, in the notch's
own fill. Left click runs the default action, right click moves it to the
notch's list, hover holds it. The drop-down banners stay off in notch mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-11-14 13:51:13 +01:00
1 parent ea8fc29544
commit f65c475455
2 files changed
+186 -5

No files matched your search

+183 -3
View File
@@ -9,12 +9,28 @@ import "../theme"
// The collapsed notch: a glass island hanging from the screen's top edge with
// concave ears, showing the time, plus cover art and a small visualizer while
// audio plays. Clicking it opens the notch panel.
// audio plays. Clicking it opens the notch panel. A new notification widens
// it: the clock and media keep the left end, the banner takes the right.
Item {
id: root
property var barScreen
readonly property real bodyWidth: ShellState.notchPillWidth
readonly property bool playing: MediaService.playing
// Newest banner, shown on the screen that was active when it arrived.
readonly property var latest: ShellState.notchMode && !ShellState.notchOpen && NotificationService.active ? NotificationService.popups[0] || null : null
property bool owner: false
property bool hadLatest: false
onLatestChanged: {
if (latest && !hadLatest)
owner = ScreenService.active === barScreen;
hadLatest = !!latest;
if (latest)
notice = latest;
}
readonly property bool showing: !!latest && owner && visible
// Holds the last banner while the notch closes around it.
property var notice: null
readonly property int noticeWidth: 340
readonly property real bodyWidth: ShellState.notchPillWidth + (showing ? noticeWidth : 0)
implicitWidth: bodyWidth + 2 * BarDrawers.ear
implicitHeight: BarDrawers.bottom
Behavior on implicitWidth {
@@ -40,9 +56,16 @@ Item {
radius: Math.min(Theme.radius, root.height / 2)
fillColor: Theme.notchFill
}
// The pill's own width at the left end; its contents stay centred there.
Item {
id: lead
x: BarDrawers.ear
width: ShellState.notchPillWidth
height: root.height
}
Row {
id: content
anchors.centerIn: parent
anchors.centerIn: lead
spacing: 10
ClippingRectangle {
visible: root.playing
@@ -109,4 +132,161 @@ Item {
AudioService.volume(false, audio.volume + (wheel.angleDelta.y > 0 ? 1 : -1) * step / 100);
}
}
Item {
id: banner
objectName: "notchNotice"
x: lead.x + lead.width
width: Math.max(0, root.width - BarDrawers.ear - x)
height: root.height
clip: true
visible: width > 1
opacity: root.showing ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: root.showing ? Theme.notchDuration * 1.6 : Theme.notchDuration * 0.6
easing.type: Easing.OutCubic
}
}
readonly property var n: root.notice
readonly property int more: Math.max(0, NotificationService.popups.length - 1)
Accessible.role: Accessible.Button
Accessible.name: n ? NotificationService.appLabel(n) + ": " + n.summary : ""
HoverHandler {
id: bannerHover
}
Rectangle {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
width: 1
height: parent.height * 0.5
color: Theme.hairline
}
// Laid out at full width so text does not reflow while the notch grows.
Row {
x: 14
width: root.noticeWidth - 26
anchors.verticalCenter: parent.verticalCenter
spacing: 10
Rectangle {
id: badge
anchors.verticalCenter: parent.verticalCenter
width: 30
height: 30
radius: 8
color: noticeIcon.status === Image.Ready ? Theme.transparent : Theme.surfaceVariant
border.width: banner.n && NotificationService.critical(banner.n) ? 1.5 : 0
border.color: Theme.urgent
Text {
anchors.centerIn: parent
visible: noticeIcon.status !== Image.Ready
text: Icons.available ? "󰂚" : "!"
font.family: Icons.available ? Icons.family : ""
color: Theme.text
font.pixelSize: 15
}
Image {
id: noticeIcon
anchors.fill: parent
source: banner.n ? NotificationService.iconFor(banner.n) || NotificationService.imageFor(banner.n) : ""
sourceSize: Qt.size(60, 60)
fillMode: Image.PreserveAspectFit
asynchronous: true
smooth: true
mipmap: true
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
width: parent.width - badge.width - parent.spacing - (count.visible ? count.width + parent.spacing : 0)
spacing: 1
Text {
objectName: "notchNoticeSummary"
width: parent.width
text: banner.n ? banner.n.summary || NotificationService.appLabel(banner.n) : ""
color: Theme.text
font.pixelSize: 13
font.weight: Font.DemiBold
elide: Text.ElideRight
maximumLineCount: 1
}
Text {
width: parent.width
visible: text !== ""
// Bodies may carry markup and line breaks; one plain line fits here.
text: banner.n ? (banner.n.body || NotificationService.appLabel(banner.n)).replace(/<[^>]*>/g, "").replace(/\s+/g, " ").trim() : ""
color: Theme.textSecondary
font.pixelSize: 12
elide: Text.ElideRight
maximumLineCount: 1
textFormat: Text.PlainText
}
}
Rectangle {
id: count
anchors.verticalCenter: parent.verticalCenter
visible: banner.more > 0
width: Math.max(22, moreText.implicitWidth + 12)
height: 20
radius: 10
color: Theme.surfaceVariant
Text {
id: moreText
anchors.centerIn: parent
text: "+" + banner.more
color: Theme.textSecondary
font.pixelSize: 11
font.weight: Font.Medium
}
}
}
// Left click runs the default action; right or middle click sends it to
// the notch's list.
MouseArea {
anchors.fill: parent
enabled: root.showing
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
onClicked: mouse => {
if (mouse.button === Qt.LeftButton)
NotificationService.activate(banner.n);
else
NotificationService.hidePopup(banner.n);
}
}
}
// 0 (critical) stays until dismissed. Each banner's time counts from its
// arrival, so older ones revealed by an expiry leave on schedule; hovering
// restarts the full time.
readonly property int lifetime: notice ? NotificationService.timeoutFor(notice) : 0
property int budget: 1
function arm(full) {
if (!showing || lifetime <= 0 || bannerHover.hovered)
return;
const at = NotificationService.times[notice.id];
budget = Math.max(400, full || at === undefined ? lifetime : lifetime - (Date.now() - at));
life.restart();
}
Timer {
id: life
interval: root.budget
running: root.showing && root.lifetime > 0 && !bannerHover.hovered
onTriggered: if (root.showing)
NotificationService.hidePopup(root.notice)
}
onNoticeChanged: arm(false)
onShowingChanged: arm(false)
Connections {
target: bannerHover
function onHoveredChanged() {
if (!bannerHover.hovered)
root.arm(true);
}
}
Connections {
target: NotificationService
function onPopupShown(n) {
if (n === root.notice)
root.arm(true);
}
}
}