From 7124024977ccb237547b88b6a96a50ac6838c354 Mon Sep 17 00:00:00 2001 From: trilene Date: Thu, 17 Dec 2020 11:25:32 -0500 Subject: Make call invites less intrusive --- resources/qml/voip/ActiveCallBar.qml | 183 +++++++++++++++++++++++++++++++++++ resources/qml/voip/CallInviteBar.qml | 95 ++++++++++++++++++ resources/qml/voip/VideoCall.qml | 6 ++ 3 files changed, 284 insertions(+) create mode 100644 resources/qml/voip/ActiveCallBar.qml create mode 100644 resources/qml/voip/CallInviteBar.qml create mode 100644 resources/qml/voip/VideoCall.qml (limited to 'resources/qml/voip') diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml new file mode 100644 index 00000000..9efdb325 --- /dev/null +++ b/resources/qml/voip/ActiveCallBar.qml @@ -0,0 +1,183 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.2 +import im.nheko 1.0 +import "../" + +Rectangle { + + visible: CallManager.isOnCall + color: callInviteBar.color + implicitHeight: visible ? rowLayout.height + 8 : 0 + + MouseArea { + anchors.fill: parent + onClicked: { + if (CallManager.isVideo) + stackLayout.currentIndex = stackLayout.currentIndex ? 0 : 1; + + } + } + + 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 { + font.pointSize: fontMetrics.font.pointSize * 1.1 + text: " " + CallManager.callParty + " " + } + + Image { + Layout.preferredWidth: 24 + Layout.preferredHeight: 24 + source: CallManager.isVideo ? "qrc:/icons/icons/ui/video-call.png" : "qrc:/icons/icons/ui/place-call.png" + } + + Label { + id: callStateLabel + + font.pointSize: fontMetrics.font.pointSize * 1.1 + } + + Item { + states: [ + State { + name: "OFFERSENT" + when: CallManager.callState == WebRTCState.OFFERSENT + + PropertyChanges { + target: callStateLabel + text: "Calling..." + } + + }, + State { + name: "CONNECTING" + when: CallManager.callState == WebRTCState.CONNECTING + + PropertyChanges { + target: callStateLabel + text: "Connecting..." + } + + }, + State { + name: "ANSWERSENT" + when: CallManager.callState == WebRTCState.ANSWERSENT + + PropertyChanges { + target: callStateLabel + text: "Connecting..." + } + + }, + State { + name: "CONNECTED" + when: CallManager.callState == WebRTCState.CONNECTED + + PropertyChanges { + target: callStateLabel + text: "00:00" + } + + PropertyChanges { + target: callTimer + startTime: Math.floor((new Date()).getTime() / 1000) + } + + PropertyChanges { + target: stackLayout + currentIndex: CallManager.isVideo ? 1 : 0 + } + + }, + State { + name: "DISCONNECTED" + when: CallManager.callState == WebRTCState.DISCONNECTED + + PropertyChanges { + target: callStateLabel + text: "" + } + + PropertyChanges { + target: stackLayout + currentIndex: 0 + } + + } + ] + } + + Timer { + id: callTimer + + property int startTime + + function pad(n) { + return (n < 10) ? ("0" + n) : n; + } + + interval: 1000 + running: CallManager.callState == WebRTCState.CONNECTED + repeat: true + onTriggered: { + var d = new Date(); + let seconds = Math.floor(d.getTime() / 1000 - startTime); + let s = Math.floor(seconds % 60); + let m = Math.floor(seconds / 60) % 60; + let h = Math.floor(seconds / 3600); + callStateLabel.text = (h ? (pad(h) + ":") : "") + pad(m) + ":" + pad(s); + } + } + + Item { + Layout.fillWidth: true + } + + ImageButton { + visible: CallManager.isVideo + width: 24 + height: 24 + buttonTextColor: "#000000" + image: ":/icons/icons/ui/toggle-camera-view.png" + hoverEnabled: true + ToolTip.visible: hovered + ToolTip.text: "Toggle camera view" + onClicked: CallManager.toggleCameraView() + } + + Item { + implicitWidth: 8 + } + + ImageButton { + width: 24 + height: 24 + buttonTextColor: "#000000" + image: CallManager.isMicMuted ? ":/icons/icons/ui/microphone-unmute.png" : ":/icons/icons/ui/microphone-mute.png" + hoverEnabled: true + ToolTip.visible: hovered + ToolTip.text: CallManager.isMicMuted ? qsTr("Unmute Mic") : qsTr("Mute Mic") + onClicked: CallManager.toggleMicMute() + } + + Item { + implicitWidth: 16 + } + + } + +} diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml new file mode 100644 index 00000000..6d4d2ac0 --- /dev/null +++ b/resources/qml/voip/CallInviteBar.qml @@ -0,0 +1,95 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.3 +import QtQuick.Dialogs 1.3 +import QtQuick.Layouts 1.2 +import im.nheko 1.0 +import "../" + +Rectangle { + + visible: CallManager.haveCallInvite + color: "#2ECC71" + implicitHeight: visible ? rowLayout.height + 8 : 0 + + MessageDialog { + id: warningDialog + icon: StandardIcon.Warning + } + + 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 { + font.pointSize: fontMetrics.font.pointSize * 1.1 + text: " " + CallManager.callParty + " " + } + + Image { + 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 ? "Video Call" : "Voice Call" + } + + Item { + Layout.fillWidth: true + } + + Button { + icon.source: CallManager.isVideo ? "qrc:/icons/icons/ui/video-call.png" : "qrc:/icons/icons/ui/place-call.png" + palette: colors + text: qsTr("Accept") + onClicked: { + if (CallManager.mics.length == 0) { + warningDialog.text = "No microphone found."; + warningDialog.open(); + return; + } + else if (!CallManager.mics.includes(Settings.microphone)) { + warningDialog.text = "Unknown microphone: " + Settings.microphone; + warningDialog.open(); + return; + } + if (CallManager.isVideo && CallManager.cameras.length > 0 && !CallManager.cameras.includes(Settings.camera)) { + warningDialog.text = "Unknown camera: " + Settings.camera; + warningDialog.open(); + return; + } + CallManager.acceptInvite(); + } + } + + Item { + implicitWidth: 8 + } + + Button { + icon.source: "qrc:/icons/icons/ui/end-call.png" + palette: colors + text: qsTr("Decline") + onClicked: { + CallManager.hangUp(); + } + } + + Item { + implicitWidth: 16 + } + } +} diff --git a/resources/qml/voip/VideoCall.qml b/resources/qml/voip/VideoCall.qml new file mode 100644 index 00000000..14408b6e --- /dev/null +++ b/resources/qml/voip/VideoCall.qml @@ -0,0 +1,6 @@ +import QtQuick 2.9 +import org.freedesktop.gstreamer.GLVideoItem 1.0 + +GstGLVideoItem { + objectName: "videoCallItem" +} -- cgit 1.5.1 From 459c59901e85d5ac4e04b48ba68a046142ea5bf8 Mon Sep 17 00:00:00 2001 From: trilene Date: Thu, 17 Dec 2020 12:45:54 -0500 Subject: Fix one-way video calls --- resources/qml/voip/ActiveCallBar.qml | 2 +- src/CallManager.h | 2 ++ src/WebRTCSession.cpp | 24 +++++++++++++++++++++++- src/WebRTCSession.h | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) (limited to 'resources/qml/voip') diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml index 9efdb325..a1ddd853 100644 --- a/resources/qml/voip/ActiveCallBar.qml +++ b/resources/qml/voip/ActiveCallBar.qml @@ -148,7 +148,7 @@ Rectangle { } ImageButton { - visible: CallManager.isVideo + visible: CallManager.haveLocalVideo width: 24 height: 24 buttonTextColor: "#000000" diff --git a/src/CallManager.h b/src/CallManager.h index e5571c88..ad25fbd1 100644 --- a/src/CallManager.h +++ b/src/CallManager.h @@ -25,6 +25,7 @@ class CallManager : public QObject Q_PROPERTY(bool haveCallInvite READ haveCallInvite NOTIFY newInviteState) Q_PROPERTY(bool isOnCall READ isOnCall NOTIFY newCallState) Q_PROPERTY(bool isVideo READ isVideo NOTIFY newInviteState) + Q_PROPERTY(bool haveLocalVideo READ haveLocalVideo NOTIFY newCallState) Q_PROPERTY(webrtc::State callState READ callState NOTIFY newCallState) Q_PROPERTY(QString callParty READ callParty NOTIFY newInviteState) Q_PROPERTY(QString callPartyAvatarUrl READ callPartyAvatarUrl NOTIFY newInviteState) @@ -40,6 +41,7 @@ public: bool haveCallInvite() const { return haveCallInvite_; } bool isOnCall() const { return session_.state() != webrtc::State::DISCONNECTED; } bool isVideo() const { return isVideo_; } + bool haveLocalVideo() const { return session_.haveLocalVideo(); } webrtc::State callState() const { return session_.state(); } QString callParty() const { return callParty_; } QString callPartyAvatarUrl() const { return callPartyAvatarUrl_; } diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index 90a693a4..a431ab54 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -555,7 +555,10 @@ getResolution(GstPad *pad) void addCameraView(GstElement *pipe, const std::pair &videoCallSize) { - GstElement *tee = gst_bin_get_by_name(GST_BIN(pipe), "videosrctee"); + GstElement *tee = gst_bin_get_by_name(GST_BIN(pipe), "videosrctee"); + if (!tee) + return; + GstElement *queue = gst_element_factory_make("queue", nullptr); GstElement *videorate = gst_element_factory_make("videorate", nullptr); gst_bin_add_many(GST_BIN(pipe), queue, videorate, nullptr); @@ -1152,6 +1155,19 @@ WebRTCSession::addVideoPipeline(int vp8PayloadType) return true; } +bool +WebRTCSession::haveLocalVideo() const +{ + if (isVideo_ && state_ >= State::INITIATED) { + GstElement *tee = gst_bin_get_by_name(GST_BIN(pipe_), "videosrctee"); + if (tee) { + gst_object_unref(tee); + return true; + } + } + return false; +} + bool WebRTCSession::isMicMuted() const { @@ -1326,6 +1342,12 @@ WebRTCSession::havePlugins(bool, std::string *) return false; } +bool +WebRTCSession::haveLocalVideo() const +{ + return false; +} + bool WebRTCSession::createOffer(bool) { diff --git a/src/WebRTCSession.h b/src/WebRTCSession.h index fe82725f..2f0fb70e 100644 --- a/src/WebRTCSession.h +++ b/src/WebRTCSession.h @@ -43,6 +43,7 @@ public: bool havePlugins(bool isVideo, std::string *errorMessage = nullptr); webrtc::State state() const { return state_; } bool isVideo() const { return isVideo_; } + bool haveLocalVideo() const; bool isOffering() const { return isOffering_; } bool isRemoteVideoRecvOnly() const { return isRemoteVideoRecvOnly_; } -- cgit 1.5.1 From 07ac7b7e85b504953b0a751a3f56b60ce0a6fb37 Mon Sep 17 00:00:00 2001 From: trilene Date: Fri, 18 Dec 2020 12:49:24 -0500 Subject: Port PlaceCall dialog to Qml --- CMakeLists.txt | 2 - resources/qml/MessageInput.qml | 23 ++++++- resources/qml/voip/PlaceCall.qml | 107 ++++++++++++++++++++++++++++++++ resources/res.qrc | 1 + src/CallManager.h | 2 +- src/ChatPage.cpp | 1 - src/dialogs/PlaceCall.cpp | 131 --------------------------------------- src/dialogs/PlaceCall.h | 44 ------------- src/timeline/InputBar.cpp | 46 -------------- src/timeline/InputBar.h | 1 - 10 files changed, 131 insertions(+), 227 deletions(-) create mode 100644 resources/qml/voip/PlaceCall.qml delete mode 100644 src/dialogs/PlaceCall.cpp delete mode 100644 src/dialogs/PlaceCall.h (limited to 'resources/qml/voip') diff --git a/CMakeLists.txt b/CMakeLists.txt index c674053f..2365ac09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,7 +253,6 @@ set(SRC_FILES src/dialogs/LeaveRoom.cpp src/dialogs/Logout.cpp src/dialogs/MemberList.cpp - src/dialogs/PlaceCall.cpp src/dialogs/PreviewUploadOverlay.cpp src/dialogs/ReCaptcha.cpp src/dialogs/ReadReceipts.cpp @@ -471,7 +470,6 @@ qt5_wrap_cpp(MOC_HEADERS src/dialogs/LeaveRoom.h src/dialogs/Logout.h src/dialogs/MemberList.h - src/dialogs/PlaceCall.h src/dialogs/PreviewUploadOverlay.h src/dialogs/RawMessage.h src/dialogs/ReCaptcha.h diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index 2847d51d..ecacedba 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.3 import QtQuick.Layouts 1.2 import QtQuick.Window 2.2 import im.nheko 1.0 +import "./voip" Rectangle { color: colors.window @@ -10,6 +11,13 @@ Rectangle { Layout.preferredHeight: textInput.height Layout.minimumHeight: 40 + Component { + id: placeCallDialog + + PlaceCall { + } + } + RowLayout { id: inputBar @@ -28,7 +36,20 @@ Rectangle { Layout.topMargin: 8 Layout.bottomMargin: 8 Layout.leftMargin: 16 - onClicked: TimelineManager.timeline.input.callButton() + onClicked: { + if (TimelineManager.timeline) { + if (CallManager.haveCallInvite) { + return; + } + else if (CallManager.isOnCall) { + CallManager.hangUp(); + } + else { + var dialog = placeCallDialog.createObject(timelineRoot); + dialog.show(); + } + } + } } ImageButton { diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml new file mode 100644 index 00000000..7bf76ca6 --- /dev/null +++ b/resources/qml/voip/PlaceCall.qml @@ -0,0 +1,107 @@ +import QtQuick 2.3 +import QtQuick.Controls 2.3 +import QtQuick.Dialogs 1.3 +import QtQuick.Layouts 1.2 +import im.nheko 1.0 +import "../" + +ApplicationWindow { + + flags: Qt.Dialog + modality: Qt.ApplicationModal + palette: colors + width: columnLayout.implicitWidth + height: columnLayout.implicitHeight + + MessageDialog { + id: warningDialog + icon: StandardIcon.Warning + } + + ColumnLayout { + + id: columnLayout + spacing: 16 + + RowLayout { + + Layout.topMargin: 16 + Layout.leftMargin: 8 + + Label { + font.pointSize: fontMetrics.font.pointSize * 1.1 + text: "Place a call to " + TimelineManager.timeline.roomName + "?" + } + + Item { + Layout.fillWidth: true + } + } + + RowLayout { + + id: rowLayout + Layout.leftMargin: 8 + Layout.rightMargin: 8 + Layout.bottomMargin: 16 + spacing: 16 + + function validateMic() { + if (CallManager.mics.length == 0) { + warningDialog.text = "No microphone found."; + warningDialog.open(); + return false; + } + else if (!CallManager.mics.includes(Settings.microphone)) { + warningDialog.text = "Unknown microphone: " + Settings.microphone; + warningDialog.open(); + return false; + } + return true; + } + + Avatar { + 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 (rowLayout.validateMic()) { + 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 (rowLayout.validateMic()) { + if (!CallManager.cameras.includes(Settings.camera)) { + warningDialog.text = "Unknown camera: " + Settings.camera; + warningDialog.open(); + return; + } + CallManager.sendInvite(TimelineManager.timeline.roomId(), true); + close(); + } + } + } + + Button { + palette: colors + text: qsTr("Cancel") + onClicked: { + close(); + } + } + } + } +} diff --git a/resources/res.qrc b/resources/res.qrc index 321fe12e..52157df0 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -159,6 +159,7 @@ qml/device-verification/Success.qml qml/voip/ActiveCallBar.qml qml/voip/CallInviteBar.qml + qml/voip/PlaceCall.qml qml/voip/VideoCall.qml diff --git a/src/CallManager.h b/src/CallManager.h index ad25fbd1..75768ee1 100644 --- a/src/CallManager.h +++ b/src/CallManager.h @@ -37,7 +37,6 @@ class CallManager : public QObject public: CallManager(QObject *); - void sendInvite(const QString &roomid, bool isVideo); bool haveCallInvite() const { return haveCallInvite_; } bool isOnCall() const { return session_.state() != webrtc::State::DISCONNECTED; } bool isVideo() const { return isVideo_; } @@ -52,6 +51,7 @@ public: void refreshTurnServer(); public slots: + void sendInvite(const QString &roomid, bool isVideo); void syncEvent(const mtx::events::collections::TimelineEvents &event); void toggleMicMute(); void toggleCameraView() { session_.toggleCameraView(); } diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 4e87349a..238c9362 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -47,7 +47,6 @@ #include "notifications/Manager.h" -#include "dialogs/PlaceCall.h" #include "dialogs/ReadReceipts.h" #include "popups/UserMentions.h" #include "timeline/TimelineViewManager.h" diff --git a/src/dialogs/PlaceCall.cpp b/src/dialogs/PlaceCall.cpp deleted file mode 100644 index 85a398a2..00000000 --- a/src/dialogs/PlaceCall.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include -#include -#include -#include -#include - -#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 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(); - }); -} - -} diff --git a/src/dialogs/PlaceCall.h b/src/dialogs/PlaceCall.h deleted file mode 100644 index e042258f..00000000 --- a/src/dialogs/PlaceCall.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include -#include - -#include -#include - -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 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 microphones_; - std::vector cameras_; -}; - -} diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index 78c8c6a3..3cddd613 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -13,7 +13,6 @@ #include #include "Cache.h" -#include "CallManager.h" #include "ChatPage.h" #include "CompletionProxyModel.h" #include "Logging.h" @@ -25,7 +24,6 @@ #include "UserSettingsPage.h" #include "UsersModel.h" #include "Utils.h" -#include "dialogs/PlaceCall.h" #include "dialogs/PreviewUploadOverlay.h" #include "emoji/EmojiModel.h" @@ -593,50 +591,6 @@ InputBar::showPreview(const QMimeData &source, QString path, const QStringList & }); } -void -InputBar::callButton() -{ - auto callManager_ = ChatPage::instance()->callManager(); - if (callManager_->haveCallInvite()) { - return; - } else if (callManager_->isOnCall()) { - callManager_->hangUp(); - } else { - auto current_room_ = room->roomId(); - if (auto roomInfo = cache::singleRoomInfo(current_room_.toStdString()); - roomInfo.member_count != 2) { - ChatPage::instance()->showNotification("Calls are limited to 1:1 rooms."); - } else { - std::vector members( - cache::getMembers(current_room_.toStdString())); - const RoomMember &callee = members.front().user_id == utils::localUser() - ? members.back() - : members.front(); - auto dialog = - new dialogs::PlaceCall(callee.user_id, - callee.display_name, - QString::fromStdString(roomInfo.name), - QString::fromStdString(roomInfo.avatar_url), - ChatPage::instance()->userSettings(), - MainWindow::instance()); - connect(dialog, - &dialogs::PlaceCall::voice, - callManager_, - [callManager_, current_room_]() { - callManager_->sendInvite(current_room_, false); - }); - connect(dialog, - &dialogs::PlaceCall::video, - callManager_, - [callManager_, current_room_]() { - callManager_->sendInvite(current_room_, true); - }); - utils::centerWidget(dialog, MainWindow::instance()); - dialog->show(); - } - } -} - void InputBar::startTyping() { diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h index 89ca34fe..c729a6fc 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h @@ -41,7 +41,6 @@ public slots: void updateState(int selectionStart, int selectionEnd, int cursorPosition, QString text); void openFileSelection(); bool uploading() const { return uploading_; } - void callButton(); void message(QString body); QObject *completerFor(QString completerName); -- cgit 1.5.1 From d315d02ee6ee77576d37eef279cf635fa31ed64a Mon Sep 17 00:00:00 2001 From: trilene Date: Sat, 19 Dec 2020 09:32:20 -0500 Subject: Use Layout margins --- resources/qml/voip/ActiveCallBar.qml | 4 +++- resources/qml/voip/CallInviteBar.qml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'resources/qml/voip') diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml index a1ddd853..e0853808 100644 --- a/resources/qml/voip/ActiveCallBar.qml +++ b/resources/qml/voip/ActiveCallBar.qml @@ -35,11 +35,13 @@ Rectangle { } Label { + Layout.leftMargin: 8 font.pointSize: fontMetrics.font.pointSize * 1.1 - text: " " + CallManager.callParty + " " + text: CallManager.callParty } 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" diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index 6d4d2ac0..61a3f0ec 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -32,11 +32,13 @@ Rectangle { } Label { + Layout.leftMargin: 8 font.pointSize: fontMetrics.font.pointSize * 1.1 - text: " " + CallManager.callParty + " " + text: CallManager.callParty } 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" -- cgit 1.5.1 From 055c6f724833a76131051d23400e5d7c57245fb2 Mon Sep 17 00:00:00 2001 From: trilene Date: Sat, 19 Dec 2020 10:49:13 -0500 Subject: Add device combos to PlaceCall dialog --- resources/qml/voip/PlaceCall.qml | 63 ++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 16 deletions(-) (limited to 'resources/qml/voip') diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index 7bf76ca6..7a839e8d 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -19,8 +19,8 @@ ApplicationWindow { } ColumnLayout { - id: columnLayout + spacing: 16 RowLayout { @@ -30,7 +30,7 @@ ApplicationWindow { Label { font.pointSize: fontMetrics.font.pointSize * 1.1 - text: "Place a call to " + TimelineManager.timeline.roomName + "?" + text: qsTr("Place a call to ") + TimelineManager.timeline.roomName + "?" } Item { @@ -39,11 +39,10 @@ ApplicationWindow { } RowLayout { + id: buttonLayout - id: rowLayout Layout.leftMargin: 8 Layout.rightMargin: 8 - Layout.bottomMargin: 16 spacing: 16 function validateMic() { @@ -52,11 +51,6 @@ ApplicationWindow { warningDialog.open(); return false; } - else if (!CallManager.mics.includes(Settings.microphone)) { - warningDialog.text = "Unknown microphone: " + Settings.microphone; - warningDialog.open(); - return false; - } return true; } @@ -71,7 +65,8 @@ ApplicationWindow { text: qsTr("Voice") icon.source: "qrc:/icons/icons/ui/place-call.png" onClicked: { - if (rowLayout.validateMic()) { + if (buttonLayout.validateMic()) { + Settings.microphone = micCombo.currentText CallManager.sendInvite(TimelineManager.timeline.roomId(), false); close(); } @@ -83,12 +78,9 @@ ApplicationWindow { text: qsTr("Video") icon.source: "qrc:/icons/icons/ui/video-call.png" onClicked: { - if (rowLayout.validateMic()) { - if (!CallManager.cameras.includes(Settings.camera)) { - warningDialog.text = "Unknown camera: " + Settings.camera; - warningDialog.open(); - return; - } + if (buttonLayout.validateMic()) { + Settings.microphone = micCombo.currentText + Settings.camera = cameraCombo.currentText CallManager.sendInvite(TimelineManager.timeline.roomId(), true); close(); } @@ -103,5 +95,44 @@ ApplicationWindow { } } } + + RowLayout { + + Layout.leftMargin: 8 + Layout.rightMargin: 8 + Layout.bottomMargin: cameraCombo.visible ? 0 : 16 + + Image { + Layout.preferredWidth: 22 + Layout.preferredHeight: 22 + source: "qrc:/icons/icons/ui/microphone-unmute.png" + } + + ComboBox { + id: micCombo + Layout.fillWidth: true + model: CallManager.mics + } + } + + RowLayout { + + visible: CallManager.cameras.length > 0 + Layout.leftMargin: 8 + Layout.rightMargin: 8 + Layout.bottomMargin: 16 + + Image { + Layout.preferredWidth: 22 + Layout.preferredHeight: 22 + source: "qrc:/icons/icons/ui/video-call.png" + } + + ComboBox { + id: cameraCombo + Layout.fillWidth: true + model: CallManager.cameras + } + } } } -- cgit 1.5.1 From 87d2074c8192e5321f76525c55bc4e44dd1bc790 Mon Sep 17 00:00:00 2001 From: trilene Date: Sun, 20 Dec 2020 09:37:22 -0500 Subject: Add devices dialog to CallInviteBar --- resources/qml/voip/CallDevices.qml | 91 ++++++++++++++++++++++++++++++++++++ resources/qml/voip/CallInviteBar.qml | 27 ++++++++++- resources/res.qrc | 1 + 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 resources/qml/voip/CallDevices.qml (limited to 'resources/qml/voip') diff --git a/resources/qml/voip/CallDevices.qml b/resources/qml/voip/CallDevices.qml new file mode 100644 index 00000000..ee3503ca --- /dev/null +++ b/resources/qml/voip/CallDevices.qml @@ -0,0 +1,91 @@ +import QtQuick 2.3 +import QtQuick.Controls 2.3 +import QtQuick.Dialogs 1.3 +import QtQuick.Layouts 1.2 +import im.nheko 1.0 +import "../" + +ApplicationWindow { + + flags: Qt.Dialog + modality: Qt.ApplicationModal + palette: colors + width: columnLayout.implicitWidth + height: columnLayout.implicitHeight + + ColumnLayout { + id: columnLayout + + spacing: 16 + + ColumnLayout { + spacing: 8 + + RowLayout { + + Layout.topMargin: 8 + Layout.leftMargin: 8 + Layout.rightMargin: 8 + + Image { + Layout.preferredWidth: 22 + Layout.preferredHeight: 22 + source: "qrc:/icons/icons/ui/microphone-unmute.png" + } + + ComboBox { + id: micCombo + Layout.fillWidth: true + model: CallManager.mics + } + } + + RowLayout { + + visible: CallManager.cameras.length > 0 + Layout.leftMargin: 8 + Layout.rightMargin: 8 + + Image { + Layout.preferredWidth: 22 + Layout.preferredHeight: 22 + source: "qrc:/icons/icons/ui/video-call.png" + } + + ComboBox { + id: cameraCombo + Layout.fillWidth: true + model: CallManager.cameras + } + } + } + + RowLayout { + + Layout.rightMargin: 8 + Layout.bottomMargin: 8 + + Item { + implicitWidth: 128 + } + + Button { + text: qsTr("Ok") + onClicked: { + Settings.microphone = micCombo.currentText + if (cameraCombo.visible) { + Settings.camera = cameraCombo.currentText + } + close(); + } + } + + Button { + text: qsTr("Cancel") + onClicked: { + close(); + } + } + } + } +} diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index 61a3f0ec..e22ee645 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -16,6 +16,13 @@ Rectangle { icon: StandardIcon.Warning } + Component { + id: devicesDialog + + CallDevices { + } + } + RowLayout { id: rowLayout @@ -53,6 +60,24 @@ Rectangle { Layout.fillWidth: true } + ImageButton { + width: 24 + height: 24 + buttonTextColor: "#000000" + image: ":/icons/icons/ui/settings.png" + hoverEnabled: true + ToolTip.visible: hovered + ToolTip.text: "Devices" + onClicked: { + var dialog = devicesDialog.createObject(timelineRoot); + dialog.show(); + } + } + + Item { + implicitWidth: 8 + } + Button { icon.source: CallManager.isVideo ? "qrc:/icons/icons/ui/video-call.png" : "qrc:/icons/icons/ui/place-call.png" palette: colors @@ -78,7 +103,7 @@ Rectangle { } Item { - implicitWidth: 8 + implicitWidth: 4 } Button { diff --git a/resources/res.qrc b/resources/res.qrc index 52157df0..ca333978 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -158,6 +158,7 @@ qml/device-verification/Failed.qml qml/device-verification/Success.qml qml/voip/ActiveCallBar.qml + qml/voip/CallDevices.qml qml/voip/CallInviteBar.qml qml/voip/PlaceCall.qml qml/voip/VideoCall.qml -- cgit 1.5.1 From 6427687d208bdf2b303d1444d978d7f83fcc2be0 Mon Sep 17 00:00:00 2001 From: trilene Date: Sun, 20 Dec 2020 10:14:55 -0500 Subject: Add missing translation marks --- resources/qml/voip/ActiveCallBar.qml | 8 ++++---- resources/qml/voip/CallInviteBar.qml | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'resources/qml/voip') diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml index e0853808..1683df6a 100644 --- a/resources/qml/voip/ActiveCallBar.qml +++ b/resources/qml/voip/ActiveCallBar.qml @@ -61,7 +61,7 @@ Rectangle { PropertyChanges { target: callStateLabel - text: "Calling..." + text: qsTr("Calling...") } }, @@ -71,7 +71,7 @@ Rectangle { PropertyChanges { target: callStateLabel - text: "Connecting..." + text: qsTr("Connecting...") } }, @@ -81,7 +81,7 @@ Rectangle { PropertyChanges { target: callStateLabel - text: "Connecting..." + text: qsTr("Connecting...") } }, @@ -157,7 +157,7 @@ Rectangle { image: ":/icons/icons/ui/toggle-camera-view.png" hoverEnabled: true ToolTip.visible: hovered - ToolTip.text: "Toggle camera view" + ToolTip.text: qsTr("Toggle camera view") onClicked: CallManager.toggleCameraView() } diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index e22ee645..43aa93b8 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -53,7 +53,7 @@ Rectangle { Label { font.pointSize: fontMetrics.font.pointSize * 1.1 - text: CallManager.isVideo ? "Video Call" : "Voice Call" + text: CallManager.isVideo ? qsTr("Video Call") : qsTr("Voice Call") } Item { @@ -67,7 +67,7 @@ Rectangle { image: ":/icons/icons/ui/settings.png" hoverEnabled: true ToolTip.visible: hovered - ToolTip.text: "Devices" + ToolTip.text: qsTr("Devices") onClicked: { var dialog = devicesDialog.createObject(timelineRoot); dialog.show(); @@ -84,17 +84,17 @@ Rectangle { text: qsTr("Accept") onClicked: { if (CallManager.mics.length == 0) { - warningDialog.text = "No microphone found."; + warningDialog.text = qsTr("No microphone found."); warningDialog.open(); return; } else if (!CallManager.mics.includes(Settings.microphone)) { - warningDialog.text = "Unknown microphone: " + Settings.microphone; + warningDialog.text = qsTr("Unknown microphone: ") + Settings.microphone; warningDialog.open(); return; } if (CallManager.isVideo && CallManager.cameras.length > 0 && !CallManager.cameras.includes(Settings.camera)) { - warningDialog.text = "Unknown camera: " + Settings.camera; + warningDialog.text = qsTr("Unknown camera: ") + Settings.camera; warningDialog.open(); return; } -- cgit 1.5.1 From 13a280df136cf4db28796175cd9dd8546acce79a Mon Sep 17 00:00:00 2001 From: trilene Date: Sun, 20 Dec 2020 10:33:22 -0500 Subject: Finesse PlaceCall dialog --- resources/qml/voip/PlaceCall.qml | 70 ++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 32 deletions(-) (limited to 'resources/qml/voip') diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index 7a839e8d..c047e625 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -43,11 +43,10 @@ ApplicationWindow { Layout.leftMargin: 8 Layout.rightMargin: 8 - spacing: 16 function validateMic() { if (CallManager.mics.length == 0) { - warningDialog.text = "No microphone found."; + warningDialog.text = qsTr("No microphone found."); warningDialog.open(); return false; } @@ -61,6 +60,10 @@ ApplicationWindow { displayName: TimelineManager.timeline.roomName } + Item { + implicitWidth: cameraCombo.visible ? 16 : 64 + } + Button { text: qsTr("Voice") icon.source: "qrc:/icons/icons/ui/place-call.png" @@ -88,7 +91,6 @@ ApplicationWindow { } Button { - palette: colors text: qsTr("Cancel") onClicked: { close(); @@ -96,42 +98,46 @@ ApplicationWindow { } } - RowLayout { + ColumnLayout { + spacing: 8 - Layout.leftMargin: 8 - Layout.rightMargin: 8 - Layout.bottomMargin: cameraCombo.visible ? 0 : 16 + RowLayout { - Image { - Layout.preferredWidth: 22 - Layout.preferredHeight: 22 - source: "qrc:/icons/icons/ui/microphone-unmute.png" - } + Layout.leftMargin: 8 + Layout.rightMargin: 8 + Layout.bottomMargin: cameraCombo.visible ? 0 : 16 - ComboBox { - id: micCombo - Layout.fillWidth: true - model: CallManager.mics - } - } + Image { + Layout.preferredWidth: 22 + Layout.preferredHeight: 22 + source: "qrc:/icons/icons/ui/microphone-unmute.png" + } - RowLayout { + ComboBox { + id: micCombo + Layout.fillWidth: true + model: CallManager.mics + } + } - visible: CallManager.cameras.length > 0 - Layout.leftMargin: 8 - Layout.rightMargin: 8 - Layout.bottomMargin: 16 + RowLayout { - Image { - Layout.preferredWidth: 22 - Layout.preferredHeight: 22 - source: "qrc:/icons/icons/ui/video-call.png" - } + visible: CallManager.cameras.length > 0 + Layout.leftMargin: 8 + Layout.rightMargin: 8 + Layout.bottomMargin: 16 + + Image { + Layout.preferredWidth: 22 + Layout.preferredHeight: 22 + source: "qrc:/icons/icons/ui/video-call.png" + } - ComboBox { - id: cameraCombo - Layout.fillWidth: true - model: CallManager.cameras + ComboBox { + id: cameraCombo + Layout.fillWidth: true + model: CallManager.cameras + } } } } -- cgit 1.5.1 From 1c4a86e502a1e57cf359ff8528fadf203c6ce027 Mon Sep 17 00:00:00 2001 From: trilene Date: Sun, 20 Dec 2020 17:12:42 -0500 Subject: Set Label text color explicitly --- resources/qml/voip/ActiveCallBar.qml | 2 ++ resources/qml/voip/CallInviteBar.qml | 2 ++ resources/qml/voip/PlaceCall.qml | 1 + 3 files changed, 5 insertions(+) (limited to 'resources/qml/voip') diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml index 1683df6a..86fe37f6 100644 --- a/resources/qml/voip/ActiveCallBar.qml +++ b/resources/qml/voip/ActiveCallBar.qml @@ -38,6 +38,7 @@ Rectangle { Layout.leftMargin: 8 font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.callParty + color: colors.windowText } Image { @@ -51,6 +52,7 @@ Rectangle { id: callStateLabel font.pointSize: fontMetrics.font.pointSize * 1.1 + color: colors.windowText } Item { diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index 43aa93b8..3b40d394 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -42,6 +42,7 @@ Rectangle { Layout.leftMargin: 8 font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.callParty + color: windowText } Image { @@ -54,6 +55,7 @@ Rectangle { Label { font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.isVideo ? qsTr("Video Call") : qsTr("Voice Call") + color: windowText } Item { diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index c047e625..99b82046 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -31,6 +31,7 @@ ApplicationWindow { Label { font.pointSize: fontMetrics.font.pointSize * 1.1 text: qsTr("Place a call to ") + TimelineManager.timeline.roomName + "?" + color: windowText } Item { -- cgit 1.5.1 From 4123e6aff1ffa756c17e89b0930a3bcabcbb8104 Mon Sep 17 00:00:00 2001 From: trilene Date: Sun, 20 Dec 2020 17:19:24 -0500 Subject: Fix previous commit --- resources/qml/voip/CallInviteBar.qml | 4 ++-- resources/qml/voip/PlaceCall.qml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'resources/qml/voip') diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index 3b40d394..93ff1042 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -42,7 +42,7 @@ Rectangle { Layout.leftMargin: 8 font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.callParty - color: windowText + color: colors.windowText } Image { @@ -55,7 +55,7 @@ Rectangle { Label { font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.isVideo ? qsTr("Video Call") : qsTr("Voice Call") - color: windowText + color: colors.windowText } Item { diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index 99b82046..4e29c1ae 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -31,7 +31,7 @@ ApplicationWindow { Label { font.pointSize: fontMetrics.font.pointSize * 1.1 text: qsTr("Place a call to ") + TimelineManager.timeline.roomName + "?" - color: windowText + color: colors.windowText } Item { -- cgit 1.5.1 From 2984d71971fb49e47ff1485ad918e9d520404e4b Mon Sep 17 00:00:00 2001 From: trilene Date: Wed, 30 Dec 2020 15:03:07 -0500 Subject: Fix Qml control colors --- resources/qml/MessageInput.qml | 5 ++- resources/qml/voip/ActiveCallBar.qml | 18 +++------ resources/qml/voip/CallDevices.qml | 75 ++++++++++++++++++------------------ resources/qml/voip/CallInviteBar.qml | 69 +++++++++++++++++---------------- resources/qml/voip/DeviceError.qml | 31 +++++++++++++++ resources/qml/voip/PlaceCall.qml | 59 +++++++++++++++++----------- resources/res.qrc | 1 + src/UserSettingsPage.cpp | 4 +- 8 files changed, 153 insertions(+), 109 deletions(-) create mode 100644 resources/qml/voip/DeviceError.qml (limited to 'resources/qml/voip') diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index ecacedba..71c61697 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -1,9 +1,9 @@ +import "./voip" import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.2 import QtQuick.Window 2.2 import im.nheko 1.0 -import "./voip" Rectangle { color: colors.window @@ -26,6 +26,7 @@ Rectangle { ImageButton { visible: CallManager.callsSupported + opacity: CallManager.haveCallInvite ? 0.3 : 1.0 Layout.alignment: Qt.AlignBottom hoverEnabled: true width: 22 @@ -46,7 +47,7 @@ Rectangle { } else { var dialog = placeCallDialog.createObject(timelineRoot); - dialog.show(); + dialog.open(); } } } diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml index 86fe37f6..0e932e13 100644 --- a/resources/qml/voip/ActiveCallBar.qml +++ b/resources/qml/voip/ActiveCallBar.qml @@ -1,8 +1,8 @@ +import "../" import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.2 import im.nheko 1.0 -import "../" Rectangle { @@ -38,7 +38,7 @@ Rectangle { Layout.leftMargin: 8 font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.callParty - color: colors.windowText + color: "#000000" } Image { @@ -52,7 +52,7 @@ Rectangle { id: callStateLabel font.pointSize: fontMetrics.font.pointSize * 1.1 - color: colors.windowText + color: "#000000" } Item { @@ -163,11 +163,9 @@ Rectangle { onClicked: CallManager.toggleCameraView() } - Item { - implicitWidth: 8 - } - ImageButton { + Layout.leftMargin: 8 + Layout.rightMargin: 16 width: 24 height: 24 buttonTextColor: "#000000" @@ -177,11 +175,5 @@ Rectangle { ToolTip.text: CallManager.isMicMuted ? qsTr("Unmute Mic") : qsTr("Mute Mic") onClicked: CallManager.toggleMicMute() } - - Item { - implicitWidth: 16 - } - } - } diff --git a/resources/qml/voip/CallDevices.qml b/resources/qml/voip/CallDevices.qml index ee3503ca..b07412c7 100644 --- a/resources/qml/voip/CallDevices.qml +++ b/resources/qml/voip/CallDevices.qml @@ -1,31 +1,44 @@ -import QtQuick 2.3 +import QtQuick 2.9 import QtQuick.Controls 2.3 -import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.2 import im.nheko 1.0 -import "../" -ApplicationWindow { +Popup { - flags: Qt.Dialog - modality: Qt.ApplicationModal - palette: colors - width: columnLayout.implicitWidth - height: columnLayout.implicitHeight + modal: true + anchors.centerIn: parent + background: Rectangle { + color: colors.window + border.color: colors.windowText + } + + // 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 ColumnLayout { - id: columnLayout spacing: 16 ColumnLayout { spacing: 8 - RowLayout { + Layout.topMargin: 8 + Layout.leftMargin: 8 + Layout.rightMargin: 8 - Layout.topMargin: 8 - Layout.leftMargin: 8 - Layout.rightMargin: 8 + RowLayout { Image { Layout.preferredWidth: 22 @@ -42,9 +55,7 @@ ApplicationWindow { RowLayout { - visible: CallManager.cameras.length > 0 - Layout.leftMargin: 8 - Layout.rightMargin: 8 + visible: CallManager.isVideo && CallManager.cameras.length > 0 Image { Layout.preferredWidth: 22 @@ -60,31 +71,21 @@ ApplicationWindow { } } - RowLayout { + DialogButtonBox { - Layout.rightMargin: 8 - Layout.bottomMargin: 8 - - Item { - implicitWidth: 128 - } + Layout.leftMargin: 128 + standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel - Button { - text: qsTr("Ok") - onClicked: { - Settings.microphone = micCombo.currentText - if (cameraCombo.visible) { - Settings.camera = cameraCombo.currentText - } - close(); + onAccepted: { + Settings.microphone = micCombo.currentText + if (cameraCombo.visible) { + Settings.camera = cameraCombo.currentText } + close(); } - Button { - text: qsTr("Cancel") - onClicked: { - close(); - } + onRejected: { + close(); } } } diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index 93ff1042..8c3a8f6a 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -1,9 +1,8 @@ +import "../" import QtQuick 2.9 import QtQuick.Controls 2.3 -import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.2 import im.nheko 1.0 -import "../" Rectangle { @@ -11,18 +10,18 @@ Rectangle { color: "#2ECC71" implicitHeight: visible ? rowLayout.height + 8 : 0 - MessageDialog { - id: warningDialog - icon: StandardIcon.Warning - } - Component { id: devicesDialog - CallDevices { } } + Component { + id: deviceError + DeviceError { + } + } + RowLayout { id: rowLayout @@ -42,7 +41,7 @@ Rectangle { Layout.leftMargin: 8 font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.callParty - color: colors.windowText + color: "#000000" } Image { @@ -55,7 +54,7 @@ Rectangle { Label { font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.isVideo ? qsTr("Video Call") : qsTr("Voice Call") - color: colors.windowText + color: "#000000" } Item { @@ -63,8 +62,9 @@ Rectangle { } ImageButton { - width: 24 - height: 24 + Layout.rightMargin: 16 + width: 20 + height: 20 buttonTextColor: "#000000" image: ":/icons/icons/ui/settings.png" hoverEnabled: true @@ -72,53 +72,56 @@ Rectangle { ToolTip.text: qsTr("Devices") onClicked: { var dialog = devicesDialog.createObject(timelineRoot); - dialog.show(); + dialog.open(); } } - Item { - implicitWidth: 8 - } - Button { + Layout.rightMargin: 4 icon.source: CallManager.isVideo ? "qrc:/icons/icons/ui/video-call.png" : "qrc:/icons/icons/ui/place-call.png" - palette: colors text: qsTr("Accept") + palette.button: colors.button + palette.buttonText: colors.buttonText + onClicked: { if (CallManager.mics.length == 0) { - warningDialog.text = qsTr("No microphone found."); - warningDialog.open(); + var dialog = deviceError.createObject(timelineRoot, { + "errorString": qsTr("No microphone found."), + "iconSource": "qrc:/icons/icons/ui/place-call.png" + }); + dialog.open(); return; } else if (!CallManager.mics.includes(Settings.microphone)) { - warningDialog.text = qsTr("Unknown microphone: ") + Settings.microphone; - warningDialog.open(); + var dialog = deviceError.createObject(timelineRoot, { + "errorString": qsTr("Unknown microphone: ") + Settings.microphone, + "iconSource": "qrc:/icons/icons/ui/place-call.png" + }); + dialog.open(); return; } if (CallManager.isVideo && CallManager.cameras.length > 0 && !CallManager.cameras.includes(Settings.camera)) { - warningDialog.text = qsTr("Unknown camera: ") + Settings.camera; - warningDialog.open(); + var dialog = deviceError.createObject(timelineRoot, { + "errorString": qsTr("Unknown camera: ") + Settings.camera, + "iconSource": "qrc:/icons/icons/ui/video-call.png" + }); + dialog.open(); return; } CallManager.acceptInvite(); } } - Item { - implicitWidth: 4 - } - Button { + Layout.rightMargin: 16 icon.source: "qrc:/icons/icons/ui/end-call.png" - palette: colors text: qsTr("Decline") + palette.button: colors.button + palette.buttonText: colors.buttonText + onClicked: { CallManager.hangUp(); } } - - Item { - implicitWidth: 16 - } } } diff --git a/resources/qml/voip/DeviceError.qml b/resources/qml/voip/DeviceError.qml new file mode 100644 index 00000000..c88c7faa --- /dev/null +++ b/resources/qml/voip/DeviceError.qml @@ -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 iconSource + + modal: true + anchors.centerIn: parent + background: Rectangle { + color: colors.window + border.color: colors.windowText + } + + RowLayout { + + Image { + Layout.preferredWidth: 16 + Layout.preferredHeight: 16 + source: iconSource + } + + Label { + text: errorString + color: colors.windowText + } + } +} diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index 4e29c1ae..8dc7d781 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -1,23 +1,39 @@ -import QtQuick 2.3 +import "../" +import QtQuick 2.9 import QtQuick.Controls 2.3 -import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.2 import im.nheko 1.0 -import "../" -ApplicationWindow { +Popup { - flags: Qt.Dialog - modality: Qt.ApplicationModal - palette: colors - width: columnLayout.implicitWidth - height: columnLayout.implicitHeight + modal: true + anchors.centerIn: parent + background: Rectangle { + color: colors.window + border.color: colors.windowText + } - MessageDialog { - id: warningDialog - icon: StandardIcon.Warning + Component { + id: deviceError + DeviceError { + } } + // 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 + ColumnLayout { id: columnLayout @@ -25,11 +41,10 @@ ApplicationWindow { RowLayout { - Layout.topMargin: 16 + Layout.topMargin: 8 Layout.leftMargin: 8 Label { - font.pointSize: fontMetrics.font.pointSize * 1.1 text: qsTr("Place a call to ") + TimelineManager.timeline.roomName + "?" color: colors.windowText } @@ -47,24 +62,24 @@ ApplicationWindow { function validateMic() { if (CallManager.mics.length == 0) { - warningDialog.text = qsTr("No microphone found."); - warningDialog.open(); + var dialog = deviceError.createObject(timelineRoot, { + "errorString": qsTr("No microphone found."), + "iconSource": "qrc:/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 } - Item { - implicitWidth: cameraCombo.visible ? 16 : 64 - } - Button { text: qsTr("Voice") icon.source: "qrc:/icons/icons/ui/place-call.png" @@ -106,7 +121,7 @@ ApplicationWindow { Layout.leftMargin: 8 Layout.rightMargin: 8 - Layout.bottomMargin: cameraCombo.visible ? 0 : 16 + Layout.bottomMargin: cameraCombo.visible ? 0 : 8 Image { Layout.preferredWidth: 22 @@ -126,7 +141,7 @@ ApplicationWindow { visible: CallManager.cameras.length > 0 Layout.leftMargin: 8 Layout.rightMargin: 8 - Layout.bottomMargin: 16 + Layout.bottomMargin: 8 Image { Layout.preferredWidth: 22 diff --git a/resources/res.qrc b/resources/res.qrc index ca333978..bceeb298 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -160,6 +160,7 @@ qml/voip/ActiveCallBar.qml qml/voip/CallDevices.qml qml/voip/CallInviteBar.qml + qml/voip/DeviceError.qml qml/voip/PlaceCall.qml qml/voip/VideoCall.qml diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 7c7ef9ab..f133c87d 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -464,7 +464,7 @@ UserSettings::applyTheme() stylefile.setFileName(":/styles/styles/nheko.qss"); QPalette lightActive( /*windowText*/ QColor("#333"), - /*button*/ QColor("#333"), + /*button*/ QColor("white"), /*light*/ QColor(0xef, 0xef, 0xef), /*dark*/ QColor(110, 110, 110), /*mid*/ QColor(220, 220, 220), @@ -477,7 +477,7 @@ UserSettings::applyTheme() lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color()); lightActive.setColor(QPalette::ToolTipText, lightActive.text().color()); lightActive.setColor(QPalette::Link, QColor("#0077b5")); - lightActive.setColor(QPalette::ButtonText, QColor("#495057")); + lightActive.setColor(QPalette::ButtonText, QColor("#333")); QApplication::setPalette(lightActive); } else if (this->theme() == "dark") { stylefile.setFileName(":/styles/styles/nheko-dark.qss"); -- cgit 1.5.1 From 2bd8a386e29e5abdf65164d6dd2fc3213de1f878 Mon Sep 17 00:00:00 2001 From: trilene Date: Wed, 6 Jan 2021 17:15:43 -0500 Subject: Color and icon button spacing fixes --- resources/qml/voip/CallDevices.qml | 19 +++---------------- resources/qml/voip/CallInviteBar.qml | 16 +++++++--------- resources/qml/voip/DeviceError.qml | 4 ++-- resources/qml/voip/PlaceCall.qml | 26 ++++++-------------------- 4 files changed, 18 insertions(+), 47 deletions(-) (limited to 'resources/qml/voip') diff --git a/resources/qml/voip/CallDevices.qml b/resources/qml/voip/CallDevices.qml index b07412c7..f0847b14 100644 --- a/resources/qml/voip/CallDevices.qml +++ b/resources/qml/voip/CallDevices.qml @@ -12,20 +12,7 @@ Popup { border.color: colors.windowText } - // 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 + palette: colors ColumnLayout { @@ -43,7 +30,7 @@ Popup { Image { Layout.preferredWidth: 22 Layout.preferredHeight: 22 - source: "qrc:/icons/icons/ui/microphone-unmute.png" + source: "image://colorimage/:/icons/icons/ui/microphone-unmute.png?" + colors.windowText } ComboBox { @@ -60,7 +47,7 @@ Popup { Image { Layout.preferredWidth: 22 Layout.preferredHeight: 22 - source: "qrc:/icons/icons/ui/video-call.png" + source: "image://colorimage/:/icons/icons/ui/video-call.png?" + colors.windowText } ComboBox { diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index 8c3a8f6a..58b89ed3 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -79,15 +79,14 @@ Rectangle { 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.button: colors.button - palette.buttonText: colors.buttonText + text: qsTr(" Accept ") + palette: colors onClicked: { if (CallManager.mics.length == 0) { var dialog = deviceError.createObject(timelineRoot, { "errorString": qsTr("No microphone found."), - "iconSource": "qrc:/icons/icons/ui/place-call.png" + "image": ":/icons/icons/ui/place-call.png" }); dialog.open(); return; @@ -95,7 +94,7 @@ Rectangle { else if (!CallManager.mics.includes(Settings.microphone)) { var dialog = deviceError.createObject(timelineRoot, { "errorString": qsTr("Unknown microphone: ") + Settings.microphone, - "iconSource": "qrc:/icons/icons/ui/place-call.png" + "image": ":/icons/icons/ui/place-call.png" }); dialog.open(); return; @@ -103,7 +102,7 @@ Rectangle { if (CallManager.isVideo && CallManager.cameras.length > 0 && !CallManager.cameras.includes(Settings.camera)) { var dialog = deviceError.createObject(timelineRoot, { "errorString": qsTr("Unknown camera: ") + Settings.camera, - "iconSource": "qrc:/icons/icons/ui/video-call.png" + "image": ":/icons/icons/ui/video-call.png" }); dialog.open(); return; @@ -115,9 +114,8 @@ Rectangle { Button { Layout.rightMargin: 16 icon.source: "qrc:/icons/icons/ui/end-call.png" - text: qsTr("Decline") - palette.button: colors.button - palette.buttonText: colors.buttonText + text: qsTr(" Decline ") + palette: colors onClicked: { CallManager.hangUp(); diff --git a/resources/qml/voip/DeviceError.qml b/resources/qml/voip/DeviceError.qml index c88c7faa..a6411b95 100644 --- a/resources/qml/voip/DeviceError.qml +++ b/resources/qml/voip/DeviceError.qml @@ -6,7 +6,7 @@ import im.nheko 1.0 Popup { property string errorString - property var iconSource + property var image modal: true anchors.centerIn: parent @@ -20,7 +20,7 @@ Popup { Image { Layout.preferredWidth: 16 Layout.preferredHeight: 16 - source: iconSource + source: "image://colorimage/" + image + "?" + colors.windowText } Label { diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index 8dc7d781..95383d95 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -8,6 +8,7 @@ Popup { modal: true anchors.centerIn: parent + palette: colors background: Rectangle { color: colors.window border.color: colors.windowText @@ -19,21 +20,6 @@ Popup { } } - // 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 - ColumnLayout { id: columnLayout @@ -64,7 +50,7 @@ Popup { if (CallManager.mics.length == 0) { var dialog = deviceError.createObject(timelineRoot, { "errorString": qsTr("No microphone found."), - "iconSource": "qrc:/icons/icons/ui/place-call.png" + "image": ":/icons/icons/ui/place-call.png" }); dialog.open(); return false; @@ -81,7 +67,7 @@ Popup { } Button { - text: qsTr("Voice") + text: qsTr(" Voice ") icon.source: "qrc:/icons/icons/ui/place-call.png" onClicked: { if (buttonLayout.validateMic()) { @@ -94,7 +80,7 @@ Popup { Button { visible: CallManager.cameras.length > 0 - text: qsTr("Video") + text: qsTr(" Video ") icon.source: "qrc:/icons/icons/ui/video-call.png" onClicked: { if (buttonLayout.validateMic()) { @@ -126,7 +112,7 @@ Popup { Image { Layout.preferredWidth: 22 Layout.preferredHeight: 22 - source: "qrc:/icons/icons/ui/microphone-unmute.png" + source: "image://colorimage/:/icons/icons/ui/microphone-unmute.png?" + colors.windowText } ComboBox { @@ -146,7 +132,7 @@ Popup { Image { Layout.preferredWidth: 22 Layout.preferredHeight: 22 - source: "qrc:/icons/icons/ui/video-call.png" + source: "image://colorimage/:/icons/icons/ui/video-call.png?" + colors.windowText } ComboBox { -- cgit 1.5.1 From cf8a47503f8f74a04bf0bb95b95ca189a6c6a19c Mon Sep 17 00:00:00 2001 From: trilene Date: Thu, 7 Jan 2021 09:48:25 -0500 Subject: Fix device discovery under GStreamer 1.16 --- resources/qml/MessageInput.qml | 1 + resources/qml/voip/CallInviteBar.qml | 1 + src/CallManager.h | 1 + src/WebRTCSession.cpp | 1 + 4 files changed, 4 insertions(+) (limited to 'resources/qml/voip') diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index 71c61697..00edb7e5 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -46,6 +46,7 @@ Rectangle { CallManager.hangUp(); } else { + CallManager.refreshDevices(); var dialog = placeCallDialog.createObject(timelineRoot); dialog.open(); } diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index 58b89ed3..5021949a 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -71,6 +71,7 @@ Rectangle { ToolTip.visible: hovered ToolTip.text: qsTr("Devices") onClicked: { + CallManager.refreshDevices(); var dialog = devicesDialog.createObject(timelineRoot); dialog.open(); } diff --git a/src/CallManager.h b/src/CallManager.h index 75768ee1..7d388efd 100644 --- a/src/CallManager.h +++ b/src/CallManager.h @@ -53,6 +53,7 @@ public: public slots: void sendInvite(const QString &roomid, bool isVideo); void syncEvent(const mtx::events::collections::TimelineEvents &event); + void refreshDevices() { session_.refreshDevices(); } void toggleMicMute(); void toggleCameraView() { session_.toggleCameraView(); } void acceptInvite(); diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index a431ab54..094a2906 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -1292,6 +1292,7 @@ WebRTCSession::refreshDevices() addDevice(GST_DEVICE_CAST(l->data)); g_list_free(devices); } + emit devicesChanged(); #endif } -- cgit 1.5.1