fix(AppMain): Open only one popup per component

Close #9131
This commit is contained in:
MishkaRogachev 2023-01-17 16:19:21 +04:00 committed by Jonathan Rainville
parent a6afdb5266
commit 0f1485fa4d
1 changed files with 15 additions and 0 deletions

View File

@ -52,6 +52,8 @@ Item {
// set from main.qml
property var sysPalette
property var activePopupComponents: []
signal closeProfilePopup()
Connections {
@ -158,8 +160,21 @@ Item {
onOpenEditDisplayNamePopup: Global.openPopup(displayNamePopupComponent)
onOpenPopupRequested: {
if (activePopupComponents.includes(popupComponent)) {
return;
}
const popup = popupComponent.createObject(appMain, params);
popup.open();
activePopupComponents.push(popupComponent);
popup.closed.connect(() => {
const removeIndex = activePopupComponents.indexOf(popupComponent);
if (removeIndex !== -1) {
activePopupComponents.splice(removeIndex, 1);
}
})
return popup;
}