From e3154fb9a50e20beacdaabff9c35e2f6eea29de3 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Sun, 24 Aug 2025 17:47:42 +0200 Subject: [PATCH] Possible Toast fix --- Modules/Toast/ToastManager.qml | 2 +- Services/ToastService.qml | 51 ++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/Modules/Toast/ToastManager.qml b/Modules/Toast/ToastManager.qml index 35fe01ed..ea65b004 100644 --- a/Modules/Toast/ToastManager.qml +++ b/Modules/Toast/ToastManager.qml @@ -52,7 +52,7 @@ Variants { Component.onCompleted: { // Register this toast with the service - ToastService.currentToast = toast + ToastService.allToasts.push(toast) // Connect dismissal signal toast.dismissed.connect(ToastService.onToastDismissed) diff --git a/Services/ToastService.qml b/Services/ToastService.qml index 8ca18a2e..38ce2db3 100644 --- a/Services/ToastService.qml +++ b/Services/ToastService.qml @@ -12,8 +12,8 @@ Singleton { property var messageQueue: [] property bool isShowingToast: false - // Reference to the current toast instance (set by ToastManager) - property var currentToast: null + // Reference to all toast instances (set by ToastManager) + property var allToasts: [] // Properties for command checking property var commandCheckCallback: null @@ -176,7 +176,7 @@ Singleton { // Process the message queue function processQueue() { - if (messageQueue.length === 0 || !currentToast) { + if (messageQueue.length === 0 || allToasts.length === 0) { isShowingToast = false return } @@ -189,24 +189,37 @@ Singleton { var toastData = messageQueue.shift() isShowingToast = true - // Configure and show toast - currentToast.label = toastData.label - currentToast.description = toastData.description - currentToast.type = toastData.type - currentToast.persistent = toastData.persistent - currentToast.duration = toastData.duration - currentToast.show() + // Configure and show toast on all screens + for (var i = 0; i < allToasts.length; i++) { + var toast = allToasts[i] + toast.label = toastData.label + toast.description = toastData.description + toast.type = toastData.type + toast.persistent = toastData.persistent + toast.duration = toastData.duration + toast.show() + } } // Called when a toast is dismissed 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 () { - processQueue() - }) + // Small delay before showing next toast + Qt.callLater(function () { + processQueue() + }) + } } // Clear all pending messages @@ -217,8 +230,10 @@ Singleton { // Hide current toast function hideCurrentToast() { - if (currentToast && isShowingToast) { - currentToast.hide() + if (isShowingToast) { + for (var i = 0; i < allToasts.length; i++) { + allToasts[i].hide() + } } }