diff --git a/qml/components/dialogs/AccountSelectorDialog.qml b/qml/components/dialogs/AccountSelectorDialog.qml index 70a2879b..66f72059 100644 --- a/qml/components/dialogs/AccountSelectorDialog.qml +++ b/qml/components/dialogs/AccountSelectorDialog.qml @@ -39,11 +39,15 @@ Item { // carry initial request until dialog is visible property int _initialAccountId: -2 // -2 = none, -1 = "All" + property var activeDialog: null /** Show dialog; optionally preselect an account id */ function open(initialAccountId) { + if (activeDialog) + return activeDialog _initialAccountId = (typeof initialAccountId === "number") ? initialAccountId : -2 - PopupUtils.open(dialogComponent) + activeDialog = PopupUtils.open(dialogComponent) + return activeDialog } /** Toggle between Local Account (0) and last active remote account */ @@ -54,15 +58,23 @@ Item { selectedAccountName = Accounts.getAccountName(0) accepted(0, selectedAccountName) } + return true } else { - var targetId = lastRemoteAccountId > 0 ? lastRemoteAccountId : Accounts.getDefaultRemoteAccountId() + var targetId = (lastRemoteAccountId > 0 && Accounts.getAccountName(lastRemoteAccountId)) + ? lastRemoteAccountId + : Accounts.getDefaultRemoteAccountId() if (targetId > 0 && selectedAccountId !== targetId) { selectedAccountId = targetId selectedAccountName = Accounts.getAccountName(targetId) accepted(targetId, selectedAccountName) + return true } else if (targetId <= 0) { - open(selectedAccountId) + if (typeof notifPopup !== "undefined") { + notifPopup.open(i18n.dtr("ubtms", "Notice"), i18n.dtr("ubtms", "You don't have any account logged in"), "warning") + } + return false } + return true } } @@ -285,6 +297,10 @@ Item { loadAccounts() } } + + Component.onDestruction: { + root.activeDialog = null + } } } } diff --git a/qml/components/feedback/NotificationPopup.qml b/qml/components/feedback/NotificationPopup.qml index 16b4d70f..74fa94f4 100644 --- a/qml/components/feedback/NotificationPopup.qml +++ b/qml/components/feedback/NotificationPopup.qml @@ -37,6 +37,8 @@ Item { property string type: "info" // "success", "error", "warning", "info" property string titleText: "Notice" property string messageText: "Something happened." + property var activeDialog: null + readonly property bool isOpen: activeDialog !== null signal closed Component { @@ -45,6 +47,7 @@ Item { Dialog { id: popupDialog title: popupWrapper.titleText + modal: true // Dark mode friendly styling StyleHints { @@ -68,7 +71,11 @@ Item { // Color logic based on type (optional, add custom styling if needed) Button { text: "OK" - onClicked: PopupUtils.close(popupDialog) + onClicked: { + PopupUtils.close(popupDialog); + popupWrapper.activeDialog = null; + popupWrapper.closed(); + } // Dark mode friendly button styling StyleHints { @@ -77,6 +84,10 @@ Item { backgroundColor: LomiriColors.orange } } + + Component.onDestruction: { + popupWrapper.activeDialog = null; + } } } @@ -87,6 +98,11 @@ Item { messageText = messageArg; if (typeArg) type = typeArg; - PopupUtils.open(dialogComponent); + + if (activeDialog) + return activeDialog; + + activeDialog = PopupUtils.open(dialogComponent); + return activeDialog; } }