AvatarImage.qml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import UM 1.4 as UM
  6. Item
  7. {
  8. // This item shows the provided image while applying a round mask to it.
  9. // It also shows a round border around it. The color is defined by the outlineColor property.
  10. id: avatar
  11. property alias source: profileImage.source
  12. property alias outlineColor: profileImageOutline.color
  13. // This should be set to the color behind the image
  14. // It fills the space around a rectangular avatar to make the image under it look circular
  15. property alias maskColor: profileImageMask.color
  16. property bool hasAvatar: source != ""
  17. Rectangle
  18. {
  19. id: profileImageBackground
  20. anchors.fill: parent
  21. radius: width
  22. color: "white"
  23. }
  24. Image
  25. {
  26. id: profileImage
  27. anchors.fill: parent
  28. fillMode: Image.PreserveAspectCrop
  29. visible: hasAvatar
  30. mipmap: true
  31. }
  32. UM.ColorImage
  33. {
  34. // This image is a rectangle with a hole in the middle.
  35. // Since we don't have access to proper masking in QT6 yet this is used as a primitive masking replacement
  36. id: profileImageMask
  37. anchors.fill: parent
  38. source: UM.Theme.getIcon("CircleMask")
  39. }
  40. UM.ColorImage
  41. {
  42. // This creates the circle outline around the image
  43. id: profileImageOutline
  44. anchors.fill: parent
  45. anchors.margins: .25
  46. visible: hasAvatar
  47. source: UM.Theme.getIcon("CircleOutline")
  48. color: UM.Theme.getColor("account_widget_outline_active")
  49. }
  50. }