diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 00a36a1348..6ca6becabd 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -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: diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 226f4f59a9..6cb4d0112e 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -7,7 +7,7 @@ import QtQuick.Controls.Styles 1.1 import QtQuick.Layouts 1.1 import QtQuick.Dialogs 1.1 -import UM 1.0 as UM +import UM 1.1 as UM UM.MainWindow { id: base @@ -30,21 +30,40 @@ UM.MainWindow { title: qsTr("&File"); MenuItem { action: actions.open; } - MenuItem { action: actions.save; } - MenuSeparator { } + Menu { + id: recentFilesMenu; + title: "Open Recent" - Instantiator { - model: Printer.recentFiles - MenuItem { - text: { - var path = modelData.toString() - return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1); + Instantiator { + model: Printer.recentFiles + MenuItem { + text: { + var path = modelData.toString() + return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1); + } + onTriggered: UM.MeshFileHandler.readLocalFile(modelData); } - onTriggered: UM.MeshFileHandler.readLocalFile(modelData); + onObjectAdded: recentFilesMenu.insertItem(index, object) + onObjectRemoved: recentFilesMenu.removeItem(object) + } + } + + MenuItem { text: "Save Selection" } + Menu { + id: saveAllMenu + title: "Save All" + + Instantiator { + model: UM.OutputDevicesModel { } + + MenuItem { + text: model.description + onTriggered: model.requestWriteToCurrentDevice(); + } + onObjectAdded: saveAllMenu.insertItem(index, object) + onObjectRemoved: saveAllMenu.removeItem(object) } - onObjectAdded: fileMenu.insertItem(index, object) - onObjectRemoved: fileMenu.removeItem(object) } MenuSeparator { } @@ -278,7 +297,6 @@ UM.MainWindow { addMachineAction: actions.addMachine; configureMachinesAction: actions.configureMachines; - saveAction: actions.save; } Rectangle { @@ -411,22 +429,6 @@ UM.MainWindow { } } - FileDialog { - id: saveDialog; - //: File save dialog title - title: qsTr("Save File"); - selectExisting: false; - - modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal; - - nameFilters: UM.MeshFileHandler.supportedWriteFileTypes - - onAccepted: - { - UM.MeshFileHandler.writeLocalFile(fileUrl); - } - } - EngineLog { id: engineLog; } @@ -442,7 +444,6 @@ UM.MainWindow { Connections { target: Printer onRequestAddPrinter: addMachine.visible = true; - onWriteToLocalFileRequested: saveDialog.open(); } Component.onCompleted: UM.Theme.load(UM.Resources.getPath(UM.Resources.ThemesLocation, "cura")) diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index 23ddfe4ed7..0c908fc789 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -13,7 +13,6 @@ Rectangle { property Action addMachineAction; property Action configureMachinesAction; - property alias saveAction: saveButton.saveAction; color: UM.Theme.colors.sidebar;