Skip to content
Snippets Groups Projects
PlaceCall.qml 4.18 KiB
Newer Older
  • Learn to ignore specific revisions
  • trilene's avatar
    trilene committed
    import "../"
    import QtQuick 2.9
    
    trilene's avatar
    trilene committed
    import QtQuick.Controls 2.3
    import QtQuick.Layouts 1.2
    import im.nheko 1.0
    
    
    trilene's avatar
    trilene committed
    Popup {
        modal: true
        anchors.centerIn: parent
    
        palette: colors
    
    trilene's avatar
    trilene committed
        Component {
            id: deviceError
    
    trilene's avatar
    trilene committed
            DeviceError {
            }
    
    trilene's avatar
    trilene committed
        }
    
        ColumnLayout {
            id: columnLayout
    
    trilene's avatar
    trilene committed
            spacing: 16
    
            RowLayout {
    
    trilene's avatar
    trilene committed
                Layout.topMargin: 8
    
    trilene's avatar
    trilene committed
                Layout.leftMargin: 8
    
                Label {
    
                    text: qsTr("Place a call to ") + TimelineManager.timeline.roomName + "?"
    
    trilene's avatar
    trilene committed
                    color: colors.windowText
    
    trilene's avatar
    trilene committed
                }
    
                Item {
                    Layout.fillWidth: true
                }
    
    trilene's avatar
    trilene committed
            }
    
            RowLayout {
    
                id: buttonLayout
    
    trilene's avatar
    trilene committed
    
                function validateMic() {
                    if (CallManager.mics.length == 0) {
    
    trilene's avatar
    trilene committed
                        var dialog = deviceError.createObject(timelineRoot, {
                            "errorString": qsTr("No microphone found."),
    
                            "image": ":/icons/icons/ui/place-call.png"
    
    trilene's avatar
    trilene committed
                        });
                        dialog.open();
    
    trilene's avatar
    trilene committed
                        return false;
                    }
                    return true;
                }
    
    
                Layout.leftMargin: 8
                Layout.rightMargin: 8
    
    
    trilene's avatar
    trilene committed
                Avatar {
    
    trilene's avatar
    trilene committed
                    Layout.rightMargin: cameraCombo.visible ? 16 : 64
    
    trilene's avatar
    trilene committed
                    width: avatarSize
                    height: avatarSize
                    url: TimelineManager.timeline.roomAvatarUrl.replace("mxc://", "image://MxcImage/")
                    displayName: TimelineManager.timeline.roomName
    
                    onClicked: TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id)
    
    trilene's avatar
    trilene committed
                }
    
                Button {
    
                    text: qsTr(" Voice ")
    
    trilene's avatar
    trilene committed
                    icon.source: "qrc:/icons/icons/ui/place-call.png"
                    onClicked: {
    
                        if (buttonLayout.validateMic()) {
    
                            Settings.microphone = micCombo.currentText;
    
    trilene's avatar
    trilene committed
                            CallManager.sendInvite(TimelineManager.timeline.roomId(), false);
                            close();
                        }
                    }
                }
    
                Button {
                    visible: CallManager.cameras.length > 0
    
                    text: qsTr(" Video ")
    
    trilene's avatar
    trilene committed
                    icon.source: "qrc:/icons/icons/ui/video-call.png"
                    onClicked: {
    
                        if (buttonLayout.validateMic()) {
    
                            Settings.microphone = micCombo.currentText;
                            Settings.camera = cameraCombo.currentText;
    
    trilene's avatar
    trilene committed
                            CallManager.sendInvite(TimelineManager.timeline.roomId(), true);
                            close();
                        }
                    }
                }
    
                Button {
                    text: qsTr("Cancel")
                    onClicked: {
                        close();
                    }
                }
    
    trilene's avatar
    trilene committed
            ColumnLayout {
                spacing: 8
    
    trilene's avatar
    trilene committed
                RowLayout {
                    Layout.leftMargin: 8
                    Layout.rightMargin: 8
    
    trilene's avatar
    trilene committed
                    Layout.bottomMargin: cameraCombo.visible ? 0 : 8
    
    trilene's avatar
    trilene committed
                    Image {
                        Layout.preferredWidth: 22
                        Layout.preferredHeight: 22
    
                        source: "image://colorimage/:/icons/icons/ui/microphone-unmute.png?" + colors.windowText
    
    trilene's avatar
    trilene committed
                    }
    
    trilene's avatar
    trilene committed
                    ComboBox {
                        id: micCombo
    
    trilene's avatar
    trilene committed
                        Layout.fillWidth: true
                        model: CallManager.mics
                    }
    
    trilene's avatar
    trilene committed
                }
    
    trilene's avatar
    trilene committed
                RowLayout {
                    visible: CallManager.cameras.length > 0
                    Layout.leftMargin: 8
                    Layout.rightMargin: 8
    
    trilene's avatar
    trilene committed
                    Layout.bottomMargin: 8
    
    trilene's avatar
    trilene committed
    
                    Image {
                        Layout.preferredWidth: 22
                        Layout.preferredHeight: 22
    
                        source: "image://colorimage/:/icons/icons/ui/video-call.png?" + colors.windowText
    
    trilene's avatar
    trilene committed
                    }
    
    trilene's avatar
    trilene committed
                    ComboBox {
                        id: cameraCombo
    
    trilene's avatar
    trilene committed
                        Layout.fillWidth: true
                        model: CallManager.cameras
                    }
    
    
        background: Rectangle {
            color: colors.window
            border.color: colors.windowText
        }