[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:06:16 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=722f1aa
The following commit has been merged in the master branch:
commit 722f1aac3e13eb6384a3be8aba82d3eeed2315fe
Author: Dan Vrátil <dvratil at redhat.com>
Date: Tue Jan 29 16:18:53 2013 +0100
Upgrade contact in ContactInfoDialog to have all neccessary features
REVIEW: 108639
---
KTp/contact-info-dialog.cpp | 127 +++++++++++++++++++++++++++-----------------
KTp/contact-info-dialog.h | 11 ++--
2 files changed, 83 insertions(+), 55 deletions(-)
diff --git a/KTp/contact-info-dialog.cpp b/KTp/contact-info-dialog.cpp
index b625065..17ad583 100644
--- a/KTp/contact-info-dialog.cpp
+++ b/KTp/contact-info-dialog.cpp
@@ -33,6 +33,7 @@
#include <TelepathyQt/ContactManager>
#include <TelepathyQt/Connection>
#include <TelepathyQt/Account>
+#include <TelepathyQt/PendingContacts>
#include <KDebug>
#include <KMessageWidget>
@@ -80,6 +81,7 @@ class ContactInfoDialog::Private
infoDataChanged(false),
avatarChanged(false),
messageWidget(0),
+ columnsLayout(0),
infoLayout(0),
stateLayout(0),
changeAvatarButton(0),
@@ -88,6 +90,7 @@ class ContactInfoDialog::Private
q(parent)
{}
+ void onContactUpgraded(Tp::PendingOperation *op);
void onContactInfoReceived(Tp::PendingOperation *op);
void onChangeAvatarButtonClicked();
void onClearAvatarButtonClicked();
@@ -107,6 +110,7 @@ class ContactInfoDialog::Private
QMap<InfoRowIndex,QWidget*> infoValueWidgets;
KMessageWidget *messageWidget;
+ QHBoxLayout *columnsLayout;
QFormLayout *infoLayout;
QFormLayout *stateLayout;
KPushButton *changeAvatarButton;
@@ -117,6 +121,69 @@ class ContactInfoDialog::Private
ContactInfoDialog *q;
};
+void ContactInfoDialog::Private::onContactUpgraded(Tp::PendingOperation* op)
+{
+ if (op->isError()) {
+ messageWidget->setMessageType(KMessageWidget::Error);
+ messageWidget->setText(op->errorMessage());
+ messageWidget->setCloseButtonVisible(false);
+ messageWidget->setWordWrap(true);
+ messageWidget->animatedShow();
+ return;
+ }
+
+ Tp::PendingContacts *contacts = qobject_cast<Tp::PendingContacts*>(op);
+ Q_ASSERT(contacts->contacts().count() == 1);
+
+ contact = contacts->contacts().first();
+
+ /* Show avatar immediatelly */
+ if (contacts->features().contains(Tp::Contact::FeatureAvatarData)) {
+ QVBoxLayout *avatarLayout = new QVBoxLayout();
+ avatarLayout->setSpacing(5);
+ avatarLayout->setAlignment(Qt::AlignHCenter);
+ columnsLayout->addLayout(avatarLayout);
+
+ avatarLabel = new QLabel(q);
+ avatarLabel->setMaximumSize(150, 150);
+ avatarLayout->addWidget(avatarLabel, 0, Qt::AlignTop);
+
+ if (editable) {
+ changeAvatarButton = new KPushButton(i18n("Change Avatar"), q);
+ connect(changeAvatarButton, SIGNAL(clicked(bool)),
+ q, SLOT(onChangeAvatarButtonClicked()));
+ avatarLayout->addWidget(changeAvatarButton);
+
+ clearAvatarButton = new KPushButton(i18n("Clear Avatar"), q);
+ connect(clearAvatarButton, SIGNAL(clicked(bool)),
+ q, SLOT(onClearAvatarButtonClicked()));
+ avatarLayout->addWidget(clearAvatarButton);
+
+ avatarLayout->addStretch(1);
+ }
+
+ QPixmap avatar(contact->avatarData().fileName);
+ if (avatar.isNull()) {
+ avatar = KIconLoader::global()->loadIcon(QLatin1String("im-user"), KIconLoader::Desktop, 128);
+ if (clearAvatarButton) {
+ clearAvatarButton->setEnabled(false);
+ }
+ }
+ avatarLabel->setPixmap(avatar.scaled(avatarLabel->maximumSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ }
+
+ /* Request detailed contact info */
+ if (contacts->features().contains(Tp::Contact::FeatureInfo)) {
+ infoLayout = new QFormLayout();
+ infoLayout->setSpacing(10);
+ columnsLayout->addLayout(infoLayout);
+
+ Tp::PendingContactInfo *op = contact->requestInfo();
+ connect(op, SIGNAL(finished(Tp::PendingOperation*)),
+ q, SLOT(onContactInfoReceived(Tp::PendingOperation*)));
+ }
+}
+
void ContactInfoDialog::Private::onContactInfoReceived(Tp::PendingOperation* op)
{
if (op->isError()) {
@@ -307,56 +374,16 @@ ContactInfoDialog::ContactInfoDialog(const Tp::AccountPtr& account, const Tp::Co
layout->addWidget(d->messageWidget);
/* 1st column: avatar; 2nd column: details */
- QHBoxLayout *hBoxLayout = new QHBoxLayout();
- hBoxLayout->setSpacing(30);
- layout->addLayout(hBoxLayout);
-
- /* Avatar */
- if (contact->actualFeatures().contains(Tp::Contact::FeatureAvatarData)) {
-
- QVBoxLayout *avatarLayout = new QVBoxLayout();
- avatarLayout->setSpacing(5);
- avatarLayout->setAlignment(Qt::AlignHCenter);
- hBoxLayout->addLayout(avatarLayout);
-
- d->avatarLabel = new QLabel(this);
- d->avatarLabel->setMaximumSize(150, 150);
- avatarLayout->addWidget(d->avatarLabel, 0, Qt::AlignTop);
-
- if (d->editable) {
- d->changeAvatarButton = new KPushButton(i18n("Change Avatar"), this);
- connect(d->changeAvatarButton, SIGNAL(clicked(bool)),
- this, SLOT(onChangeAvatarButtonClicked()));
- avatarLayout->addWidget(d->changeAvatarButton);
-
- d->clearAvatarButton = new KPushButton(i18n("Clear Avatar"), this);
- connect(d->clearAvatarButton, SIGNAL(clicked(bool)),
- this, SLOT(onClearAvatarButtonClicked()));
- avatarLayout->addWidget(d->clearAvatarButton);
-
- avatarLayout->addStretch(1);
- }
-
- QPixmap avatar(contact->avatarData().fileName);
- if (avatar.isNull()) {
- avatar = KIconLoader::global()->loadIcon(QLatin1String("im-user"), KIconLoader::Desktop, 128);
- if (d->clearAvatarButton) {
- d->clearAvatarButton->setEnabled(false);
- }
- }
- d->avatarLabel->setPixmap(avatar.scaled(d->avatarLabel->maximumSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
- }
-
- /* Details */
- if (contact->actualFeatures().contains(Tp::Contact::FeatureInfo)) {
- d->infoLayout = new QFormLayout();
- d->infoLayout->setSpacing(10);
- hBoxLayout->addLayout(d->infoLayout);
-
- Tp::PendingContactInfo *op = contact->requestInfo();
- connect(op, SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(onContactInfoReceived(Tp::PendingOperation*)));
- }
+ d->columnsLayout = new QHBoxLayout();
+ d->columnsLayout->setSpacing(30);
+ layout->addLayout(d->columnsLayout);
+
+ /* Make sure the contact has all neccessary features ready */
+ Tp::PendingContacts *op = contact->manager()->upgradeContacts(
+ QList<Tp::ContactPtr>() << contact,
+ Tp::Features() << Tp::Contact::FeatureAvatarData
+ << Tp::Contact::FeatureInfo);
+ connect(op, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onContactUpgraded(Tp::PendingOperation*)));
/* State Info - there is no point showing this information when it's about ourselves */
if (!d->editable) {
diff --git a/KTp/contact-info-dialog.h b/KTp/contact-info-dialog.h
index dd320ad..2bf8a57 100644
--- a/KTp/contact-info-dialog.h
+++ b/KTp/contact-info-dialog.h
@@ -47,11 +47,12 @@ class KTP_EXPORT ContactInfoDialog : public KDialog
class Private;
Private * const d;
- Q_PRIVATE_SLOT(d, void onContactInfoReceived(Tp::PendingOperation*));
- Q_PRIVATE_SLOT(d, void onChangeAvatarButtonClicked());
- Q_PRIVATE_SLOT(d, void onClearAvatarButtonClicked());
- Q_PRIVATE_SLOT(d, void onInfoDataChanged());
-;
+ Q_PRIVATE_SLOT(d, void onContactUpgraded(Tp::PendingOperation*))
+ Q_PRIVATE_SLOT(d, void onContactInfoReceived(Tp::PendingOperation*))
+ Q_PRIVATE_SLOT(d, void onChangeAvatarButtonClicked())
+ Q_PRIVATE_SLOT(d, void onClearAvatarButtonClicked())
+ Q_PRIVATE_SLOT(d, void onInfoDataChanged())
+
};
} // namespace KTp
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list