The launcher now works like a notification there: the notch pill widens at its own height, the clock and now playing keep the left end, and a search field with the top matches as a row of icons fills the right. Enter launches the highlighted match, Tab and arrows move along the row, Escape clears then closes, and a click elsewhere closes it. The bar window takes the keyboard while it is open. Clipboard history and emoji still open the launcher window, which now only shows for those modes. NotchGlance moves to components so the launcher and notch can share it without importing each other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
274 lines
10 KiB
QML
274 lines
10 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, with the search where the banner would be.
|
|
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.notchSearch && ScreenService.current(ShellState.launcherScreen) === barScreen && visible
|
|
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: 520
|
|
readonly property real bodyWidth: ShellState.notchPillWidth + (searching ? searchWidth : showing ? noticeWidth : 0)
|
|
implicitWidth: bodyWidth + 2 * BarDrawers.ear
|
|
implicitHeight: BarDrawers.bottom
|
|
Behavior on implicitWidth {
|
|
NumberAnimation {
|
|
duration: Theme.notchDuration * 1.6
|
|
easing.type: Easing.BezierSpline
|
|
easing.bezierCurve: [0.2, 0, 0, 1, 1, 1]
|
|
}
|
|
}
|
|
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: 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
|
|
}
|
|
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.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);
|
|
}
|
|
}
|
|
}
|
|
Item {
|
|
objectName: "notchSearch"
|
|
x: lead.x + lead.width
|
|
width: Math.max(0, root.width - BarDrawers.ear - x)
|
|
height: root.height
|
|
clip: true
|
|
opacity: root.searching ? 1 : 0
|
|
visible: width > 1 && opacity > 0
|
|
Behavior on opacity {
|
|
NumberAnimation {
|
|
duration: root.searching ? Theme.notchDuration * 1.6 : Theme.notchDuration * 0.6
|
|
easing.type: Easing.OutCubic
|
|
}
|
|
}
|
|
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 it does not reflow while the notch grows.
|
|
NotchSearch {
|
|
width: root.searchWidth
|
|
height: parent.height
|
|
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);
|
|
}
|
|
}
|
|
}
|