Debian Codegraph @

resources/qml/dialogs/ConfirmJoinRoomDialog.qml

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