Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-client-gnome
Commits
f33a8f52
Commit
f33a8f52
authored
Jan 09, 2019
by
Sébastien Blin
Committed by
Philippe Gorley
Aug 23, 2019
Browse files
chatview: show generated avatar into the chatview
Change-Id: I7f132d4c5d7a1e68463cd065015e2639664250f6 Gitlab:
#947
parent
9f8431e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/chatview.cpp
View file @
f33a8f52
...
...
@@ -30,6 +30,9 @@
// GTK
#include
<glib/gi18n.h>
// Qt
#include
<QSize>
// LRC
#include
<api/contactmodel.h>
#include
<api/conversationmodel.h>
...
...
@@ -38,8 +41,12 @@
#include
<api/call.h>
// Client
#include
"utils/files.h"
#include
"marshals.h"
#include
"utils/files.h"
#include
"native/pixbufmanipulator.h"
/* size of avatar */
static
constexpr
int
AVATAR_WIDTH
=
150
;
/* px */
static
constexpr
int
AVATAR_HEIGHT
=
150
;
/* px */
struct
CppImpl
{
struct
Interaction
{
...
...
@@ -460,25 +467,41 @@ load_participants_images(ChatView *self)
auto
contactUri
=
priv
->
conversation_
->
participants
.
front
();
try
{
auto
&
contact
=
(
*
priv
->
accountInfo_
)
->
contactModel
->
getContact
(
contactUri
);
if
(
!
contact
.
profileInfo
.
avatar
.
empty
())
{
webkit_chat_container_set_sender_image
(
WEBKIT_CHAT_CONTAINER
(
priv
->
webkit_chat_container
),
contactUri
,
contact
.
profileInfo
.
avatar
);
std
::
string
avatar_str
=
contact
.
profileInfo
.
avatar
;
if
(
avatar_str
.
empty
())
{
auto
var_photo
=
Interfaces
::
PixbufManipulator
().
conversationPhoto
(
*
priv
->
conversation_
,
**
(
priv
->
accountInfo_
),
QSize
(
AVATAR_WIDTH
,
AVATAR_HEIGHT
),
contact
.
isPresent
);
auto
image
=
var_photo
.
value
<
std
::
shared_ptr
<
GdkPixbuf
>>
();
auto
ba
=
Interfaces
::
PixbufManipulator
().
toByteArray
(
var_photo
);
avatar_str
=
ba
.
toBase64
().
toStdString
();
}
webkit_chat_container_set_sender_image
(
WEBKIT_CHAT_CONTAINER
(
priv
->
webkit_chat_container
),
contactUri
,
avatar_str
);
}
catch
(
const
std
::
out_of_range
&
)
{
// ContactModel::getContact() exception
}
// For this account
if
(
!
(
*
priv
->
accountInfo_
)
->
profileInfo
.
avatar
.
empty
())
{
webkit_chat_container_set_sender_image
(
WEBKIT_CHAT_CONTAINER
(
priv
->
webkit_chat_container
),
(
*
priv
->
accountInfo_
)
->
profileInfo
.
uri
,
(
*
priv
->
accountInfo_
)
->
profileInfo
.
avatar
);
std
::
string
avatar_str
=
(
*
priv
->
accountInfo_
)
->
profileInfo
.
avatar
;
if
(
avatar_str
.
empty
())
{
auto
default_photo
=
QVariant
::
fromValue
(
Interfaces
::
PixbufManipulator
().
scaleAndFrame
(
Interfaces
::
PixbufManipulator
().
generateAvatar
(
""
,
""
).
get
(),
QSize
(
AVATAR_WIDTH
,
AVATAR_HEIGHT
),
false
));
auto
ba
=
Interfaces
::
PixbufManipulator
().
toByteArray
(
default_photo
);
avatar_str
=
ba
.
toBase64
().
toStdString
();
}
webkit_chat_container_set_sender_image
(
WEBKIT_CHAT_CONTAINER
(
priv
->
webkit_chat_container
),
(
*
priv
->
accountInfo_
)
->
profileInfo
.
uri
,
avatar_str
);
}
static
void
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment