keep going on refactoring vcard

This commit is contained in:
Blue 2023-02-02 21:39:38 +03:00
parent 4af16b75bf
commit edf1ee60cd
Signed by: blue
GPG key ID: 9B203B252A63EE38
13 changed files with 483 additions and 55 deletions

View file

@ -17,14 +17,85 @@
#include "info.h"
#include "ui_info.h"
UI::Info::Info(const Shared::Info& info, QWidget* parent):
UI::Info::Info(QWidget* parent):
QWidget(parent),
m_ui(new Ui::Info())
m_ui(new Ui::Info()),
contactGeneral(nullptr),
contactContacts(nullptr),
description(nullptr),
overlay(new QWidget()),
progress(new Progress(100)),
progressLabel(new QLabel())
{
m_ui->setupUi(this);
initializeOverlay();
}
UI::Info::~Info()
{}
UI::Info::~Info() {
if (contactGeneral != nullptr)
contactGeneral->deleteLater();
if (contactContacts != nullptr)
contactContacts->deleteLater();
if (description != nullptr)
description->deleteLater();
overlay->deleteLater();
}
void UI::Info::setData(const Shared::Info& info) {
switch (info.type) {
case Shared::EntryType::contact:
initializeContactGeneral(info);
initializeContactContacts(info);
initializeDescription(info.editable);
break;
default:
break;
}
}
void UI::Info::initializeOverlay() {
QGridLayout* gr = static_cast<QGridLayout*>(layout());
gr->addWidget(overlay, 0, 0, 4, 1);
QVBoxLayout* nl = new QVBoxLayout();
QGraphicsOpacityEffect* opacity = new QGraphicsOpacityEffect();
opacity->setOpacity(0.8);
overlay->setLayout(nl);
overlay->setBackgroundRole(QPalette::Base);
overlay->setAutoFillBackground(true);
overlay->setGraphicsEffect(opacity);
progressLabel->setAlignment(Qt::AlignCenter);
QFont pf = progressLabel->font();
pf.setBold(true);
pf.setPointSize(26);
progressLabel->setFont(pf);
progressLabel->setWordWrap(true);
nl->addStretch();
nl->addWidget(progress);
nl->addWidget(progressLabel);
nl->addStretch();
overlay->hide();
}
void UI::Info::showProgress(const QString& line) {
progressLabel->setText(line);
overlay->show();
progress->start();
}
void UI::Info::hideProgress() {
overlay->hide();
progress->stop();
}
void UI::Info::initializeContactGeneral(const Shared::Info& info) {
if (contactGeneral == nullptr) {
contactGeneral = new ContactGeneral;
m_ui->tabWidget->addTab(contactGeneral, contactGeneral->title());
}
contactGeneral->setVCard(info.jid, info.vcard, info.editable);
}