1
0
forked from blue/squawk

progress for VCard widget, date of receiving

This commit is contained in:
Blue 2019-10-31 17:01:48 +03:00
parent f3515f1104
commit e924715a57
8 changed files with 832 additions and 730 deletions

View File

@ -533,6 +533,11 @@ void Shared::VCard::setOrgUnit(const QString& unit)
} }
} }
QDateTime Shared::VCard::getReceivingTime() const
{
return receivingTime;
}
QIcon Shared::availabilityIcon(Shared::Availability av, bool big) QIcon Shared::availabilityIcon(Shared::Availability av, bool big)
{ {
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ? const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?

View File

@ -300,6 +300,7 @@ public:
void setOrgRole(const QString& role); void setOrgRole(const QString& role);
QString getOrgTitle() const; QString getOrgTitle() const;
void setOrgTitle(const QString& title); void setOrgTitle(const QString& title);
QDateTime getReceivingTime() const;
private: private:
QString fullName; QString fullName;

View File

@ -751,6 +751,7 @@ void Squawk::responseVCard(const QString& jid, const Shared::VCard& card)
std::map<QString, VCard*>::const_iterator itr = vCards.find(jid); std::map<QString, VCard*>::const_iterator itr = vCards.find(jid);
if (itr != vCards.end()) { if (itr != vCards.end()) {
itr->second->setVCard(card); itr->second->setVCard(card);
itr->second->hideProgress();
} }
} }
@ -790,6 +791,7 @@ void Squawk::onActivateVCard(const QString& account, const QString& jid, bool ed
card->show(); card->show();
card->raise(); card->raise();
card->activateWindow(); card->activateWindow();
card->showProgress(tr("Downloading vCard"));
emit requestVCard(account, jid); emit requestVCard(account, jid);
} }

View File

@ -63,7 +63,6 @@ Message::Message(const Shared::Message& source, bool outgoing, const QString& p_
dFont.setItalic(true); dFont.setItalic(true);
dFont.setPointSize(dFont.pointSize() - 2); dFont.setPointSize(dFont.pointSize() - 2);
date->setFont(dFont); date->setFont(dFont);
date->setForegroundRole(QPalette::ToolTipText);
QFont f; QFont f;
f.setBold(true); f.setBold(true);

View File

@ -34,9 +34,10 @@ Progress::Progress(quint16 p_size, QWidget* parent):
label.setFrameStyle(0); label.setFrameStyle(0);
label.setContentsMargins(0, 0, 0, 0); label.setContentsMargins(0, 0, 0, 0);
label.setInteractive(false); label.setInteractive(false);
label.setStyleSheet("background: transparent");
pixmap->setTransformOriginPoint(size / 2, size / 2); pixmap->setTransformOriginPoint(size / 2, size / 2);
pixmap->setTransformationMode(Qt::SmoothTransformation); pixmap->setTransformationMode(Qt::SmoothTransformation);
pixmap->setOffset(0, 0);; pixmap->setOffset(0, 0);
animation.setDuration(500); animation.setDuration(500);
animation.setStartValue(0.0f); animation.setStartValue(0.0f);

View File

@ -30,7 +30,10 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
avatarMenu(nullptr), avatarMenu(nullptr),
editable(edit), editable(edit),
currentAvatarType(Shared::Avatar::empty), currentAvatarType(Shared::Avatar::empty),
currentAvatarPath("") currentAvatarPath(""),
progress(new Progress(100)),
progressLabel(new QLabel()),
overlay(new QWidget())
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->jabberID->setText(jid); m_ui->jabberID->setText(jid);
@ -50,6 +53,7 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
m_ui->avatarButton->setMenu(avatarMenu); m_ui->avatarButton->setMenu(avatarMenu);
avatarMenu->addAction(setAvatar); avatarMenu->addAction(setAvatar);
avatarMenu->addAction(clearAvatar); avatarMenu->addAction(clearAvatar);
m_ui->title->setText(tr("Your card"));
} else { } else {
m_ui->buttonBox->hide(); m_ui->buttonBox->hide();
m_ui->fullName->setReadOnly(true); m_ui->fullName->setReadOnly(true);
@ -64,6 +68,7 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
m_ui->organizationRole->setReadOnly(true); m_ui->organizationRole->setReadOnly(true);
m_ui->description->setReadOnly(true); m_ui->description->setReadOnly(true);
m_ui->url->setReadOnly(true); m_ui->url->setReadOnly(true);
m_ui->title->setText(tr("Contact %1 card").arg(jid));
} }
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &VCard::onButtonBoxAccepted); connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &VCard::onButtonBoxAccepted);
@ -73,6 +78,23 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
int height = m_ui->personalForm->minimumSize().height() - avatarButtonMargins.height(); int height = m_ui->personalForm->minimumSize().height() - avatarButtonMargins.height();
m_ui->avatarButton->setIconSize(QSize(height, height)); m_ui->avatarButton->setIconSize(QSize(height, height));
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);
progressLabel->setStyleSheet("font: 16pt");
nl->addStretch();
nl->addWidget(progress);
nl->addWidget(progressLabel);
nl->addStretch();
overlay->hide();
} }
VCard::~VCard() VCard::~VCard()
@ -102,6 +124,9 @@ void VCard::setVCard(const Shared::VCard& card)
m_ui->organizationRole->setText(card.getOrgRole()); m_ui->organizationRole->setText(card.getOrgRole());
m_ui->description->setText(card.getDescription()); m_ui->description->setText(card.getDescription());
m_ui->url->setText(card.getUrl()); m_ui->url->setText(card.getUrl());
QDateTime receivingTime = card.getReceivingTime();
m_ui->receivingTimeLabel->setText(tr("Received %1 at %2").arg(receivingTime.date().toString()).arg(receivingTime.time().toString()));
currentAvatarType = card.getAvatarType(); currentAvatarType = card.getAvatarType();
currentAvatarPath = card.getAvatarPath(); currentAvatarPath = card.getAvatarPath();
@ -211,3 +236,16 @@ void VCard::onAvatarSelected()
} }
} }
} }
void VCard::showProgress(const QString& line)
{
progressLabel->setText(line);
overlay->show();
progress->start();
}
void VCard::hideProgress()
{
overlay->hide();
progress->stop();
}

View File

@ -27,10 +27,14 @@
#include <QMimeDatabase> #include <QMimeDatabase>
#include <QImage> #include <QImage>
#include <QStandardPaths> #include <QStandardPaths>
#include <QLabel>
#include <QGraphicsOpacityEffect>
#include <QVBoxLayout>
#include <set> #include <set>
#include "../../global.h" #include "../../global.h"
#include "../utils/progress.h"
namespace Ui namespace Ui
{ {
@ -50,6 +54,8 @@ public:
void setVCard(const Shared::VCard& card); void setVCard(const Shared::VCard& card);
void setVCard(const QString& jid, const Shared::VCard& card); void setVCard(const QString& jid, const Shared::VCard& card);
QString getJid() const; QString getJid() const;
void showProgress(const QString& = "");
void hideProgress();
signals: signals:
void saveVCard(const Shared::VCard& card); void saveVCard(const Shared::VCard& card);
@ -67,6 +73,9 @@ private:
bool editable; bool editable;
Shared::Avatar currentAvatarType; Shared::Avatar currentAvatarType;
QString currentAvatarPath; QString currentAvatarPath;
Progress* progress;
QLabel* progressLabel;
QWidget* overlay;
static const std::set<QString> supportedTypes; static const std::set<QString> supportedTypes;

File diff suppressed because it is too large Load Diff