[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:28 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=3d518bb
The following commit has been merged in the master branch:
commit 3d518bb19711f4d96a254a38d5401e1a49a40aa1
Author: Alin M Elena <alinm.elena at gmail.com>
Date: Fri Mar 1 17:31:03 2013 +0000
new method for KTp::Contact avatarPixmap()
the offline avatars are returned as gray
this addresses part of bug #315965
REVIEW: 109231
---
KTp/Models/contacts-list-model.cpp | 3 +++
KTp/contact.cpp | 46 +++++++++++++++++++++++++++++++++-----
KTp/contact.h | 6 +++++
KTp/types.h | 1 +
4 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/KTp/Models/contacts-list-model.cpp b/KTp/Models/contacts-list-model.cpp
index 692bcfd..22d8e12 100644
--- a/KTp/Models/contacts-list-model.cpp
+++ b/KTp/Models/contacts-list-model.cpp
@@ -51,6 +51,7 @@ KTp::ContactsListModel::ContactsListModel(QObject *parent) :
roles[KTp::ContactClientTypesRole]= "clientTypes";
roles[KTp::ContactAvatarPathRole]= "avatar";
+ roles[KTp::ContactAvatarPixmapRole]="avatarQPixmap";
roles[KTp::ContactGroupsRole]= "groups";
roles[KTp::ContactPresenceMessageRole]= "presenceMessage";
roles[KTp::ContactPresenceTypeRole]= "presenceType";
@@ -109,6 +110,8 @@ QVariant KTp::ContactsListModel::data(const QModelIndex &index, int role) const
return contact->clientTypes();
case KTp::ContactAvatarPathRole:
return contact->avatarData().fileName;
+ case KTp::ContactAvatarPixmapRole:
+ return contact->avatarPixmap();
case KTp::ContactGroupsRole:
return contact->groups();
diff --git a/KTp/contact.cpp b/KTp/contact.cpp
index 0602200..d9ad096 100644
--- a/KTp/contact.cpp
+++ b/KTp/contact.cpp
@@ -21,6 +21,12 @@
#include <TelepathyQt/ContactManager>
#include <TelepathyQt/Connection>
#include <TelepathyQt/ContactCapabilities>
+#include <TelepathyQt/AvatarData>
+
+#include <QBitmap>
+#include <QPixmap>
+
+#include <KIconLoader>
#include "capabilities-hack-private.h"
@@ -28,7 +34,7 @@ KTp::Contact::Contact(Tp::ContactManager *manager, const Tp::ReferencedHandles &
: Tp::Contact(manager, handle, requestedFeatures, attributes)
{
connect(manager->connection().data(), SIGNAL(destroyed()), SIGNAL(invalidated()));
- connect(manager->connection().data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)), SIGNAL(invalidated()));
+ connect(manager->connection().data(), SIGNAL(invalidated(Tp::DBusProxy*, QString, QString)), SIGNAL(invalidated()));
}
KTp::Presence KTp::Contact::presence() const
@@ -44,9 +50,9 @@ bool KTp::Contact::audioCallCapability() const
Tp::ConnectionPtr connection = manager()->connection();
if (connection) {
bool contactCanStreamAudio = CapabilitiesHackPrivate::audioCalls(
- capabilities(), connection->cmName());
+ capabilities(), connection->cmName());
bool selfCanStreamAudio = CapabilitiesHackPrivate::audioCalls(
- connection->selfContact()->capabilities(), connection->cmName());
+ connection->selfContact()->capabilities(), connection->cmName());
return contactCanStreamAudio && selfCanStreamAudio;
}
return false;
@@ -60,9 +66,9 @@ bool KTp::Contact::videoCallCapability() const
Tp::ConnectionPtr connection = manager()->connection();
if (connection) {
bool contactCanStreamVideo = CapabilitiesHackPrivate::videoCalls(
- capabilities(), connection->cmName());
+ capabilities(), connection->cmName());
bool selfCanStreamVideo = CapabilitiesHackPrivate::videoCalls(
- connection->selfContact()->capabilities(), connection->cmName());
+ connection->selfContact()->capabilities(), connection->cmName());
return contactCanStreamVideo && selfCanStreamVideo;
}
@@ -94,3 +100,33 @@ QStringList KTp::Contact::clientTypes() const
return Tp::Contact::clientTypes();
}
+QPixmap KTp::Contact::avatarPixmap()
+{
+ QString file = Tp::Contact::avatarData().fileName;
+ QPixmap avatar;
+ if (file.isEmpty()) {
+ avatar = KIconLoader::global()->loadIcon(QLatin1String("im-user"), KIconLoader::NoGroup, 96);
+ } else {
+ avatar.load(file);
+ }
+ if (Tp::Contact::presence().type() == Tp::ConnectionPresenceTypeOffline) {
+ avatarToGray(avatar);
+ }
+ return avatar;
+}
+
+void KTp::Contact::avatarToGray(QPixmap &avatar)
+{
+ QImage image = avatar.toImage();
+ QBitmap alphaMask = avatar.mask();
+ for (int i = 0; i < image.width(); ++i) {
+ for (int j = 0; j < image.height(); ++j) {
+ int colour = qGray(image.pixel(i, j));
+ image.setPixel(i, j, qRgb(colour, colour, colour));
+ }
+ }
+ avatar = avatar.fromImage(image);
+ avatar.setMask(alphaMask);
+}
+
+
diff --git a/KTp/contact.h b/KTp/contact.h
index c332c7d..7b84c22 100644
--- a/KTp/contact.h
+++ b/KTp/contact.h
@@ -44,9 +44,15 @@ public:
//Overridden as a workaround for upstream bug https://bugs.freedesktop.org/show_bug.cgi?id=55883
QStringList clientTypes() const;
+ /** Returns the pixmap of an avatar coloured according to the presence*/
+ QPixmap avatarPixmap();
Q_SIGNALS:
void invalidated();
+
+private:
+ void avatarToGray(QPixmap &avatar);
+
};
diff --git a/KTp/types.h b/KTp/types.h
index 4ef0002..3239118 100644
--- a/KTp/types.h
+++ b/KTp/types.h
@@ -70,6 +70,7 @@ namespace KTp
ContactCanAudioCallRole, ///< bool. You and contact can both audio call
ContactCanVideoCallRole, ///< bool. You and contact can both video call
ContactTubesRole, ///< stringlist. common supported dbus + stream services between you and contact
+ ContactAvatarPixmapRole, ///< QPixmap the pixmap that shall be use as avatar image
//heading roles
HeaderTotalUsersRole = Qt::UserRole + 3000,
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list