diff --git a/plugins/UFPWriter/UFPWriter.py b/plugins/UFPWriter/UFPWriter.py index 6179872b2d..af208209e4 100644 --- a/plugins/UFPWriter/UFPWriter.py +++ b/plugins/UFPWriter/UFPWriter.py @@ -72,24 +72,25 @@ class UFPWriter(MeshWriter): gcode.write(gcode_textio.getvalue().encode("UTF-8")) archive.addRelation(virtual_path = "/3D/model.gcode", relation_type = "http://schemas.ultimaker.org/package/2018/relationships/gcode") - self._createSnapshot() - - # Store the thumbnail. - if self._snapshot: - archive.addContentType(extension = "png", mime_type = "image/png") - thumbnail = archive.getStream("/Metadata/thumbnail.png") - - thumbnail_buffer = QBuffer() - thumbnail_buffer.open(QBuffer.ReadWrite) - thumbnail_image = self._snapshot - thumbnail_image.save(thumbnail_buffer, "PNG") - - thumbnail.write(thumbnail_buffer.data()) - archive.addRelation(virtual_path = "/Metadata/thumbnail.png", - relation_type = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail", - origin = "/3D/model.gcode") - else: - Logger.log("d", "Thumbnail not created, cannot save it") + # TODO temporarily commented out, as is causes a crash whenever the UFPWriter is called outside of the main thread + # self._createSnapshot() + # + # # Store the thumbnail. + # if self._snapshot: + # archive.addContentType(extension = "png", mime_type = "image/png") + # thumbnail = archive.getStream("/Metadata/thumbnail.png") + # + # thumbnail_buffer = QBuffer() + # thumbnail_buffer.open(QBuffer.ReadWrite) + # thumbnail_image = self._snapshot + # thumbnail_image.save(thumbnail_buffer, "PNG") + # + # thumbnail.write(thumbnail_buffer.data()) + # archive.addRelation(virtual_path = "/Metadata/thumbnail.png", + # relation_type = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail", + # origin = "/3D/model.gcode") + # else: + # Logger.log("d", "Thumbnail not created, cannot save it") # Store the material. application = CuraApplication.getInstance() diff --git a/resources/qml/Menus/FileMenu.qml b/resources/qml/Menus/FileMenu.qml index 94fc2358e1..5ea1c9bc06 100644 --- a/resources/qml/Menus/FileMenu.qml +++ b/resources/qml/Menus/FileMenu.qml @@ -4,7 +4,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 -import UM 1.2 as UM +import UM 1.6 as UM import Cura 1.0 as Cura Menu @@ -37,8 +37,9 @@ Menu MenuItem { id: saveWorkspaceMenu - shortcut: StandardKey.Save + shortcut: visible ? StandardKey.Save : "" text: catalog.i18nc("@title:menu menubar:file", "&Save Project...") + visible: saveProjectMenu.model.count == 1 onTriggered: { var args = { "filter_by_machine": false, "file_type": "workspace", "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml" }; @@ -54,6 +55,15 @@ Menu } } + UM.ProjectOutputDevicesModel { id: projectOutputDevicesModel } + + SaveProjectMenu + { + id: saveProjectMenu + model: projectOutputDevicesModel + visible: model.count > 1 + } + MenuSeparator { } MenuItem diff --git a/resources/qml/Menus/SaveProjectMenu.qml b/resources/qml/Menus/SaveProjectMenu.qml new file mode 100644 index 0000000000..100e6f2ea4 --- /dev/null +++ b/resources/qml/Menus/SaveProjectMenu.qml @@ -0,0 +1,53 @@ +// Copyright (c) 2021 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +import UM 1.6 as UM +import Cura 1.1 as Cura + +import "../Dialogs" + +Menu +{ + id: saveProjectMenu + title: catalog.i18nc("@title:menu menubar:file", "Save Project...") + property alias model: projectOutputDevices.model + + Instantiator + { + id: projectOutputDevices + MenuItem + { + text: model.name + onTriggered: + { + var args = {}; + if (UM.Preferences.getValue("cura/dialog_on_project_save")) + { + saveWorkspaceDialog.deviceId = model.id + saveWorkspaceDialog.args = args + saveWorkspaceDialog.open() + } + else + { + UM.OutputDeviceManager.requestWriteToDevice(model.id, PrintInformation.jobName, args) + } + } + // Unassign the shortcuts when the submenu is invisible (i.e. when there is only one project output device) to avoid ambiguous shortcuts. + // When there is only the LocalFileOutputDevice, the Ctrl+S shortcut is assigned to the saveWorkspaceMenu MenuItem + shortcut: saveProjectMenu.visible ? model.shortcut : "" + } + onObjectAdded: saveProjectMenu.insertItem(index, object) + onObjectRemoved: saveProjectMenu.removeItem(object) + } + + WorkspaceSummaryDialog + { + id: saveWorkspaceDialog + property var args + property var deviceId + onYes: UM.OutputDeviceManager.requestWriteToDevice(deviceId, PrintInformation.jobName, args) + } +} diff --git a/resources/qml/Widgets/ComboBox.qml b/resources/qml/Widgets/ComboBox.qml index d4c526e265..26324d7773 100644 --- a/resources/qml/Widgets/ComboBox.qml +++ b/resources/qml/Widgets/ComboBox.qml @@ -15,6 +15,18 @@ ComboBox { id: control + UM.I18nCatalog + { + id: catalog + name: "cura" + } + + property var defaultTextOnEmptyModel: catalog.i18nc("@label", "No items to select from") // Text displayed in the combobox when the model is empty + property var defaultTextOnEmptyIndex: "" // Text displayed in the combobox when the model has items but no item is selected + enabled: model.count > 0 + + onVisibleChanged: { popup.close() } + states: [ State { @@ -67,11 +79,22 @@ ComboBox anchors.verticalCenter: parent.verticalCenter anchors.right: downArrow.left - text: control.currentText + text: + { + if (control.model.count == 0) + { + return control.defaultTextOnEmptyModel != "" ? control.defaultTextOnEmptyModel : control.defaultTextOnEmptyIndex + } + else + { + return control.currentIndex == -1 ? control.defaultTextOnEmptyIndex : control.currentText + } + } + textFormat: Text.PlainText renderType: Text.NativeRendering font: UM.Theme.getFont("default") - color: UM.Theme.getColor("setting_control_text") + color: control.currentIndex == -1 ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text") elide: Text.ElideRight verticalAlignment: Text.AlignVCenter } @@ -81,6 +104,7 @@ ComboBox y: control.height - UM.Theme.getSize("default_lining").height width: control.width implicitHeight: contentItem.implicitHeight + 2 * UM.Theme.getSize("default_lining").width + bottomMargin: UM.Theme.getSize("default_margin").height padding: UM.Theme.getSize("default_lining").width contentItem: ListView @@ -133,7 +157,7 @@ ComboBox text: delegateItem.text textFormat: Text.PlainText renderType: Text.NativeRendering - color: control.contentItem.color + color: UM.Theme.getColor("setting_control_text") font: UM.Theme.getFont("default") elide: Text.ElideRight verticalAlignment: Text.AlignVCenter