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.
|
# Can also be done by clicking on current tab button at the top right.
|
||||||
hide_room_pane = ["Alt+Ctrl+R"]
|
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"]
|
invite = ["Alt+I"]
|
||||||
leave = ["Alt+Escape"]
|
leave = ["Alt+Escape"]
|
||||||
forget = ["Alt+Shift+Escape"]
|
|
||||||
|
|
||||||
# Open the file picker to upload files in the current chat.
|
# Open the file picker to upload files in the current chat.
|
||||||
send_file = ["Alt+S"]
|
send_file = ["Alt+S"]
|
||||||
|
|
|
@ -227,11 +227,17 @@ HTile {
|
||||||
}
|
}
|
||||||
|
|
||||||
HMenuItemPopupSpawner {
|
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"
|
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"
|
popup: "Popups/LeaveRoomPopup.qml"
|
||||||
properties: ({
|
properties: ({
|
||||||
|
@ -239,21 +245,7 @@ HTile {
|
||||||
roomId: model.id,
|
roomId: model.id,
|
||||||
roomName: model.display_name,
|
roomName: model.display_name,
|
||||||
inviterId: model.inviter_id,
|
inviterId: model.inviter_id,
|
||||||
})
|
left: model.left,
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,13 @@ Banner {
|
||||||
buttonCallbacks: ({
|
buttonCallbacks: ({
|
||||||
forget: button => {
|
forget: button => {
|
||||||
window.makePopup(
|
window.makePopup(
|
||||||
"Popups/ForgetRoomPopup.qml",
|
"Popups/LeaveRoomPopup.qml",
|
||||||
{
|
{
|
||||||
userId: chat.userId,
|
userId: chat.userId,
|
||||||
roomId: chat.roomId,
|
roomId: chat.roomId,
|
||||||
roomName: chat.roomInfo.display_name,
|
roomName: chat.roomInfo.display_name,
|
||||||
|
inviterId: chat.roomInfo.inviter_id,
|
||||||
|
left: true,
|
||||||
},
|
},
|
||||||
obj => {
|
obj => {
|
||||||
obj.onOk.connect(() => { button.loading = true }) // FIXME
|
obj.onOk.connect(() => { button.loading = true }) // FIXME
|
||||||
|
|
|
@ -59,19 +59,11 @@ Item {
|
||||||
roomId,
|
roomId,
|
||||||
roomName: roomInfo.display_name,
|
roomName: roomInfo.display_name,
|
||||||
inviterId: roomInfo.inviter_id,
|
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 {
|
Timer {
|
||||||
interval: 300
|
interval: 300
|
||||||
running: ! ready
|
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
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Layouts 1.12
|
||||||
import "../Base"
|
import "../Base"
|
||||||
import "../Base/Buttons"
|
import "../Base/Buttons"
|
||||||
|
|
||||||
|
@ -12,18 +13,40 @@ HFlickableColumnPopup {
|
||||||
property string roomId: ""
|
property string roomId: ""
|
||||||
property string roomName: ""
|
property string roomName: ""
|
||||||
property string inviterId: ""
|
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 {
|
page.footer: AutoDirectionLayout {
|
||||||
ApplyButton {
|
ApplyButton {
|
||||||
id: leaveButton
|
id: leaveButton
|
||||||
icon.name: "room-leave"
|
icon.name: popup.left ? "room-forget" : "room-leave"
|
||||||
text: inviterId ? qsTr("Decline") : qsTr("Leave")
|
text:
|
||||||
|
popup.left ? qsTr("Forget") :
|
||||||
|
popup.inviterId ? qsTr("Decline") :
|
||||||
|
qsTr("Leave")
|
||||||
|
|
||||||
onClicked: {
|
onClicked:
|
||||||
py.callClientCoro(userId, "room_leave", [roomId], leftCallback)
|
forgetCheck.checked || popup.left ?
|
||||||
popup.close()
|
popup.forget() :
|
||||||
}
|
popup.leave()
|
||||||
}
|
}
|
||||||
|
|
||||||
CancelButton {
|
CancelButton {
|
||||||
|
@ -35,19 +58,34 @@ HFlickableColumnPopup {
|
||||||
|
|
||||||
SummaryLabel {
|
SummaryLabel {
|
||||||
readonly property string roomText:
|
readonly property string roomText:
|
||||||
utils.htmlColorize(roomName, theme.colors.accentText)
|
utils.htmlColorize(popup.roomName, theme.colors.accentText)
|
||||||
|
|
||||||
textFormat: Text.StyledText
|
textFormat: Text.StyledText
|
||||||
text:
|
text:
|
||||||
inviterId ?
|
popup.left ? qsTr("Forget the history for %1?").arg(roomText) :
|
||||||
qsTr("Decline invite to %1?").arg(roomText) :
|
popup.inviterId ? qsTr("Decline invite to %1?").arg(roomText) :
|
||||||
qsTr("Leave %1?").arg(roomText)
|
qsTr("Leave %1?").arg(roomText)
|
||||||
}
|
}
|
||||||
|
|
||||||
DetailsLabel {
|
DetailsLabel {
|
||||||
visible: inviterId === ""
|
text:
|
||||||
text: qsTr(
|
popup.left ?
|
||||||
"If this room is private, you will not be able to rejoin it."
|
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