Add ToastService, NToast etc
This commit is contained in:
parent
1993e28c18
commit
1d860da42e
18 changed files with 534 additions and 31 deletions
54
Modules/Toast/ToastManager.qml
Normal file
54
Modules/Toast/ToastManager.qml
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import qs.Commons
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
// ToastManager creates toast overlays on each screen
|
||||
Variants {
|
||||
model: Quickshell.screens
|
||||
|
||||
delegate: PanelWindow {
|
||||
id: root
|
||||
|
||||
required property ShellScreen modelData
|
||||
readonly property real scaling: ScalingService.scale(screen)
|
||||
screen: modelData
|
||||
|
||||
// Position at top, centered horizontally
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
}
|
||||
|
||||
// Small height when hidden, appropriate height when visible
|
||||
implicitHeight: toast.visible ? toast.height + Style.barHeight * scaling + Style.marginS * scaling : 1
|
||||
|
||||
// Transparent background
|
||||
color: Color.transparent
|
||||
|
||||
// High layer to appear above other panels
|
||||
//WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||
exclusionMode: PanelWindow.ExclusionMode.Ignore
|
||||
|
||||
NToast {
|
||||
id: toast
|
||||
scaling: root.scaling
|
||||
|
||||
// Position just below where the bar would be
|
||||
targetY: Style.barHeight * scaling + Style.marginS * scaling
|
||||
|
||||
Component.onCompleted: {
|
||||
// Register this toast with the service
|
||||
ToastService.currentToast = toast
|
||||
|
||||
// Connect dismissal signal
|
||||
toast.dismissed.connect(ToastService.onToastDismissed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue