PrintJobPreview.qml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.Dialogs 1.1
  5. import QtQuick.Controls 2.0
  6. import QtQuick.Controls.Styles 1.3
  7. import QtGraphicalEffects 1.0
  8. import QtQuick.Controls 1.4 as LegacyControls
  9. import UM 1.3 as UM
  10. // Includes print job name, owner, and preview
  11. Item {
  12. property var job: null;
  13. property var useUltibot: false;
  14. height: 100 * screenScaleFactor;
  15. width: height;
  16. // Skeleton
  17. Rectangle {
  18. anchors.fill: parent;
  19. color: UM.Theme.getColor("monitor_skeleton_fill");
  20. radius: UM.Theme.getSize("default_margin").width;
  21. visible: !job;
  22. }
  23. // Actual content
  24. Image {
  25. id: previewImage;
  26. visible: job;
  27. source: job ? job.previewImageUrl : "";
  28. opacity: {
  29. if (job == null) {
  30. return 1.0;
  31. }
  32. var states = ["wait_cleanup", "wait_user_action", "error", "paused"];
  33. if (states.indexOf(job.state) !== -1) {
  34. return 0.5;
  35. }
  36. return 1.0;
  37. }
  38. anchors.fill: parent;
  39. }
  40. UM.RecolorImage {
  41. id: ultibotImage;
  42. anchors.centerIn: parent;
  43. color: UM.Theme.getColor("monitor_placeholder_image"); // TODO: Theme!
  44. height: parent.height;
  45. source: "../svg/ultibot.svg";
  46. sourceSize {
  47. height: height;
  48. width: width;
  49. }
  50. /* Since print jobs ALWAYS have an image url, we have to check if that image URL errors or
  51. not in order to determine if we show the placeholder (ultibot) image instead. */
  52. visible: job && previewImage.status == Image.Error;
  53. width: parent.width;
  54. }
  55. UM.RecolorImage {
  56. id: statusImage;
  57. anchors.centerIn: parent;
  58. color: "black"; // TODO: Theme!
  59. height: Math.round(0.5 * parent.height);
  60. source: job && job.state == "error" ? "../svg/aborted-icon.svg" : "";
  61. sourceSize {
  62. height: height;
  63. width: width;
  64. }
  65. visible: source != "";
  66. width: Math.round(0.5 * parent.width);
  67. }
  68. }