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)
{
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?

View File

@ -300,6 +300,7 @@ public:
void setOrgRole(const QString& role);
QString getOrgTitle() const;
void setOrgTitle(const QString& title);
QDateTime getReceivingTime() const;
private:
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);
if (itr != vCards.end()) {
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->raise();
card->activateWindow();
card->showProgress(tr("Downloading vCard"));
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.setPointSize(dFont.pointSize() - 2);
date->setFont(dFont);
date->setForegroundRole(QPalette::ToolTipText);
QFont f;
f.setBold(true);

View File

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

View File

@ -30,7 +30,10 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
avatarMenu(nullptr),
editable(edit),
currentAvatarType(Shared::Avatar::empty),
currentAvatarPath("")
currentAvatarPath(""),
progress(new Progress(100)),
progressLabel(new QLabel()),
overlay(new QWidget())
{
m_ui->setupUi(this);
m_ui->jabberID->setText(jid);
@ -50,6 +53,7 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
m_ui->avatarButton->setMenu(avatarMenu);
avatarMenu->addAction(setAvatar);
avatarMenu->addAction(clearAvatar);
m_ui->title->setText(tr("Your card"));
} else {
m_ui->buttonBox->hide();
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->description->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);
@ -73,6 +78,23 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
int height = m_ui->personalForm->minimumSize().height() - avatarButtonMargins.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()
@ -102,6 +124,9 @@ void VCard::setVCard(const Shared::VCard& card)
m_ui->organizationRole->setText(card.getOrgRole());
m_ui->description->setText(card.getDescription());
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();
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 <QImage>
#include <QStandardPaths>
#include <QLabel>
#include <QGraphicsOpacityEffect>
#include <QVBoxLayout>
#include <set>
#include "../../global.h"
#include "../utils/progress.h"
namespace Ui
{
@ -50,6 +54,8 @@ public:
void setVCard(const Shared::VCard& card);
void setVCard(const QString& jid, const Shared::VCard& card);
QString getJid() const;
void showProgress(const QString& = "");
void hideProgress();
signals:
void saveVCard(const Shared::VCard& card);
@ -67,6 +73,9 @@ private:
bool editable;
Shared::Avatar currentAvatarType;
QString currentAvatarPath;
Progress* progress;
QLabel* progressLabel;
QWidget* overlay;
static const std::set<QString> supportedTypes;

View File

@ -2,18 +2,35 @@
<ui version="4.0">
<class>VCard</class>
<widget class="QWidget" name="VCard">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>594</width>
<height>595</height>
<height>651</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>6</number>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>6</number>
</property>
@ -26,8 +43,37 @@
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="title">
<property name="styleSheet">
<string notr="true">font: 16pt </string>
</property>
<property name="text">
<string notr="true">Contact john@dow.org card</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="receivingTimeLabel">
<property name="styleSheet">
<string notr="true">font: italic 8pt;</string>
</property>
<property name="text">
<string>Received 12.07.2007 at 17.35</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
@ -69,71 +115,6 @@
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="personalHeading">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;Personal information&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="Line" name="personalLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0" rowspan="7">
<spacer name="generalLeftHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="generalHeading">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt; font-weight:600;&quot;&gt;General&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="3" rowspan="7">
<spacer name="generalRightHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="organizationHeading">
<property name="sizePolicy">
@ -153,117 +134,6 @@
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<layout class="QFormLayout" name="organizationForm">
<property name="formAlignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="organizationNameLabel">
<property name="text">
<string>Organization name</string>
</property>
<property name="buddy">
<cstring>organizationName</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="organizationName">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="organizationDepartmentLabel">
<property name="text">
<string>Unit / Department</string>
</property>
<property name="buddy">
<cstring>organizationDepartment</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="organizationDepartment">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="roleLabel">
<property name="text">
<string>Role / Profession</string>
</property>
<property name="buddy">
<cstring>organizationRole</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="organizationRole">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="organizationTitleLabel">
<property name="text">
<string>Job title</string>
</property>
<property name="buddy">
<cstring>organizationTitle</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="organizationTitle">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<layout class="QFormLayout" name="personalForm">
<property name="sizeConstraint">
@ -391,6 +261,206 @@
</item>
</layout>
</item>
<item row="7" column="1" colspan="2">
<layout class="QFormLayout" name="organizationForm">
<property name="formAlignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="organizationNameLabel">
<property name="text">
<string>Organization name</string>
</property>
<property name="buddy">
<cstring>organizationName</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="organizationName">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="organizationDepartmentLabel">
<property name="text">
<string>Unit / Department</string>
</property>
<property name="buddy">
<cstring>organizationDepartment</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="organizationDepartment">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="roleLabel">
<property name="text">
<string>Role / Profession</string>
</property>
<property name="buddy">
<cstring>organizationRole</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="organizationRole">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="organizationTitleLabel">
<property name="text">
<string>Job title</string>
</property>
<property name="buddy">
<cstring>organizationTitle</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="organizationTitle">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="1" colspan="2">
<widget class="Line" name="organizationLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<layout class="QFormLayout" name="commonForm">
<item row="0" column="1">
<widget class="QLineEdit" name="fullName"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="fullNameLabel">
<property name="text">
<string>Full name</string>
</property>
<property name="buddy">
<cstring>fullName</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" rowspan="7">
<spacer name="generalLeftHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1" colspan="2">
<widget class="Line" name="personalLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="generalHeading">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt; font-weight:600;&quot;&gt;General&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="3" rowspan="7">
<spacer name="generalRightHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="personalHeading">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;Personal information&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="avatarButton">
<property name="sizePolicy">
@ -429,30 +499,6 @@
</property>
</widget>
</item>
<item row="8" column="1" colspan="2">
<widget class="Line" name="organizationLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<layout class="QFormLayout" name="commonForm">
<item row="0" column="1">
<widget class="QLineEdit" name="fullName"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="fullNameLabel">
<property name="text">
<string>Full name</string>
</property>
<property name="buddy">
<cstring>fullName</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item row="9" column="1" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
@ -514,8 +560,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>582</width>
<height>471</height>
<width>575</width>
<height>475</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,4,1">
@ -775,6 +821,8 @@
</widget>
</item>
</layout>
</item>
</layout>
<action name="actionSetAvatar">
<property name="icon">
<iconset theme="photo">
@ -806,7 +854,6 @@
<tabstop>organizationDepartment</tabstop>
<tabstop>organizationRole</tabstop>
<tabstop>organizationTitle</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>jabberID</tabstop>
<tabstop>url</tabstop>
<tabstop>description</tabstop>