UM3InfoComponents.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Layouts 1.1
  6. import QtQuick.Window 2.1
  7. import UM 1.2 as UM
  8. import Cura 1.0 as Cura
  9. Item {
  10. id: base;
  11. property string activeQualityDefinitionId: Cura.MachineManager.activeQualityDefinitionId;
  12. property bool isUM3: activeQualityDefinitionId == "ultimaker3" || activeQualityDefinitionId.match("ultimaker_") != null;
  13. property bool printerConnected: Cura.MachineManager.printerConnected;
  14. property bool printerAcceptsCommands:
  15. {
  16. if (printerConnected && Cura.MachineManager.printerOutputDevices[0])
  17. {
  18. return Cura.MachineManager.printerOutputDevices[0].acceptsCommands
  19. }
  20. return false
  21. }
  22. property bool authenticationRequested:
  23. {
  24. if (printerConnected && Cura.MachineManager.printerOutputDevices[0])
  25. {
  26. var device = Cura.MachineManager.printerOutputDevices[0]
  27. // AuthState.AuthenticationRequested or AuthState.AuthenticationReceived
  28. return device.authenticationState == 2 || device.authenticationState == 5
  29. }
  30. return false
  31. }
  32. property var materialNames:
  33. {
  34. if (printerConnected && Cura.MachineManager.printerOutputDevices[0])
  35. {
  36. return Cura.MachineManager.printerOutputDevices[0].materialNames
  37. }
  38. return null
  39. }
  40. property var hotendIds:
  41. {
  42. if (printerConnected && Cura.MachineManager.printerOutputDevices[0])
  43. {
  44. return Cura.MachineManager.printerOutputDevices[0].hotendIds
  45. }
  46. return null
  47. }
  48. UM.I18nCatalog {
  49. id: catalog;
  50. name: "cura";
  51. }
  52. Row {
  53. objectName: "networkPrinterConnectButton";
  54. spacing: UM.Theme.getSize("default_margin").width;
  55. visible: isUM3;
  56. Button {
  57. height: UM.Theme.getSize("save_button_save_to_button").height;
  58. onClicked: Cura.MachineManager.printerOutputDevices[0].requestAuthentication();
  59. style: UM.Theme.styles.print_setup_action_button;
  60. text: catalog.i18nc("@action:button", "Request Access");
  61. tooltip: catalog.i18nc("@info:tooltip", "Send access request to the printer");
  62. visible: printerConnected && !printerAcceptsCommands && !authenticationRequested;
  63. }
  64. Button {
  65. height: UM.Theme.getSize("save_button_save_to_button").height;
  66. onClicked: connectActionDialog.show();
  67. style: UM.Theme.styles.print_setup_action_button;
  68. text: catalog.i18nc("@action:button", "Connect");
  69. tooltip: catalog.i18nc("@info:tooltip", "Connect to a printer");
  70. visible: !printerConnected;
  71. }
  72. }
  73. UM.Dialog {
  74. id: connectActionDialog;
  75. rightButtons: Button {
  76. iconName: "dialog-close";
  77. onClicked: connectActionDialog.reject();
  78. text: catalog.i18nc("@action:button", "Close");
  79. }
  80. Loader {
  81. anchors.fill: parent;
  82. source: "DiscoverUM3Action.qml";
  83. }
  84. }
  85. }