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