mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-10 12:59:02 +08:00
WIP: Fix quality sliderbar
This commit is contained in:
parent
e0f82fb5c6
commit
1a19175b35
@ -67,6 +67,7 @@ class NewQualityProfilesModel(ListModel):
|
|||||||
|
|
||||||
item = {"id": "TODO", # TODO: probably will be removed
|
item = {"id": "TODO", # TODO: probably will be removed
|
||||||
"name": quality_group.name,
|
"name": quality_group.name,
|
||||||
|
"quality_type": quality_group.quality_type,
|
||||||
"layer_height": layer_height + self._layer_height_unit,
|
"layer_height": layer_height + self._layer_height_unit,
|
||||||
"layer_height_without_unit": layer_height,
|
"layer_height_without_unit": layer_height,
|
||||||
"available": quality_group.is_available,
|
"available": quality_group.is_available,
|
||||||
@ -74,6 +75,9 @@ class NewQualityProfilesModel(ListModel):
|
|||||||
|
|
||||||
item_list.append(item)
|
item_list.append(item)
|
||||||
|
|
||||||
|
# Sort items based on layer_height
|
||||||
|
item_list = sorted(item_list, key = lambda x: float(x["layer_height_without_unit"]))
|
||||||
|
|
||||||
self.setItems(item_list)
|
self.setItems(item_list)
|
||||||
|
|
||||||
def _fetchLayerHeight(self, quality_group: "QualityGroup"):
|
def _fetchLayerHeight(self, quality_group: "QualityGroup"):
|
||||||
@ -84,9 +88,6 @@ class NewQualityProfilesModel(ListModel):
|
|||||||
unit = ""
|
unit = ""
|
||||||
self._layer_height_unit = unit
|
self._layer_height_unit = unit
|
||||||
|
|
||||||
if not quality_group.is_available:
|
|
||||||
return ""
|
|
||||||
|
|
||||||
# Get layer_height from the quality profile for the GlobalStack
|
# Get layer_height from the quality profile for the GlobalStack
|
||||||
container = quality_group.node_for_global.getContainer()
|
container = quality_group.node_for_global.getContainer()
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ Menu
|
|||||||
MenuSeparator
|
MenuSeparator
|
||||||
{
|
{
|
||||||
id: customSeparator
|
id: customSeparator
|
||||||
visible: Cura.UserProfilesModel.rowCount > 0
|
visible: Cura.NewCustomQualityProfilesModel.rowCount > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Instantiator
|
Instantiator
|
||||||
|
@ -57,7 +57,10 @@ Item
|
|||||||
interval: 50
|
interval: 50
|
||||||
running: false
|
running: false
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: Cura.MachineManager.setActiveQuality(Cura.ProfilesModel.getItem(qualitySlider.value).id)
|
onTriggered: {
|
||||||
|
var item = Cura.NewQualityProfilesModel.getItem(qualitySlider.value);
|
||||||
|
Cura.MachineManager.activeQualityGroup = item.quality_group;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: qualityModel.update()
|
Component.onCompleted: qualityModel.update()
|
||||||
@ -102,14 +105,14 @@ Item
|
|||||||
var availableMin = -1
|
var availableMin = -1
|
||||||
var availableMax = -1
|
var availableMax = -1
|
||||||
|
|
||||||
for (var i = 0; i < Cura.ProfilesModel.rowCount(); i++) {
|
for (var i = 0; i < Cura.NewQualityProfilesModel.rowCount(); i++) {
|
||||||
var qualityItem = Cura.ProfilesModel.getItem(i)
|
var qualityItem = Cura.NewQualityProfilesModel.getItem(i)
|
||||||
|
|
||||||
// Add each quality item to the UI quality model
|
// Add each quality item to the UI quality model
|
||||||
qualityModel.append(qualityItem)
|
qualityModel.append(qualityItem)
|
||||||
|
|
||||||
// Set selected value
|
// Set selected value
|
||||||
if (Cura.MachineManager.activeQualityType == qualityItem.metadata.quality_type) {
|
if (Cura.MachineManager.activeQualityType == qualityItem.quality_type) {
|
||||||
|
|
||||||
// set to -1 when switching to user created profile so all ticks are clickable
|
// set to -1 when switching to user created profile so all ticks are clickable
|
||||||
if (Cura.SimpleModeSettingsManager.isProfileUserCreated) {
|
if (Cura.SimpleModeSettingsManager.isProfileUserCreated) {
|
||||||
@ -165,7 +168,7 @@ Item
|
|||||||
qualityModel.existingQualityProfile = 0
|
qualityModel.existingQualityProfile = 0
|
||||||
|
|
||||||
// check, the ticks count cannot be less than zero
|
// check, the ticks count cannot be less than zero
|
||||||
qualityModel.totalTicks = Math.max(0, Cura.ProfilesModel.rowCount() - 1)
|
qualityModel.totalTicks = Math.max(0, Cura.NewQualityProfilesModel.rowCount() - 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,13 +194,13 @@ Item
|
|||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: Math.round(UM.Theme.getSize("sidebar_margin").height / 2)
|
anchors.topMargin: Math.round(UM.Theme.getSize("sidebar_margin").height / 2)
|
||||||
color: (Cura.MachineManager.activeMachine != null && Cura.ProfilesModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
|
color: (Cura.MachineManager.activeMachine != null && Cura.NewQualityProfilesModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
|
||||||
text:
|
text:
|
||||||
{
|
{
|
||||||
var result = ""
|
var result = ""
|
||||||
if(Cura.MachineManager.activeMachine != null)
|
if(Cura.MachineManager.activeMachine != null)
|
||||||
{
|
{
|
||||||
result = Cura.ProfilesModel.getItem(index).layer_height_without_unit
|
result = Cura.NewQualityProfilesModel.getItem(index).layer_height_without_unit
|
||||||
|
|
||||||
if(result == undefined)
|
if(result == undefined)
|
||||||
{
|
{
|
||||||
@ -262,7 +265,7 @@ Item
|
|||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
color: Cura.ProfilesModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
|
color: Cura.NewQualityProfilesModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
|
||||||
width: 1 * screenScaleFactor
|
width: 1 * screenScaleFactor
|
||||||
height: 6 * screenScaleFactor
|
height: 6 * screenScaleFactor
|
||||||
y: 0
|
y: 0
|
||||||
@ -408,9 +411,10 @@ Item
|
|||||||
// if the current profile is user-created, switch to a built-in quality
|
// if the current profile is user-created, switch to a built-in quality
|
||||||
if (Cura.SimpleModeSettingsManager.isProfileUserCreated)
|
if (Cura.SimpleModeSettingsManager.isProfileUserCreated)
|
||||||
{
|
{
|
||||||
if (Cura.ProfilesModel.rowCount() > 0)
|
if (Cura.NewQualityProfilesModel.rowCount() > 0)
|
||||||
{
|
{
|
||||||
Cura.MachineManager.setActiveQuality(Cura.ProfilesModel.getItem(0).id)
|
var item = Cura.NewQualityProfilesModel.getItem(0);
|
||||||
|
Cura.MachineManager.activeQualityGroup = item.quality_group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Cura.SimpleModeSettingsManager.isProfileCustomized)
|
if (Cura.SimpleModeSettingsManager.isProfileCustomized)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user