Toast: refactored service vs UI.
This commit is contained in:
parent
f9d7de2e3c
commit
d348cfc2b0
8 changed files with 341 additions and 526 deletions
|
|
@ -9,105 +9,13 @@ import qs.Widgets
|
|||
Variants {
|
||||
model: Quickshell.screens
|
||||
|
||||
delegate: Loader {
|
||||
delegate: ToastScreen {
|
||||
required property ShellScreen modelData
|
||||
property real scaling: ScalingService.getScreenScale(modelData)
|
||||
|
||||
Connections {
|
||||
target: ScalingService
|
||||
function onScaleChanged(screenName, scale) {
|
||||
if (screenName === modelData.name) {
|
||||
scaling = scale
|
||||
}
|
||||
}
|
||||
}
|
||||
screen: modelData
|
||||
scaling: ScalingService.getScreenScale(modelData)
|
||||
|
||||
// Only show on screens that have notifications enabled
|
||||
active: Settings.isLoaded && modelData ? (Settings.data.notifications.monitors.includes(modelData.name) || (Settings.data.notifications.monitors.length === 0)) : false
|
||||
|
||||
sourceComponent: PanelWindow {
|
||||
id: root
|
||||
|
||||
screen: modelData
|
||||
|
||||
// Position at top of screen, always allow horizontal centering
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
}
|
||||
|
||||
// Set a width instead of anchoring left/right so we can click on the side of the toast
|
||||
implicitWidth: 500 * scaling
|
||||
|
||||
// Small height when hidden, appropriate height when visible
|
||||
implicitHeight: Math.round(toast.visible ? toast.height + Style.marginM * scaling : 1)
|
||||
|
||||
// Set margins based on bar position
|
||||
margins.top: {
|
||||
switch (Settings.data.bar.position) {
|
||||
case "top":
|
||||
return (Style.barHeight + Style.marginS) * scaling + (Settings.data.bar.floating ? Settings.data.bar.marginVertical * Style.marginXL * scaling : 0)
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
margins.bottom: {
|
||||
switch (Settings.data.bar.position) {
|
||||
case "bottom":
|
||||
return (Style.barHeight + Style.marginS) * scaling + (Settings.data.bar.floating ? Settings.data.bar.marginVertical * Style.marginXL * scaling : 0)
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
margins.right: {
|
||||
switch (Settings.data.bar.position) {
|
||||
case "left":
|
||||
case "top":
|
||||
case "bottom":
|
||||
return Style.marginM * scaling
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
margins.left: {
|
||||
switch (Settings.data.bar.position) {
|
||||
case "right":
|
||||
return Style.marginM * scaling
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// Transparent background
|
||||
color: Color.transparent
|
||||
|
||||
// Overlay layer to appear above other panels
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||
exclusionMode: PanelWindow.ExclusionMode.Ignore
|
||||
|
||||
NToast {
|
||||
id: toast
|
||||
screen: modelData
|
||||
|
||||
// Simple positioning - margins already account for bar
|
||||
targetY: Style.marginS * scaling
|
||||
|
||||
// Hidden position - always start from above the screen
|
||||
hiddenY: -toast.height - 20
|
||||
|
||||
Component.onCompleted: {
|
||||
// Register this toast with the service
|
||||
ToastService.allToasts.push(toast)
|
||||
|
||||
// Connect dismissal signal
|
||||
toast.dismissed.connect(ToastService.onToastDismissed)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Only activate on enabled screens
|
||||
active: Settings.isLoaded && modelData && (Settings.data.notifications.monitors.includes(modelData.name) || Settings.data.notifications.monitors.length === 0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue