2019-03-21 23:28:14 -04:00
|
|
|
import QtQuick 2.7
|
2019-04-28 15:18:36 -04:00
|
|
|
import "../Base"
|
2019-07-03 22:31:29 -04:00
|
|
|
import "../utils.js" as Utils
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2019-04-28 11:32:02 -04:00
|
|
|
Rectangle {
|
2019-05-11 15:52:56 -04:00
|
|
|
property var name: null
|
|
|
|
property var imageUrl: null
|
2019-07-06 17:50:55 -04:00
|
|
|
property int dimension: theme.avatar.size
|
2019-05-11 15:52:56 -04:00
|
|
|
property bool hidden: false
|
2019-04-19 02:07:01 -04:00
|
|
|
|
2019-04-28 11:32:02 -04:00
|
|
|
width: dimension
|
|
|
|
height: hidden ? 1 : dimension
|
2019-04-28 14:20:30 -04:00
|
|
|
implicitWidth: dimension
|
|
|
|
implicitHeight: hidden ? 1 : dimension
|
|
|
|
|
2019-04-28 11:32:02 -04:00
|
|
|
opacity: hidden ? 0 : 1
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2019-07-06 17:50:55 -04:00
|
|
|
color: name ? Utils.avatarColor(name) : theme.avatar.background.unknown
|
2019-04-28 11:32:02 -04:00
|
|
|
|
|
|
|
HLabel {
|
|
|
|
z: 1
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: ! hidden
|
|
|
|
|
2019-05-11 15:52:56 -04:00
|
|
|
text: name ? name.charAt(0) : "?"
|
2019-07-06 17:50:55 -04:00
|
|
|
color: theme.avatar.letter
|
2019-04-28 11:32:02 -04:00
|
|
|
font.pixelSize: parent.height / 1.4
|
2019-03-21 23:28:14 -04:00
|
|
|
}
|
|
|
|
|
2019-04-28 11:32:02 -04:00
|
|
|
HImage {
|
|
|
|
z: 2
|
2019-03-21 23:28:14 -04:00
|
|
|
anchors.fill: parent
|
2019-07-06 23:43:51 -04:00
|
|
|
//visible: ! hidden && imageUrl
|
|
|
|
visible: false
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2019-07-06 23:43:51 -04:00
|
|
|
//Component.onCompleted: if (imageUrl) { source = imageUrl }
|
2019-03-21 23:28:14 -04:00
|
|
|
fillMode: Image.PreserveAspectCrop
|
2019-04-28 11:32:02 -04:00
|
|
|
sourceSize.width: dimension
|
2019-03-21 23:28:14 -04:00
|
|
|
}
|
|
|
|
}
|