summary refs log tree commit diff
path: root/resources/qml/voip/CallInvite.qml
blob: 8a609c32dbcf842c69177d75f6bba6bda6e98db8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

import "../"
import QtQuick 2.9
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import im.nheko 1.0

Popup {
    id: callInv

    closePolicy: Popup.NoAutoClose
    width: parent.width
    height: parent.height

    Component {
        id: deviceError

        DeviceError {
        }

    }

    Connections {
        function onNewInviteState() {
            if (!CallManager.haveCallInvite)
                close();

        }

        target: CallManager
    }

    ColumnLayout {
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        anchors.horizontalCenter: parent.horizontalCenter

        Label {
            Layout.alignment: Qt.AlignCenter
            Layout.topMargin: callInv.parent.height / 25
            Layout.fillWidth: true
            text: CallManager.callPartyDisplayName
            font.pointSize: fontMetrics.font.pointSize * 2
            color: palette.windowText
            horizontalAlignment: Text.AlignHCenter
        }

        Avatar {
            Layout.alignment: Qt.AlignCenter
            Layout.preferredHeight: callInv.height / 5
            Layout.preferredWidth: callInv.height / 5
            url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/")
            userid: CallManager.callParty
            displayName: CallManager.callPartyDisplayName
        }

        ColumnLayout {
            Layout.alignment: Qt.AlignCenter
            Layout.bottomMargin: callInv.height / 25

            Image {
                property string image: CallManager.callType == Voip.VIDEO ? ":/icons/icons/ui/video.svg" : ":/icons/icons/ui/place-call.svg"

                Layout.alignment: Qt.AlignCenter
                Layout.preferredWidth: callInv.height / 10
                Layout.preferredHeight: callInv.height / 10
                source: "image://colorimage/" + image + "?" + palette.windowText
            }

            Label {
                Layout.alignment: Qt.AlignCenter
                text: CallManager.callType == Voip.VIDEO ? qsTr("Video Call") : qsTr("Voice Call")
                font.pointSize: fontMetrics.font.pointSize * 2
                color: palette.windowText
            }

        }

        ColumnLayout {
            id: deviceCombos

            property int imageSize: callInv.height / 20

            Layout.alignment: Qt.AlignCenter
            Layout.bottomMargin: callInv.height / 25

            RowLayout {
                Layout.alignment: Qt.AlignCenter

                Image {
                    Layout.preferredWidth: deviceCombos.imageSize
                    Layout.preferredHeight: deviceCombos.imageSize
                    source: "image://colorimage/:/icons/icons/ui/microphone-unmute.svg?" + palette.windowText
                }

                ComboBox {
                    id: micCombo

                    Layout.fillWidth: true
                    model: CallManager.mics
                }

            }

            RowLayout {
                visible: CallManager.callType == Voip.VIDEO && CallManager.cameras.length > 0
                Layout.alignment: Qt.AlignCenter

                Image {
                    Layout.preferredWidth: deviceCombos.imageSize
                    Layout.preferredHeight: deviceCombos.imageSize
                    source: "image://colorimage/:/icons/icons/ui/video.svg?" + palette.windowText
                }

                ComboBox {
                    id: cameraCombo

                    Layout.fillWidth: true
                    model: CallManager.cameras
                }

            }

        }

        RowLayout {
            id: buttonLayout

            property int buttonSize: callInv.height / 8

            function validateMic() {
                if (CallManager.mics.length == 0) {
                    var dialog = deviceError.createObject(timelineRoot, {
                        "errorString": qsTr("No microphone found."),
                        "image": ":/icons/icons/ui/place-call.svg"
                    });
                    dialog.open();
                    timelineRoot.destroyOnClose(dialog);
                    return false;
                }
                return true;
            }

            Layout.alignment: Qt.AlignCenter
            spacing: callInv.height / 6

            RoundButton {
                implicitWidth: buttonLayout.buttonSize
                implicitHeight: buttonLayout.buttonSize
                onClicked: {
                    CallManager.rejectInvite();
                    close();
                }

                background: Rectangle {
                    radius: buttonLayout.buttonSize / 2
                    color: "#ff0000"
                }

                contentItem: Image {
                    source: "image://colorimage/:/icons/icons/ui/end-call.svg?#ffffff"
                }

            }

            RoundButton {
                id: acceptButton

                property string image: CallManager.callType == Voip.VIDEO ? ":/icons/icons/ui/video.svg" : ":/icons/icons/ui/place-call.svg"

                implicitWidth: buttonLayout.buttonSize
                implicitHeight: buttonLayout.buttonSize
                onClicked: {
                    if (buttonLayout.validateMic()) {
                        Settings.microphone = micCombo.currentText;
                        if (cameraCombo.visible)
                            Settings.camera = cameraCombo.currentText;

                        CallManager.acceptInvite();
                        close();
                    }
                }

                background: Rectangle {
                    radius: buttonLayout.buttonSize / 2
                    color: "#00ff00"
                }

                contentItem: Image {
                    source: "image://colorimage/" + acceptButton.image + "?#ffffff"
                }

            }

        }

    }

    background: Rectangle {
        color: palette.window
        border.color: palette.windowText
    }

}