2020-09-23 19:57:54 -04:00
|
|
|
// 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
|
2020-07-11 22:52:14 -04:00
|
|
|
import "../Base"
|
|
|
|
import "../Base/Buttons"
|
2019-09-09 09:12:51 -04:00
|
|
|
|
2020-06-25 08:32:08 -04:00
|
|
|
HFlickableColumnPopup {
|
|
|
|
id: popup
|
2019-09-09 09:12:51 -04:00
|
|
|
|
|
|
|
property string userId: ""
|
|
|
|
property string roomId: ""
|
|
|
|
property string roomName: ""
|
2021-04-13 14:44:24 -04:00
|
|
|
property string inviterId: ""
|
2021-04-13 15:38:52 -04:00
|
|
|
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()
|
|
|
|
}
|
2020-06-25 08:32:08 -04:00
|
|
|
|
2020-07-11 22:52:14 -04:00
|
|
|
page.footer: AutoDirectionLayout {
|
2020-06-25 08:32:08 -04:00
|
|
|
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")
|
2020-06-25 08:32:08 -04:00
|
|
|
|
2021-04-13 15:38:52 -04:00
|
|
|
onClicked:
|
|
|
|
forgetCheck.checked || popup.left ?
|
|
|
|
popup.forget() :
|
|
|
|
popup.leave()
|
2020-06-25 08:32:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CancelButton {
|
|
|
|
onClicked: popup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onOpened: leaveButton.forceActiveFocus()
|
|
|
|
|
|
|
|
SummaryLabel {
|
2021-04-13 14:44:24 -04:00
|
|
|
readonly property string roomText:
|
2021-04-13 15:38:52 -04:00
|
|
|
utils.htmlColorize(popup.roomName, theme.colors.accentText)
|
2021-04-13 14:44:24 -04:00
|
|
|
|
2020-06-25 08:32:08 -04:00
|
|
|
textFormat: Text.StyledText
|
2021-04-13 14:44:24 -04:00
|
|
|
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) :
|
2021-04-13 14:44:24 -04:00
|
|
|
qsTr("Leave %1?").arg(roomText)
|
2020-06-25 08:32:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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."
|
2020-06-25 08:32:08 -04:00
|
|
|
)
|
2021-04-13 15:38:52 -04:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2020-06-25 08:32:08 -04:00
|
|
|
}
|
2019-09-09 09:12:51 -04:00
|
|
|
}
|