CameraButton.qml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 QtQuick.Controls.Styles 1.3
  6. import UM 1.3 as UM
  7. import Cura 1.0 as Cura
  8. Button
  9. {
  10. property var iconSource: null
  11. width: UM.Theme.getSize("button").width * 0.75 //Matching the size of the content of tool buttons.
  12. height: UM.Theme.getSize("button").height * 0.75
  13. hoverEnabled: true
  14. background: Rectangle
  15. {
  16. anchors.fill: parent
  17. radius: 0.5 * width
  18. color: parent.enabled ? (parent.hovered ? UM.Theme.getColor("monitor_secondary_button_hover") : "transparent") : UM.Theme.getColor("monitor_icon_disabled")
  19. }
  20. UM.RecolorImage
  21. {
  22. id: icon
  23. anchors
  24. {
  25. horizontalCenter: parent.horizontalCenter
  26. verticalCenter: parent.verticalCenter
  27. }
  28. color: enabled ? UM.Theme.getColor("primary") : UM.Theme.getColor("main_background")
  29. height: width
  30. source: iconSource
  31. width: Math.round(parent.width / 2)
  32. }
  33. onClicked:
  34. {
  35. if (OutputDevice.activeCameraUrl != "")
  36. {
  37. OutputDevice.setActiveCameraUrl("")
  38. }
  39. else
  40. {
  41. OutputDevice.setActiveCameraUrl(modelData.cameraUrl)
  42. }
  43. }
  44. }