Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jami-client-windows
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
savoirfairelinux
jami-client-windows
Commits
a13b48c3
Commit
a13b48c3
authored
Jan 18, 2016
by
Edric Milaret
Browse files
Options
Downloads
Patches
Plain Diff
ui: make photo round
Change-Id: I5738d1a435b0587ad1b1a9d0639ba7ea8f83bedf Tuleap: #148
parent
d0b3375f
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
pixbufmanipulator.cpp
+16
-7
16 additions, 7 deletions
pixbufmanipulator.cpp
smartlistdelegate.cpp
+2
-0
2 additions, 0 deletions
smartlistdelegate.cpp
windowscontactbackend.cpp
+19
-2
19 additions, 2 deletions
windowscontactbackend.cpp
windowscontactbackend.h
+1
-0
1 addition, 0 deletions
windowscontactbackend.h
with
38 additions
and
9 deletions
pixbufmanipulator.cpp
+
16
−
7
View file @
a13b48c3
...
@@ -147,26 +147,35 @@ QVariant PixbufManipulator::decorationRole(const QModelIndex& index)
...
@@ -147,26 +147,35 @@ QVariant PixbufManipulator::decorationRole(const QModelIndex& index)
QVariant
PixbufManipulator
::
decorationRole
(
const
Call
*
c
)
QVariant
PixbufManipulator
::
decorationRole
(
const
Call
*
c
)
{
{
QImage
photo
;
if
(
c
&&
c
->
peerContactMethod
()
if
(
c
&&
c
->
peerContactMethod
()
&&
c
->
peerContactMethod
()
->
contact
()
&&
c
->
peerContactMethod
()
->
contact
()
&&
c
->
peerContactMethod
()
->
contact
()
->
photo
().
isValid
())
{
&&
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
)
QVariant
PixbufManipulator
::
decorationRole
(
const
ContactMethod
*
cm
)
{
{
QImage
photo
;
if
(
cm
&&
cm
->
contact
()
&&
cm
->
contact
()
->
photo
().
isValid
())
if
(
cm
&&
cm
->
contact
()
&&
cm
->
contact
()
->
photo
().
isValid
())
return
cm
->
contact
()
->
photo
().
value
<
QImage
>
();
photo
=
cm
->
contact
()
->
photo
().
value
<
QImage
>
();
return
QVariant
::
fromValue
(
scaleAndFrame
(
fallbackAvatar_
,
imgSize_
));
else
photo
=
fallbackAvatar_
;
return
QVariant
::
fromValue
(
scaleAndFrame
(
photo
,
imgSize_
));
}
}
QVariant
PixbufManipulator
::
decorationRole
(
const
Person
*
p
)
QVariant
PixbufManipulator
::
decorationRole
(
const
Person
*
p
)
{
{
QImage
photo
;
if
(
p
&&
p
->
photo
().
isValid
())
if
(
p
&&
p
->
photo
().
isValid
())
return
p
->
photo
();
photo
=
p
->
photo
().
value
<
QImage
>
();
return
QVariant
::
fromValue
(
scaleAndFrame
(
fallbackAvatar_
,
imgSize_
));
else
photo
=
fallbackAvatar_
;
return
QVariant
::
fromValue
(
scaleAndFrame
(
photo
,
imgSize_
));
}
}
}
// namespace Interfaces
}
// namespace Interfaces
This diff is collapsed.
Click to expand it.
smartlistdelegate.cpp
+
2
−
0
View file @
a13b48c3
...
@@ -40,6 +40,8 @@ SmartListDelegate::paint(QPainter* painter
...
@@ -40,6 +40,8 @@ SmartListDelegate::paint(QPainter* painter
)
const
)
const
{
{
QStyleOptionViewItem
opt
(
option
);
QStyleOptionViewItem
opt
(
option
);
painter
->
setRenderHint
(
QPainter
::
Antialiasing
);
opt
.
decorationSize
=
QSize
(
sizeImage_
,
sizeImage_
);
opt
.
decorationPosition
=
QStyleOptionViewItem
::
Left
;
opt
.
decorationPosition
=
QStyleOptionViewItem
::
Left
;
opt
.
decorationAlignment
=
Qt
::
AlignCenter
;
opt
.
decorationAlignment
=
Qt
::
AlignCenter
;
if
(
opt
.
state
&
QStyle
::
State_HasFocus
)
if
(
opt
.
state
&
QStyle
::
State_HasFocus
)
...
...
...
...
This diff is collapsed.
Click to expand it.
windowscontactbackend.cpp
+
19
−
2
View file @
a13b48c3
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include
"windowscontactbackend.h"
#include
"windowscontactbackend.h"
#include
<QtXml>
#include
<QtXml>
#include
<QPainter>
#include
"personmodel.h"
#include
"personmodel.h"
#include
"categorizedcontactmodel.h"
#include
"categorizedcontactmodel.h"
...
@@ -289,8 +290,7 @@ WindowsContactBackend::getPersonFromContactFile(const QDir& contactDir,
...
@@ -289,8 +290,7 @@ WindowsContactBackend::getPersonFromContactFile(const QDir& contactDir,
QImage
photo
;
QImage
photo
;
photo
.
load
(
photoValue
);
photo
.
load
(
photoValue
);
if
(
not
photo
.
isNull
())
if
(
not
photo
.
isNull
())
p
->
setPhoto
(
photo
.
scaled
(
sizePhoto_
,
sizePhoto_
,
Qt
::
KeepAspectRatio
,
p
->
setPhoto
(
getCirclePhoto
(
photo
));
Qt
::
SmoothTransformation
));
}
}
}
}
else
if
(
name
==
"EmailAddress"
)
{
else
if
(
name
==
"EmailAddress"
)
{
...
@@ -345,6 +345,23 @@ WindowsContactBackend::getPersonFromContactFile(const QDir& contactDir,
...
@@ -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
bool
WindowsContactBackend
::
reload
()
WindowsContactBackend
::
reload
()
{
{
...
...
...
...
This diff is collapsed.
Click to expand it.
windowscontactbackend.h
+
1
−
0
View file @
a13b48c3
...
@@ -55,6 +55,7 @@ private:
...
@@ -55,6 +55,7 @@ private:
private:
private:
bool
getPersonFromContactFile
(
const
QDir
&
contactDir
,
const
QString
&
contactFileName
);
bool
getPersonFromContactFile
(
const
QDir
&
contactDir
,
const
QString
&
contactFileName
);
QImage
getCirclePhoto
(
const
QImage
original
);
};
};
class
WindowsContactEditor
:
public
CollectionEditor
<
Person
>
class
WindowsContactEditor
:
public
CollectionEditor
<
Person
>
...
...
...
...
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
sign in
to comment