matrixion/src/dialogs/PlaceCall.cpp

67 lines
1.9 KiB
C++
Raw Normal View History

2020-07-11 02:19:48 +03:00
#include <QLabel>
#include <QPushButton>
#include <QString>
#include <QVBoxLayout>
#include "Config.h"
2020-07-23 04:15:45 +03:00
#include "Utils.h"
2020-07-11 02:19:48 +03:00
#include "dialogs/PlaceCall.h"
2020-07-23 04:15:45 +03:00
#include "ui/Avatar.h"
2020-07-11 02:19:48 +03:00
namespace dialogs {
2020-07-23 04:15:45 +03:00
PlaceCall::PlaceCall(
const QString &callee,
const QString &displayName,
const QString &roomName,
const QString &avatarUrl,
QWidget *parent) : QWidget(parent)
2020-07-11 02:19:48 +03:00
{
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);
2020-07-24 01:36:10 +03:00
auto buttonLayout = new QHBoxLayout;
2020-07-11 02:19:48 +03:00
buttonLayout->setSpacing(15);
buttonLayout->setMargin(0);
2020-07-23 04:15:45 +03:00
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));
2020-07-11 02:19:48 +03:00
voiceBtn_ = new QPushButton(tr("Voice Call"), this);
voiceBtn_->setDefault(true);
cancelBtn_ = new QPushButton(tr("Cancel"), this);
buttonLayout->addStretch(1);
2020-07-23 04:15:45 +03:00
buttonLayout->addWidget(avatar);
2020-07-11 02:19:48 +03:00
buttonLayout->addWidget(voiceBtn_);
buttonLayout->addWidget(cancelBtn_);
2020-07-23 04:15:45 +03:00
QString name = displayName.isEmpty() ? callee : displayName;
QLabel *label = new QLabel("Place a call to " + name + "?", this);
2020-07-11 02:19:48 +03:00
layout->addWidget(label);
layout->addLayout(buttonLayout);
connect(voiceBtn_, &QPushButton::clicked, this, [this]() {
emit voice();
emit close();
});
connect(cancelBtn_, &QPushButton::clicked, this, [this]() {
emit cancel();
emit close();
});
}
}