matrixion/src/dialogs/PlaceCall.cpp

69 lines
2.1 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-08-01 21:31:10 +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())
2020-08-01 21:31:10 +03:00
avatar->setImage(avatarUrl);
2020-07-23 04:15:45 +03:00
else
2020-08-01 21:31:10 +03:00
avatar->setLetter(utils::firstChar(roomName));
const int iconSize = 24;
voiceBtn_ = new QPushButton(tr("Voice"), this);
voiceBtn_->setIcon(QIcon(":/icons/icons/ui/place-call.png"));
voiceBtn_->setIconSize(QSize(iconSize, iconSize));
2020-07-11 02:19:48 +03:00
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-08-01 21:31:10 +03:00
QString name = displayName.isEmpty() ? callee : displayName;
2020-07-23 04:15:45 +03:00
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();
});
}
}