Possible Toast fix
This commit is contained in:
parent
f1a8624945
commit
e3154fb9a5
2 changed files with 34 additions and 19 deletions
|
|
@ -52,7 +52,7 @@ Variants {
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
// Register this toast with the service
|
// Register this toast with the service
|
||||||
ToastService.currentToast = toast
|
ToastService.allToasts.push(toast)
|
||||||
|
|
||||||
// Connect dismissal signal
|
// Connect dismissal signal
|
||||||
toast.dismissed.connect(ToastService.onToastDismissed)
|
toast.dismissed.connect(ToastService.onToastDismissed)
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ Singleton {
|
||||||
property var messageQueue: []
|
property var messageQueue: []
|
||||||
property bool isShowingToast: false
|
property bool isShowingToast: false
|
||||||
|
|
||||||
// Reference to the current toast instance (set by ToastManager)
|
// Reference to all toast instances (set by ToastManager)
|
||||||
property var currentToast: null
|
property var allToasts: []
|
||||||
|
|
||||||
// Properties for command checking
|
// Properties for command checking
|
||||||
property var commandCheckCallback: null
|
property var commandCheckCallback: null
|
||||||
|
|
@ -176,7 +176,7 @@ Singleton {
|
||||||
|
|
||||||
// Process the message queue
|
// Process the message queue
|
||||||
function processQueue() {
|
function processQueue() {
|
||||||
if (messageQueue.length === 0 || !currentToast) {
|
if (messageQueue.length === 0 || allToasts.length === 0) {
|
||||||
isShowingToast = false
|
isShowingToast = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -189,24 +189,37 @@ Singleton {
|
||||||
var toastData = messageQueue.shift()
|
var toastData = messageQueue.shift()
|
||||||
isShowingToast = true
|
isShowingToast = true
|
||||||
|
|
||||||
// Configure and show toast
|
// Configure and show toast on all screens
|
||||||
currentToast.label = toastData.label
|
for (var i = 0; i < allToasts.length; i++) {
|
||||||
currentToast.description = toastData.description
|
var toast = allToasts[i]
|
||||||
currentToast.type = toastData.type
|
toast.label = toastData.label
|
||||||
currentToast.persistent = toastData.persistent
|
toast.description = toastData.description
|
||||||
currentToast.duration = toastData.duration
|
toast.type = toastData.type
|
||||||
currentToast.show()
|
toast.persistent = toastData.persistent
|
||||||
|
toast.duration = toastData.duration
|
||||||
|
toast.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when a toast is dismissed
|
// Called when a toast is dismissed
|
||||||
function onToastDismissed() {
|
function onToastDismissed() {
|
||||||
|
// Check if all toasts are dismissed
|
||||||
|
var allDismissed = true
|
||||||
|
for (var i = 0; i < allToasts.length; i++) {
|
||||||
|
if (allToasts[i].visible) {
|
||||||
|
allDismissed = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allDismissed) {
|
||||||
|
isShowingToast = false
|
||||||
|
|
||||||
isShowingToast = false
|
// Small delay before showing next toast
|
||||||
|
Qt.callLater(function () {
|
||||||
// Small delay before showing next toast
|
processQueue()
|
||||||
Qt.callLater(function () {
|
})
|
||||||
processQueue()
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear all pending messages
|
// Clear all pending messages
|
||||||
|
|
@ -217,8 +230,10 @@ Singleton {
|
||||||
|
|
||||||
// Hide current toast
|
// Hide current toast
|
||||||
function hideCurrentToast() {
|
function hideCurrentToast() {
|
||||||
if (currentToast && isShowingToast) {
|
if (isShowingToast) {
|
||||||
currentToast.hide()
|
for (var i = 0; i < allToasts.length; i++) {
|
||||||
|
allToasts[i].hide()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue