CameraButton.qml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2021 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.3
  4. import QtQuick.Controls 2.4
  5. import UM 1.3 as UM
  6. import Cura 1.0 as Cura
  7. Button
  8. {
  9. property var iconSource: null
  10. width: UM.Theme.getSize("button").width * 0.75 //Matching the size of the content of tool buttons.
  11. height: UM.Theme.getSize("button").height * 0.75
  12. hoverEnabled: true
  13. background: Rectangle
  14. {
  15. anchors.fill: parent
  16. radius: 0.5 * width
  17. color: parent.enabled ? (parent.hovered ? UM.Theme.getColor("monitor_card_hover") : "transparent") : UM.Theme.getColor("monitor_icon_disabled")
  18. }
  19. UM.RecolorImage
  20. {
  21. id: icon
  22. anchors
  23. {
  24. horizontalCenter: parent.horizontalCenter
  25. verticalCenter: parent.verticalCenter
  26. }
  27. color: enabled ? UM.Theme.getColor("primary") : UM.Theme.getColor("main_background")
  28. height: width
  29. source: iconSource
  30. width: Math.round(parent.width / 2)
  31. }
  32. onClicked:
  33. {
  34. if (OutputDevice.activeCameraUrl != "")
  35. {
  36. OutputDevice.setActiveCameraUrl("")
  37. }
  38. else
  39. {
  40. OutputDevice.setActiveCameraUrl(modelData.cameraUrl)
  41. }
  42. }
  43. }