summary refs log tree commit diff
path: root/src/dialogs
diff options
context:
space:
mode:
authortrilene <trilene@runbox.com>2020-07-10 19:19:48 -0400
committertrilene <trilene@runbox.com>2020-07-10 19:19:48 -0400
commit7a206441c86cd2aa84cbbbc6be803f03b2f355ab (patch)
tree1fe734ab983daa8998eb23432bd560d7dabf7866 /src/dialogs
parentFix m.relates_to being sent as 'null' when not set in encrypted messages. (diff)
downloadnheko-7a206441c86cd2aa84cbbbc6be803f03b2f355ab.tar.xz
Support voice calls
Diffstat (limited to 'src/dialogs')
-rw-r--r--src/dialogs/AcceptCall.cpp53
-rw-r--r--src/dialogs/AcceptCall.h26
-rw-r--r--src/dialogs/PlaceCall.cpp60
-rw-r--r--src/dialogs/PlaceCall.h28
4 files changed, 167 insertions, 0 deletions
diff --git a/src/dialogs/AcceptCall.cpp b/src/dialogs/AcceptCall.cpp
new file mode 100644

index 00000000..f04a613a --- /dev/null +++ b/src/dialogs/AcceptCall.cpp
@@ -0,0 +1,53 @@ +#include <QLabel> +#include <QPushButton> +#include <QVBoxLayout> + +#include "Config.h" +#include "dialogs/AcceptCall.h" + +namespace dialogs { + +AcceptCall::AcceptCall(const QString &caller, const QString &displayName, QWidget *parent) + : QWidget(parent) +{ + 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); + + acceptBtn_ = new QPushButton(tr("Accept"), this); + acceptBtn_->setDefault(true); + rejectBtn_ = new QPushButton(tr("Reject"), this); + + buttonLayout->addStretch(1); + buttonLayout->addWidget(acceptBtn_); + buttonLayout->addWidget(rejectBtn_); + + QLabel *label; + if (!displayName.isEmpty() && displayName != caller) + label = new QLabel("Accept call from " + displayName + " (" + caller + ")?", this); + else + label = new QLabel("Accept call from " + caller + "?", this); + + layout->addWidget(label); + layout->addLayout(buttonLayout); + + connect(acceptBtn_, &QPushButton::clicked, this, [this]() { + emit accept(); + emit close(); + }); + connect(rejectBtn_, &QPushButton::clicked, this, [this]() { + emit reject(); + emit close(); + }); +} + +} diff --git a/src/dialogs/AcceptCall.h b/src/dialogs/AcceptCall.h new file mode 100644
index 00000000..a410d6b7 --- /dev/null +++ b/src/dialogs/AcceptCall.h
@@ -0,0 +1,26 @@ +#pragma once + +#include <QString> +#include <QWidget> + +class QPushButton; + +namespace dialogs { + +class AcceptCall : public QWidget +{ + Q_OBJECT + +public: + AcceptCall(const QString &caller, const QString &displayName, QWidget *parent = nullptr); + +signals: + void accept(); + void reject(); + +private: + QPushButton *acceptBtn_; + QPushButton *rejectBtn_; +}; + +} diff --git a/src/dialogs/PlaceCall.cpp b/src/dialogs/PlaceCall.cpp new file mode 100644
index 00000000..8b37ff6a --- /dev/null +++ b/src/dialogs/PlaceCall.cpp
@@ -0,0 +1,60 @@ +#include <QLabel> +#include <QPushButton> +#include <QString> +#include <QVBoxLayout> + +#include "Config.h" +#include "dialogs/PlaceCall.h" + +namespace dialogs { + +PlaceCall::PlaceCall(const QString &callee, const QString &displayName, QWidget *parent) + : QWidget(parent) +{ + 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); + + voiceBtn_ = new QPushButton(tr("Voice Call"), this); + voiceBtn_->setDefault(true); + videoBtn_ = new QPushButton(tr("Video Call"), this); + cancelBtn_ = new QPushButton(tr("Cancel"), this); + + buttonLayout->addStretch(1); + buttonLayout->addWidget(voiceBtn_); + buttonLayout->addWidget(videoBtn_); + buttonLayout->addWidget(cancelBtn_); + + QLabel *label; + if (!displayName.isEmpty() && displayName != callee) + label = new QLabel("Place a call to " + displayName + " (" + callee + ")?", this); + else + label = new QLabel("Place a call to " + callee + "?", this); + + layout->addWidget(label); + layout->addLayout(buttonLayout); + + connect(voiceBtn_, &QPushButton::clicked, this, [this]() { + emit voice(); + emit close(); + }); + connect(videoBtn_, &QPushButton::clicked, this, [this]() { + 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 new file mode 100644
index 00000000..b4de1428 --- /dev/null +++ b/src/dialogs/PlaceCall.h
@@ -0,0 +1,28 @@ +#pragma once + +#include <QWidget> + +class QPushButton; +class QString; + +namespace dialogs { + +class PlaceCall : public QWidget +{ + Q_OBJECT + +public: + PlaceCall(const QString &callee, const QString &displayName, QWidget *parent = nullptr); + +signals: + void voice(); + void video(); + void cancel(); + +private: + QPushButton *voiceBtn_; + QPushButton *videoBtn_; + QPushButton *cancelBtn_; +}; + +}