matrixion/resources/qml/dialogs/ConfirmJoinRoomDialog.qml

139 lines
4.2 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
import ".."
import "../ui"
import QtQuick 2.15
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import QtQuick.Window 2.13
import im.nheko 1.0
ApplicationWindow {
id: joinRoomRoot
required property RoomSummary summary
color: palette.window
2023-10-31 05:11:03 +03:00
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
height: content.implicitHeight + Nheko.paddingLarge + footer.implicitHeight
2023-10-31 05:11:03 +03:00
modality: Qt.WindowModal
title: summary.isSpace ? qsTr("Confirm community join") : qsTr("Confirm room join")
width: 350
footer: DialogButtonBox {
id: dbb
standardButtons: DialogButtonBox.Cancel
onAccepted: {
summary.reason = reason.text;
summary.join();
joinRoomRoot.close();
}
onRejected: {
joinRoomRoot.close();
}
Button {
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
enabled: input.text.match("#.+?:.{3,}")
text: summary.isKnockOnly ? qsTr("Knock") : qsTr("Join")
}
}
Shortcut {
sequence: StandardKey.Cancel
2023-10-31 05:11:03 +03:00
onActivated: dbb.rejected()
}
ColumnLayout {
id: content
2023-10-31 05:11:03 +03:00
anchors.fill: parent
2023-10-31 05:11:03 +03:00
anchors.margins: Nheko.paddingMedium
spacing: Nheko.paddingMedium
Avatar {
2023-10-31 05:11:03 +03:00
Layout.alignment: Qt.AlignHCenter
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 130
Layout.preferredWidth: 130
2023-10-31 05:11:03 +03:00
Layout.topMargin: Nheko.paddingMedium
displayName: summary.roomName
roomid: summary.roomid
url: summary.roomAvatarUrl.replace("mxc://", "image://MxcImage/")
}
Spinner {
Layout.alignment: Qt.AlignHCenter
foreground: palette.mid
running: !summary.isLoaded
2023-10-31 05:11:03 +03:00
visible: !summary.isLoaded
}
TextEdit {
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
color: palette.text
font.pixelSize: fontMetrics.font.pixelSize * 2
horizontalAlignment: TextEdit.AlignHCenter
2023-10-31 05:11:03 +03:00
readOnly: true
selectByMouse: true
2023-10-31 05:11:03 +03:00
text: summary.roomName
textFormat: TextEdit.RichText
wrapMode: TextEdit.Wrap
}
TextEdit {
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
color: palette.text
font.pixelSize: fontMetrics.font.pixelSize * 0.8
horizontalAlignment: TextEdit.AlignHCenter
2023-10-31 05:11:03 +03:00
readOnly: true
selectByMouse: true
2023-10-31 05:11:03 +03:00
text: summary.roomid
textFormat: TextEdit.RichText
wrapMode: TextEdit.Wrap
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
2023-10-31 05:11:03 +03:00
spacing: Nheko.paddingMedium
MatrixText {
text: qsTr("%n member(s)", "", summary.memberCount)
}
ImageButton {
enabled: false
2023-10-31 05:11:03 +03:00
image: ":/icons/icons/ui/people.svg"
}
}
TextEdit {
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
color: palette.text
horizontalAlignment: TextEdit.AlignHCenter
2023-10-31 05:11:03 +03:00
readOnly: true
selectByMouse: true
2023-10-31 05:11:03 +03:00
text: summary.roomTopic
textFormat: TextEdit.RichText
wrapMode: TextEdit.Wrap
}
Label {
id: promptLabel
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
color: palette.text
font.bold: true
horizontalAlignment: Text.AlignHCenter
2023-10-31 05:11:03 +03:00
text: summary.isKnockOnly ? qsTr("This room can't be joined directly. You can, however, knock on the room and room members can accept or decline this join request. You can additionally provide a reason for them to let you in below:") : qsTr("Do you want to join this room? You can optionally add a reason below:")
wrapMode: Text.Wrap
}
MatrixTextField {
id: reason
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
focus: true
text: joinRoomRoot.summary.reason
}
}
}