display presence status
- Modify RecentContactsView so that it displays the number of unread
messages as a number
- Modify PixbufManipulator so that it draws presence status if
displayPresence parameter is set to true. It dispays presence status
as a green circle in the corner of the avatar.
[SS: moved drawing call to PixbufManipulator from RecentContactsView]
[SS: fixed unread count being hardcoded to 10]
Tuleap: #1379
Change-Id: I1fda061d26f231e9d0bb82f044eac91ecdb74db8
Signed-off-by: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
diff --git a/src/native/pixbufmanipulator.cpp b/src/native/pixbufmanipulator.cpp
index 1e534bf..3790d58 100644
--- a/src/native/pixbufmanipulator.cpp
+++ b/src/native/pixbufmanipulator.cpp
@@ -36,7 +36,7 @@
}
std::shared_ptr<GdkPixbuf>
-PixbufManipulator::scaleAndFrame(const GdkPixbuf *photo, const QSize& size)
+PixbufManipulator::scaleAndFrame(const GdkPixbuf *photo, const QSize& size, bool display_presence, bool is_present)
{
/**
* for now, respect the height requested
@@ -63,14 +63,25 @@
g_object_unref};
/* frame photo */
- return {ring_frame_avatar(scaled_photo.get()), g_object_unref};
+ std::shared_ptr<GdkPixbuf> result {
+ ring_frame_avatar(scaled_photo.get()),
+ g_object_unref
+ };
+
+ /* draw presence */
+ if (display_presence)
+ result.reset(ring_draw_presence(result.get(), is_present), g_object_unref);
+
+ return result;
}
QVariant
PixbufManipulator::callPhoto(Call* c, const QSize& size, bool displayPresence)
{
- if (c->type() == Call::Type::CONFERENCE)
- return QVariant::fromValue(scaleAndFrame(conferenceAvatar_.get(), size));
+ if (c->type() == Call::Type::CONFERENCE) {
+ /* conferences are always "online" */
+ return QVariant::fromValue(scaleAndFrame(conferenceAvatar_.get(), size, displayPresence, TRUE));
+ }
return callPhoto(c->peerContactMethod(), size, displayPresence);
}
@@ -80,15 +91,13 @@
if (n->contact()) {
return contactPhoto(n->contact(), size, displayPresence);
} else {
- return QVariant::fromValue(scaleAndFrame(fallbackAvatar_.get(), size));
+ return QVariant::fromValue(scaleAndFrame(fallbackAvatar_.get(), size, displayPresence, n->isPresent()));
}
}
QVariant
PixbufManipulator::contactPhoto(Person* c, const QSize& size, bool displayPresence)
{
- Q_UNUSED(displayPresence);
-
/**
* try to get the photo
* otherwise use the fallback avatar
@@ -101,7 +110,7 @@
else
photo = fallbackAvatar_;
- return QVariant::fromValue(scaleAndFrame(photo.get(), size));
+ return QVariant::fromValue(scaleAndFrame(photo.get(), size, displayPresence, c->isPresent()));
}
QVariant PixbufManipulator::personPhoto(const QByteArray& data, const QString& type)
diff --git a/src/native/pixbufmanipulator.h b/src/native/pixbufmanipulator.h
index 3122678..ddeb4e1 100644
--- a/src/native/pixbufmanipulator.h
+++ b/src/native/pixbufmanipulator.h
@@ -55,7 +55,7 @@
QVariant decorationRole(const Account* p) override;
private:
- std::shared_ptr<GdkPixbuf> scaleAndFrame(const GdkPixbuf *photo, const QSize& size);
+ std::shared_ptr<GdkPixbuf> scaleAndFrame(const GdkPixbuf *photo, const QSize& size, bool display_presence = false, bool is_present = false);
std::shared_ptr<GdkPixbuf> fallbackAvatar_;
std::shared_ptr<GdkPixbuf> conferenceAvatar_;
};