Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions qml/components/dialogs/AccountSelectorDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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
}
}

Expand Down Expand Up @@ -285,6 +297,10 @@ Item {
loadAccounts()
}
}

Component.onDestruction: {
root.activeDialog = null
}
}
}
}
20 changes: 18 additions & 2 deletions qml/components/feedback/NotificationPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -45,6 +47,7 @@ Item {
Dialog {
id: popupDialog
title: popupWrapper.titleText
modal: true

// Dark mode friendly styling
StyleHints {
Expand All @@ -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 {
Expand All @@ -77,6 +84,10 @@ Item {
backgroundColor: LomiriColors.orange
}
}

Component.onDestruction: {
popupWrapper.activeDialog = null;
}
}
}

Expand All @@ -87,6 +98,11 @@ Item {
messageText = messageArg;
if (typeArg)
type = typeArg;
PopupUtils.open(dialogComponent);

if (activeDialog)
return activeDialog;

activeDialog = PopupUtils.open(dialogComponent);
return activeDialog;
}
}
Loading