-
Notifications
You must be signed in to change notification settings - Fork 5
/
Avatar.qml
40 lines (37 loc) · 1.02 KB
/
Avatar.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import QtQuick 2.3
import QtGraphicalEffects 1.0
Rectangle {
property bool active: false
property alias avatarImage: avatar_image.source
height: width
color: main_window.lightBlue
radius: 0.5*width
border.width: active?0.02*width:0
border.color: "white"
clip: true
Rectangle {
id: inner_circle
anchors.centerIn: parent
width: 0.8*parent.width
height: width
color: "transparent"
Image {
id: avatar_image
visible: false
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
mipmap: true // better downscaling quality, but may affect performance
}
Image {
id: mask
source: "img/circular-mask-for-avatar.svg"
sourceSize: Qt.size(parent.width, parent.height)
visible: false
}
OpacityMask {
anchors.fill: avatar_image
source: avatar_image
maskSource: mask
}
}
}