Debian Codegraph @

resources/qml/dialogs/JoinRoomDialog.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import ".."
6 import QtQuick 2.12
7 import QtQuick.Controls 2.5
8 import QtQuick.Layouts 1.3
9 import im.nheko 1.0
10
11 ApplicationWindow {
12 id: joinRoomRoot
13
14 title: qsTr("Join room")
15 modality: Qt.WindowModal
16 flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
17 color: palette.window
18 width: 350
19 height: fontMetrics.lineSpacing * 7
20
21 Shortcut {
22 sequence: StandardKey.Cancel
23 onActivated: dbb.rejected()
24 }
25
26 ColumnLayout {
27 spacing: Nheko.paddingMedium
28 anchors.margins: Nheko.paddingMedium
29 anchors.fill: parent
30
31 Label {
32 id: promptLabel
33
34 text: qsTr("Room ID or alias")
35 color: palette.text
36 }
37
38 MatrixTextField {
39 id: input
40
41 focus: true
42 Layout.fillWidth: true
43 onAccepted: {
44 if (input.text.match("#.+?:.{3,}"))
45 dbb.accepted();
46
47 }
48 }
49
50 }
51
52 footer: DialogButtonBox {
53 id: dbb
54
55 standardButtons: DialogButtonBox.Cancel
56 onAccepted: {
57 Nheko.joinRoom(input.text);
58 joinRoomRoot.close();
59 }
60 onRejected: {
61 joinRoomRoot.close();
62 }
63
64 Button {
65 text: qsTr("Join")
66 enabled: input.text.match("#.+?:.{3,}")
67 DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
68 }
69
70 }
71
72 }