mirror of https://github.com/Nheko-Reborn/nheko
commit
49abcb24b5
@ -0,0 +1,79 @@ |
|||||||
|
import QtQuick 2.9 |
||||||
|
import QtQuick.Controls 2.3 |
||||||
|
import QtQuick.Layouts 1.2 |
||||||
|
import im.nheko 1.0 |
||||||
|
|
||||||
|
Popup { |
||||||
|
|
||||||
|
modal: true |
||||||
|
anchors.centerIn: parent |
||||||
|
background: Rectangle { |
||||||
|
color: colors.window |
||||||
|
border.color: colors.windowText |
||||||
|
} |
||||||
|
|
||||||
|
palette: colors |
||||||
|
|
||||||
|
ColumnLayout { |
||||||
|
|
||||||
|
spacing: 16 |
||||||
|
|
||||||
|
ColumnLayout { |
||||||
|
spacing: 8 |
||||||
|
|
||||||
|
Layout.topMargin: 8 |
||||||
|
Layout.leftMargin: 8 |
||||||
|
Layout.rightMargin: 8 |
||||||
|
|
||||||
|
RowLayout { |
||||||
|
|
||||||
|
Image { |
||||||
|
Layout.preferredWidth: 22 |
||||||
|
Layout.preferredHeight: 22 |
||||||
|
source: "image://colorimage/:/icons/icons/ui/microphone-unmute.png?" + colors.windowText |
||||||
|
} |
||||||
|
|
||||||
|
ComboBox { |
||||||
|
id: micCombo |
||||||
|
Layout.fillWidth: true |
||||||
|
model: CallManager.mics |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
RowLayout { |
||||||
|
|
||||||
|
visible: CallManager.isVideo && CallManager.cameras.length > 0 |
||||||
|
|
||||||
|
Image { |
||||||
|
Layout.preferredWidth: 22 |
||||||
|
Layout.preferredHeight: 22 |
||||||
|
source: "image://colorimage/:/icons/icons/ui/video-call.png?" + colors.windowText |
||||||
|
} |
||||||
|
|
||||||
|
ComboBox { |
||||||
|
id: cameraCombo |
||||||
|
Layout.fillWidth: true |
||||||
|
model: CallManager.cameras |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
DialogButtonBox { |
||||||
|
|
||||||
|
Layout.leftMargin: 128 |
||||||
|
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel |
||||||
|
|
||||||
|
onAccepted: { |
||||||
|
Settings.microphone = micCombo.currentText |
||||||
|
if (cameraCombo.visible) { |
||||||
|
Settings.camera = cameraCombo.currentText |
||||||
|
} |
||||||
|
close(); |
||||||
|
} |
||||||
|
|
||||||
|
onRejected: { |
||||||
|
close(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,126 @@ |
|||||||
|
import "../" |
||||||
|
import QtQuick 2.9 |
||||||
|
import QtQuick.Controls 2.3 |
||||||
|
import QtQuick.Layouts 1.2 |
||||||
|
import im.nheko 1.0 |
||||||
|
|
||||||
|
Rectangle { |
||||||
|
|
||||||
|
visible: CallManager.haveCallInvite |
||||||
|
color: "#2ECC71" |
||||||
|
implicitHeight: visible ? rowLayout.height + 8 : 0 |
||||||
|
|
||||||
|
Component { |
||||||
|
id: devicesDialog |
||||||
|
CallDevices { |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Component { |
||||||
|
id: deviceError |
||||||
|
DeviceError { |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
RowLayout { |
||||||
|
id: rowLayout |
||||||
|
|
||||||
|
anchors.left: parent.left |
||||||
|
anchors.right: parent.right |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
anchors.leftMargin: 8 |
||||||
|
|
||||||
|
Avatar { |
||||||
|
width: avatarSize |
||||||
|
height: avatarSize |
||||||
|
url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/") |
||||||
|
displayName: CallManager.callParty |
||||||
|
} |
||||||
|
|
||||||
|
Label { |
||||||
|
Layout.leftMargin: 8 |
||||||
|
font.pointSize: fontMetrics.font.pointSize * 1.1 |
||||||
|
text: CallManager.callParty |
||||||
|
color: "#000000" |
||||||
|
} |
||||||
|
|
||||||
|
Image { |
||||||
|
Layout.leftMargin: 4 |
||||||
|
Layout.preferredWidth: 24 |
||||||
|
Layout.preferredHeight: 24 |
||||||
|
source: CallManager.isVideo ? "qrc:/icons/icons/ui/video-call.png" : "qrc:/icons/icons/ui/place-call.png" |
||||||
|
} |
||||||
|
|
||||||
|
Label { |
||||||
|
font.pointSize: fontMetrics.font.pointSize * 1.1 |
||||||
|
text: CallManager.isVideo ? qsTr("Video Call") : qsTr("Voice Call") |
||||||
|
color: "#000000" |
||||||
|
} |
||||||
|
|
||||||
|
Item { |
||||||
|
Layout.fillWidth: true |
||||||
|
} |
||||||
|
|
||||||
|
ImageButton { |
||||||
|
Layout.rightMargin: 16 |
||||||
|
width: 20 |
||||||
|
height: 20 |
||||||
|
buttonTextColor: "#000000" |
||||||
|
image: ":/icons/icons/ui/settings.png" |
||||||
|
hoverEnabled: true |
||||||
|
ToolTip.visible: hovered |
||||||
|
ToolTip.text: qsTr("Devices") |
||||||
|
onClicked: { |
||||||
|
CallManager.refreshDevices(); |
||||||
|
var dialog = devicesDialog.createObject(timelineRoot); |
||||||
|
dialog.open(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Button { |
||||||
|
Layout.rightMargin: 4 |
||||||
|
icon.source: CallManager.isVideo ? "qrc:/icons/icons/ui/video-call.png" : "qrc:/icons/icons/ui/place-call.png" |
||||||
|
text: qsTr(" Accept ") |
||||||
|
palette: colors |
||||||
|
|
||||||
|
onClicked: { |
||||||
|
if (CallManager.mics.length == 0) { |
||||||
|
var dialog = deviceError.createObject(timelineRoot, { |
||||||
|
"errorString": qsTr("No microphone found."), |
||||||
|
"image": ":/icons/icons/ui/place-call.png" |
||||||
|
}); |
||||||
|
dialog.open(); |
||||||
|
return; |
||||||
|
} |
||||||
|
else if (!CallManager.mics.includes(Settings.microphone)) { |
||||||
|
var dialog = deviceError.createObject(timelineRoot, { |
||||||
|
"errorString": qsTr("Unknown microphone: ") + Settings.microphone, |
||||||
|
"image": ":/icons/icons/ui/place-call.png" |
||||||
|
}); |
||||||
|
dialog.open(); |
||||||
|
return; |
||||||
|
} |
||||||
|
if (CallManager.isVideo && CallManager.cameras.length > 0 && !CallManager.cameras.includes(Settings.camera)) { |
||||||
|
var dialog = deviceError.createObject(timelineRoot, { |
||||||
|
"errorString": qsTr("Unknown camera: ") + Settings.camera, |
||||||
|
"image": ":/icons/icons/ui/video-call.png" |
||||||
|
}); |
||||||
|
dialog.open(); |
||||||
|
return; |
||||||
|
} |
||||||
|
CallManager.acceptInvite(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Button { |
||||||
|
Layout.rightMargin: 16 |
||||||
|
icon.source: "qrc:/icons/icons/ui/end-call.png" |
||||||
|
text: qsTr(" Decline ") |
||||||
|
palette: colors |
||||||
|
|
||||||
|
onClicked: { |
||||||
|
CallManager.hangUp(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
import QtQuick 2.9 |
||||||
|
import QtQuick.Controls 2.3 |
||||||
|
import QtQuick.Layouts 1.2 |
||||||
|
import im.nheko 1.0 |
||||||
|
|
||||||
|
Popup { |
||||||
|
|
||||||
|
property string errorString |
||||||
|
property var image |
||||||
|
|
||||||
|
modal: true |
||||||
|
anchors.centerIn: parent |
||||||
|
background: Rectangle { |
||||||
|
color: colors.window |
||||||
|
border.color: colors.windowText |
||||||
|
} |
||||||
|
|
||||||
|
RowLayout { |
||||||
|
|
||||||
|
Image { |
||||||
|
Layout.preferredWidth: 16 |
||||||
|
Layout.preferredHeight: 16 |
||||||
|
source: "image://colorimage/" + image + "?" + colors.windowText |
||||||
|
} |
||||||
|
|
||||||
|
Label { |
||||||
|
text: errorString |
||||||
|
color: colors.windowText |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,146 @@ |
|||||||
|
import "../" |
||||||
|
import QtQuick 2.9 |
||||||
|
import QtQuick.Controls 2.3 |
||||||
|
import QtQuick.Layouts 1.2 |
||||||
|
import im.nheko 1.0 |
||||||
|
|
||||||
|
Popup { |
||||||
|
|
||||||
|
modal: true |
||||||
|
anchors.centerIn: parent |
||||||
|
palette: colors |
||||||
|
background: Rectangle { |
||||||
|
color: colors.window |
||||||
|
border.color: colors.windowText |
||||||
|
} |
||||||
|
|
||||||
|
Component { |
||||||
|
id: deviceError |
||||||
|
DeviceError { |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ColumnLayout { |
||||||
|
id: columnLayout |
||||||
|
|
||||||
|
spacing: 16 |
||||||
|
|
||||||
|
RowLayout { |
||||||
|
|
||||||
|
Layout.topMargin: 8 |
||||||
|
Layout.leftMargin: 8 |
||||||
|
|
||||||
|
Label { |
||||||
|
text: qsTr("Place a call to ") + TimelineManager.timeline.roomName + "?" |
||||||
|
color: colors.windowText |
||||||
|
} |
||||||
|
|
||||||
|
Item { |
||||||
|
Layout.fillWidth: true |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
RowLayout { |
||||||
|
id: buttonLayout |
||||||
|
|
||||||
|
Layout.leftMargin: 8 |
||||||
|
Layout.rightMargin: 8 |
||||||
|
|
||||||
|
function validateMic() { |
||||||
|
if (CallManager.mics.length == 0) { |
||||||
|
var dialog = deviceError.createObject(timelineRoot, { |
||||||
|
"errorString": qsTr("No microphone found."), |
||||||
|
"image": ":/icons/icons/ui/place-call.png" |
||||||
|
}); |
||||||
|
dialog.open(); |
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
Avatar { |
||||||
|
Layout.rightMargin: cameraCombo.visible ? 16 : 64 |
||||||
|
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 |
||||||
|
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 |
||||||
|
CallManager.sendInvite(TimelineManager.timeline.roomId(), true); |
||||||
|
close(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Button { |
||||||
|
text: qsTr("Cancel") |
||||||
|
onClicked: { |
||||||
|
close(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ColumnLayout { |
||||||
|
spacing: 8 |
||||||
|
|
||||||
|
RowLayout { |
||||||
|
|
||||||
|
Layout.leftMargin: 8 |
||||||
|
Layout.rightMargin: 8 |
||||||
|
Layout.bottomMargin: cameraCombo.visible ? 0 : 8 |
||||||
|
|
||||||
|
Image { |
||||||
|
Layout.preferredWidth: 22 |
||||||
|
Layout.preferredHeight: 22 |
||||||
|
source: "image://colorimage/:/icons/icons/ui/microphone-unmute.png?" + colors.windowText |
||||||
|
} |
||||||
|
|
||||||
|
ComboBox { |
||||||
|
id: micCombo |
||||||
|
Layout.fillWidth: true |
||||||
|
model: CallManager.mics |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
RowLayout { |
||||||
|
|
||||||
|
visible: CallManager.cameras.length > 0 |
||||||
|
Layout.leftMargin: 8 |
||||||
|
Layout.rightMargin: 8 |
||||||
|
Layout.bottomMargin: 8 |
||||||
|
|
||||||
|
Image { |
||||||
|
Layout.preferredWidth: 22 |
||||||
|
Layout.preferredHeight: 22 |
||||||
|
source: "image://colorimage/:/icons/icons/ui/video-call.png?" + colors.windowText |
||||||
|
} |
||||||
|
|
||||||
|
ComboBox { |
||||||
|
id: cameraCombo |
||||||
|
Layout.fillWidth: true |
||||||
|
model: CallManager.cameras |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,152 +0,0 @@ |
|||||||
#include <QComboBox> |
|
||||||
#include <QLabel> |
|
||||||
#include <QPushButton> |
|
||||||
#include <QString> |
|
||||||
#include <QVBoxLayout> |
|
||||||
|
|
||||||
#include "ChatPage.h" |
|
||||||
#include "Config.h" |
|
||||||
#include "UserSettingsPage.h" |
|
||||||
#include "Utils.h" |
|
||||||
#include "WebRTCSession.h" |
|
||||||
#include "dialogs/AcceptCall.h" |
|
||||||
#include "ui/Avatar.h" |
|
||||||
|
|
||||||
namespace dialogs { |
|
||||||
|
|
||||||
AcceptCall::AcceptCall(const QString &caller, |
|
||||||
const QString &displayName, |
|
||||||
const QString &roomName, |
|
||||||
const QString &avatarUrl, |
|
||||||
bool isVideo, |
|
||||||
QWidget *parent) |
|
||||||
: QWidget(parent) |
|
||||||
{ |
|
||||||
std::string errorMessage; |
|
||||||
WebRTCSession *session = &WebRTCSession::instance(); |
|
||||||
if (!session->havePlugins(false, &errorMessage)) { |
|
||||||
emit ChatPage::instance()->showNotification(QString::fromStdString(errorMessage)); |
|
||||||
emit close(); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (isVideo && !session->havePlugins(true, &errorMessage)) { |
|
||||||
emit ChatPage::instance()->showNotification(QString::fromStdString(errorMessage)); |
|
||||||
emit close(); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
session->refreshDevices(); |
|
||||||
microphones_ = session->getDeviceNames( |
|
||||||
false, ChatPage::instance()->userSettings()->microphone().toStdString()); |
|
||||||
if (microphones_.empty()) { |
|
||||||
emit ChatPage::instance()->showNotification( |
|
||||||
tr("Incoming call: No microphone found.")); |
|
||||||
emit close(); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (isVideo) |
|
||||||
cameras_ = session->getDeviceNames( |
|
||||||
true, ChatPage::instance()->userSettings()->camera().toStdString()); |
|
||||||
|
|
||||||
setAutoFillBackground(true); |
|
||||||
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); |
|
||||||
setWindowModality(Qt::WindowModal); |
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true); |
|
||||||
|
|
||||||
setMinimumWidth(conf::modals::MIN_WIDGET_WIDTH); |
|
||||||
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); |
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this); |
|
||||||
layout->setSpacing(conf::modals::WIDGET_SPACING); |
|
||||||
layout->setMargin(conf::modals::WIDGET_MARGIN); |
|
||||||
|
|
||||||
QFont f; |
|
||||||
f.setPointSizeF(f.pointSizeF()); |
|
||||||
|
|
||||||
QFont labelFont; |
|
||||||
labelFont.setWeight(QFont::Medium); |
|
||||||
|
|
||||||
QLabel *displayNameLabel = nullptr; |
|
||||||
if (!displayName.isEmpty() && displayName != caller) { |
|
||||||
displayNameLabel = new QLabel(displayName, this); |
|
||||||
labelFont.setPointSizeF(f.pointSizeF() * 2); |
|
||||||
displayNameLabel->setFont(labelFont); |
|
||||||
displayNameLabel->setAlignment(Qt::AlignCenter); |
|
||||||
} |
|
||||||
|
|
||||||
QLabel *callerLabel = new QLabel(caller, this); |
|
||||||
labelFont.setPointSizeF(f.pointSizeF() * 1.2); |
|
||||||
callerLabel->setFont(labelFont); |
|
||||||
callerLabel->setAlignment(Qt::AlignCenter); |
|
||||||
|
|
||||||
auto avatar = new Avatar(this, QFontMetrics(f).height() * 6); |
|
||||||
if (!avatarUrl.isEmpty()) |
|
||||||
avatar->setImage(avatarUrl); |
|
||||||
else |
|
||||||
avatar->setLetter(utils::firstChar(roomName)); |
|
||||||
|
|
||||||
const int iconSize = 22; |
|
||||||
QLabel *callTypeIndicator = new QLabel(this); |
|
||||||
callTypeIndicator->setPixmap( |
|
||||||
QIcon(isVideo ? ":/icons/icons/ui/video-call.png" : ":/icons/icons/ui/place-call.png") |
|
||||||
.pixmap(QSize(iconSize * 2, iconSize * 2))); |
|
||||||
|
|
||||||
QLabel *callTypeLabel = new QLabel(isVideo ? tr("Video Call") : tr("Voice Call"), this); |
|
||||||
labelFont.setPointSizeF(f.pointSizeF() * 1.1); |
|
||||||
callTypeLabel->setFont(labelFont); |
|
||||||
callTypeLabel->setAlignment(Qt::AlignCenter); |
|
||||||
|
|
||||||
auto buttonLayout = new QHBoxLayout; |
|
||||||
buttonLayout->setSpacing(18); |
|
||||||
acceptBtn_ = new QPushButton(tr("Accept"), this); |
|
||||||
acceptBtn_->setDefault(true); |
|
||||||
acceptBtn_->setIcon( |
|
||||||
QIcon(isVideo ? ":/icons/icons/ui/video-call.png" : ":/icons/icons/ui/place-call.png")); |
|
||||||
acceptBtn_->setIconSize(QSize(iconSize, iconSize)); |
|
||||||
|
|
||||||
rejectBtn_ = new QPushButton(tr("Reject"), this); |
|
||||||
rejectBtn_->setIcon(QIcon(":/icons/icons/ui/end-call.png")); |
|
||||||
rejectBtn_->setIconSize(QSize(iconSize, iconSize)); |
|
||||||
buttonLayout->addWidget(acceptBtn_); |
|
||||||
buttonLayout->addWidget(rejectBtn_); |
|
||||||
|
|
||||||
microphoneCombo_ = new QComboBox(this); |
|
||||||
for (const auto &m : microphones_) |
|
||||||
microphoneCombo_->addItem(QIcon(":/icons/icons/ui/microphone-unmute.png"), |
|
||||||
QString::fromStdString(m)); |
|
||||||
|
|
||||||
if (!cameras_.empty()) { |
|
||||||
cameraCombo_ = new QComboBox(this); |
|
||||||
for (const auto &c : cameras_) |
|
||||||
cameraCombo_->addItem(QIcon(":/icons/icons/ui/video-call.png"), |
|
||||||
QString::fromStdString(c)); |
|
||||||
} |
|
||||||
|
|
||||||
if (displayNameLabel) |
|
||||||
layout->addWidget(displayNameLabel, 0, Qt::AlignCenter); |
|
||||||
layout->addWidget(callerLabel, 0, Qt::AlignCenter); |
|
||||||
layout->addWidget(avatar, 0, Qt::AlignCenter); |
|
||||||
layout->addWidget(callTypeIndicator, 0, Qt::AlignCenter); |
|
||||||
layout->addWidget(callTypeLabel, 0, Qt::AlignCenter); |
|
||||||
layout->addLayout(buttonLayout); |
|
||||||
layout->addWidget(microphoneCombo_); |
|
||||||
if (cameraCombo_) |
|
||||||
layout->addWidget(cameraCombo_); |
|
||||||
|
|
||||||
connect(acceptBtn_, &QPushButton::clicked, this, [this]() { |
|
||||||
ChatPage::instance()->userSettings()->setMicrophone( |
|
||||||
QString::fromStdString(microphones_[microphoneCombo_->currentIndex()])); |
|
||||||
if (cameraCombo_) { |
|
||||||
ChatPage::instance()->userSettings()->setCamera( |
|
||||||
QString::fromStdString(cameras_[cameraCombo_->currentIndex()])); |
|
||||||
} |
|
||||||
emit accept(); |
|
||||||
emit close(); |
|
||||||
}); |
|
||||||
connect(rejectBtn_, &QPushButton::clicked, this, [this]() { |
|
||||||
emit reject(); |
|
||||||
emit close(); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,39 +0,0 @@ |
|||||||
#pragma once |
|
||||||
|
|
||||||
#include <string> |
|
||||||
#include <vector> |
|
||||||
|
|
||||||
#include <QWidget> |
|
||||||
|
|
||||||
class QComboBox; |
|
||||||
class QPushButton; |
|
||||||
class QString; |
|
||||||
|
|
||||||
namespace dialogs { |
|
||||||
|
|
||||||
class AcceptCall : public QWidget |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
|
|
||||||
public: |
|
||||||
AcceptCall(const QString &caller, |
|
||||||
const QString &displayName, |
|
||||||
const QString &roomName, |
|
||||||
const QString &avatarUrl, |
|
||||||
bool isVideo, |
|
||||||
QWidget *parent = nullptr); |
|
||||||
|
|
||||||
signals: |
|
||||||
void accept(); |
|
||||||
void reject(); |
|
||||||
|
|
||||||
private: |
|
||||||
QPushButton *acceptBtn_ = nullptr; |
|
||||||
QPushButton *rejectBtn_ = nullptr; |
|
||||||
QComboBox *microphoneCombo_ = nullptr; |
|
||||||
QComboBox *cameraCombo_ = nullptr; |
|
||||||
std::vector<std::string> microphones_; |
|
||||||
std::vector<std::string> cameras_; |
|
||||||
}; |
|
||||||
|
|
||||||
} |
|
@ -1,131 +0,0 @@ |
|||||||
#include <QComboBox> |
|
||||||
#include <QLabel> |
|
||||||
#include <QPushButton> |
|
||||||
#include <QString> |
|
||||||
#include <QVBoxLayout> |
|
||||||
|
|
||||||
#include "ChatPage.h" |
|
||||||
#include "Config.h" |
|
||||||
#include "UserSettingsPage.h" |
|
||||||
#include "Utils.h" |
|
||||||
#include "WebRTCSession.h" |
|
||||||
#include "dialogs/PlaceCall.h" |
|
||||||
#include "ui/Avatar.h" |
|
||||||
|
|
||||||
namespace dialogs { |
|
||||||
|
|
||||||
PlaceCall::PlaceCall(const QString &callee, |
|
||||||
const QString &displayName, |
|
||||||
const QString &roomName, |
|
||||||
const QString &avatarUrl, |
|
||||||
QSharedPointer<UserSettings> settings, |
|
||||||
QWidget *parent) |
|
||||||
: QWidget(parent) |
|
||||||
{ |
|
||||||
std::string errorMessage; |
|
||||||
WebRTCSession *session = &WebRTCSession::instance(); |
|
||||||
if (!session->havePlugins(false, &errorMessage)) { |
|
||||||
emit ChatPage::instance()->showNotification(QString::fromStdString(errorMessage)); |
|
||||||
emit close(); |
|
||||||
return; |
|
||||||
} |
|
||||||
session->refreshDevices(); |
|
||||||
microphones_ = session->getDeviceNames(false, settings->microphone().toStdString()); |
|
||||||
if (microphones_.empty()) { |
|
||||||
emit ChatPage::instance()->showNotification(tr("No microphone found.")); |
|
||||||
emit close(); |
|
||||||
return; |
|
||||||
} |
|
||||||
cameras_ = session->getDeviceNames(true, settings->camera().toStdString()); |
|
||||||
|
|
||||||
setAutoFillBackground(true); |
|
||||||
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); |
|
||||||
setWindowModality(Qt::WindowModal); |
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true); |
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this); |
|
||||||
layout->setSpacing(conf::modals::WIDGET_SPACING); |
|
||||||
layout->setMargin(conf::modals::WIDGET_MARGIN); |
|
||||||
|
|
||||||
auto buttonLayout = new QHBoxLayout; |
|
||||||
buttonLayout->setSpacing(15); |
|
||||||
buttonLayout->setMargin(0); |
|
||||||
|
|
||||||
QFont f; |
|
||||||
f.setPointSizeF(f.pointSizeF()); |
|
||||||
auto avatar = new Avatar(this, QFontMetrics(f).height() * 3); |
|
||||||
if (!avatarUrl.isEmpty()) |
|
||||||
avatar->setImage(avatarUrl); |
|
||||||
else |
|
||||||
avatar->setLetter(utils::firstChar(roomName)); |
|
||||||
|
|
||||||
voiceBtn_ = new QPushButton(tr("Voice"), this); |
|
||||||
voiceBtn_->setIcon(QIcon(":/icons/icons/ui/place-call.png")); |
|
||||||
voiceBtn_->setIconSize(QSize(iconSize_, iconSize_)); |
|
||||||
voiceBtn_->setDefault(true); |
|
||||||
|
|
||||||
if (!cameras_.empty()) { |
|
||||||
videoBtn_ = new QPushButton(tr("Video"), this); |
|
||||||
videoBtn_->setIcon(QIcon(":/icons/icons/ui/video-call.png")); |
|
||||||
videoBtn_->setIconSize(QSize(iconSize_, iconSize_)); |
|
||||||
} |
|
||||||
cancelBtn_ = new QPushButton(tr("Cancel"), this); |
|
||||||
|
|
||||||
buttonLayout->addWidget(avatar); |
|
||||||
buttonLayout->addStretch(); |
|
||||||
buttonLayout->addWidget(voiceBtn_); |
|
||||||
if (videoBtn_) |
|
||||||
buttonLayout->addWidget(videoBtn_); |
|
||||||
buttonLayout->addWidget(cancelBtn_); |
|
||||||
|
|
||||||
QString name = displayName.isEmpty() ? callee : displayName; |
|
||||||
QLabel *label = new QLabel(tr("Place a call to ") + name + "?", this); |
|
||||||
|
|
||||||
microphoneCombo_ = new QComboBox(this); |
|
||||||
for (const auto &m : microphones_) |
|
||||||
microphoneCombo_->addItem(QIcon(":/icons/icons/ui/microphone-unmute.png"), |
|
||||||
QString::fromStdString(m)); |
|
||||||
|
|
||||||
if (videoBtn_) { |
|
||||||
cameraCombo_ = new QComboBox(this); |
|
||||||
for (const auto &c : cameras_) |
|
||||||
cameraCombo_->addItem(QIcon(":/icons/icons/ui/video-call.png"), |
|
||||||
QString::fromStdString(c)); |
|
||||||
} |
|
||||||
|
|
||||||
layout->addWidget(label); |
|
||||||
layout->addLayout(buttonLayout); |
|
||||||
layout->addStretch(); |
|
||||||
layout->addWidget(microphoneCombo_); |
|
||||||
if (videoBtn_) |
|
||||||
layout->addWidget(cameraCombo_); |
|
||||||
|
|
||||||
connect(voiceBtn_, &QPushButton::clicked, this, [this, settings]() { |
|
||||||
settings->setMicrophone( |
|
||||||
QString::fromStdString(microphones_[microphoneCombo_->currentIndex()])); |
|
||||||
emit voice(); |
|
||||||
emit close(); |
|
||||||
}); |
|
||||||
if (videoBtn_) |
|
||||||
connect(videoBtn_, &QPushButton::clicked, this, [this, settings, session]() { |
|
||||||
std::string error; |
|
||||||
if (!session->havePlugins(true, &error)) { |
|
||||||
emit ChatPage::instance()->showNotification( |
|
||||||
QString::fromStdString(error)); |
|
||||||
emit close(); |
|
||||||
return; |
|
||||||
} |
|
||||||
settings->setMicrophone( |
|
||||||
QString::fromStdString(microphones_[microphoneCombo_->currentIndex()])); |
|
||||||
settings->setCamera( |
|
||||||
QString::fromStdString(cameras_[cameraCombo_->currentIndex()])); |
|
||||||
emit video(); |
|
||||||
emit close(); |
|
||||||
}); |
|
||||||
connect(cancelBtn_, &QPushButton::clicked, this, [this]() { |
|
||||||
emit cancel(); |
|
||||||
emit close(); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,44 +0,0 @@ |
|||||||
#pragma once |
|
||||||
|
|
||||||
#include <string> |
|
||||||
#include <vector> |
|
||||||
|
|
||||||
#include <QSharedPointer> |
|
||||||
#include <QWidget> |
|
||||||
|
|
||||||
class QComboBox; |
|
||||||
class QPushButton; |
|
||||||
class QString; |
|
||||||
class UserSettings; |
|
||||||
|
|
||||||
namespace dialogs { |
|
||||||
|
|
||||||
class PlaceCall : public QWidget |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
|
|
||||||
public: |
|
||||||
PlaceCall(const QString &callee, |
|
||||||
const QString &displayName, |
|
||||||
const QString &roomName, |
|
||||||
const QString &avatarUrl, |
|
||||||
QSharedPointer<UserSettings> settings, |
|
||||||
QWidget *parent = nullptr); |
|
||||||
|
|
||||||
signals: |
|
||||||
void voice(); |
|
||||||
void video(); |
|
||||||
void cancel(); |
|
||||||
|
|
||||||
private: |
|
||||||
const int iconSize_ = 18; |
|
||||||
QPushButton *voiceBtn_ = nullptr; |
|
||||||
QPushButton *videoBtn_ = nullptr; |
|
||||||
QPushButton *cancelBtn_ = nullptr; |
|
||||||
QComboBox *microphoneCombo_ = nullptr; |
|
||||||
QComboBox *cameraCombo_ = nullptr; |
|
||||||
std::vector<std::string> microphones_; |
|
||||||
std::vector<std::string> cameras_; |
|
||||||
}; |
|
||||||
|
|
||||||
} |
|
Loading…
Reference in new issue