1// SPDX-FileCopyrightText: 2021 Nheko Contributors
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5import QtQuick 2.9
6import QtQuick.Controls 2.3
7import QtQuick.Layouts 1.2
8import im.nheko 1.0
9
10Popup {
11    modal: true
12    palette: Nheko.colors
13    // only set the anchors on Qt 5.12 or higher
14    // see https://doc.qt.io/qt-5/qml-qtquick-controls2-popup.html#anchors.centerIn-prop
15    Component.onCompleted: {
16        if (anchors)
17            anchors.centerIn = parent;
18
19    }
20
21    ColumnLayout {
22        spacing: 16
23
24        ColumnLayout {
25            spacing: 8
26            Layout.topMargin: 8
27            Layout.leftMargin: 8
28            Layout.rightMargin: 8
29
30            RowLayout {
31                Image {
32                    Layout.preferredWidth: 22
33                    Layout.preferredHeight: 22
34                    source: "image://colorimage/:/icons/icons/ui/microphone-unmute.svg?" + Nheko.colors.windowText
35                }
36
37                ComboBox {
38                    id: micCombo
39
40                    Layout.fillWidth: true
41                    model: CallManager.mics
42                }
43
44            }
45
46            RowLayout {
47                visible: CallManager.callType == CallType.VIDEO && CallManager.cameras.length > 0
48
49                Image {
50                    Layout.preferredWidth: 22
51                    Layout.preferredHeight: 22
52                    source: "image://colorimage/:/icons/icons/ui/video-call.svg?" + Nheko.colors.windowText
53                }
54
55                ComboBox {
56                    id: cameraCombo
57
58                    Layout.fillWidth: true
59                    model: CallManager.cameras
60                }
61
62            }
63
64        }
65
66        DialogButtonBox {
67            Layout.leftMargin: 128
68            standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
69            onAccepted: {
70                Settings.microphone = micCombo.currentText;
71                if (cameraCombo.visible)
72                    Settings.camera = cameraCombo.currentText;
73
74                close();
75            }
76            onRejected: {
77                close();
78            }
79        }
80
81    }
82
83    background: Rectangle {
84        color: Nheko.colors.window
85        border.color: Nheko.colors.windowText
86    }
87
88}
89