2020-10-08 22:11:21 +03:00
|
|
|
import QtGraphicalEffects 1.0
|
2019-09-07 23:22:07 +03:00
|
|
|
import QtQuick 2.6
|
2020-03-28 21:12:00 +03:00
|
|
|
import QtQuick.Controls 2.3
|
2020-06-24 17:24:22 +03:00
|
|
|
import im.nheko 1.0
|
|
|
|
|
2019-09-07 23:22:07 +03:00
|
|
|
Rectangle {
|
2020-10-08 22:11:21 +03:00
|
|
|
id: avatar
|
|
|
|
|
|
|
|
property alias url: img.source
|
|
|
|
property string userid
|
|
|
|
property string displayName
|
2020-11-30 18:05:24 +03:00
|
|
|
|
|
|
|
property string usrUrl: TimelineManager.timeline.avatarUrl(userid)
|
2019-09-07 23:22:07 +03:00
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
width: 48
|
|
|
|
height: 48
|
|
|
|
radius: Settings.avatarCircles ? height / 2 : 3
|
2020-10-26 15:50:44 +03:00
|
|
|
color: colors.alternateBase
|
2019-09-07 23:22:07 +03:00
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
Label {
|
|
|
|
anchors.fill: parent
|
|
|
|
text: TimelineManager.escapeEmoji(displayName ? String.fromCodePoint(displayName.codePointAt(0)) : "")
|
|
|
|
textFormat: Text.RichText
|
|
|
|
font.pixelSize: avatar.height / 2
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
visible: img.status != Image.Ready
|
|
|
|
color: colors.text
|
|
|
|
}
|
2019-09-07 23:22:07 +03:00
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
Image {
|
|
|
|
id: img
|
2019-11-03 03:17:40 +03:00
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
anchors.fill: parent
|
|
|
|
asynchronous: true
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
|
|
|
mipmap: true
|
2020-08-21 22:17:35 +03:00
|
|
|
smooth: true
|
2020-10-08 22:11:21 +03:00
|
|
|
sourceSize.width: avatar.width
|
|
|
|
sourceSize.height: avatar.height
|
|
|
|
layer.enabled: true
|
2019-09-07 23:22:07 +03:00
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
layer.effect: OpacityMask {
|
2020-06-08 02:45:24 +03:00
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
maskSource: Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
width: avatar.width
|
|
|
|
height: avatar.height
|
|
|
|
radius: Settings.avatarCircles ? height / 2 : 3
|
|
|
|
}
|
2020-06-08 02:45:24 +03:00
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
2020-06-08 02:45:24 +03:00
|
|
|
|
2020-11-30 18:05:24 +03:00
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
|
|
|
|
anchors.fill: parent
|
2020-11-30 22:58:37 +03:00
|
|
|
onClicked: TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id)
|
2020-11-30 18:05:24 +03:00
|
|
|
}
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
2020-09-03 18:01:58 +03:00
|
|
|
|
2020-10-08 22:11:21 +03:00
|
|
|
Rectangle {
|
|
|
|
anchors.bottom: avatar.bottom
|
|
|
|
anchors.right: avatar.right
|
|
|
|
visible: !!userid
|
|
|
|
height: avatar.height / 6
|
|
|
|
width: height
|
|
|
|
radius: Settings.avatarCircles ? height / 2 : height / 4
|
|
|
|
color: {
|
|
|
|
switch (TimelineManager.userPresence(userid)) {
|
|
|
|
case "online":
|
|
|
|
return "#00cc66";
|
|
|
|
case "unavailable":
|
|
|
|
return "#ff9933";
|
|
|
|
case "offline":
|
|
|
|
default:
|
|
|
|
// return "#a82353" don't show anything if offline, since it is confusing, if presence is disabled
|
|
|
|
"transparent";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-08 02:45:24 +03:00
|
|
|
|
2019-09-07 23:22:07 +03:00
|
|
|
}
|