mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Add a selector for the intent profile
CURA-6534
This commit is contained in:
parent
2d8c19203e
commit
35ec70a3cf
5 changed files with 95 additions and 4 deletions
|
@ -12,12 +12,14 @@ from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
class IntentModel(ListModel):
|
class IntentModel(ListModel):
|
||||||
NameRole = Qt.UserRole + 1
|
NameRole = Qt.UserRole + 1
|
||||||
IdRole = Qt.UserRole + 2
|
IdRole = Qt.UserRole + 2
|
||||||
|
ContainerRole = Qt.UserRole + 3
|
||||||
|
|
||||||
def __init__(self, parent: Optional[QObject] = None) -> None:
|
def __init__(self, parent: Optional[QObject] = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self.addRoleName(self.NameRole, "name")
|
self.addRoleName(self.NameRole, "name")
|
||||||
self.addRoleName(self.IdRole, "id")
|
self.addRoleName(self.IdRole, "id")
|
||||||
|
self.addRoleName(self.ContainerRole, "container")
|
||||||
|
|
||||||
ContainerRegistry.getInstance().containerAdded.connect(self._onChanged)
|
ContainerRegistry.getInstance().containerAdded.connect(self._onChanged)
|
||||||
ContainerRegistry.getInstance().containerRemoved.connect(self._onChanged)
|
ContainerRegistry.getInstance().containerRemoved.connect(self._onChanged)
|
||||||
|
@ -31,6 +33,6 @@ class IntentModel(ListModel):
|
||||||
def _update(self) -> None:
|
def _update(self) -> None:
|
||||||
new_items = []
|
new_items = []
|
||||||
for container in ContainerRegistry.getInstance().findInstanceContainers(type="intent"):
|
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)
|
self.setItems(new_items)
|
||||||
|
|
|
@ -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".
|
# \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:
|
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.
|
## Get the quality container.
|
||||||
#
|
#
|
||||||
|
|
|
@ -47,6 +47,7 @@ EMPTY_INTENT_CONTAINER_ID = "empty_intent"
|
||||||
empty_intent_container = copy.deepcopy(empty_container)
|
empty_intent_container = copy.deepcopy(empty_container)
|
||||||
empty_intent_container.setMetaDataEntry("id", EMPTY_INTENT_CONTAINER_ID)
|
empty_intent_container.setMetaDataEntry("id", EMPTY_INTENT_CONTAINER_ID)
|
||||||
empty_intent_container.setMetaDataEntry("type", "intent")
|
empty_intent_container.setMetaDataEntry("type", "intent")
|
||||||
|
empty_intent_container.setName(catalog.i18nc("@info:No intent profile selected", "Default"))
|
||||||
|
|
||||||
|
|
||||||
# All empty container IDs set
|
# All empty container IDs set
|
||||||
|
|
44
resources/qml/Menus/IntentMenu.qml
Normal file
44
resources/qml/Menus/IntentMenu.qml
Normal file
|
@ -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 }
|
||||||
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import QtQuick.Controls 2.0
|
import QtQuick.Controls 2.0
|
||||||
|
import QtQuick.Controls 1.1 as OldControls
|
||||||
|
|
||||||
import UM 1.3 as UM
|
import UM 1.3 as UM
|
||||||
import Cura 1.0 as Cura
|
import Cura 1.0 as Cura
|
||||||
|
@ -24,12 +25,55 @@ Item
|
||||||
anchors
|
anchors
|
||||||
{
|
{
|
||||||
top: parent.top
|
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
|
left: parent.left
|
||||||
leftMargin: parent.padding
|
leftMargin: parent.padding
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: parent.padding
|
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
|
UM.TabRow
|
||||||
|
@ -40,7 +84,7 @@ Item
|
||||||
|
|
||||||
anchors
|
anchors
|
||||||
{
|
{
|
||||||
top: globalProfileRow.bottom
|
top: intent.bottom
|
||||||
topMargin: UM.Theme.getSize("default_margin").height
|
topMargin: UM.Theme.getSize("default_margin").height
|
||||||
left: parent.left
|
left: parent.left
|
||||||
leftMargin: parent.padding
|
leftMargin: parent.padding
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue