Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
jami-client-windows
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
savoirfairelinux
jami-client-windows
Commits
a13b48c3
Commit
a13b48c3
authored
Jan 18, 2016
by
Edric Milaret
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ui: make photo round
Change-Id: I5738d1a435b0587ad1b1a9d0639ba7ea8f83bedf Tuleap: #148
parent
d0b3375f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
9 deletions
+38
-9
pixbufmanipulator.cpp
pixbufmanipulator.cpp
+16
-7
smartlistdelegate.cpp
smartlistdelegate.cpp
+2
-0
windowscontactbackend.cpp
windowscontactbackend.cpp
+19
-2
windowscontactbackend.h
windowscontactbackend.h
+1
-0
No files found.
pixbufmanipulator.cpp
View file @
a13b48c3
...
...
@@ -29,7 +29,7 @@
namespace
Interfaces
{
PixbufManipulator
::
PixbufManipulator
()
:
fallbackAvatar_
(
QImage
(
":/images/user/btn-default-userpic.svg"
))
:
fallbackAvatar_
(
QImage
(
":/images/user/btn-default-userpic.svg"
))
{}
QImage
...
...
@@ -147,26 +147,35 @@ QVariant PixbufManipulator::decorationRole(const QModelIndex& index)
QVariant
PixbufManipulator
::
decorationRole
(
const
Call
*
c
)
{
QImage
photo
;
if
(
c
&&
c
->
peerContactMethod
()
&&
c
->
peerContactMethod
()
->
contact
()
&&
c
->
peerContactMethod
()
->
contact
()
->
photo
().
isValid
())
{
return
c
->
peerContactMethod
()
->
contact
()
->
photo
().
value
<
QImage
>
();
photo
=
c
->
peerContactMethod
()
->
contact
()
->
photo
().
value
<
QImage
>
();
}
return
QVariant
::
fromValue
(
scaleAndFrame
(
fallbackAvatar_
,
imgSize_
));
else
photo
=
fallbackAvatar_
;
return
QVariant
::
fromValue
(
scaleAndFrame
(
photo
,
imgSize_
));
}
QVariant
PixbufManipulator
::
decorationRole
(
const
ContactMethod
*
cm
)
{
QImage
photo
;
if
(
cm
&&
cm
->
contact
()
&&
cm
->
contact
()
->
photo
().
isValid
())
return
cm
->
contact
()
->
photo
().
value
<
QImage
>
();
return
QVariant
::
fromValue
(
scaleAndFrame
(
fallbackAvatar_
,
imgSize_
));
photo
=
cm
->
contact
()
->
photo
().
value
<
QImage
>
();
else
photo
=
fallbackAvatar_
;
return
QVariant
::
fromValue
(
scaleAndFrame
(
photo
,
imgSize_
));
}
QVariant
PixbufManipulator
::
decorationRole
(
const
Person
*
p
)
{
QImage
photo
;
if
(
p
&&
p
->
photo
().
isValid
())
return
p
->
photo
();
return
QVariant
::
fromValue
(
scaleAndFrame
(
fallbackAvatar_
,
imgSize_
));
photo
=
p
->
photo
().
value
<
QImage
>
();
else
photo
=
fallbackAvatar_
;
return
QVariant
::
fromValue
(
scaleAndFrame
(
photo
,
imgSize_
));
}
}
// namespace Interfaces
smartlistdelegate.cpp
View file @
a13b48c3
...
...
@@ -40,6 +40,8 @@ SmartListDelegate::paint(QPainter* painter
)
const
{
QStyleOptionViewItem
opt
(
option
);
painter
->
setRenderHint
(
QPainter
::
Antialiasing
);
opt
.
decorationSize
=
QSize
(
sizeImage_
,
sizeImage_
);
opt
.
decorationPosition
=
QStyleOptionViewItem
::
Left
;
opt
.
decorationAlignment
=
Qt
::
AlignCenter
;
if
(
opt
.
state
&
QStyle
::
State_HasFocus
)
...
...
windowscontactbackend.cpp
View file @
a13b48c3
...
...
@@ -19,6 +19,7 @@
#include "windowscontactbackend.h"
#include <QtXml>
#include <QPainter>
#include "personmodel.h"
#include "categorizedcontactmodel.h"
...
...
@@ -289,8 +290,7 @@ WindowsContactBackend::getPersonFromContactFile(const QDir& contactDir,
QImage
photo
;
photo
.
load
(
photoValue
);
if
(
not
photo
.
isNull
())
p
->
setPhoto
(
photo
.
scaled
(
sizePhoto_
,
sizePhoto_
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
));
p
->
setPhoto
(
getCirclePhoto
(
photo
));
}
}
else
if
(
name
==
"EmailAddress"
)
{
...
...
@@ -345,6 +345,23 @@ WindowsContactBackend::getPersonFromContactFile(const QDir& contactDir,
}
}
QImage
WindowsContactBackend
::
getCirclePhoto
(
const
QImage
original
)
{
QImage
target
(
sizePhoto_
,
sizePhoto_
,
QImage
::
Format_ARGB32_Premultiplied
);
target
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
target
);
painter
.
setRenderHints
(
QPainter
::
Antialiasing
|
QPainter
::
SmoothPixmapTransform
);
painter
.
setBrush
(
QBrush
(
Qt
::
white
));
painter
.
drawEllipse
(
0
,
0
,
sizePhoto_
,
sizePhoto_
);
painter
.
setCompositionMode
(
QPainter
::
CompositionMode_SourceIn
);
painter
.
drawImage
(
0
,
0
,
original
.
scaled
(
60
,
60
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
)
.
convertToFormat
(
QImage
::
Format_ARGB32_Premultiplied
));
return
target
;
}
bool
WindowsContactBackend
::
reload
()
{
...
...
windowscontactbackend.h
View file @
a13b48c3
...
...
@@ -55,6 +55,7 @@ private:
private:
bool
getPersonFromContactFile
(
const
QDir
&
contactDir
,
const
QString
&
contactFileName
);
QImage
getCirclePhoto
(
const
QImage
original
);
};
class
WindowsContactEditor
:
public
CollectionEditor
<
Person
>
...
...
Write
Preview
Markdown
is supported
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