forked from blue/squawk
some methods to cVard
This commit is contained in:
parent
e7be046e9f
commit
c4d22c9c14
5 changed files with 139 additions and 38 deletions
|
@ -19,13 +19,74 @@
|
|||
#include "vcard.h"
|
||||
#include "ui_vcard.h"
|
||||
|
||||
VCard::VCard(QWidget* parent):
|
||||
VCard::VCard(bool edit, QWidget* parent):
|
||||
QWidget(parent),
|
||||
m_ui(new Ui::VCard())
|
||||
m_ui(new Ui::VCard()),
|
||||
avatar(":/images/logo.svg", 64)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (edit) {
|
||||
|
||||
} else {
|
||||
m_ui->buttonBox->hide();
|
||||
m_ui->firstName->setReadOnly(true);
|
||||
m_ui->middleName->setReadOnly(true);
|
||||
m_ui->lastName->setReadOnly(true);
|
||||
m_ui->nickName->setReadOnly(true);
|
||||
m_ui->birthday->setReadOnly(true);
|
||||
m_ui->organizationName->setReadOnly(true);
|
||||
m_ui->organizationDepartment->setReadOnly(true);
|
||||
m_ui->organizationTitle->setReadOnly(true);
|
||||
m_ui->organizationRole->setReadOnly(true);
|
||||
m_ui->description->setReadOnly(true);
|
||||
m_ui->jabberID->setReadOnly(true);
|
||||
}
|
||||
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &VCard::onButtonBoxAccepted);
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::rejected, m_ui->buttonBox, &QDialogButtonBox::deleteLater);
|
||||
}
|
||||
|
||||
VCard::~VCard()
|
||||
{
|
||||
}
|
||||
|
||||
void VCard::setVCard(const QString& jid, const Shared::VCard& card)
|
||||
{
|
||||
m_ui->jabberID->setText(jid);
|
||||
m_ui->firstName->setText(card.getFirstName());
|
||||
m_ui->middleName->setText(card.getMiddleName());
|
||||
m_ui->lastName->setText(card.getLastName());
|
||||
m_ui->nickName->setText(card.getNickName());
|
||||
m_ui->birthday->setDate(card.getBirthday());
|
||||
//m_ui->organizationName->setText(card.get());
|
||||
//m_ui->organizationDepartment->setText(card.get());
|
||||
//m_ui->organizationTitle->setText(card.get());
|
||||
//m_ui->organizationRole->setText(card.get());
|
||||
m_ui->description->setText(card.getDescription());
|
||||
|
||||
QString path;
|
||||
switch (card.getAvatarType()) {
|
||||
case Shared::Avatar::empty:
|
||||
path = QApplication::palette().window().color().lightnessF() > 0.5 ? ":/images/fallback/dark/big/user.svg" : ":/images/fallback/light/big/user.svg";
|
||||
break;
|
||||
case Shared::Avatar::autocreated:
|
||||
case Shared::Avatar::valid:
|
||||
path = card.getAvatarPath();
|
||||
break;
|
||||
}
|
||||
avatar.setPath(path);
|
||||
}
|
||||
|
||||
void VCard::onButtonBoxAccepted()
|
||||
{
|
||||
Shared::VCard card;
|
||||
card.setFirstName(m_ui->firstName->text());
|
||||
card.setMiddleName(m_ui->middleName->text());
|
||||
card.setLastName(m_ui->lastName->text());
|
||||
card.setNickName(m_ui->nickName->text());
|
||||
card.setBirthday(m_ui->birthday->date());
|
||||
card.setDescription(m_ui->description->toPlainText());
|
||||
|
||||
emit saveVCard(m_ui->jabberID->text(), card);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue