mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 04:36:01 +08:00
Merge branch '2.3' of https://github.com/Ultimaker/Cura into 2.3
This commit is contained in:
commit
5f3ec7c910
@ -511,8 +511,6 @@ class CuraApplication(QtApplication):
|
|||||||
if self.getController().getActiveTool():
|
if self.getController().getActiveTool():
|
||||||
self._previous_active_tool = self.getController().getActiveTool().getPluginId()
|
self._previous_active_tool = self.getController().getActiveTool().getPluginId()
|
||||||
self.getController().setActiveTool(None)
|
self.getController().setActiveTool(None)
|
||||||
else:
|
|
||||||
self._previous_active_tool = None
|
|
||||||
|
|
||||||
def _onToolOperationStopped(self, event):
|
def _onToolOperationStopped(self, event):
|
||||||
if self._center_after_select:
|
if self._center_after_select:
|
||||||
|
@ -103,8 +103,9 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
|
|||||||
|
|
||||||
self._firmware_view.show()
|
self._firmware_view.show()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot(str)
|
||||||
def updateAllFirmware(self):
|
def updateAllFirmware(self, file_name):
|
||||||
|
file_name = file_name.replace("file://", "") # File dialogs prepend the path with file://, which we don't need / want
|
||||||
if not self._usb_output_devices:
|
if not self._usb_output_devices:
|
||||||
Message(i18n_catalog.i18nc("@info", "Cannot update firmware, there were no connected printers found.")).show()
|
Message(i18n_catalog.i18nc("@info", "Cannot update firmware, there were no connected printers found.")).show()
|
||||||
return
|
return
|
||||||
@ -114,26 +115,26 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
|
|||||||
self.spawnFirmwareInterface("")
|
self.spawnFirmwareInterface("")
|
||||||
for printer_connection in self._usb_output_devices:
|
for printer_connection in self._usb_output_devices:
|
||||||
try:
|
try:
|
||||||
self._usb_output_devices[printer_connection].updateFirmware(Resources.getPath(CuraApplication.ResourceTypes.Firmware, self._getDefaultFirmwareName()))
|
self._usb_output_devices[printer_connection].updateFirmware(file_name)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
# Should only happen in dev environments where the resources/firmware folder is absent.
|
# Should only happen in dev environments where the resources/firmware folder is absent.
|
||||||
self._usb_output_devices[printer_connection].setProgress(100, 100)
|
self._usb_output_devices[printer_connection].setProgress(100, 100)
|
||||||
Logger.log("w", "No firmware found for printer %s called '%s'" %(printer_connection, self._getDefaultFirmwareName()))
|
Logger.log("w", "No firmware found for printer %s called '%s'" % (printer_connection, self.getDefaultFirmwareName()))
|
||||||
Message(i18n_catalog.i18nc("@info",
|
Message(i18n_catalog.i18nc("@info",
|
||||||
"Could not find firmware required for the printer at %s.") % printer_connection).show()
|
"Could not find firmware required for the printer at %s.") % printer_connection).show()
|
||||||
self._firmware_view.close()
|
self._firmware_view.close()
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@pyqtSlot(str, result = bool)
|
@pyqtSlot(str, str, result = bool)
|
||||||
def updateFirmwareBySerial(self, serial_port):
|
def updateFirmwareBySerial(self, serial_port, file_name):
|
||||||
if serial_port in self._usb_output_devices:
|
if serial_port in self._usb_output_devices:
|
||||||
self.spawnFirmwareInterface(self._usb_output_devices[serial_port].getSerialPort())
|
self.spawnFirmwareInterface(self._usb_output_devices[serial_port].getSerialPort())
|
||||||
try:
|
try:
|
||||||
self._usb_output_devices[serial_port].updateFirmware(Resources.getPath(CuraApplication.ResourceTypes.Firmware, self._getDefaultFirmwareName()))
|
self._usb_output_devices[serial_port].updateFirmware(file_name)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self._firmware_view.close()
|
self._firmware_view.close()
|
||||||
Logger.log("e", "Could not find firmware required for this machine called '%s'" %(self._getDefaultFirmwareName()))
|
Logger.log("e", "Could not find firmware required for this machine called '%s'" % (self.getDefaultFirmwareName()))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -147,7 +148,8 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
|
|||||||
|
|
||||||
return USBPrinterOutputDeviceManager._instance
|
return USBPrinterOutputDeviceManager._instance
|
||||||
|
|
||||||
def _getDefaultFirmwareName(self):
|
@pyqtSlot(result = str)
|
||||||
|
def getDefaultFirmwareName(self):
|
||||||
# Check if there is a valid global container stack
|
# Check if there is a valid global container stack
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if not global_container_stack:
|
if not global_container_stack:
|
||||||
@ -193,13 +195,13 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
|
|||||||
Logger.log("d", "Choosing basic firmware for machine %s.", machine_id)
|
Logger.log("d", "Choosing basic firmware for machine %s.", machine_id)
|
||||||
hex_file = machine_without_extras[machine_id] # Return "basic" firmware
|
hex_file = machine_without_extras[machine_id] # Return "basic" firmware
|
||||||
else:
|
else:
|
||||||
Logger.log("e", "There is no firmware for machine %s.", machine_id)
|
Logger.log("w", "There is no firmware for machine %s.", machine_id)
|
||||||
|
|
||||||
if hex_file:
|
if hex_file:
|
||||||
return hex_file.format(baudrate=baudrate)
|
return Resources.getPath(CuraApplication.ResourceTypes.Firmware, hex_file.format(baudrate=baudrate))
|
||||||
else:
|
else:
|
||||||
Logger.log("e", "Could not find any firmware for machine %s.", machine_id)
|
Logger.log("w", "Could not find any firmware for machine %s.", machine_id)
|
||||||
raise FileNotFoundError()
|
return ""
|
||||||
|
|
||||||
## Helper to identify serial ports (and scan for them)
|
## Helper to identify serial ports (and scan for them)
|
||||||
def _addRemovePorts(self, serial_ports):
|
def _addRemovePorts(self, serial_ports):
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
from cura.MachineAction import MachineAction
|
from cura.MachineAction import MachineAction
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
|
import cura.Settings.CuraContainerRegistry
|
||||||
|
import UM.Settings.DefinitionContainer
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
||||||
@ -7,3 +9,9 @@ class UpgradeFirmwareMachineAction(MachineAction):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("UpgradeFirmware", catalog.i18nc("@action", "Upgrade Firmware"))
|
super().__init__("UpgradeFirmware", catalog.i18nc("@action", "Upgrade Firmware"))
|
||||||
self._qml_url = "UpgradeFirmwareMachineAction.qml"
|
self._qml_url = "UpgradeFirmwareMachineAction.qml"
|
||||||
|
cura.Settings.CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
|
||||||
|
|
||||||
|
def _onContainerAdded(self, container):
|
||||||
|
# Add this action as a supported action to all machine definitions
|
||||||
|
if isinstance(container, UM.Settings.DefinitionContainer) and container.getMetaDataEntry("type") == "machine" and container.getMetaDataEntry("supports_usb_connection"):
|
||||||
|
UM.Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey())
|
||||||
|
@ -5,6 +5,7 @@ import QtQuick 2.2
|
|||||||
import QtQuick.Controls 1.1
|
import QtQuick.Controls 1.1
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import QtQuick.Window 2.1
|
import QtQuick.Window 2.1
|
||||||
|
import QtQuick.Dialogs 1.2 // For filedialog
|
||||||
|
|
||||||
import UM 1.2 as UM
|
import UM 1.2 as UM
|
||||||
import Cura 1.0 as Cura
|
import Cura 1.0 as Cura
|
||||||
@ -44,34 +45,45 @@ Cura.MachineAction
|
|||||||
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
||||||
width: parent.width
|
width: parent.width
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
text: catalog.i18nc("@label", "The firmware shipping with new Ultimakers works, but upgrades have been made to make better prints, and make calibration easier.");
|
text: catalog.i18nc("@label", "The firmware shipping with new Printers works, but new versions tend to have more features and improvements.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Label
|
|
||||||
{
|
|
||||||
id: upgradeText2
|
|
||||||
anchors.top: upgradeText1.bottom
|
|
||||||
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
|
||||||
width: parent.width
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
text: catalog.i18nc("@label", "Cura requires these new features and thus your firmware will most likely need to be upgraded. You can do so now.");
|
|
||||||
}
|
|
||||||
Row
|
Row
|
||||||
{
|
{
|
||||||
anchors.top: upgradeText2.bottom
|
anchors.top: upgradeText1.bottom
|
||||||
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
spacing: UM.Theme.getSize("default_margin").width
|
spacing: UM.Theme.getSize("default_margin").width
|
||||||
|
property var firmwareName: Cura.USBPrinterManager.getDefaultFirmwareName()
|
||||||
Button
|
Button
|
||||||
{
|
{
|
||||||
id: upgradeButton
|
id: autoUpgradeButton
|
||||||
text: catalog.i18nc("@action:button","Upgrade to Marlin Firmware");
|
text: catalog.i18nc("@action:button", "Automatically upgrade Firmware");
|
||||||
|
enabled: parent.firmwareName != ""
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
Cura.USBPrinterManager.updateAllFirmware()
|
Cura.USBPrinterManager.updateAllFirmware(parent.firmwareName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button
|
||||||
|
{
|
||||||
|
id: manualUpgradeButton
|
||||||
|
text: catalog.i18nc("@action:button", "Upload custom Firmware");
|
||||||
|
onClicked:
|
||||||
|
{
|
||||||
|
customFirmwareDialog.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileDialog
|
||||||
|
{
|
||||||
|
id: customFirmwareDialog
|
||||||
|
title: catalog.i18nc("@title:window", "Select custom firmware")
|
||||||
|
nameFilters: "Firmware image files (*.hex)"
|
||||||
|
selectExisting: true
|
||||||
|
onAccepted: Cura.USBPrinterManager.updateAllFirmware(fileUrl)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,8 @@
|
|||||||
"machine_extruder_trains":
|
"machine_extruder_trains":
|
||||||
{
|
{
|
||||||
"0": "fdmextruder"
|
"0": "fdmextruder"
|
||||||
}
|
},
|
||||||
|
"supports_usb_connection": true
|
||||||
},
|
},
|
||||||
"settings":
|
"settings":
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user