AvatarImage.qml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.1
  5. import QtGraphicalEffects 1.0
  6. import UM 1.4 as UM
  7. Item
  8. {
  9. // This item shows the provided image while applying a round mask to it.
  10. // It also shows a round border around it. The color is defined by the outlineColor property.
  11. id: avatar
  12. property alias source: profileImage.source
  13. property alias outlineColor: profileImageOutline.color
  14. Image
  15. {
  16. id: profileImage
  17. anchors.fill: parent
  18. source: UM.Theme.getImage("avatar_default")
  19. fillMode: Image.PreserveAspectCrop
  20. visible: false
  21. }
  22. Rectangle
  23. {
  24. id: profileImageMask
  25. anchors.fill: parent
  26. radius: width
  27. }
  28. OpacityMask
  29. {
  30. anchors.fill: parent
  31. source: profileImage
  32. maskSource: profileImageMask
  33. cached: true
  34. }
  35. UM.RecolorImage
  36. {
  37. id: profileImageOutline
  38. anchors.centerIn: parent
  39. // Make it a bit bigger than it has to, otherwise it sometimes shows a white border.
  40. width: parent.width + 2
  41. height: parent.height + 2
  42. source: UM.Theme.getIcon("circle_outline")
  43. sourceSize: Qt.size(parent.width, parent.height)
  44. color: UM.Theme.getColor("account_widget_ouline_active")
  45. }
  46. }