vCard #29
@ -344,8 +344,7 @@ void Core::Account::addedAccount(const QString& jid)
|
|||||||
} else {
|
} else {
|
||||||
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::empty));
|
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::empty));
|
||||||
cData.insert("avatarPath", "");
|
cData.insert("avatarPath", "");
|
||||||
client.vCardManager().requestVCard(jid);
|
requestVCard(jid);
|
||||||
pendingVCardRequests.insert(jid);
|
|
||||||
}
|
}
|
||||||
int grCount = 0;
|
int grCount = 0;
|
||||||
for (QSet<QString>::const_iterator itr = gr.begin(), end = gr.end(); itr != end; ++itr) {
|
for (QSet<QString>::const_iterator itr = gr.begin(), end = gr.end(); itr != end; ++itr) {
|
||||||
@ -442,17 +441,14 @@ void Core::Account::onPresenceReceived(const QXmppPresence& p_presence)
|
|||||||
case QXmppPresence::VCardUpdateValidPhoto: //there is a photo, need to load
|
case QXmppPresence::VCardUpdateValidPhoto: //there is a photo, need to load
|
||||||
if (cnt->hasAvatar()) {
|
if (cnt->hasAvatar()) {
|
||||||
if (cnt->isAvatarAutoGenerated()) {
|
if (cnt->isAvatarAutoGenerated()) {
|
||||||
client.vCardManager().requestVCard(jid);
|
requestVCard(jid);
|
||||||
pendingVCardRequests.insert(jid);
|
|
||||||
} else {
|
} else {
|
||||||
if (cnt->avatarHash() != p_presence.photoHash()) {
|
if (cnt->avatarHash() != p_presence.photoHash()) {
|
||||||
client.vCardManager().requestVCard(jid);
|
requestVCard(jid);
|
||||||
pendingVCardRequests.insert(jid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
client.vCardManager().requestVCard(jid);
|
requestVCard(jid);
|
||||||
pendingVCardRequests.insert(jid);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1494,3 +1490,17 @@ void Core::Account::onContactAvatarChanged(Shared::Avatar type, const QString& p
|
|||||||
emit changeContact(item->jid, cData);
|
emit changeContact(item->jid, cData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Account::requestVCard(const QString& jid)
|
||||||
|
{
|
||||||
|
if (pendingVCardRequests.find(jid) == pendingVCardRequests.end()) {
|
||||||
|
if (jid == getLogin() + "@" + getServer()) {
|
||||||
|
if (!ownVCardRequestInProgress) {
|
||||||
|
client.vCardManager().requestClientVCard();
|
||||||
|
ownVCardRequestInProgress = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
client.vCardManager().requestVCard(jid);
|
||||||
|
pendingVCardRequests.insert(jid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -133,6 +133,7 @@ void Core::Squawk::addAccount(const QString& login, const QString& server, const
|
|||||||
connect(acc, &Account::changeRoomParticipant, this, &Squawk::onAccountChangeRoomPresence);
|
connect(acc, &Account::changeRoomParticipant, this, &Squawk::onAccountChangeRoomPresence);
|
||||||
connect(acc, &Account::removeRoomParticipant, this, &Squawk::onAccountRemoveRoomPresence);
|
connect(acc, &Account::removeRoomParticipant, this, &Squawk::onAccountRemoveRoomPresence);
|
||||||
|
|
||||||
|
connect(acc, &Account::receivedVCard, this, &Squawk::responseVCard);
|
||||||
|
|
||||||
QMap<QString, QVariant> map = {
|
QMap<QString, QVariant> map = {
|
||||||
{"login", login},
|
{"login", login},
|
||||||
@ -507,7 +508,7 @@ void Core::Squawk::addContactToGroupRequest(const QString& account, const QStrin
|
|||||||
{
|
{
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to add contact" << jid << "of existing account" << account << "to the group" << groupName << ", skipping";
|
qDebug() << "An attempt to add contact" << jid << "of non existing account" << account << "to the group" << groupName << ", skipping";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
itr->second->addContactToGroupRequest(jid, groupName);
|
itr->second->addContactToGroupRequest(jid, groupName);
|
||||||
@ -517,7 +518,7 @@ void Core::Squawk::removeContactFromGroupRequest(const QString& account, const Q
|
|||||||
{
|
{
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to add contact" << jid << "of existing account" << account << "to the group" << groupName << ", skipping";
|
qDebug() << "An attempt to add contact" << jid << "of non existing account" << account << "to the group" << groupName << ", skipping";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
itr->second->removeContactFromGroupRequest(jid, groupName);
|
itr->second->removeContactFromGroupRequest(jid, groupName);
|
||||||
@ -527,8 +528,18 @@ void Core::Squawk::renameContactRequest(const QString& account, const QString& j
|
|||||||
{
|
{
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to rename contact" << jid << "of existing account" << account << ", skipping";
|
qDebug() << "An attempt to rename contact" << jid << "of non existing account" << account << ", skipping";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
itr->second->renameContactRequest(jid, newName);
|
itr->second->renameContactRequest(jid, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Squawk::requestVCard(const QString& account, const QString& jid)
|
||||||
|
{
|
||||||
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
|
if (itr == amap.end()) {
|
||||||
|
qDebug() << "An attempt to request" << jid << "vcard of non existing account" << account << ", skipping";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
itr->second->requestVCard(jid);
|
||||||
|
}
|
||||||
|
@ -66,6 +66,7 @@ signals:
|
|||||||
void fileLocalPathResponse(const QString& messageId, const QString& path);
|
void fileLocalPathResponse(const QString& messageId, const QString& path);
|
||||||
void downloadFileError(const QString& messageId, const QString& error);
|
void downloadFileError(const QString& messageId, const QString& error);
|
||||||
void downloadFileProgress(const QString& messageId, qreal value);
|
void downloadFileProgress(const QString& messageId, qreal value);
|
||||||
|
void responseVCard(const QString& jid, const Shared::VCard& card);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start();
|
void start();
|
||||||
@ -91,6 +92,7 @@ public slots:
|
|||||||
void removeRoomRequest(const QString& account, const QString& jid);
|
void removeRoomRequest(const QString& account, const QString& jid);
|
||||||
void fileLocalPathRequest(const QString& messageId, const QString& url);
|
void fileLocalPathRequest(const QString& messageId, const QString& url);
|
||||||
void downloadFileRequest(const QString& messageId, const QString& url);
|
void downloadFileRequest(const QString& messageId, const QString& url);
|
||||||
|
void requestVCard(const QString& account, const QString& jid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::deque<Account*> Accounts;
|
typedef std::deque<Account*> Accounts;
|
||||||
|
2
main.cpp
2
main.cpp
@ -105,6 +105,7 @@ int main(int argc, char *argv[])
|
|||||||
QObject::connect(&w, &Squawk::addContactToGroupRequest, squawk, &Core::Squawk::addContactToGroupRequest);
|
QObject::connect(&w, &Squawk::addContactToGroupRequest, squawk, &Core::Squawk::addContactToGroupRequest);
|
||||||
QObject::connect(&w, &Squawk::removeContactFromGroupRequest, squawk, &Core::Squawk::removeContactFromGroupRequest);
|
QObject::connect(&w, &Squawk::removeContactFromGroupRequest, squawk, &Core::Squawk::removeContactFromGroupRequest);
|
||||||
QObject::connect(&w, &Squawk::renameContactRequest, squawk, &Core::Squawk::renameContactRequest);
|
QObject::connect(&w, &Squawk::renameContactRequest, squawk, &Core::Squawk::renameContactRequest);
|
||||||
|
QObject::connect(&w, &Squawk::requestVCard, squawk, &Core::Squawk::requestVCard);
|
||||||
|
|
||||||
QObject::connect(squawk, &Core::Squawk::newAccount, &w, &Squawk::newAccount);
|
QObject::connect(squawk, &Core::Squawk::newAccount, &w, &Squawk::newAccount);
|
||||||
QObject::connect(squawk, &Core::Squawk::addContact, &w, &Squawk::addContact);
|
QObject::connect(squawk, &Core::Squawk::addContact, &w, &Squawk::addContact);
|
||||||
@ -131,6 +132,7 @@ int main(int argc, char *argv[])
|
|||||||
QObject::connect(squawk, &Core::Squawk::fileLocalPathResponse, &w, &Squawk::fileLocalPathResponse);
|
QObject::connect(squawk, &Core::Squawk::fileLocalPathResponse, &w, &Squawk::fileLocalPathResponse);
|
||||||
QObject::connect(squawk, &Core::Squawk::downloadFileProgress, &w, &Squawk::downloadFileProgress);
|
QObject::connect(squawk, &Core::Squawk::downloadFileProgress, &w, &Squawk::downloadFileProgress);
|
||||||
QObject::connect(squawk, &Core::Squawk::downloadFileError, &w, &Squawk::downloadFileError);
|
QObject::connect(squawk, &Core::Squawk::downloadFileError, &w, &Squawk::downloadFileError);
|
||||||
|
QObject::connect(squawk, &Core::Squawk::responseVCard, &w, &Squawk::responseVCard);
|
||||||
|
|
||||||
|
|
||||||
//qDebug() << QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
//qDebug() << QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||||
|
@ -241,3 +241,12 @@ void Models::Account::setAvatarPath(const QString& path)
|
|||||||
changed(8); //it's uncoditional because the path doesn't change when one avatar of the same type replaces another, sha1 sums checks are on the backend
|
changed(8); //it's uncoditional because the path doesn't change when one avatar of the same type replaces another, sha1 sums checks are on the backend
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Models::Account::getBareJid() const
|
||||||
|
{
|
||||||
|
return login + "@" + server;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Models::Account::getFullJid() const
|
||||||
|
{
|
||||||
|
return getBareJid() + "/" + resource;
|
||||||
|
}
|
||||||
|
@ -64,6 +64,9 @@ namespace Models {
|
|||||||
|
|
||||||
void update(const QString& field, const QVariant& value);
|
void update(const QString& field, const QVariant& value);
|
||||||
|
|
||||||
|
QString getBareJid() const;
|
||||||
|
QString getFullJid() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString login;
|
QString login;
|
||||||
QString password;
|
QString password;
|
||||||
|
@ -29,7 +29,9 @@ Squawk::Squawk(QWidget *parent) :
|
|||||||
rosterModel(),
|
rosterModel(),
|
||||||
conversations(),
|
conversations(),
|
||||||
contextMenu(new QMenu()),
|
contextMenu(new QMenu()),
|
||||||
dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus())
|
dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()),
|
||||||
|
requestedFiles(),
|
||||||
|
vCards()
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->roster->setModel(&rosterModel);
|
m_ui->roster->setModel(&rosterModel);
|
||||||
@ -136,12 +138,19 @@ void Squawk::closeEvent(QCloseEvent* event)
|
|||||||
if (accounts != 0) {
|
if (accounts != 0) {
|
||||||
accounts->close();
|
accounts->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Conversations::const_iterator itr = conversations.begin(), end = conversations.end(); itr != end; ++itr) {
|
for (Conversations::const_iterator itr = conversations.begin(), end = conversations.end(); itr != end; ++itr) {
|
||||||
disconnect(itr->second, SIGNAL(destroyed(QObject*)), this, SLOT(onConversationClosed(QObject*)));
|
disconnect(itr->second, &Conversation::destroyed, this, &Squawk::onConversationClosed);
|
||||||
itr->second->close();
|
itr->second->close();
|
||||||
}
|
}
|
||||||
conversations.clear();
|
conversations.clear();
|
||||||
|
|
||||||
|
for (std::map<QString, VCard*>::const_iterator itr = vCards.begin(), end = vCards.end(); itr != end; ++itr) {
|
||||||
|
disconnect(itr->second, &VCard::destroyed, this, &Squawk::onVCardClosed);
|
||||||
|
itr->second->close();
|
||||||
|
}
|
||||||
|
vCards.clear();
|
||||||
|
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,6 +551,10 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QAction* card = contextMenu->addAction(Shared::icon("user-properties"), tr("VCard"));
|
||||||
|
card->setEnabled(active);
|
||||||
|
connect(card, &QAction::triggered, std::bind(&Squawk::onActivateVCard, this, name, acc->getBareJid(), true));
|
||||||
|
|
||||||
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove"));
|
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove"));
|
||||||
remove->setEnabled(active);
|
remove->setEnabled(active);
|
||||||
connect(remove, &QAction::triggered, [this, name]() {
|
connect(remove, &QAction::triggered, [this, name]() {
|
||||||
@ -636,6 +649,10 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
QAction* card = contextMenu->addAction(Shared::icon("user-properties"), tr("VCard"));
|
||||||
|
card->setEnabled(active);
|
||||||
|
connect(card, &QAction::triggered, std::bind(&Squawk::onActivateVCard, this, accName, cnt->getJid(), false));
|
||||||
|
|
||||||
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove"));
|
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove"));
|
||||||
remove->setEnabled(active);
|
remove->setEnabled(active);
|
||||||
connect(remove, &QAction::triggered, [this, cnt]() {
|
connect(remove, &QAction::triggered, [this, cnt]() {
|
||||||
@ -721,3 +738,45 @@ void Squawk::removeRoomParticipant(const QString& account, const QString& jid, c
|
|||||||
{
|
{
|
||||||
rosterModel.removeRoomParticipant(account, jid, name);
|
rosterModel.removeRoomParticipant(account, jid, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Squawk::onVCardClosed()
|
||||||
|
{
|
||||||
|
VCard* vCard = static_cast<VCard*>(sender());
|
||||||
|
|
||||||
|
std::map<QString, VCard*>::const_iterator itr = vCards.find(vCard->getJid());
|
||||||
|
if (itr == vCards.end()) {
|
||||||
|
qDebug() << "VCard has been closed but can not be found among other opened vCards, application is most probably going to crash";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vCards.erase(itr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Squawk::onActivateVCard(const QString& account, const QString& jid, bool edition)
|
||||||
|
{
|
||||||
|
std::map<QString, VCard*>::const_iterator itr = vCards.find(jid);
|
||||||
|
VCard* card;
|
||||||
|
Models::Contact::Messages deque;
|
||||||
|
if (itr != vCards.end()) {
|
||||||
|
card = itr->second;
|
||||||
|
} else {
|
||||||
|
card = new VCard(jid, edition);
|
||||||
|
card->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
vCards.insert(std::make_pair(jid, card));
|
||||||
|
|
||||||
|
connect(card, &VCard::destroyed, this, &Squawk::onVCardClosed);
|
||||||
|
}
|
||||||
|
|
||||||
|
card->show();
|
||||||
|
card->raise();
|
||||||
|
card->activateWindow();
|
||||||
|
|
||||||
|
emit requestVCard(account, jid);
|
||||||
|
}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "widgets/room.h"
|
#include "widgets/room.h"
|
||||||
#include "widgets/newcontact.h"
|
#include "widgets/newcontact.h"
|
||||||
#include "widgets/joinconference.h"
|
#include "widgets/joinconference.h"
|
||||||
|
#include "widgets/vcard.h"
|
||||||
#include "models/roster.h"
|
#include "models/roster.h"
|
||||||
|
|
||||||
#include "../global.h"
|
#include "../global.h"
|
||||||
@ -71,6 +72,7 @@ signals:
|
|||||||
void removeRoomRequest(const QString& account, const QString& jid);
|
void removeRoomRequest(const QString& account, const QString& jid);
|
||||||
void fileLocalPathRequest(const QString& messageId, const QString& url);
|
void fileLocalPathRequest(const QString& messageId, const QString& url);
|
||||||
void downloadFileRequest(const QString& messageId, const QString& url);
|
void downloadFileRequest(const QString& messageId, const QString& url);
|
||||||
|
void requestVCard(const QString& account, const QString& jid);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void newAccount(const QMap<QString, QVariant>& account);
|
void newAccount(const QMap<QString, QVariant>& account);
|
||||||
@ -96,6 +98,7 @@ public slots:
|
|||||||
void fileLocalPathResponse(const QString& messageId, const QString& path);
|
void fileLocalPathResponse(const QString& messageId, const QString& path);
|
||||||
void downloadFileError(const QString& messageId, const QString& error);
|
void downloadFileError(const QString& messageId, const QString& error);
|
||||||
void downloadFileProgress(const QString& messageId, qreal value);
|
void downloadFileProgress(const QString& messageId, qreal value);
|
||||||
|
void responseVCard(const QString& jid, const Shared::VCard& card);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<Models::Roster::ElId, Conversation*> Conversations;
|
typedef std::map<Models::Roster::ElId, Conversation*> Conversations;
|
||||||
@ -107,6 +110,7 @@ private:
|
|||||||
QMenu* contextMenu;
|
QMenu* contextMenu;
|
||||||
QDBusInterface dbus;
|
QDBusInterface dbus;
|
||||||
std::map<QString, std::set<Models::Roster::ElId>> requestedFiles;
|
std::map<QString, std::set<Models::Roster::ElId>> requestedFiles;
|
||||||
|
std::map<QString, VCard*> vCards;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent * event) override;
|
void closeEvent(QCloseEvent * event) override;
|
||||||
@ -121,6 +125,8 @@ private slots:
|
|||||||
void onAccountsSizeChanged(unsigned int size);
|
void onAccountsSizeChanged(unsigned int size);
|
||||||
void onAccountsClosed(QObject* parent = 0);
|
void onAccountsClosed(QObject* parent = 0);
|
||||||
void onConversationClosed(QObject* parent = 0);
|
void onConversationClosed(QObject* parent = 0);
|
||||||
|
void onVCardClosed();
|
||||||
|
void onActivateVCard(const QString& account, const QString& jid, bool edition = false);
|
||||||
void onComboboxActivated(int index);
|
void onComboboxActivated(int index);
|
||||||
void onRosterItemDoubleClicked(const QModelIndex& item);
|
void onRosterItemDoubleClicked(const QModelIndex& item);
|
||||||
void onConversationMessage(const Shared::Message& msg);
|
void onConversationMessage(const Shared::Message& msg);
|
||||||
|
@ -26,6 +26,17 @@ Image::Image(const QString& path, quint16 p_minWidth, QWidget* parent):
|
|||||||
minWidth(p_minWidth)
|
minWidth(p_minWidth)
|
||||||
{
|
{
|
||||||
setScaledContents(true);
|
setScaledContents(true);
|
||||||
|
recalculateAspectRatio();
|
||||||
|
}
|
||||||
|
|
||||||
|
Image::Image(const QString& path, quint16 width, quint16 height, quint16 p_minWidth, QWidget* parent):
|
||||||
|
QLabel(parent),
|
||||||
|
pixmap(QIcon(path).pixmap(QSize(width, height))),
|
||||||
|
aspectRatio(0),
|
||||||
|
minWidth(p_minWidth)
|
||||||
|
{
|
||||||
|
setScaledContents(true);
|
||||||
|
recalculateAspectRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::~Image()
|
Image::~Image()
|
||||||
@ -39,6 +50,11 @@ int Image::heightForWidth(int width) const
|
|||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Image::widthForHeight(int height) const
|
||||||
|
{
|
||||||
|
return height * aspectRatio;
|
||||||
|
}
|
||||||
|
|
||||||
bool Image::hasHeightForWidth() const
|
bool Image::hasHeightForWidth() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -67,3 +83,9 @@ void Image::setPath(const QString& path)
|
|||||||
pixmap = QPixmap(path);
|
pixmap = QPixmap(path);
|
||||||
recalculateAspectRatio();
|
recalculateAspectRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Image::setPath(const QString& path, quint16 width, quint16 height)
|
||||||
|
{
|
||||||
|
pixmap = QPixmap(QIcon(path).pixmap(QSize(width, height)));
|
||||||
|
recalculateAspectRatio();
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo write docs
|
* @todo write docs
|
||||||
@ -29,12 +30,15 @@ class Image : public QLabel
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Image(const QString& path, quint16 minWidth = 50, QWidget* parent = nullptr);
|
Image(const QString& path, quint16 minWidth = 50, QWidget* parent = nullptr);
|
||||||
|
Image(const QString& path, quint16 width, quint16 height, quint16 minWidth = 50, QWidget* parent = nullptr);
|
||||||
|
|
||||||
~Image();
|
~Image();
|
||||||
|
|
||||||
int heightForWidth(int width) const override;
|
int heightForWidth(int width) const override;
|
||||||
|
int widthForHeight(int height) const;
|
||||||
bool hasHeightForWidth() const override;
|
bool hasHeightForWidth() const override;
|
||||||
void setPath(const QString& path);
|
void setPath(const QString& path);
|
||||||
|
void setPath(const QString& path, quint16 width, quint16 height);
|
||||||
void setMinWidth(quint16 minWidth);
|
void setMinWidth(quint16 minWidth);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -19,12 +19,19 @@
|
|||||||
#include "vcard.h"
|
#include "vcard.h"
|
||||||
#include "ui_vcard.h"
|
#include "ui_vcard.h"
|
||||||
|
|
||||||
VCard::VCard(bool edit, QWidget* parent):
|
VCard::VCard(const QString& jid, bool edit, QWidget* parent):
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
m_ui(new Ui::VCard()),
|
m_ui(new Ui::VCard()),
|
||||||
avatar(":/images/logo.svg", 64)
|
avatar(QApplication::palette().window().color().lightnessF() > 0.5 ? ":/images/fallback/dark/big/user.svg" : ":/images/fallback/light/big/user.svg", 256, 256, 256)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
m_ui->jabberID->setText(jid);
|
||||||
|
m_ui->jabberID->setReadOnly(true);
|
||||||
|
QGridLayout* general = static_cast<QGridLayout*>(m_ui->General->layout());
|
||||||
|
general->addWidget(&avatar, 2, 2, 1, 1);
|
||||||
|
avatar.setFrameShape(QFrame::StyledPanel);
|
||||||
|
avatar.setFrameShadow(QFrame::Sunken);
|
||||||
|
avatar.setMargin(6);
|
||||||
|
|
||||||
if (edit) {
|
if (edit) {
|
||||||
|
|
||||||
@ -40,11 +47,15 @@ VCard::VCard(bool edit, QWidget* parent):
|
|||||||
m_ui->organizationTitle->setReadOnly(true);
|
m_ui->organizationTitle->setReadOnly(true);
|
||||||
m_ui->organizationRole->setReadOnly(true);
|
m_ui->organizationRole->setReadOnly(true);
|
||||||
m_ui->description->setReadOnly(true);
|
m_ui->description->setReadOnly(true);
|
||||||
m_ui->jabberID->setReadOnly(true);
|
m_ui->url->setReadOnly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &VCard::onButtonBoxAccepted);
|
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &VCard::onButtonBoxAccepted);
|
||||||
connect(m_ui->buttonBox, &QDialogButtonBox::rejected, m_ui->buttonBox, &QDialogButtonBox::deleteLater);
|
connect(m_ui->buttonBox, &QDialogButtonBox::rejected, m_ui->buttonBox, &QDialogButtonBox::deleteLater);
|
||||||
|
|
||||||
|
int height = m_ui->personalForm->minimumSize().height();
|
||||||
|
avatar.setMaximumSize(avatar.widthForHeight(height), height);
|
||||||
|
avatar.setMinimumSize(avatar.widthForHeight(height), height);
|
||||||
}
|
}
|
||||||
|
|
||||||
VCard::~VCard()
|
VCard::~VCard()
|
||||||
@ -54,6 +65,11 @@ VCard::~VCard()
|
|||||||
void VCard::setVCard(const QString& jid, const Shared::VCard& card)
|
void VCard::setVCard(const QString& jid, const Shared::VCard& card)
|
||||||
{
|
{
|
||||||
m_ui->jabberID->setText(jid);
|
m_ui->jabberID->setText(jid);
|
||||||
|
setVCard(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VCard::setVCard(const Shared::VCard& card)
|
||||||
|
{
|
||||||
m_ui->firstName->setText(card.getFirstName());
|
m_ui->firstName->setText(card.getFirstName());
|
||||||
m_ui->middleName->setText(card.getMiddleName());
|
m_ui->middleName->setText(card.getMiddleName());
|
||||||
m_ui->lastName->setText(card.getLastName());
|
m_ui->lastName->setText(card.getLastName());
|
||||||
@ -65,17 +81,24 @@ void VCard::setVCard(const QString& jid, const Shared::VCard& card)
|
|||||||
//m_ui->organizationRole->setText(card.get());
|
//m_ui->organizationRole->setText(card.get());
|
||||||
m_ui->description->setText(card.getDescription());
|
m_ui->description->setText(card.getDescription());
|
||||||
|
|
||||||
QString path;
|
|
||||||
switch (card.getAvatarType()) {
|
switch (card.getAvatarType()) {
|
||||||
case Shared::Avatar::empty:
|
case Shared::Avatar::empty:
|
||||||
path = QApplication::palette().window().color().lightnessF() > 0.5 ? ":/images/fallback/dark/big/user.svg" : ":/images/fallback/light/big/user.svg";
|
avatar.setPath(QApplication::palette().window().color().lightnessF() > 0.5 ? ":/images/fallback/dark/big/user.svg" : ":/images/fallback/light/big/user.svg", 256, 256);
|
||||||
break;
|
break;
|
||||||
case Shared::Avatar::autocreated:
|
case Shared::Avatar::autocreated:
|
||||||
case Shared::Avatar::valid:
|
case Shared::Avatar::valid:
|
||||||
path = card.getAvatarPath();
|
avatar.setPath(card.getAvatarPath());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
avatar.setPath(path);
|
|
||||||
|
int height = m_ui->personalForm->minimumSize().height();
|
||||||
|
avatar.setMaximumSize(avatar.widthForHeight(height), height);
|
||||||
|
avatar.setMinimumSize(avatar.widthForHeight(height), height);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString VCard::getJid() const
|
||||||
|
{
|
||||||
|
return m_ui->jabberID->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VCard::onButtonBoxAccepted()
|
void VCard::onButtonBoxAccepted()
|
||||||
@ -88,5 +111,5 @@ void VCard::onButtonBoxAccepted()
|
|||||||
card.setBirthday(m_ui->birthday->date());
|
card.setBirthday(m_ui->birthday->date());
|
||||||
card.setDescription(m_ui->description->toPlainText());
|
card.setDescription(m_ui->description->toPlainText());
|
||||||
|
|
||||||
emit saveVCard(m_ui->jabberID->text(), card);
|
emit saveVCard(card);
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,15 @@ class VCard : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VCard(bool edit = false, QWidget* parent = nullptr);
|
VCard(const QString& jid, bool edit = false, QWidget* parent = nullptr);
|
||||||
~VCard();
|
~VCard();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void saveVCard(const QString& jid, const Shared::VCard& card);
|
void saveVCard(const Shared::VCard& card);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onButtonBoxAccepted();
|
void onButtonBoxAccepted();
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>544</width>
|
<width>560</width>
|
||||||
<height>534</height>
|
<height>534</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -80,6 +80,12 @@
|
|||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p><span style=" font-size:16pt; font-weight:600;">Personal information</span></p></body></html></string>
|
<string><html><head/><body><p><span style=" font-size:16pt; font-weight:600;">Personal information</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
@ -97,6 +103,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<layout class="QFormLayout" name="personalForm">
|
<layout class="QFormLayout" name="personalForm">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
|
</property>
|
||||||
<property name="formAlignment">
|
<property name="formAlignment">
|
||||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||||
</property>
|
</property>
|
||||||
@ -104,13 +113,13 @@
|
|||||||
<widget class="QLineEdit" name="middleName">
|
<widget class="QLineEdit" name="middleName">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>200</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>350</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -120,13 +129,13 @@
|
|||||||
<widget class="QLineEdit" name="firstName">
|
<widget class="QLineEdit" name="firstName">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>200</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>350</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -166,13 +175,13 @@
|
|||||||
<widget class="QLineEdit" name="lastName">
|
<widget class="QLineEdit" name="lastName">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>200</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>350</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -192,13 +201,13 @@
|
|||||||
<widget class="QLineEdit" name="nickName">
|
<widget class="QLineEdit" name="nickName">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>200</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>350</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -219,35 +228,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QFrame" name="avatarFrame">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="sizeIncrement">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="3" rowspan="7">
|
<item row="2" column="3" rowspan="7">
|
||||||
<spacer name="generalRightHSpacer">
|
<spacer name="generalRightHSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -314,7 +294,7 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="organizationNameLabel">
|
<widget class="QLabel" name="organizationNameLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Name</string>
|
<string>Organization name</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>organizationName</cstring>
|
<cstring>organizationName</cstring>
|
||||||
@ -325,13 +305,13 @@
|
|||||||
<widget class="QLineEdit" name="organizationName">
|
<widget class="QLineEdit" name="organizationName">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>200</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>350</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -340,7 +320,7 @@
|
|||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="organizationDepartmentLabel">
|
<widget class="QLabel" name="organizationDepartmentLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Department</string>
|
<string>Unit / Department</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>organizationDepartment</cstring>
|
<cstring>organizationDepartment</cstring>
|
||||||
@ -351,13 +331,13 @@
|
|||||||
<widget class="QLineEdit" name="organizationDepartment">
|
<widget class="QLineEdit" name="organizationDepartment">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>200</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>350</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -366,7 +346,7 @@
|
|||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="roleLabel">
|
<widget class="QLabel" name="roleLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Role</string>
|
<string>Role / Profession</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>organizationRole</cstring>
|
<cstring>organizationRole</cstring>
|
||||||
@ -377,13 +357,13 @@
|
|||||||
<widget class="QLineEdit" name="organizationRole">
|
<widget class="QLineEdit" name="organizationRole">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>200</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>350</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -392,7 +372,7 @@
|
|||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="organizationTitleLabel">
|
<widget class="QLabel" name="organizationTitleLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Title</string>
|
<string>Job title</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>organizationTitle</cstring>
|
<cstring>organizationTitle</cstring>
|
||||||
@ -403,13 +383,13 @@
|
|||||||
<widget class="QLineEdit" name="organizationTitle">
|
<widget class="QLineEdit" name="organizationTitle">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>200</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>350</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -479,7 +459,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>532</width>
|
<width>548</width>
|
||||||
<height>410</height>
|
<height>410</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -547,7 +527,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="lineEdit">
|
<widget class="QLineEdit" name="url">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>150</width>
|
||||||
|
Loading…
Reference in New Issue
Block a user