fix(Profile): ensure profile popup has window

When the profile popup is opened inside the contacts list, it doesn't have
a surrounding window context (`Popup` types should usually be used within `ApplicationWindow`
or `Window` components as per https://doc.qt.io/qt-5/qml-qtquick-controls2-popup.html).

This is problematic when popup are nested, like it's the case with the
nickname popup that will be instantiated by the profile popup.
With no window context, such nested popup can't be opened by the application.

This commit ensures the profile popup is created with a proper context,
fixing the issue that the nickname popup won't open when visting via
contacts list.

Fixes #2216
This commit is contained in:
Pascal Precht 2021-04-12 13:40:38 +02:00 committed by Iuri Matias
parent 438517a610
commit 57ac94c4ac
1 changed files with 9 additions and 5 deletions

View File

@ -15,6 +15,11 @@ ListView {
property string lowerCaseSearchString: searchString.toLowerCase() property string lowerCaseSearchString: searchString.toLowerCase()
property string contactToRemove: "" property string contactToRemove: ""
property Component profilePopupComponent: ProfilePopup {
id: profilePopup
onClosed: destroy()
}
width: parent.width width: parent.width
model: contacts model: contacts
@ -26,7 +31,10 @@ ListView {
identicon: model.thumbnailImage || model.identicon identicon: model.thumbnailImage || model.identicon
isContact: model.isContact isContact: model.isContact
isBlocked: model.isBlocked isBlocked: model.isBlocked
profileClick: profilePopup.openPopup.bind(profilePopup) profileClick: function (showFooter, userName, fromAuthor, identicon, textParam, nickName) {
var popup = profilePopupComponent.createObject(contactList);
popup.openPopup(showFooter, userName, fromAuthor, identicon, textParam, nickName);
}
visible: searchString === "" || visible: searchString === "" ||
model.name.toLowerCase().includes(lowerCaseSearchString) || model.name.toLowerCase().includes(lowerCaseSearchString) ||
model.address.toLowerCase().includes(lowerCaseSearchString) model.address.toLowerCase().includes(lowerCaseSearchString)
@ -41,10 +49,6 @@ ListView {
} }
} }
ProfilePopup {
id: profilePopup
}
// TODO: Make BlockContactConfirmationDialog a dynamic component on a future refactor // TODO: Make BlockContactConfirmationDialog a dynamic component on a future refactor
BlockContactConfirmationDialog { BlockContactConfirmationDialog {
id: blockContactConfirmationDialog id: blockContactConfirmationDialog