matrixion/resources/qml/voip/CallInviteBar.qml

127 lines
4.3 KiB
QML
Raw Normal View History

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