48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#include "invitedialog.h"
|
|
#include "qrcode_utils.h"
|
|
#include <QVBoxLayout>
|
|
#include <QHBoxLayout>
|
|
#include <QLineEdit>
|
|
#include <QPushButton>
|
|
#include <QLabel>
|
|
#include <QClipboard>
|
|
#include <QApplication>
|
|
|
|
InviteDialog::InviteDialog(const QString& link, QWidget* parent)
|
|
: QDialog(parent), m_link(link)
|
|
{
|
|
setWindowTitle("Пригласительная ссылка");
|
|
setMinimumWidth(420);
|
|
setModal(true);
|
|
|
|
auto *layout = new QVBoxLayout(this);
|
|
layout->setSpacing(12);
|
|
|
|
auto *linkEdit = new QLineEdit(m_link, this);
|
|
linkEdit->setReadOnly(true);
|
|
linkEdit->setStyleSheet("padding: 6px; font-family: monospace;");
|
|
layout->addWidget(linkEdit);
|
|
|
|
auto *btnLayout = new QHBoxLayout();
|
|
auto *copyBtn = new QPushButton("Скопировать", this);
|
|
connect(copyBtn, &QPushButton::clicked, this, [this, linkEdit]() {
|
|
QApplication::clipboard()->setText(m_link);
|
|
linkEdit->setFocus();
|
|
});
|
|
btnLayout->addWidget(copyBtn);
|
|
btnLayout->addStretch();
|
|
layout->addLayout(btnLayout);
|
|
|
|
auto *qrLabel = new QLabel(this);
|
|
QImage qrImage = generateQRCode(m_link);
|
|
if (!qrImage.isNull())
|
|
qrLabel->setPixmap(QPixmap::fromImage(qrImage).scaled(
|
|
180, 180, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
|
qrLabel->setAlignment(Qt::AlignCenter);
|
|
layout->addWidget(qrLabel, 0, Qt::AlignCenter);
|
|
|
|
auto *closeBtn = new QPushButton("OK", this);
|
|
connect(closeBtn, &QPushButton::clicked, this, &QDialog::accept);
|
|
layout->addWidget(closeBtn, 0, Qt::AlignRight);
|
|
}
|