nheko/resources/qml/voip/CallInviteBar.qml

134 lines
4.1 KiB
QML
Raw Normal View History

2021-03-05 00:35:15 +01:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
2021-03-05 00:35:15 +01:00
// SPDX-License-Identifier: GPL-3.0-or-later
2020-12-30 21:03:07 +01:00
import "../"
import QtQuick 2.9
2020-12-17 17:25:32 +01:00
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
2020-12-17 17:25:32 +01:00
import im.nheko 1.0
Rectangle {
2021-01-12 20:22:52 +01:00
visible: CallManager.haveCallInvite && !Settings.mobileMode
2020-12-17 17:25:32 +01:00
color: "#2ECC71"
implicitHeight: visible ? rowLayout.height + 8 : 0
2020-12-20 15:37:22 +01:00
Component {
id: devicesDialog
2021-01-11 23:51:39 +01:00
2020-12-20 15:37:22 +01:00
CallDevices {
}
2021-01-11 23:51:39 +01:00
2020-12-20 15:37:22 +01:00
}
2020-12-30 21:03:07 +01:00
Component {
id: deviceError
2021-01-11 23:51:39 +01:00
2020-12-30 21:03:07 +01:00
DeviceError {
}
2021-01-11 23:51:39 +01:00
2020-12-30 21:03:07 +01:00
}
2020-12-17 17:25:32 +01:00
RowLayout {
id: rowLayout
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 8
Avatar {
2021-05-13 11:32:20 +02:00
width: Nheko.avatarSize
height: Nheko.avatarSize
2020-12-17 17:25:32 +01:00
url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/")
2021-09-05 02:54:02 +02:00
userid: CallManager.callParty
displayName: CallManager.callPartyDisplayName
onClicked: TimelineManager.openImageOverlay(room.avatarUrl(userid), room.data.eventId)
2020-12-17 17:25:32 +01:00
}
Label {
2020-12-19 15:32:20 +01:00
Layout.leftMargin: 8
2020-12-17 17:25:32 +01:00
font.pointSize: fontMetrics.font.pointSize * 1.1
2021-09-05 02:54:02 +02:00
text: CallManager.callPartyDisplayName
2020-12-30 21:03:07 +01:00
color: "#000000"
2020-12-17 17:25:32 +01:00
}
Image {
2020-12-19 15:32:20 +01:00
Layout.leftMargin: 4
2020-12-17 17:25:32 +01:00
Layout.preferredWidth: 24
Layout.preferredHeight: 24
2021-11-14 02:23:10 +01:00
source: CallManager.callType == CallType.VIDEO ? "qrc:/icons/icons/ui/video.svg" : "qrc:/icons/icons/ui/place-call.svg"
2020-12-17 17:25:32 +01:00
}
Label {
font.pointSize: fontMetrics.font.pointSize * 1.1
2021-02-18 21:55:29 +01:00
text: CallManager.callType == CallType.VIDEO ? qsTr("Video Call") : qsTr("Voice Call")
2020-12-30 21:03:07 +01:00
color: "#000000"
2020-12-17 17:25:32 +01:00
}
Item {
Layout.fillWidth: true
}
2020-12-20 15:37:22 +01:00
ImageButton {
2020-12-30 21:03:07 +01:00
Layout.rightMargin: 16
width: 20
height: 20
2020-12-20 15:37:22 +01:00
buttonTextColor: "#000000"
2021-11-14 02:23:10 +01:00
image: ":/icons/icons/ui/settings.svg"
2020-12-20 15:37:22 +01:00
hoverEnabled: true
ToolTip.visible: hovered
2020-12-20 16:14:55 +01:00
ToolTip.text: qsTr("Devices")
2020-12-20 15:37:22 +01:00
onClicked: {
2021-01-11 23:51:39 +01:00
var dialog = devicesDialog.createObject(timelineRoot);
dialog.open();
2020-12-20 15:37:22 +01:00
}
}
2020-12-17 17:25:32 +01:00
Button {
2020-12-30 21:03:07 +01:00
Layout.rightMargin: 4
2021-11-14 02:23:10 +01:00
icon.source: CallManager.callType == CallType.VIDEO ? "qrc:/icons/icons/ui/video.svg" : "qrc:/icons/icons/ui/place-call.svg"
2021-01-15 13:57:19 +01:00
text: qsTr("Accept")
2021-05-13 08:23:56 +02:00
palette: Nheko.colors
2020-12-17 17:25:32 +01:00
onClicked: {
if (CallManager.mics.length == 0) {
2020-12-30 21:03:07 +01:00
var dialog = deviceError.createObject(timelineRoot, {
"errorString": qsTr("No microphone found."),
2021-11-14 02:23:10 +01:00
"image": ":/icons/icons/ui/place-call.svg"
2020-12-30 21:03:07 +01:00
});
dialog.open();
2021-01-11 23:51:39 +01:00
return ;
} else if (!CallManager.mics.includes(Settings.microphone)) {
2020-12-30 21:03:07 +01:00
var dialog = deviceError.createObject(timelineRoot, {
2021-01-15 13:57:19 +01:00
"errorString": qsTr("Unknown microphone: %1").arg(Settings.microphone),
2021-11-14 02:23:10 +01:00
"image": ":/icons/icons/ui/place-call.svg"
2020-12-30 21:03:07 +01:00
});
dialog.open();
2021-01-11 23:51:39 +01:00
return ;
2020-12-17 17:25:32 +01:00
}
2021-02-18 21:55:29 +01:00
if (CallManager.callType == CallType.VIDEO && CallManager.cameras.length > 0 && !CallManager.cameras.includes(Settings.camera)) {
2020-12-30 21:03:07 +01:00
var dialog = deviceError.createObject(timelineRoot, {
2021-01-15 13:57:19 +01:00
"errorString": qsTr("Unknown camera: %1").arg(Settings.camera),
2021-11-14 02:23:10 +01:00
"image": ":/icons/icons/ui/video.svg"
2020-12-30 21:03:07 +01:00
});
dialog.open();
2021-01-11 23:51:39 +01:00
return ;
2020-12-17 17:25:32 +01:00
}
CallManager.acceptInvite();
}
}
Button {
2020-12-30 21:03:07 +01:00
Layout.rightMargin: 16
2021-11-14 02:23:10 +01:00
icon.source: "qrc:/icons/icons/ui/end-call.svg"
2021-01-15 13:57:19 +01:00
text: qsTr("Decline")
2021-05-13 08:23:56 +02:00
palette: Nheko.colors
2020-12-17 17:25:32 +01:00
onClicked: {
CallManager.hangUp();
}
}
2021-01-11 23:51:39 +01:00
2020-12-17 17:25:32 +01:00
}
2021-01-11 23:51:39 +01:00
2020-12-17 17:25:32 +01:00
}