Debian Codegraph @

resources/qml/voip/CallInviteBar.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import "../"
6 import QtQuick
7 import QtQuick.Controls
8 import QtQuick.Layouts
9 import im.nheko
10
11 Rectangle {
12 visible: CallManager.haveCallInvite && !Settings.mobileMode
13 color: "#2ECC71"
14 implicitHeight: visible ? rowLayout.height + 8 : 0
15
16 Component {
17 id: devicesDialog
18
19 CallDevices {
20 }
21
22 }
23
24 Component {
25 id: deviceError
26
27 DeviceError {
28 }
29
30 }
31
32 RowLayout {
33 id: rowLayout
34
35 anchors.left: parent.left
36 anchors.right: parent.right
37 anchors.verticalCenter: parent.verticalCenter
38 anchors.leftMargin: 8
39
40 Avatar {
41 implicitWidth: Nheko.avatarSize
42 implicitHeight: Nheko.avatarSize
43 url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/")
44 userid: CallManager.callParty
45 displayName: CallManager.callPartyDisplayName
46 onClicked: TimelineManager.openImageOverlay(room, room.avatarUrl(userid), room.data.eventId)
47 }
48
49 Label {
50 Layout.leftMargin: 8
51 font.pointSize: fontMetrics.font.pointSize * 1.1
52 text: CallManager.callPartyDisplayName
53 color: "#000000"
54 }
55
56 Image {
57 Layout.leftMargin: 4
58 Layout.preferredWidth: 24
59 Layout.preferredHeight: 24
60 source: CallManager.callType == Voip.VIDEO ? "qrc:/icons/icons/ui/video.svg" : "qrc:/icons/icons/ui/place-call.svg"
61 }
62
63 Label {
64 font.pointSize: fontMetrics.font.pointSize * 1.1
65 text: CallManager.callType == Voip.VIDEO ? qsTr("Video Call") : qsTr("Voice Call")
66 color: "#000000"
67 }
68
69 Item {
70 Layout.fillWidth: true
71 }
72
73 ImageButton {
74 Layout.rightMargin: 16
75 Layout.preferredWidth: 20
76 Layout.preferredHeight: 20
77 buttonTextColor: "#000000"
78 image: ":/icons/icons/ui/settings.svg"
79 hoverEnabled: true
80 ToolTip.visible: hovered
81 ToolTip.text: qsTr("Devices")
82 onClicked: {
83 var dialog = devicesDialog.createObject(timelineRoot);
84 dialog.open();
85 timelineRoot.destroyOnClose(dialog);
86 }
87 }
88
89 Button {
90 Layout.rightMargin: 4
91 icon.source: CallManager.callType == Voip.VIDEO ? "qrc:/icons/icons/ui/video.svg" : "qrc:/icons/icons/ui/place-call.svg"
92 text: qsTr("Accept")
93 onClicked: {
94 if (CallManager.mics.length == 0) {
95 var dialog = deviceError.createObject(timelineRoot, {
96 "errorString": qsTr("No microphone found."),
97 "image": ":/icons/icons/ui/place-call.svg"
98 });
99 dialog.open();
100 timelineRoot.destroyOnClose(dialog);
101 return ;
102 } else if (!CallManager.mics.includes(Settings.microphone)) {
103 var dialog = deviceError.createObject(timelineRoot, {
104 "errorString": qsTr("Unknown microphone: %1").arg(Settings.microphone),
105 "image": ":/icons/icons/ui/place-call.svg"
106 });
107 dialog.open();
108 timelineRoot.destroyOnClose(dialog);
109 return ;
110 }
111 if (CallManager.callType == Voip.VIDEO && CallManager.cameras.length > 0 && !CallManager.cameras.includes(Settings.camera)) {
112 var dialog = deviceError.createObject(timelineRoot, {
113 "errorString": qsTr("Unknown camera: %1").arg(Settings.camera),
114 "image": ":/icons/icons/ui/video.svg"
115 });
116 dialog.open();
117 timelineRoot.destroyOnClose(dialog);
118 return ;
119 }
120 CallManager.acceptInvite();
121 }
122 }
123
124 Button {
125 Layout.rightMargin: 16
126 icon.source: "qrc:/icons/icons/ui/end-call.svg"
127 text: qsTr("Decline")
128 onClicked: {
129 CallManager.rejectInvite();
130 }
131 }
132
133 }
134
135 }