The notification daemon and popup stack now live under HyprChrome/Widgets/Notifications and are owned by HyprChromeShell, so popups land on the rail's monitor below its exclusive zone. Replaces widgets/notifications; NotificationCard renders headless for tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
211 lines
6.5 KiB
QML
211 lines
6.5 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import QtQuick.Shapes
|
|
import qs.HyprChrome.Theme
|
|
|
|
// Chamfered chrome for one notification card: PolkitPanel's silhouette, tighter
|
|
// metrics, a tintable accent (urgency) and a close box in the header.
|
|
//
|
|
// Not PolkitPanel itself: that file is the prompt's alone to restyle.
|
|
Item {
|
|
id: panel
|
|
|
|
property string panelId: ""
|
|
property string title: ""
|
|
property string meta: ""
|
|
property color accentColor: Theme.accent
|
|
|
|
property int chamfer: 12
|
|
property int padding: 12
|
|
property int outlineWidth: 1
|
|
property int accentLineThickness: 3
|
|
|
|
readonly property int headerHeight: 26
|
|
property int headerGap: 10
|
|
readonly property int headerPadding: 8
|
|
|
|
property real capGap: 4
|
|
readonly property real capOffset: panel.capGap / Math.SQRT2
|
|
readonly property real activeChamfer: Math.max(2, Math.min(panel.chamfer, panel.height / 2 - 1))
|
|
readonly property real accentLineWidth: Math.min(panel.width, slugChip.width + panel.headerPadding * 2)
|
|
|
|
default property alias content: body.data
|
|
|
|
signal closeRequested
|
|
|
|
implicitHeight: Math.round(body.y + body.height + panel.padding)
|
|
|
|
Shape {
|
|
id: panelShape
|
|
|
|
anchors.fill: parent
|
|
preferredRendererType: Shape.CurveRenderer
|
|
|
|
ShapePath {
|
|
fillColor: Theme.surface
|
|
strokeColor: Theme.hair
|
|
strokeWidth: panel.outlineWidth
|
|
|
|
startX: 0; startY: 0
|
|
PathLine { x: panelShape.width - panel.activeChamfer; y: 0 }
|
|
PathLine { x: panelShape.width; y: panel.activeChamfer }
|
|
PathLine { x: panelShape.width; y: panelShape.height }
|
|
PathLine { x: panel.activeChamfer; y: panelShape.height }
|
|
PathLine { x: 0; y: panelShape.height - panel.activeChamfer }
|
|
PathLine { x: 0; y: 0 }
|
|
}
|
|
|
|
ShapePath {
|
|
fillColor: panel.accentColor
|
|
strokeWidth: 0
|
|
|
|
startX: panelShape.width - panel.activeChamfer + panel.capOffset
|
|
startY: -panel.capOffset
|
|
PathLine { x: panelShape.width + panel.capOffset; y: panel.activeChamfer - panel.capOffset }
|
|
PathLine { x: panelShape.width + panel.capOffset; y: -panel.capOffset }
|
|
PathLine { x: panelShape.width - panel.activeChamfer + panel.capOffset; y: -panel.capOffset }
|
|
}
|
|
|
|
ShapePath {
|
|
fillColor: panel.accentColor
|
|
strokeWidth: 0
|
|
|
|
startX: panel.activeChamfer - panel.capOffset
|
|
startY: panelShape.height + panel.capOffset
|
|
PathLine { x: -panel.capOffset; y: panelShape.height - panel.activeChamfer + panel.capOffset }
|
|
PathLine { x: -panel.capOffset; y: panelShape.height + panel.capOffset }
|
|
PathLine { x: panel.activeChamfer - panel.capOffset; y: panelShape.height + panel.capOffset }
|
|
}
|
|
|
|
ShapePath {
|
|
fillColor: panel.accentColor
|
|
strokeWidth: 0
|
|
|
|
startX: 0; startY: 0
|
|
PathLine { x: panel.accentLineWidth; y: 0 }
|
|
PathLine { x: panel.accentLineWidth; y: panel.accentLineThickness }
|
|
PathLine { x: 0; y: panel.accentLineThickness }
|
|
PathLine { x: 0; y: 0 }
|
|
}
|
|
|
|
ShapePath {
|
|
fillColor: panel.accentColor
|
|
strokeWidth: 0
|
|
|
|
startX: panelShape.width; startY: panelShape.height
|
|
PathLine { x: panelShape.width - panel.accentLineWidth; y: panelShape.height }
|
|
PathLine { x: panelShape.width - panel.accentLineWidth; y: panelShape.height - panel.accentLineThickness }
|
|
PathLine { x: panelShape.width; y: panelShape.height - panel.accentLineThickness }
|
|
PathLine { x: panelShape.width; y: panelShape.height }
|
|
}
|
|
}
|
|
|
|
Row {
|
|
id: headerRow
|
|
|
|
x: panel.headerPadding
|
|
y: Math.round((panel.headerHeight - height) / 2)
|
|
width: headerEnd.x - x - 8
|
|
spacing: panel.headerPadding + 6
|
|
|
|
Rectangle {
|
|
id: slugChip
|
|
|
|
width: slugText.implicitWidth + 8
|
|
height: slugText.implicitHeight + 4
|
|
color: panel.accentColor
|
|
|
|
Text {
|
|
id: slugText
|
|
|
|
anchors.centerIn: parent
|
|
text: panel.panelId
|
|
color: Theme.surface
|
|
font.family: Theme.microFont
|
|
font.pixelSize: 10
|
|
font.bold: true
|
|
}
|
|
}
|
|
|
|
Text {
|
|
anchors.verticalCenter: slugChip.verticalCenter
|
|
width: Math.max(0, headerRow.width - slugChip.width - headerRow.spacing)
|
|
text: panel.title
|
|
color: Theme.text
|
|
font.family: Theme.displayFont
|
|
font.pixelSize: 11
|
|
font.bold: true
|
|
font.letterSpacing: 1.1
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
|
|
Row {
|
|
id: headerEnd
|
|
|
|
// Clear of the top-right chamfer.
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: panel.activeChamfer + 2
|
|
y: Math.round((panel.headerHeight - height) / 2)
|
|
spacing: 8
|
|
|
|
Text {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
visible: panel.meta.length > 0
|
|
text: panel.meta
|
|
color: Theme.muted
|
|
font.family: Theme.microFont
|
|
font.pixelSize: 8
|
|
font.letterSpacing: 0.7
|
|
}
|
|
|
|
Rectangle {
|
|
id: closeBox
|
|
|
|
width: 16
|
|
height: 16
|
|
color: closeArea.containsMouse ? panel.accentColor : "transparent"
|
|
border.width: 1
|
|
border.color: closeArea.containsMouse ? panel.accentColor : Theme.disabled
|
|
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: "✕"
|
|
color: closeArea.containsMouse ? Theme.surface : Theme.muted
|
|
font.family: Theme.microFont
|
|
font.pixelSize: 9
|
|
font.bold: true
|
|
}
|
|
|
|
MouseArea {
|
|
id: closeArea
|
|
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onClicked: panel.closeRequested()
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
x: 1
|
|
y: panel.headerHeight
|
|
width: parent.width - 2
|
|
height: 1
|
|
color: Theme.text
|
|
opacity: 0.12
|
|
}
|
|
|
|
// Measured by childrenRect: children carry their own size, no anchoring.
|
|
Item {
|
|
id: body
|
|
|
|
x: panel.padding
|
|
y: panel.headerHeight + panel.headerGap
|
|
width: Math.max(0, panel.width - panel.padding * 2)
|
|
height: childrenRect.height
|
|
}
|
|
}
|