UpgradeFirmwareMachineAction.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright (c) 2016 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 QtQuick.Dialogs 1.2 // For filedialog
  8. import UM 1.2 as UM
  9. import Cura 1.0 as Cura
  10. Cura.MachineAction
  11. {
  12. anchors.fill: parent;
  13. property bool printerConnected: Cura.MachineManager.printerConnected
  14. property var activeOutputDevice: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null
  15. Item
  16. {
  17. id: upgradeFirmwareMachineAction
  18. anchors.fill: parent;
  19. UM.I18nCatalog { id: catalog; name:"cura"}
  20. Label
  21. {
  22. id: pageTitle
  23. width: parent.width
  24. text: catalog.i18nc("@title", "Upgrade Firmware")
  25. wrapMode: Text.WordWrap
  26. font.pointSize: 18
  27. }
  28. Label
  29. {
  30. id: pageDescription
  31. anchors.top: pageTitle.bottom
  32. anchors.topMargin: UM.Theme.getSize("default_margin").height
  33. width: parent.width
  34. wrapMode: Text.WordWrap
  35. text: catalog.i18nc("@label", "Firmware is the piece of software running directly on your 3D printer. This firmware controls the step motors, regulates the temperature and ultimately makes your printer work.")
  36. }
  37. Label
  38. {
  39. id: upgradeText1
  40. anchors.top: pageDescription.bottom
  41. anchors.topMargin: UM.Theme.getSize("default_margin").height
  42. width: parent.width
  43. wrapMode: Text.WordWrap
  44. text: catalog.i18nc("@label", "The firmware shipping with new printers works, but new versions tend to have more features and improvements.");
  45. }
  46. Row
  47. {
  48. anchors.top: upgradeText1.bottom
  49. anchors.topMargin: UM.Theme.getSize("default_margin").height
  50. anchors.horizontalCenter: parent.horizontalCenter
  51. width: childrenRect.width
  52. spacing: UM.Theme.getSize("default_margin").width
  53. property var firmwareName: Cura.USBPrinterManager.getDefaultFirmwareName()
  54. Button
  55. {
  56. id: autoUpgradeButton
  57. text: catalog.i18nc("@action:button", "Automatically upgrade Firmware");
  58. enabled: parent.firmwareName != "" && activeOutputDevice
  59. onClicked:
  60. {
  61. activeOutputDevice.updateFirmware(parent.firmwareName)
  62. }
  63. }
  64. Button
  65. {
  66. id: manualUpgradeButton
  67. text: catalog.i18nc("@action:button", "Upload custom Firmware");
  68. enabled: activeOutputDevice != null
  69. onClicked:
  70. {
  71. customFirmwareDialog.open()
  72. }
  73. }
  74. }
  75. FileDialog
  76. {
  77. id: customFirmwareDialog
  78. title: catalog.i18nc("@title:window", "Select custom firmware")
  79. nameFilters: "Firmware image files (*.hex)"
  80. selectExisting: true
  81. onAccepted: activeOutputDevice.updateFirmware(fileUrl)
  82. }
  83. }
  84. }