Commit cf4c4d5c authored by Ronan Abhamon's avatar Ronan Abhamon

fix(Avatar): supports images

parent 30e805b5
import QtQuick 2.7 import QtQuick 2.7
import QtGraphicalEffects 1.0
Rectangle { // ===================================================================
Item {
property string username property string username
property string image property alias image: imageToFilter.source
color: '#8F8F8F' Rectangle {
radius: 20 anchors.fill: parent
color: '#8F8F8F'
id: avatar
radius: 20
}
Text { Text {
anchors.centerIn: parent anchors.centerIn: parent
color: '#FFFFFF'
text: (function () { text: (function () {
var spaceIndex = username.indexOf(' ') var spaceIndex = username.indexOf(' ')
var firstLetter = username.charAt(0) var firstLetter = username.charAt(0)
...@@ -19,6 +27,21 @@ Rectangle { ...@@ -19,6 +27,21 @@ Rectangle {
return firstLetter + username.charAt(spaceIndex + 1) return firstLetter + username.charAt(spaceIndex + 1)
})() })()
color: '#FFFFFF' }
Image {
anchors.fill: parent
id: imageToFilter
fillMode: Image.PreserveAspectFit
// Image must be invisible.
// The only visible image is the OpacityMask!
visible: false
}
OpacityMask {
anchors.fill: imageToFilter
source: imageToFilter
maskSource: avatar
} }
} }
...@@ -117,6 +117,11 @@ ColumnLayout { ...@@ -117,6 +117,11 @@ ColumnLayout {
$presence: 'disconnected' $presence: 'disconnected'
$username: 'Cecelia Cyler' $username: 'Cecelia Cyler'
} }
ListElement {
$image: ''
$presence: 'disconnected'
$username: 'Toto'
}
ListElement { ListElement {
$image: '' $image: ''
$presence: 'absent' $presence: 'absent'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment