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
|
QualityTypeRole = Qt.UserRole + 2
|
||||||
LayerHeightRole = Qt.UserRole + 3
|
LayerHeightRole = Qt.UserRole + 3
|
||||||
AvailableRole = Qt.UserRole + 4
|
AvailableRole = Qt.UserRole + 4
|
||||||
|
IntentRole = Qt.UserRole + 5
|
||||||
|
|
||||||
def __init__(self, parent: Optional[QObject] = None) -> None:
|
def __init__(self, parent: Optional[QObject] = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
@ -27,6 +28,7 @@ class IntentModel(ListModel):
|
||||||
self.addRoleName(self.QualityTypeRole, "quality_type")
|
self.addRoleName(self.QualityTypeRole, "quality_type")
|
||||||
self.addRoleName(self.LayerHeightRole, "layer_height")
|
self.addRoleName(self.LayerHeightRole, "layer_height")
|
||||||
self.addRoleName(self.AvailableRole, "available")
|
self.addRoleName(self.AvailableRole, "available")
|
||||||
|
self.addRoleName(self.IntentRole, "intent_category")
|
||||||
|
|
||||||
self._intent_category = "engineering"
|
self._intent_category = "engineering"
|
||||||
|
|
||||||
|
@ -59,12 +61,32 @@ class IntentModel(ListModel):
|
||||||
return
|
return
|
||||||
quality_groups = ContainerTree.getInstance().getCurrentQualityGroups()
|
quality_groups = ContainerTree.getInstance().getCurrentQualityGroups()
|
||||||
|
|
||||||
|
layer_heights_added = []
|
||||||
for quality_tuple, quality_group in quality_groups.items():
|
for quality_tuple, quality_group in quality_groups.items():
|
||||||
new_items.append({"name": quality_group.name,
|
# 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],
|
"quality_type": quality_tuple[1],
|
||||||
"layer_height": self._fetchLayerHeight(quality_group),
|
"layer_height": layer_height,
|
||||||
"available": True
|
"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"])
|
new_items = sorted(new_items, key=lambda x: x["layer_height"])
|
||||||
self.setItems(new_items)
|
self.setItems(new_items)
|
||||||
|
@ -98,3 +120,6 @@ class IntentModel(ListModel):
|
||||||
layer_height = layer_height(global_stack)
|
layer_height = layer_height(global_stack)
|
||||||
|
|
||||||
return float(layer_height)
|
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 QtQuick.Controls.Styles 1.4
|
||||||
|
|
||||||
import UM 1.2 as UM
|
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
|
id: activeProfileButtonGroup
|
||||||
exclusive: true
|
exclusive: true
|
||||||
onClicked: Cura.MachineManager.activeQualityGroup = button.identifier
|
onClicked: Cura.IntentManager.selectIntent(button.modelData.intent_category, button.modelData.quality_type)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Cura.LabelBar
|
Cura.LabelBar
|
||||||
|
@ -114,29 +115,32 @@ Item
|
||||||
modelKey: "layer_height"
|
modelKey: "layer_height"
|
||||||
}
|
}
|
||||||
|
|
||||||
Cura.RadioCheckbar
|
Repeater
|
||||||
{
|
{
|
||||||
anchors
|
model: Cura.IntentCategoryModel{}
|
||||||
|
Cura.RadioCheckbar
|
||||||
{
|
{
|
||||||
left: parent.left
|
anchors
|
||||||
right: parent.right
|
|
||||||
}
|
|
||||||
|
|
||||||
model: Cura.QualityProfilesDropDownMenuModel
|
|
||||||
buttonGroup: activeProfileButtonGroup
|
|
||||||
modelKey: "quality_group"
|
|
||||||
|
|
||||||
function checkedFunction(modelItem)
|
|
||||||
{
|
|
||||||
if(Cura.MachineManager.hasCustomQuality)
|
|
||||||
{
|
{
|
||||||
// When user created profile is active, no quality tickbox should be active.
|
left: parent.left
|
||||||
return false
|
right: parent.right
|
||||||
}
|
}
|
||||||
return Cura.MachineManager.activeQualityType == modelItem.quality_type
|
dataModel: model["qualities"]
|
||||||
|
buttonGroup: activeProfileButtonGroup
|
||||||
|
|
||||||
|
function checkedFunction(modelItem)
|
||||||
|
{
|
||||||
|
if(Cura.MachineManager.hasCustomQuality)
|
||||||
|
{
|
||||||
|
// When user created profile is active, no quality tickbox should be active.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category
|
||||||
|
}
|
||||||
|
|
||||||
|
isCheckedFunction: checkedFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
isCheckedFunction: checkedFunction
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,12 +18,7 @@ Item
|
||||||
implicitWidth: 200
|
implicitWidth: 200
|
||||||
implicitHeight: checkboxSize
|
implicitHeight: checkboxSize
|
||||||
|
|
||||||
property var model: null
|
property var dataModel: 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"
|
|
||||||
|
|
||||||
// The horizontal inactive bar that sits behind the buttons
|
// The horizontal inactive bar that sits behind the buttons
|
||||||
Rectangle
|
Rectangle
|
||||||
|
@ -45,6 +40,7 @@ Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RowLayout
|
RowLayout
|
||||||
{
|
{
|
||||||
id: buttonBar
|
id: buttonBar
|
||||||
|
@ -56,7 +52,7 @@ Item
|
||||||
Repeater
|
Repeater
|
||||||
{
|
{
|
||||||
id: repeater
|
id: repeater
|
||||||
model: base.model
|
model: base.dataModel
|
||||||
height: checkboxSize
|
height: checkboxSize
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
|
@ -75,7 +71,9 @@ Item
|
||||||
height: barSize
|
height: barSize
|
||||||
width: buttonBar.width / (repeater.count - 1) - activeComponent.width - 2
|
width: buttonBar.width / (repeater.count - 1) - activeComponent.width - 2
|
||||||
color: defaultItemColor
|
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
|
anchors
|
||||||
{
|
{
|
||||||
right: activeComponent.left
|
right: activeComponent.left
|
||||||
|
@ -87,9 +85,7 @@ Item
|
||||||
id: activeComponent
|
id: activeComponent
|
||||||
sourceComponent: isEnabled? checkboxComponent : disabledComponent
|
sourceComponent: isEnabled? checkboxComponent : disabledComponent
|
||||||
width: checkboxSize
|
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
|
property var modelItem: model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +123,8 @@ Item
|
||||||
ButtonGroup.group: buttonGroup
|
ButtonGroup.group: buttonGroup
|
||||||
width: checkboxSize
|
width: checkboxSize
|
||||||
height: checkboxSize
|
height: checkboxSize
|
||||||
property var identifier: modelItem[base.modelKey]
|
property var modelData: modelItem
|
||||||
|
|
||||||
checked: isCheckedFunction(modelItem)
|
checked: isCheckedFunction(modelItem)
|
||||||
indicator: Rectangle
|
indicator: Rectangle
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue