moment/src/gui/Popups/LeaveRoomPopup.qml

93 lines
2.6 KiB
QML
Raw Normal View History

// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
2019-12-19 07:46:16 -04:00
// SPDX-License-Identifier: LGPL-3.0-or-later
2019-09-09 09:12:51 -04:00
import QtQuick 2.12
2021-04-13 15:38:52 -04:00
import QtQuick.Layouts 1.12
import "../Base"
import "../Base/Buttons"
2019-09-09 09:12:51 -04:00
HFlickableColumnPopup {
id: popup
2019-09-09 09:12:51 -04:00
property string userId: ""
property string roomId: ""
property string roomName: ""
property string inviterId: ""
2021-04-13 15:38:52 -04:00
property bool left: false
property var leftCallback: null
2021-04-13 15:38:52 -04:00
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], leftCallback)
2021-04-13 15:38:52 -04:00
popup.close()
}
page.footer: AutoDirectionLayout {
ApplyButton {
id: leaveButton
2021-04-13 15:38:52 -04:00
icon.name: popup.left ? "room-forget" : "room-leave"
text:
popup.left ? qsTr("Forget") :
popup.inviterId ? qsTr("Decline") :
qsTr("Leave")
2021-04-13 15:38:52 -04:00
onClicked:
forgetCheck.checked || popup.left ?
popup.forget() :
popup.leave()
}
CancelButton {
onClicked: popup.close()
}
}
onOpened: leaveButton.forceActiveFocus()
SummaryLabel {
readonly property string roomText:
2021-04-13 15:38:52 -04:00
utils.htmlColorize(popup.roomName, theme.colors.accentText)
textFormat: Text.StyledText
text:
2021-04-13 15:38:52 -04:00
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 {
2021-04-13 15:38:52 -04:00
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."
)
2021-04-13 15:38:52 -04:00
Layout.fillWidth: true
}
2019-09-09 09:12:51 -04:00
}