Show default avatar if user has no avatar picture set

CURA-5784
This commit is contained in:
Jaime van Kessel 2018-11-05 14:55:22 +01:00
parent 2bb7b352ef
commit 99bac25ab2
2 changed files with 26 additions and 2 deletions

View file

@ -11,6 +11,7 @@ Column
{
property var profile: null
property var loggedIn: false
property var profileImage: ""
padding: 2 * UM.Theme.getSize("default_margin").height
spacing: 2 * UM.Theme.getSize("default_margin").height
@ -21,7 +22,18 @@ Column
width: UM.Theme.getSize("avatar_image").width
height: UM.Theme.getSize("avatar_image").height
anchors.horizontalCenter: parent.horizontalCenter
source: loggedIn ? profile["profile_image_url"] : UM.Theme.getImage("avatar_no_user")
source:
{
if(loggedIn)
{
if(profileImage)
{
return profileImage
}
return UM.Theme.getImage("avatar_no_user")
}
return UM.Theme.getImage("avatar_no_user")
}
outlineColor: loggedIn ? UM.Theme.getColor("account_widget_outline_active") : UM.Theme.getColor("lining")
}

View file

@ -25,7 +25,18 @@ Button
anchors.verticalCenter: accountWidget.verticalCenter
anchors.horizontalCenter: accountWidget.horizontalCenter
source: loggedIn ? profile["profile_image_url"] : UM.Theme.getImage("avatar_no_user")
source:
{
if(loggedIn)
{
if(profile["profile_image_url"])
{
return profile["profile_image_url"]
}
return UM.Theme.getImage("avatar_no_user")
}
return UM.Theme.getImage("avatar_no_user")
}
outlineColor: loggedIn ? UM.Theme.getColor("account_widget_outline_active") : UM.Theme.getColor("lining")
}
@ -45,6 +56,7 @@ Button
id: panel
profile: Cura.API.account.userProfile
loggedIn: Cura.API.account.isLoggedIn
profileImage: Cura.API.account.profileImageUrl
}
background: UM.PointingRectangle