mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 11:17:49 -06:00
Ensure that each intent gets it's own bar in recommended
CURA-6598
This commit is contained in:
parent
24d6d5b102
commit
5401a4db15
3 changed files with 60 additions and 34 deletions
|
@ -19,6 +19,7 @@ class IntentModel(ListModel):
|
|||
QualityTypeRole = Qt.UserRole + 2
|
||||
LayerHeightRole = Qt.UserRole + 3
|
||||
AvailableRole = Qt.UserRole + 4
|
||||
IntentRole = Qt.UserRole + 5
|
||||
|
||||
def __init__(self, parent: Optional[QObject] = None) -> None:
|
||||
super().__init__(parent)
|
||||
|
@ -27,6 +28,7 @@ class IntentModel(ListModel):
|
|||
self.addRoleName(self.QualityTypeRole, "quality_type")
|
||||
self.addRoleName(self.LayerHeightRole, "layer_height")
|
||||
self.addRoleName(self.AvailableRole, "available")
|
||||
self.addRoleName(self.IntentRole, "intent_category")
|
||||
|
||||
self._intent_category = "engineering"
|
||||
|
||||
|
@ -59,12 +61,32 @@ class IntentModel(ListModel):
|
|||
return
|
||||
quality_groups = ContainerTree.getInstance().getCurrentQualityGroups()
|
||||
|
||||
layer_heights_added = []
|
||||
for quality_tuple, quality_group in quality_groups.items():
|
||||
# Add the intents that are of the correct category
|
||||
if quality_tuple[0] == self._intent_category:
|
||||
layer_height = self._fetchLayerHeight(quality_group)
|
||||
new_items.append({"name": quality_group.name,
|
||||
"quality_type": quality_tuple[1],
|
||||
"layer_height": self._fetchLayerHeight(quality_group),
|
||||
"available": True
|
||||
"layer_height": layer_height,
|
||||
"available": quality_group.is_available,
|
||||
"intent_category": self._intent_category
|
||||
})
|
||||
layer_heights_added.append(layer_height)
|
||||
|
||||
# Now that we added all intents that we found something for, ensure that we set add ticks (and layer_heights)
|
||||
# for all groups that we don't have anything for (and set it to not available)
|
||||
for quality_tuple, quality_group in quality_groups.items():
|
||||
# Add the intents that are of the correct category
|
||||
if quality_tuple[0] != self._intent_category:
|
||||
layer_height = self._fetchLayerHeight(quality_group)
|
||||
if layer_height not in layer_heights_added:
|
||||
new_items.append({"name": "Unavailable",
|
||||
"quality_type": "",
|
||||
"layer_height": layer_height,
|
||||
"intent_category": self._intent_category,
|
||||
"available": False})
|
||||
layer_heights_added.append(layer_height)
|
||||
|
||||
new_items = sorted(new_items, key=lambda x: x["layer_height"])
|
||||
self.setItems(new_items)
|
||||
|
@ -98,3 +120,6 @@ class IntentModel(ListModel):
|
|||
layer_height = layer_height(global_stack)
|
||||
|
||||
return float(layer_height)
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.items)
|
||||
|
|
|
@ -7,7 +7,7 @@ import QtQuick.Controls 2.3 as Controls2
|
|||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
import Cura 1.6 as Cura
|
||||
|
||||
|
||||
//
|
||||
|
@ -98,7 +98,8 @@ Item
|
|||
{
|
||||
id: activeProfileButtonGroup
|
||||
exclusive: true
|
||||
onClicked: Cura.MachineManager.activeQualityGroup = button.identifier
|
||||
onClicked: Cura.IntentManager.selectIntent(button.modelData.intent_category, button.modelData.quality_type)
|
||||
|
||||
}
|
||||
|
||||
Cura.LabelBar
|
||||
|
@ -114,6 +115,9 @@ Item
|
|||
modelKey: "layer_height"
|
||||
}
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: Cura.IntentCategoryModel{}
|
||||
Cura.RadioCheckbar
|
||||
{
|
||||
anchors
|
||||
|
@ -121,10 +125,8 @@ Item
|
|||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
model: Cura.QualityProfilesDropDownMenuModel
|
||||
dataModel: model["qualities"]
|
||||
buttonGroup: activeProfileButtonGroup
|
||||
modelKey: "quality_group"
|
||||
|
||||
function checkedFunction(modelItem)
|
||||
{
|
||||
|
@ -133,10 +135,12 @@ Item
|
|||
// When user created profile is active, no quality tickbox should be active.
|
||||
return false
|
||||
}
|
||||
return Cura.MachineManager.activeQualityType == modelItem.quality_type
|
||||
return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category
|
||||
}
|
||||
|
||||
isCheckedFunction: checkedFunction
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,12 +18,7 @@ Item
|
|||
implicitWidth: 200
|
||||
implicitHeight: checkboxSize
|
||||
|
||||
property var model: null
|
||||
|
||||
// What key of the model should be used to set the identifier of the checkbox.
|
||||
// This is used to figure out what checkbox just got toggled. Set a buttonGroup and listen to it's clicked signal.
|
||||
// You can use button.identifier to figure out which button was clicked.
|
||||
property string modelKey: "name"
|
||||
property var dataModel: null
|
||||
|
||||
// The horizontal inactive bar that sits behind the buttons
|
||||
Rectangle
|
||||
|
@ -45,6 +40,7 @@ Item
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
RowLayout
|
||||
{
|
||||
id: buttonBar
|
||||
|
@ -56,7 +52,7 @@ Item
|
|||
Repeater
|
||||
{
|
||||
id: repeater
|
||||
model: base.model
|
||||
model: base.dataModel
|
||||
height: checkboxSize
|
||||
Item
|
||||
{
|
||||
|
@ -75,7 +71,9 @@ Item
|
|||
height: barSize
|
||||
width: buttonBar.width / (repeater.count - 1) - activeComponent.width - 2
|
||||
color: defaultItemColor
|
||||
|
||||
// This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator
|
||||
// but not when using the exact same QML in Cura.
|
||||
y: 0.5 * checkboxSize
|
||||
anchors
|
||||
{
|
||||
right: activeComponent.left
|
||||
|
@ -87,9 +85,7 @@ Item
|
|||
id: activeComponent
|
||||
sourceComponent: isEnabled? checkboxComponent : disabledComponent
|
||||
width: checkboxSize
|
||||
// This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator
|
||||
// but not when using the exact same QML in Cura.
|
||||
y: -0.5 * checkboxSize
|
||||
|
||||
property var modelItem: model
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +123,8 @@ Item
|
|||
ButtonGroup.group: buttonGroup
|
||||
width: checkboxSize
|
||||
height: checkboxSize
|
||||
property var identifier: modelItem[base.modelKey]
|
||||
property var modelData: modelItem
|
||||
|
||||
checked: isCheckedFunction(modelItem)
|
||||
indicator: Rectangle
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue