- Implement shaders to make round images and use qsb --qt6. - Add picture to Friend. - Display username if displayname is not found. - Compute initials from C++ with emojis. - Add Accounts list in a popup from main window. - Add a hack on account to update avatar on all AcountModel. - Add Avatar item for initials/picture. - Add Contact description item. - Make sizes proportionals to match designs. - Add image colorization.
77 lines
2 KiB
QML
77 lines
2 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
|
|
onAccountChanged: if(account) replace(avatar, StackView.Immediate)
|
|
property string address: account ? account.core.identityAddress : ''
|
|
property var displayNameObj: UtilsCpp.getDisplayName(address)
|
|
property bool haveAvatar: (account && account.core.pictureUri )
|
|
|| (contact && contact.core.pictureUri)
|
|
|
|
initialItem: haveAvatar ? avatar : initials
|
|
Component{
|
|
id: initials
|
|
Rectangle {
|
|
id: initialItem
|
|
property string initials: UtilsCpp.getInitials(mainItem.displayNameObj.value)
|
|
onInitialsChanged: console.log("newInit:"+initials)
|
|
radius: width / 2
|
|
color: DefaultStyle.main2_200
|
|
height: mainItem.height
|
|
width: height
|
|
Component.onCompleted: console.log("init:"+initials)
|
|
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'
|
|
}
|
|
}
|
|
}
|
|
}
|