diff --git a/cura/Machines/Models/IntentModel.py b/cura/Machines/Models/IntentModel.py index 4a67ae3c87..3f480e2eef 100644 --- a/cura/Machines/Models/IntentModel.py +++ b/cura/Machines/Models/IntentModel.py @@ -12,12 +12,14 @@ from UM.Settings.ContainerRegistry import ContainerRegistry class IntentModel(ListModel): NameRole = Qt.UserRole + 1 IdRole = Qt.UserRole + 2 + ContainerRole = Qt.UserRole + 3 def __init__(self, parent: Optional[QObject] = None) -> None: super().__init__(parent) self.addRoleName(self.NameRole, "name") self.addRoleName(self.IdRole, "id") + self.addRoleName(self.ContainerRole, "container") ContainerRegistry.getInstance().containerAdded.connect(self._onChanged) ContainerRegistry.getInstance().containerRemoved.connect(self._onChanged) @@ -31,6 +33,6 @@ class IntentModel(ListModel): def _update(self) -> None: new_items = [] for container in ContainerRegistry.getInstance().findInstanceContainers(type="intent"): - new_items.append({"name": container.getName(), "id": container.getId()}) + new_items.append({"name": container.getName(), "id": container.getId(), "container": container}) self.setItems(new_items) diff --git a/cura/Settings/CuraContainerStack.py b/cura/Settings/CuraContainerStack.py index af319ceb51..278bc1dc4f 100755 --- a/cura/Settings/CuraContainerStack.py +++ b/cura/Settings/CuraContainerStack.py @@ -93,7 +93,7 @@ class CuraContainerStack(ContainerStack): # # \param new_intent The new intent container. It is expected to have a "type" metadata entry with the value "intent". def setIntent(self, new_intent: InstanceContainer, postpone_emit: bool = False) -> None: - self.replaceContainer(_ContainerIndexes.Quality, new_intent, postpone_emit=postpone_emit) + self.replaceContainer(_ContainerIndexes.Intent, new_intent, postpone_emit=postpone_emit) ## Get the quality container. # diff --git a/cura/Settings/cura_empty_instance_containers.py b/cura/Settings/cura_empty_instance_containers.py index 62b01d32d9..e8a6df8ff1 100644 --- a/cura/Settings/cura_empty_instance_containers.py +++ b/cura/Settings/cura_empty_instance_containers.py @@ -47,6 +47,7 @@ EMPTY_INTENT_CONTAINER_ID = "empty_intent" empty_intent_container = copy.deepcopy(empty_container) empty_intent_container.setMetaDataEntry("id", EMPTY_INTENT_CONTAINER_ID) empty_intent_container.setMetaDataEntry("type", "intent") +empty_intent_container.setName(catalog.i18nc("@info:No intent profile selected", "Default")) # All empty container IDs set diff --git a/resources/qml/Menus/IntentMenu.qml b/resources/qml/Menus/IntentMenu.qml new file mode 100644 index 0000000000..410ab70eb7 --- /dev/null +++ b/resources/qml/Menus/IntentMenu.qml @@ -0,0 +1,44 @@ +// Copyright (c) 2019 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 1.4 + +import UM 1.2 as UM +import Cura 1.6 as Cura + +Menu +{ + id: menu + title: "Intent" + + property int extruderIndex: 0 + + Cura.IntentModel + { + id: intentModel + } + + Instantiator + { + model: intentModel + + MenuItem + { + text: model.name + checkable: true + checked: false + Binding on checked + { + when: Cura.MachineManager.activeStack != null + value: Cura.MachineManager.activeStack.intent == model.container + } + exclusiveGroup: group + onTriggered: Cura.MachineManager.activeStack.intent = model.container + } + + onObjectAdded: menu.insertItem(index, object) + onObjectRemoved: menu.removeItem(object) + } + ExclusiveGroup { id: group } +} diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 98bb5c0405..e6a35455f2 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -3,6 +3,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 +import QtQuick.Controls 1.1 as OldControls import UM 1.3 as UM import Cura 1.0 as Cura @@ -24,12 +25,55 @@ Item anchors { top: parent.top - topMargin: parent.padding + left: parent.left + right: parent.right + margins: parent.padding + } + } + Item + { + id: intent + height: childrenRect.height + + anchors + { + top: globalProfileRow.bottom + topMargin: UM.Theme.getSize("default_margin").height left: parent.left leftMargin: parent.padding right: parent.right rightMargin: parent.padding } + + Label + { + id: intentLabel + anchors + { + top: parent.top + bottom: parent.bottom + left: parent.left + right: intentSelection.left + } + text: catalog.i18nc("@label", "Intent") + font: UM.Theme.getFont("medium") + color: UM.Theme.getColor("text") + verticalAlignment: Text.AlignVCenter + } + OldControls.ToolButton + { + id: intentSelection + text: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.intent.name : "" + tooltip: text + height: UM.Theme.getSize("print_setup_big_item").height + width: UM.Theme.getSize("print_setup_big_item").width + anchors.right: parent.right + style: UM.Theme.styles.print_setup_header_button + activeFocusOnPress: true + + menu: Cura.IntentMenu { extruderIndex: Cura.ExtruderManager.activeExtruderIndex } + } + } UM.TabRow @@ -40,7 +84,7 @@ Item anchors { - top: globalProfileRow.bottom + top: intent.bottom topMargin: UM.Theme.getSize("default_margin").height left: parent.left leftMargin: parent.padding