AvatarImage.qml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. mipmap: true
  22. }
  23. Rectangle
  24. {
  25. id: profileImageMask
  26. anchors.fill: parent
  27. radius: width
  28. }
  29. OpacityMask
  30. {
  31. anchors.fill: parent
  32. source: profileImage
  33. maskSource: profileImageMask
  34. cached: true
  35. }
  36. UM.RecolorImage
  37. {
  38. id: profileImageOutline
  39. anchors.centerIn: parent
  40. // Make it a bit bigger than it has to, otherwise it sometimes shows a white border.
  41. width: parent.width + 2
  42. height: parent.height + 2
  43. source: UM.Theme.getIcon("circle_outline")
  44. sourceSize: Qt.size(parent.width, parent.height)
  45. color: UM.Theme.getColor("account_widget_ouline_active")
  46. }
  47. }