UpgradeFirmwareMachineAction.qml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. Item
  14. {
  15. id: upgradeFirmwareMachineAction
  16. anchors.fill: parent;
  17. UM.I18nCatalog { id: catalog; name:"cura"}
  18. Label
  19. {
  20. id: pageTitle
  21. width: parent.width
  22. text: catalog.i18nc("@title", "Upgrade Firmware")
  23. wrapMode: Text.WordWrap
  24. font.pointSize: 18
  25. }
  26. Label
  27. {
  28. id: pageDescription
  29. anchors.top: pageTitle.bottom
  30. anchors.topMargin: UM.Theme.getSize("default_margin").height
  31. width: parent.width
  32. wrapMode: Text.WordWrap
  33. 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.")
  34. }
  35. Label
  36. {
  37. id: upgradeText1
  38. anchors.top: pageDescription.bottom
  39. anchors.topMargin: UM.Theme.getSize("default_margin").height
  40. width: parent.width
  41. wrapMode: Text.WordWrap
  42. text: catalog.i18nc("@label", "The firmware shipping with new printers works, but new versions tend to have more features and improvements.");
  43. }
  44. Row
  45. {
  46. anchors.top: upgradeText1.bottom
  47. anchors.topMargin: UM.Theme.getSize("default_margin").height
  48. anchors.horizontalCenter: parent.horizontalCenter
  49. width: childrenRect.width
  50. spacing: UM.Theme.getSize("default_margin").width
  51. property var firmwareName: Cura.USBPrinterManager.getDefaultFirmwareName()
  52. Button
  53. {
  54. id: autoUpgradeButton
  55. text: catalog.i18nc("@action:button", "Automatically upgrade Firmware");
  56. enabled: parent.firmwareName != ""
  57. onClicked:
  58. {
  59. Cura.USBPrinterManager.updateAllFirmware(parent.firmwareName)
  60. }
  61. }
  62. Button
  63. {
  64. id: manualUpgradeButton
  65. text: catalog.i18nc("@action:button", "Upload custom Firmware");
  66. onClicked:
  67. {
  68. customFirmwareDialog.open()
  69. }
  70. }
  71. }
  72. FileDialog
  73. {
  74. id: customFirmwareDialog
  75. title: catalog.i18nc("@title:window", "Select custom firmware")
  76. nameFilters: "Firmware image files (*.hex)"
  77. selectExisting: true
  78. onAccepted: Cura.USBPrinterManager.updateAllFirmware(fileUrl)
  79. }
  80. }
  81. }