Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-qt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-qt
Commits
d4d73da8
Commit
d4d73da8
authored
3 years ago
by
Sébastien Blin
Browse files
Options
Downloads
Patches
Plain Diff
utils: improve conversationAvatar for swarm
Change-Id: I59383870785900a8413bc15377d6de427f48384b
parent
7139eecc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/utils.cpp
+32
-2
32 additions, 2 deletions
src/utils.cpp
src/utils.h
+1
-0
1 addition, 0 deletions
src/utils.h
with
33 additions
and
2 deletions
src/utils.cpp
+
32
−
2
View file @
d4d73da8
...
...
@@ -396,10 +396,23 @@ Utils::conversationAvatar(LRCInstance* instance,
auto
&
accInfo
=
instance
->
accountModel
().
getAccountInfo
(
accountId
.
isEmpty
()
?
instance
->
get_currentAccountId
()
:
accountId
);
auto
*
convModel
=
accInfo
.
conversationModel
.
get
();
Q_FOREACH
(
const
auto
peerUri
,
convModel
->
peersForConversation
(
convId
))
{
auto
peerAvatar
=
Utils
::
contactPhoto
(
instance
,
peerUri
,
size
);
auto
members
=
convModel
->
peersForConversation
(
convId
);
if
(
members
.
size
()
<
1
)
return
avatar
;
if
(
members
.
size
()
==
1
)
{
// Only member in the swarm or 1:1, draw only peer's avatar
auto
peerAvatar
=
Utils
::
contactPhoto
(
instance
,
members
[
0
],
size
);
painter
.
drawImage
(
avatar
.
rect
(),
peerAvatar
);
return
avatar
;
}
// Else, combine avatars
auto
idx
=
0
;
auto
peerAAvatar
=
Utils
::
contactPhoto
(
instance
,
members
[
0
],
size
);
auto
peerBAvatar
=
Utils
::
contactPhoto
(
instance
,
members
[
1
],
size
);
peerAAvatar
=
Utils
::
halfCrop
(
peerAAvatar
,
true
);
peerBAvatar
=
Utils
::
halfCrop
(
peerBAvatar
,
false
);
painter
.
drawImage
(
avatar
.
rect
(),
peerAAvatar
);
painter
.
drawImage
(
avatar
.
rect
(),
peerBAvatar
);
}
catch
(
const
std
::
exception
&
e
)
{
qDebug
()
<<
Q_FUNC_INFO
<<
e
.
what
();
}
...
...
@@ -453,6 +466,23 @@ Utils::getCirclePhoto(const QImage original, int sizePhoto)
return
target
;
}
QImage
Utils
::
halfCrop
(
const
QImage
original
,
bool
leftSide
)
{
auto
width
=
original
.
size
().
width
();
auto
height
=
original
.
size
().
height
();
QImage
target
(
width
,
height
,
QImage
::
Format_ARGB32_Premultiplied
);
target
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
target
);
painter
.
setRenderHints
(
QPainter
::
Antialiasing
|
QPainter
::
SmoothPixmapTransform
);
painter
.
setBrush
(
QBrush
(
Qt
::
white
));
painter
.
drawRect
(
leftSide
?
0
:
width
/
2
+
2
,
0
,
width
/
2
-
(
leftSide
?
2
:
0
),
height
);
painter
.
setCompositionMode
(
QPainter
::
CompositionMode_SourceIn
);
painter
.
drawImage
(
0
,
0
,
original
,
0
,
0
);
return
target
;
}
QSize
Utils
::
getRealSize
(
QScreen
*
screen
)
{
...
...
This diff is collapsed.
Click to expand it.
src/utils.h
+
1
−
0
View file @
d4d73da8
...
...
@@ -95,6 +95,7 @@ QImage conversationAvatar(LRCInstance* instance,
const
QSize
&
size
=
defaultAvatarSize
,
const
QString
&
accountId
=
{});
QImage
getCirclePhoto
(
const
QImage
original
,
int
sizePhoto
);
QImage
halfCrop
(
const
QImage
original
,
bool
leftSide
);
QColor
getAvatarColor
(
const
QString
&
canonicalUri
);
QImage
fallbackAvatar
(
const
QString
&
canonicalUriStr
,
const
QString
&
letterStr
=
{},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment