Merge the Leave and Forget room popups
This commit is contained in:
parent
b40c43ef2f
commit
70ae16a7c1
|
@ -390,10 +390,9 @@ class Keys:
|
|||
# Can also be done by clicking on current tab button at the top right.
|
||||
hide_room_pane = ["Alt+Ctrl+R"]
|
||||
|
||||
# Invite new members, leave or forget the current chat.
|
||||
# Invite new members or leave the current chat.
|
||||
invite = ["Alt+I"]
|
||||
leave = ["Alt+Escape"]
|
||||
forget = ["Alt+Shift+Escape"]
|
||||
|
||||
# Open the file picker to upload files in the current chat.
|
||||
send_file = ["Alt+S"]
|
||||
|
|
|
@ -227,11 +227,17 @@ HTile {
|
|||
}
|
||||
|
||||
HMenuItemPopupSpawner {
|
||||
visible: invited || joined
|
||||
icon.name: invited ? "invite-decline" : "room-leave"
|
||||
icon.color: theme.colors.negativeBackground
|
||||
text: invited ? qsTr("Decline invite") : qsTr("Leave")
|
||||
enabled: accountModel.presence !== "offline"
|
||||
icon.color: theme.colors.negativeBackground
|
||||
icon.name:
|
||||
parted ? "room-forget" :
|
||||
invited ? "invite-decline" :
|
||||
"room-leave"
|
||||
|
||||
text:
|
||||
parted ? qsTr("Forget history") :
|
||||
invited ? qsTr("Decline invite") :
|
||||
qsTr("Leave")
|
||||
|
||||
popup: "Popups/LeaveRoomPopup.qml"
|
||||
properties: ({
|
||||
|
@ -239,21 +245,7 @@ HTile {
|
|||
roomId: model.id,
|
||||
roomName: model.display_name,
|
||||
inviterId: model.inviter_id,
|
||||
})
|
||||
}
|
||||
|
||||
HMenuItemPopupSpawner {
|
||||
icon.name: "room-forget"
|
||||
icon.color: theme.colors.negativeBackground
|
||||
text: qsTr("Forget")
|
||||
enabled: accountModel.presence !== "offline"
|
||||
|
||||
popup: "Popups/ForgetRoomPopup.qml"
|
||||
autoDestruct: false
|
||||
properties: ({
|
||||
userId: model.for_account,
|
||||
roomId: model.id,
|
||||
roomName: model.display_name,
|
||||
left: model.left,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,11 +25,13 @@ Banner {
|
|||
buttonCallbacks: ({
|
||||
forget: button => {
|
||||
window.makePopup(
|
||||
"Popups/ForgetRoomPopup.qml",
|
||||
"Popups/LeaveRoomPopup.qml",
|
||||
{
|
||||
userId: chat.userId,
|
||||
roomId: chat.roomId,
|
||||
roomName: chat.roomInfo.display_name,
|
||||
userId: chat.userId,
|
||||
roomId: chat.roomId,
|
||||
roomName: chat.roomInfo.display_name,
|
||||
inviterId: chat.roomInfo.inviter_id,
|
||||
left: true,
|
||||
},
|
||||
obj => {
|
||||
obj.onOk.connect(() => { button.loading = true }) // FIXME
|
||||
|
|
|
@ -59,19 +59,11 @@ Item {
|
|||
roomId,
|
||||
roomName: roomInfo.display_name,
|
||||
inviterId: roomInfo.inviter_id,
|
||||
left: roomInfo.left,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
sequences: window.settings.Keys.Chat.forget
|
||||
active: userInfo && userInfo.presence !== "offline"
|
||||
onActivated: window.makePopup(
|
||||
"Popups/ForgetRoomPopup.qml",
|
||||
{userId, roomId, roomName: roomInfo.display_name},
|
||||
)
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 300
|
||||
running: ! ready
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import "../Base"
|
||||
import "../Base/Buttons"
|
||||
|
||||
HFlickableColumnPopup {
|
||||
id: popup
|
||||
|
||||
property string userId: ""
|
||||
property string roomId: ""
|
||||
property string roomName: ""
|
||||
|
||||
property bool canDestroy: false
|
||||
|
||||
function forget() {
|
||||
py.callClientCoro(userId, "room_forget", [roomId], () => {
|
||||
if (window.uiState.page === "Pages/Chat/Chat.qml" &&
|
||||
window.uiState.pageProperties.userRoomId[0] === userId &&
|
||||
window.uiState.pageProperties.userRoomId[1] === roomId)
|
||||
{
|
||||
window.mainUI.pageLoader.showPrevious() ||
|
||||
window.mainUI.pageLoader.show("Pages/Default.qml")
|
||||
|
||||
Qt.callLater(popup.destroy)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
page.footer: AutoDirectionLayout {
|
||||
ApplyButton {
|
||||
id: forgetButton
|
||||
text: qsTr("Forget")
|
||||
icon.name: "room-forget"
|
||||
onClicked: forget()
|
||||
}
|
||||
|
||||
CancelButton {
|
||||
onClicked: {
|
||||
canDestroy = true
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onOpened: forgetButton.forceActiveFocus()
|
||||
onClosed: if (canDestroy) Qt.callLater(popup.destroy)
|
||||
|
||||
SummaryLabel {
|
||||
text: qsTr("Leave %1 and lose the history?").arg(
|
||||
utils.htmlColorize(roomName, theme.colors.accentText),
|
||||
)
|
||||
textFormat: Text.StyledText
|
||||
}
|
||||
|
||||
DetailsLabel {
|
||||
text: qsTr(
|
||||
"You will not be able to see the messages you received in " +
|
||||
"this room anymore.\n\n" +
|
||||
|
||||
"If all members forget the room, it will be removed from the " +
|
||||
"servers."
|
||||
)
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import "../Base"
|
||||
import "../Base/Buttons"
|
||||
|
||||
|
@ -12,18 +13,40 @@ HFlickableColumnPopup {
|
|||
property string roomId: ""
|
||||
property string roomName: ""
|
||||
property string inviterId: ""
|
||||
property var leftCallback: null
|
||||
property bool left: false
|
||||
|
||||
function forget() {
|
||||
py.callClientCoro(userId, "room_forget", [roomId], () => {
|
||||
if (window.uiState.page === "Pages/Chat/Chat.qml" &&
|
||||
window.uiState.pageProperties.userRoomId[0] === userId &&
|
||||
window.uiState.pageProperties.userRoomId[1] === roomId)
|
||||
{
|
||||
window.mainUI.pageLoader.showPrevious() ||
|
||||
window.mainUI.pageLoader.show("Pages/Default.qml")
|
||||
|
||||
Qt.callLater(popup.destroy)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function leave() {
|
||||
py.callClientCoro(userId, "room_leave", [roomId])
|
||||
popup.close()
|
||||
}
|
||||
|
||||
page.footer: AutoDirectionLayout {
|
||||
ApplyButton {
|
||||
id: leaveButton
|
||||
icon.name: "room-leave"
|
||||
text: inviterId ? qsTr("Decline") : qsTr("Leave")
|
||||
icon.name: popup.left ? "room-forget" : "room-leave"
|
||||
text:
|
||||
popup.left ? qsTr("Forget") :
|
||||
popup.inviterId ? qsTr("Decline") :
|
||||
qsTr("Leave")
|
||||
|
||||
onClicked: {
|
||||
py.callClientCoro(userId, "room_leave", [roomId], leftCallback)
|
||||
popup.close()
|
||||
}
|
||||
onClicked:
|
||||
forgetCheck.checked || popup.left ?
|
||||
popup.forget() :
|
||||
popup.leave()
|
||||
}
|
||||
|
||||
CancelButton {
|
||||
|
@ -35,19 +58,34 @@ HFlickableColumnPopup {
|
|||
|
||||
SummaryLabel {
|
||||
readonly property string roomText:
|
||||
utils.htmlColorize(roomName, theme.colors.accentText)
|
||||
utils.htmlColorize(popup.roomName, theme.colors.accentText)
|
||||
|
||||
textFormat: Text.StyledText
|
||||
text:
|
||||
inviterId ?
|
||||
qsTr("Decline invite to %1?").arg(roomText) :
|
||||
popup.left ? qsTr("Forget the history for %1?").arg(roomText) :
|
||||
popup.inviterId ? qsTr("Decline invite to %1?").arg(roomText) :
|
||||
qsTr("Leave %1?").arg(roomText)
|
||||
}
|
||||
|
||||
DetailsLabel {
|
||||
visible: inviterId === ""
|
||||
text: qsTr(
|
||||
"If this room is private, you will not be able to rejoin it."
|
||||
text:
|
||||
popup.left ?
|
||||
forgetCheck.subtitle.text :
|
||||
qsTr(
|
||||
"If this room is private, you will not be able to rejoin it " +
|
||||
"without a new invite."
|
||||
)
|
||||
}
|
||||
|
||||
HCheckBox {
|
||||
id: forgetCheck
|
||||
visible: ! popup.left
|
||||
text: qsTr("Forget this room's history")
|
||||
subtitle.text: qsTr(
|
||||
"You will lose access to any previously received messages.\n" +
|
||||
"If all members forget a room, servers will erase it."
|
||||
)
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user