CameraButton.qml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2018 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. id: base
  10. property var iconSource: null;
  11. color: "#0a0850" // TODO: Theme!
  12. height: width;
  13. radius: Math.round(0.5 * width);
  14. width: 24 * screenScaleFactor;
  15. property var enabled: true
  16. UM.RecolorImage {
  17. id: icon;
  18. anchors {
  19. horizontalCenter: parent.horizontalCenter;
  20. verticalCenter: parent.verticalCenter;
  21. }
  22. color: UM.Theme.getColor("primary_text");
  23. height: width;
  24. source: iconSource;
  25. width: Math.round(parent.width / 2);
  26. }
  27. MouseArea {
  28. id: clickArea;
  29. anchors.fill: parent;
  30. hoverEnabled: base.enabled
  31. onClicked: {
  32. if (base.enabled)
  33. {
  34. if (OutputDevice.activeCameraUrl != "")
  35. {
  36. OutputDevice.setActiveCameraUrl("")
  37. }
  38. else
  39. {
  40. OutputDevice.setActiveCameraUrl(modelData.cameraUrl)
  41. }
  42. }
  43. }
  44. }
  45. }