linux.x86.linphone/Linphone/view/Item/Contact/Avatar.qml
Julien Wadel a43430fa34 Fix crashes on SafeConnection.
Display missed notifications and fit text size from content.
Add account from profile menu and display Login Page with back button.
Default account selection and change avatar from accounts list.
Remove deprecated function on Friends DB.
Return username by default on display name computation.
Update SDK.
2023-12-06 10:10:08 +01:00

75 lines
1.9 KiB
QML

import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import QtQuick.Effects
import Linphone
import UtilsCpp
// Avatar using initial of the username in case
// they don't have any profile picture
StackView{
id: mainItem
property FriendGui contact
property AccountGui account
property string address: account ? account.core.identityAddress : ''
property var displayNameObj: UtilsCpp.getDisplayName(address)
property bool haveAvatar: (account && account.core.pictureUri )
|| (contact && contact.core.pictureUri)
onHaveAvatarChanged: replace(haveAvatar ? avatar : initials, StackView.Immediate)
initialItem: haveAvatar ? avatar : initials
Component{
id: initials
Rectangle {
id: initialItem
property string initials: UtilsCpp.getInitials(mainItem.displayNameObj.value)
radius: width / 2
color: DefaultStyle.main2_200
height: mainItem.height
width: height
Text {
anchors.fill: parent
anchors.centerIn: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: initialItem.initials
font {
pixelSize: initialItem.height * 36 / 120
weight: 800 * DefaultStyle.dp
capitalization: Font.AllUppercase
}
}
}
}
Component{
id: avatar
Item {
id: avatarItem
height: mainItem.height
width: height
Image {
id: image
visible: false
width: parent.width
height: parent.height
sourceSize.width: avatarItem.width
sourceSize.height: avatarItem.height
fillMode: Image.PreserveAspectCrop
anchors.centerIn: parent
source: mainItem.account ? mainItem.account.core.pictureUri : mainItem.contact.core.pictureUri
mipmap: true
}
ShaderEffect {
id: roundEffect
property variant src: image
property double edge: 0.9
anchors.fill: parent
vertexShader: 'qrc:/data/shaders/roundEffect.vert.qsb'
fragmentShader: 'qrc:/data/shaders/roundEffect.frag.qsb'
}
}
}
}