mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 23:23:57 -06:00
Remove the output_device related stuff from CuraApplication and fix the qml
This is now properly handled by the Output Device API in Uranium
This commit is contained in:
parent
baf4ea9523
commit
c2e672591c
3 changed files with 31 additions and 148 deletions
|
@ -111,15 +111,6 @@ class CuraApplication(QtApplication):
|
|||
def run(self):
|
||||
self._i18n_catalog = i18nCatalog("cura");
|
||||
|
||||
self.addOutputDevice("local_file", {
|
||||
"id": "local_file",
|
||||
"function": self._writeToLocalFile,
|
||||
"description": self._i18n_catalog.i18nc("Save button tooltip", "Save to Disk"),
|
||||
"shortDescription": self._i18n_catalog.i18nc("Save button tooltip", "Save to Disk"),
|
||||
"icon": "save",
|
||||
"priority": 0
|
||||
})
|
||||
|
||||
self.showSplashMessage(self._i18n_catalog.i18nc("Splash screen message", "Setting up scene..."))
|
||||
|
||||
controller = self.getController()
|
||||
|
@ -159,8 +150,6 @@ class CuraApplication(QtApplication):
|
|||
self.setMainQml(Resources.getPath(Resources.QmlFilesLocation, "Cura.qml"))
|
||||
self.initializeEngine()
|
||||
|
||||
self.getStorageDevice("LocalFileStorage").removableDrivesChanged.connect(self._removableDrivesChanged)
|
||||
|
||||
if self.getMachines():
|
||||
active_machine_pref = Preferences.getInstance().getValue("cura/active_machine")
|
||||
if active_machine_pref:
|
||||
|
@ -173,7 +162,6 @@ class CuraApplication(QtApplication):
|
|||
else:
|
||||
self.requestAddPrinter.emit()
|
||||
|
||||
self._removableDrivesChanged()
|
||||
if self._engine.rootObjects:
|
||||
self.closeSplash()
|
||||
|
||||
|
@ -360,16 +348,6 @@ class CuraApplication(QtApplication):
|
|||
def expandedCategories(self):
|
||||
return Preferences.getInstance().getValue("cura/categories_expanded").split(";")
|
||||
|
||||
outputDevicesChanged = pyqtSignal()
|
||||
|
||||
@pyqtProperty("QVariantMap", notify = outputDevicesChanged)
|
||||
def outputDevices(self):
|
||||
return self._output_devices
|
||||
|
||||
@pyqtProperty("QStringList", notify = outputDevicesChanged)
|
||||
def outputDeviceNames(self):
|
||||
return self._output_devices.keys()
|
||||
|
||||
@pyqtSlot(str, result = "QVariant")
|
||||
def getSettingValue(self, key):
|
||||
if not self.getActiveMachine():
|
||||
|
@ -385,82 +363,6 @@ class CuraApplication(QtApplication):
|
|||
|
||||
self.getActiveMachine().setSettingValueByKey(key, value)
|
||||
|
||||
## Add an output device that can be written to.
|
||||
#
|
||||
# \param id \type{string} The identifier used to identify the device.
|
||||
# \param device \type{StorageDevice} A dictionary of device information.
|
||||
# It should contains the following:
|
||||
# - function: A function to be called when trying to write to the device. Will be passed the device id as first parameter.
|
||||
# - description: A translated string containing a description of what happens when writing to the device.
|
||||
# - icon: The icon to use to represent the device.
|
||||
# - priority: The priority of the device. The device with the highest priority will be used as the default device.
|
||||
def addOutputDevice(self, id, device):
|
||||
self._output_devices[id] = device
|
||||
self.outputDevicesChanged.emit()
|
||||
|
||||
## Remove output device
|
||||
# \param id \type{string} The identifier used to identify the device.
|
||||
# \sa PrinterApplication::addOutputDevice()
|
||||
def removeOutputDevice(self, id):
|
||||
if id in self._output_devices:
|
||||
del self._output_devices[id]
|
||||
self.outputDevicesChanged.emit()
|
||||
|
||||
@pyqtSlot(str)
|
||||
def writeToOutputDevice(self, device):
|
||||
self._output_devices[device]["function"](device)
|
||||
|
||||
writeToLocalFileRequested = pyqtSignal()
|
||||
|
||||
def _writeToLocalFile(self, device):
|
||||
self.writeToLocalFileRequested.emit()
|
||||
|
||||
def _writeToSD(self, device):
|
||||
for node in DepthFirstIterator(self.getController().getScene().getRoot()):
|
||||
if type(node) is not SceneNode or not node.getMeshData():
|
||||
continue
|
||||
|
||||
try:
|
||||
path = self.getStorageDevice("LocalFileStorage").getRemovableDrives()[device]
|
||||
except KeyError:
|
||||
Logger.log("e", "Tried to write to unknown SD card %s", device)
|
||||
return
|
||||
|
||||
filename = os.path.join(path, node.getName()[0:node.getName().rfind(".")] + ".gcode")
|
||||
|
||||
message = Message(self._output_devices[device]["description"], 0, False, -1)
|
||||
message.show()
|
||||
|
||||
job = WriteMeshJob(filename, node.getMeshData())
|
||||
job._sdcard = device
|
||||
job._message = message
|
||||
job.start()
|
||||
job.finished.connect(self._onWriteToSDFinished)
|
||||
|
||||
return
|
||||
|
||||
def _removableDrivesChanged(self):
|
||||
drives = self.getStorageDevice("LocalFileStorage").getRemovableDrives()
|
||||
for drive in drives:
|
||||
if drive not in self._output_devices:
|
||||
self.addOutputDevice(drive, {
|
||||
"id": drive,
|
||||
"function": self._writeToSD,
|
||||
"description": self._i18n_catalog.i18nc("Save button tooltip. {0} is sd card name", "Save to SD Card {0}").format(drive),
|
||||
"shortDescription": self._i18n_catalog.i18nc("Save button tooltip. {0} is sd card name", "Save to SD Card {0}").format(""),
|
||||
"icon": "save_sd",
|
||||
"priority": 1
|
||||
})
|
||||
|
||||
drives_to_remove = []
|
||||
for device in self._output_devices:
|
||||
if device not in drives:
|
||||
if self._output_devices[device]["function"] == self._writeToSD:
|
||||
drives_to_remove.append(device)
|
||||
|
||||
for drive in drives_to_remove:
|
||||
self.removeOutputDevice(drive)
|
||||
|
||||
def _onActiveMachineChanged(self):
|
||||
machine = self.getActiveMachine()
|
||||
if machine:
|
||||
|
@ -486,25 +388,6 @@ class CuraApplication(QtApplication):
|
|||
else:
|
||||
self._platform.setPosition(Vector(0.0, 0.0, 0.0))
|
||||
|
||||
def _onWriteToSDFinished(self, job):
|
||||
message = Message(self._i18n_catalog.i18nc("Saved to SD message, {0} is sdcard, {1} is filename", "Saved to SD Card {0} as {1}").format(job._sdcard, job.getFileName()))
|
||||
message.addAction(
|
||||
"eject",
|
||||
self._i18n_catalog.i18nc("Message action", "Eject"),
|
||||
"eject",
|
||||
self._i18n_catalog.i18nc("Message action tooltip, {0} is sdcard", "Eject SD Card {0}").format(job._sdcard)
|
||||
)
|
||||
|
||||
job._message.hide()
|
||||
|
||||
message._sdcard = job._sdcard
|
||||
message.actionTriggered.connect(self._onMessageActionTriggered)
|
||||
message.show()
|
||||
|
||||
def _onMessageActionTriggered(self, message, action):
|
||||
if action == "eject":
|
||||
self.getStorageDevice("LocalFileStorage").ejectRemovableDrive(message._sdcard)
|
||||
|
||||
def _onFileLoaded(self, job):
|
||||
mesh = job.getResult()
|
||||
if mesh != None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue