CameraButton.qml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.3
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.3
  6. import UM 1.3 as UM
  7. import Cura 1.0 as Cura
  8. Rectangle
  9. {
  10. id: base
  11. property var enabled: true
  12. property var iconSource: null
  13. color: enabled ? UM.Theme.getColor("monitor_icon_primary") : UM.Theme.getColor("monitor_icon_disabled")
  14. height: width
  15. radius: Math.round(0.5 * width)
  16. width: 24 * screenScaleFactor
  17. UM.RecolorImage
  18. {
  19. id: icon
  20. anchors
  21. {
  22. horizontalCenter: parent.horizontalCenter
  23. verticalCenter: parent.verticalCenter
  24. }
  25. color: UM.Theme.getColor("monitor_icon_accent")
  26. height: width
  27. source: iconSource
  28. width: Math.round(parent.width / 2)
  29. }
  30. MouseArea
  31. {
  32. id: clickArea
  33. anchors.fill: parent
  34. hoverEnabled: base.enabled
  35. onClicked:
  36. {
  37. if (base.enabled)
  38. {
  39. if (OutputDevice.activeCameraUrl != "")
  40. {
  41. OutputDevice.setActiveCameraUrl("")
  42. }
  43. else
  44. {
  45. OutputDevice.setActiveCameraUrl(modelData.cameraUrl)
  46. }
  47. }
  48. }
  49. }
  50. }