Add window.makePopup(), utils.makePopup() wrapper

This commit is contained in:
miruka 2020-08-03 01:26:35 -04:00
parent c813e92ac7
commit a389238024
12 changed files with 27 additions and 18 deletions

View File

@ -14,10 +14,10 @@ HMenuItem {
utils.makePopup(
popup,
null,
utils.objectUpdate(
{ focusOnClosed: menu.previouslyFocused }, properties,
),
null,
autoDestruct,
)
}

View File

@ -146,7 +146,7 @@ HTile {
onClicked: {
actionMenu.focusOnClosed = null
utils.makePopup(
window.makePopup(
"Popups/KeyVerificationPopup.qml",
{
focusOnClosed: nameField,

View File

@ -49,7 +49,7 @@ HColumnPage {
function deleteDevices(...indice) {
if (indice.length === 1 && indice[0] === 0) {
utils.makePopup("Popups/SignOutPopup.qml", { userId: page.userId })
window.makePopup("Popups/SignOutPopup.qml", {userId: page.userId})
return
}
@ -62,14 +62,14 @@ HColumnPage {
deviceIds.push(deviceList.model.get(i).id)
}
utils.makePopup(
window.makePopup(
"Popups/DeleteDevicesPopup.qml",
{
userId: page.userId,
deviceIds,
deletedCallback: () => {
deleteOwnDevice ?
utils.makePopup(
window.makePopup(
"Popups/SignOutPopup.qml", { userId: page.userId },
) :
page.loadDevices()

View File

@ -23,7 +23,7 @@ Banner {
buttonCallbacks: ({
forget: button => {
utils.makePopup(
window.makePopup(
"Popups/ForgetRoomPopup.qml",
{
userId: chat.userId,
@ -31,7 +31,7 @@ Banner {
roomName: chat.roomInfo.display_name,
},
obj => {
obj.onOk.connect(() => { button.loading = true })
obj.onOk.connect(() => { button.loading = true }) // FIXME
},
false,
)

View File

@ -35,7 +35,7 @@ Item {
HShortcut {
sequences: window.settings.keys.leaveRoom
active: userInfo && userInfo.presence !== "offline"
onActivated: utils.makePopup(
onActivated: window.makePopup(
"Popups/LeaveRoomPopup.qml",
{userId, roomId, roomName: roomInfo.display_name},
)
@ -44,7 +44,7 @@ Item {
HShortcut {
sequences: window.settings.keys.forgetRoom
active: userInfo && userInfo.presence !== "offline"
onActivated: utils.makePopup(
onActivated: window.makePopup(
"Popups/ForgetRoomPopup.qml",
{userId, roomId, roomName: roomInfo.display_name},
)

View File

@ -165,7 +165,7 @@ HTextArea {
}
}
onCustomImagePaste: utils.makePopup(
onCustomImagePaste: window.makePopup(
"Popups/ConfirmClipboardUploadPopup.qml",
{
userId: chat.userId,

View File

@ -21,7 +21,7 @@ HButton {
HShortcut {
sequences: window.settings.keys.sendFileFromPathInClipboard
onActivated: utils.makePopup(
onActivated: window.makePopup(
"Popups/ConfirmUploadPopup.qml",
{
userId: chat.userId,

View File

@ -134,7 +134,7 @@ HColumnLayout {
qsTr("Invite members to this room") :
qsTr("No permission to invite members to this room")
onClicked: utils.makePopup(
onClicked: window.makePopup(
"Popups/InviteToRoomPopup.qml",
{
userId: chat.userId,

View File

@ -74,7 +74,7 @@ Rectangle {
enabled: (events && events.length > 0) || events === null
sequences: window.settings.keys.removeFocusedOrSelectedMessages
onActivated: utils.makePopup(
onActivated: window.makePopup(
"Popups/RedactPopup.qml",
{
preferUserId: chat.userId,
@ -200,7 +200,7 @@ Rectangle {
HShortcut {
sequences: window.settings.keys.clearRoomMessages
onActivated: utils.makePopup(
onActivated: window.makePopup(
"Popups/ClearMessagesPopup.qml",
{
userId: window.uiState.pageProperties.userId,
@ -413,7 +413,7 @@ Rectangle {
const fullMxc =
forLink || (isAnimated(event) ? "" : event.media_url)
utils.makePopup(
window.makePopup(
"Popups/ImageViewerPopup/ImageViewerPopup.qml",
{
thumbnailTitle: getThumbnailTitle(event),

View File

@ -80,7 +80,7 @@ Python {
return
}
utils.makePopup(
window.makePopup(
"Popups/UnexpectedErrorPopup.qml",
{ errorType: type, message, traceback },
)

View File

@ -65,8 +65,8 @@ QtObject {
}
function makePopup(urlComponent, properties={}, callback=null,
autoDestruct=true, parent=window) {
function makePopup(urlComponent, parent, properties={}, callback=null,
autoDestruct=true) {
makeObject(urlComponent, parent, properties, (popup) => {
popup.open()
if (autoDestruct) popup.closed.connect(() => { popup.destroy() })

View File

@ -57,6 +57,15 @@ ApplicationWindow {
}
}
function makePopup(
urlComponent, properties={}, callback=null, autoDestruct=true,
) {
utils.makePopup(
urlComponent, window, properties, callback, autoDestruct,
)
}
flags: Qt.WA_TranslucentBackground
minimumWidth: theme ? theme.minimumSupportedWidth : 240