Skip to content
Snippets Groups Projects
PlaceCall.qml 4.53 KiB
Newer Older
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 {
trilene's avatar
trilene committed
    modal: true
    anchors.centerIn: parent
    background: Rectangle {
        color: colors.window
        border.color: colors.windowText
    }
trilene's avatar
trilene committed
    Component {
        id: deviceError
        DeviceError {
        }
trilene's avatar
trilene committed
    // palette: colors
    // colorize controls correctly
    palette.base:             colors.base
    palette.brightText:       colors.brightText
    palette.button:           colors.button
    palette.buttonText:       colors.buttonText
    palette.dark:             colors.dark
    palette.highlight:        colors.highlight
    palette.highlightedText:  colors.highlightedText
    palette.light:            colors.light
    palette.mid:              colors.mid
    palette.text:             colors.text
    palette.window:           colors.window
    palette.windowText:       colors.windowText

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
            }
        }

        RowLayout {
            id: buttonLayout
trilene's avatar
trilene committed

            Layout.leftMargin: 8
            Layout.rightMargin: 8

            function validateMic() {
                if (CallManager.mics.length == 0) {
trilene's avatar
trilene committed
                    var dialog = deviceError.createObject(timelineRoot, {
                        "errorString": qsTr("No microphone found."),
                        "iconSource": "qrc:/icons/icons/ui/place-call.png"
                    });
                    dialog.open();
trilene's avatar
trilene committed
                    return false;
                }
                return true;
            }

            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
            }

            Button {
                text: qsTr("Voice")
                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")
                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 {
trilene's avatar
trilene committed
                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: "qrc:/icons/icons/ui/microphone-unmute.png"
                }
trilene's avatar
trilene committed
                ComboBox {
                    id: micCombo
                    Layout.fillWidth: true
                    model: CallManager.mics
                }
            }
trilene's avatar
trilene committed
            RowLayout {
trilene's avatar
trilene committed
                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: "qrc:/icons/icons/ui/video-call.png"
                }
trilene's avatar
trilene committed
                ComboBox {
                    id: cameraCombo
                    Layout.fillWidth: true
                    model: CallManager.cameras
                }