|
| 1 | +// SPDX-FileCopyrightText: 2021 Nheko Contributors |
| 2 | +// SPDX-FileCopyrightText: 2022 Nheko Contributors |
| 3 | +// |
| 4 | +// SPDX-License-Identifier: GPL-3.0-or-later |
| 5 | + |
| 6 | +import ".." |
| 7 | +import "../ui" |
| 8 | +import Qt.labs.platform 1.1 as Platform |
| 9 | +import QtQuick 2.15 |
| 10 | +import QtQuick.Controls 2.3 |
| 11 | +import QtQuick.Layouts 1.2 |
| 12 | +import QtQuick.Window 2.13 |
| 13 | +import im.nheko 1.0 |
| 14 | + |
| 15 | +ApplicationWindow { |
| 16 | + id: joinRoomRoot |
| 17 | + |
| 18 | + required property RoomSummary summary |
| 19 | + |
| 20 | + title: qsTr("Confirm room join") |
| 21 | + modality: Qt.WindowModal |
| 22 | + flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint |
| 23 | + palette: Nheko.colors |
| 24 | + color: Nheko.colors.window |
| 25 | + width: 350 |
| 26 | + height: content.implicitHeight + Nheko.paddingLarge + footer.implicitHeight |
| 27 | + |
| 28 | + Shortcut { |
| 29 | + sequence: StandardKey.Cancel |
| 30 | + onActivated: dbb.rejected() |
| 31 | + } |
| 32 | + |
| 33 | + ColumnLayout { |
| 34 | + id: content |
| 35 | + spacing: Nheko.paddingMedium |
| 36 | + anchors.margins: Nheko.paddingMedium |
| 37 | + anchors.fill: parent |
| 38 | + |
| 39 | + Avatar { |
| 40 | + Layout.topMargin: Nheko.paddingMedium |
| 41 | + url: summary.roomAvatarUrl.replace("mxc://", "image://MxcImage/") |
| 42 | + roomid: summary.roomid |
| 43 | + displayName: summary.roomName |
| 44 | + height: 130 |
| 45 | + width: 130 |
| 46 | + Layout.alignment: Qt.AlignHCenter |
| 47 | + } |
| 48 | + |
| 49 | + Spinner { |
| 50 | + Layout.alignment: Qt.AlignHCenter |
| 51 | + visible: !summary.isLoaded |
| 52 | + foreground: Nheko.colors.mid |
| 53 | + running: !summary.isLoaded |
| 54 | + } |
| 55 | + |
| 56 | + TextEdit { |
| 57 | + readOnly: true |
| 58 | + textFormat: TextEdit.RichText |
| 59 | + text: summary.roomName |
| 60 | + font.pixelSize: fontMetrics.font.pixelSize * 2 |
| 61 | + color: Nheko.colors.text |
| 62 | + |
| 63 | + Layout.alignment: Qt.AlignHCenter |
| 64 | + Layout.fillWidth: true |
| 65 | + horizontalAlignment: TextEdit.AlignHCenter |
| 66 | + wrapMode: TextEdit.Wrap |
| 67 | + selectByMouse: true |
| 68 | + } |
| 69 | + TextEdit { |
| 70 | + readOnly: true |
| 71 | + textFormat: TextEdit.RichText |
| 72 | + text: summary.roomid |
| 73 | + font.pixelSize: fontMetrics.font.pixelSize * 0.8 |
| 74 | + color: Nheko.colors.text |
| 75 | + |
| 76 | + Layout.alignment: Qt.AlignHCenter |
| 77 | + Layout.fillWidth: true |
| 78 | + horizontalAlignment: TextEdit.AlignHCenter |
| 79 | + wrapMode: TextEdit.Wrap |
| 80 | + selectByMouse: true |
| 81 | + } |
| 82 | + RowLayout { |
| 83 | + spacing: Nheko.paddingMedium |
| 84 | + Layout.alignment: Qt.AlignHCenter |
| 85 | + |
| 86 | + MatrixText { |
| 87 | + text: qsTr("%n member(s)", "", summary.memberCount) |
| 88 | + } |
| 89 | + |
| 90 | + ImageButton { |
| 91 | + image: ":/icons/icons/ui/people.svg" |
| 92 | + enabled: false |
| 93 | + } |
| 94 | + |
| 95 | + } |
| 96 | + TextEdit { |
| 97 | + readOnly: true |
| 98 | + textFormat: TextEdit.RichText |
| 99 | + text: summary.roomTopic |
| 100 | + color: Nheko.colors.text |
| 101 | + |
| 102 | + Layout.alignment: Qt.AlignHCenter |
| 103 | + Layout.fillWidth: true |
| 104 | + horizontalAlignment: TextEdit.AlignHCenter |
| 105 | + wrapMode: TextEdit.Wrap |
| 106 | + selectByMouse: true |
| 107 | + } |
| 108 | + |
| 109 | + Label { |
| 110 | + id: promptLabel |
| 111 | + |
| 112 | + 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:") |
| 113 | + color: Nheko.colors.text |
| 114 | + Layout.fillWidth: true |
| 115 | + horizontalAlignment: Text.AlignHCenter |
| 116 | + wrapMode: Text.Wrap |
| 117 | + font.bold: true |
| 118 | + } |
| 119 | + |
| 120 | + MatrixTextField { |
| 121 | + id: reason |
| 122 | + |
| 123 | + focus: true |
| 124 | + Layout.fillWidth: true |
| 125 | + text: joinRoomRoot.summary.reason |
| 126 | + } |
| 127 | + |
| 128 | + } |
| 129 | + |
| 130 | + footer: DialogButtonBox { |
| 131 | + id: dbb |
| 132 | + |
| 133 | + standardButtons: DialogButtonBox.Cancel |
| 134 | + onAccepted: { |
| 135 | + summary.reason = reason.text; |
| 136 | + summary.join(); |
| 137 | + joinRoomRoot.close(); |
| 138 | + } |
| 139 | + onRejected: { |
| 140 | + joinRoomRoot.close(); |
| 141 | + } |
| 142 | + |
| 143 | + Button { |
| 144 | + text: summary.isKnockOnly ? qsTr("Knock") : qsTr("Join") |
| 145 | + enabled: input.text.match("#.+?:.{3,}") |
| 146 | + DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole |
| 147 | + } |
| 148 | + |
| 149 | + } |
| 150 | + |
| 151 | +} |
0 commit comments