The launcher's contents (search, results, app grid, commands, clipboard history and emoji) move into LauncherView, which the launcher window hosts normally and the notch hosts in notch mode. In the notch it is one more face of the same shape: the search sits in the band beside the clock, sized to the band so it never clips, and the notch springs wider and then down to fit whatever is below (springs as on pocket-dots, scaled by the notch speed settings). The bar window grows tall only while it is open, with input still masked to the shapes. The separate window, the hand-over between them and the compact search are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
308 lines
12 KiB
QML
308 lines
12 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import "../components"
|
|
import "../core"
|
|
import "../launcher"
|
|
import "../services"
|
|
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. A new notification widens
|
|
// it: the clock and media keep the left end, the banner takes the right. The
|
|
// launcher opens the same way, as one more face of the notch (the pocket-dots
|
|
// way): its search sits in the band beside the clock, and the notch grows
|
|
// down to fit the results, clipboard history or emoji below it.
|
|
Item {
|
|
id: root
|
|
property var barScreen
|
|
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 searching: ShellState.notchLauncher && ScreenService.current(ShellState.launcherScreen) === barScreen
|
|
readonly property bool showing: !!latest && owner && visible && !searching
|
|
// Holds the last banner while the notch closes around it.
|
|
property var notice: null
|
|
readonly property int noticeWidth: 340
|
|
readonly property int searchWidth: ConfigService.ready ? ConfigService.data.launcher.width : 680
|
|
readonly property real band: BarDrawers.bottom
|
|
readonly property real bodyWidth: ShellState.notchPillWidth + (searching ? searchWidth : showing ? noticeWidth : 0)
|
|
// The launcher's results hang below the band.
|
|
readonly property real bodyHeight: band + (searching ? launcher.bodyHeight : 0)
|
|
// Tallest the launcher may grow; the bar window reserves this while open.
|
|
readonly property real maxBodyHeight: Math.min(460, (barScreen ? barScreen.height : 1080) * 0.6)
|
|
implicitWidth: bodyWidth + 2 * BarDrawers.ear
|
|
implicitHeight: bodyHeight
|
|
// Springs, as on pocket-dots: the width arrives quickly and stays, the
|
|
// height follows with a little slack, so the notch widens and then drops.
|
|
// The notch speed settings stiffen or soften them.
|
|
readonly property real springScale: Theme.duration / (searching || showing ? Theme.notchOpenDuration : Theme.notchCloseDuration)
|
|
Behavior on implicitWidth {
|
|
SpringAnimation {
|
|
spring: 5.2 * root.springScale
|
|
damping: 0.58
|
|
epsilon: 0.25
|
|
}
|
|
}
|
|
Behavior on implicitHeight {
|
|
SpringAnimation {
|
|
spring: 3.1 * root.springScale
|
|
damping: 0.34
|
|
epsilon: 0.25
|
|
}
|
|
}
|
|
Demand {
|
|
service: CavaService
|
|
counter: "widgetConsumers"
|
|
active: root.visible && root.playing
|
|
}
|
|
DrawerShape {
|
|
bodyWidth: root.width - 2 * BarDrawers.ear
|
|
bodyHeight: root.height
|
|
ear: BarDrawers.ear
|
|
radius: Math.min(Theme.radius, root.height / 2)
|
|
fillColor: root.searching ? Theme.notchLauncherFill : Theme.notchFill
|
|
Behavior on fillColor {
|
|
ColorAnimation {
|
|
duration: root.searching ? Theme.notchColorDuration : Math.min(Theme.notchColorDuration, Theme.notchCloseDuration)
|
|
}
|
|
}
|
|
}
|
|
// 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.band
|
|
}
|
|
NotchGlance {
|
|
anchors.centerIn: lead
|
|
playing: root.playing
|
|
}
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
anchors.leftMargin: BarDrawers.ear
|
|
anchors.rightMargin: BarDrawers.ear
|
|
cursorShape: Qt.PointingHandCursor
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
onClicked: mouse => {
|
|
if (mouse.button === Qt.RightButton)
|
|
MediaService.toggle();
|
|
else
|
|
ShellState.toggleNotch();
|
|
}
|
|
// Wheel changes the volume, as on pocket-dots.
|
|
onWheel: wheel => {
|
|
const audio = AudioService.sink ? AudioService.sink.audio : null;
|
|
const step = ConfigService.ready ? ConfigService.data.osd.step : 5;
|
|
if (audio && wheel.angleDelta.y !== 0)
|
|
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.band
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
Item {
|
|
objectName: "notchLauncher"
|
|
x: BarDrawers.ear
|
|
width: Math.max(0, root.width - 2 * BarDrawers.ear)
|
|
height: root.height
|
|
clip: true
|
|
// Comes in once the notch has started to widen, and leaves first.
|
|
opacity: root.searching ? 1 : 0
|
|
visible: width > 1 && opacity > 0
|
|
Behavior on opacity {
|
|
SequentialAnimation {
|
|
PauseAnimation {
|
|
duration: root.searching ? Theme.notchOpenDuration * 0.5 : 0
|
|
}
|
|
NumberAnimation {
|
|
duration: root.searching ? Theme.notchOpenDuration : Theme.notchCloseDuration * 0.5
|
|
easing.type: root.searching ? Easing.OutCubic : Easing.InQuad
|
|
}
|
|
}
|
|
}
|
|
Rectangle {
|
|
x: ShellState.notchPillWidth
|
|
y: root.band * 0.25
|
|
width: 1
|
|
height: root.band * 0.5
|
|
color: Theme.hairline
|
|
}
|
|
// Laid out at full size so it does not reflow while the notch grows.
|
|
LauncherView {
|
|
id: launcher
|
|
width: ShellState.notchPillWidth + root.searchWidth
|
|
height: Math.max(root.band, parent.height)
|
|
notch: true
|
|
band: root.band
|
|
barInset: ShellState.notchPillWidth
|
|
maxBodyHeight: root.maxBodyHeight
|
|
active: root.searching
|
|
}
|
|
}
|
|
// 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);
|
|
}
|
|
}
|
|
}
|