mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 02:25:54 +08:00
Brackets on new line
As far as I've seen them when I scrolled through this. Contributes to issue CURA-5324.
This commit is contained in:
parent
258a90d850
commit
bd145c451b
@ -57,7 +57,8 @@ Item
|
|||||||
interval: 50
|
interval: 50
|
||||||
running: false
|
running: false
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: {
|
onTriggered:
|
||||||
|
{
|
||||||
var item = Cura.QualityProfilesDropDownMenuModel.getItem(qualitySlider.value);
|
var item = Cura.QualityProfilesDropDownMenuModel.getItem(qualitySlider.value);
|
||||||
Cura.MachineManager.activeQualityGroup = item.quality_group;
|
Cura.MachineManager.activeQualityGroup = item.quality_group;
|
||||||
}
|
}
|
||||||
@ -77,7 +78,8 @@ Item
|
|||||||
{
|
{
|
||||||
// update needs to be called when the widgets are visible, otherwise the step width calculation
|
// update needs to be called when the widgets are visible, otherwise the step width calculation
|
||||||
// will fail because the width of an invisible item is 0.
|
// will fail because the width of an invisible item is 0.
|
||||||
if (visible) {
|
if (visible)
|
||||||
|
{
|
||||||
qualityModel.update();
|
qualityModel.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,24 +99,30 @@ Item
|
|||||||
property var qualitySliderAvailableMax: 0
|
property var qualitySliderAvailableMax: 0
|
||||||
property var qualitySliderMarginRight: 0
|
property var qualitySliderMarginRight: 0
|
||||||
|
|
||||||
function update () {
|
function update ()
|
||||||
|
{
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
var availableMin = -1
|
var availableMin = -1
|
||||||
var availableMax = -1
|
var availableMax = -1
|
||||||
|
|
||||||
for (var i = 0; i < Cura.QualityProfilesDropDownMenuModel.rowCount(); i++) {
|
for (var i = 0; i < Cura.QualityProfilesDropDownMenuModel.rowCount(); i++)
|
||||||
|
{
|
||||||
var qualityItem = Cura.QualityProfilesDropDownMenuModel.getItem(i)
|
var qualityItem = Cura.QualityProfilesDropDownMenuModel.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.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)
|
||||||
|
{
|
||||||
qualityModel.qualitySliderActiveIndex = -1
|
qualityModel.qualitySliderActiveIndex = -1
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
qualityModel.qualitySliderActiveIndex = i
|
qualityModel.qualitySliderActiveIndex = i
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,18 +130,21 @@ Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set min available
|
// Set min available
|
||||||
if (qualityItem.available && availableMin == -1) {
|
if (qualityItem.available && availableMin == -1)
|
||||||
|
{
|
||||||
availableMin = i
|
availableMin = i
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set max available
|
// Set max available
|
||||||
if (qualityItem.available) {
|
if (qualityItem.available)
|
||||||
|
{
|
||||||
availableMax = i
|
availableMax = i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set total available ticks for active slider part
|
// Set total available ticks for active slider part
|
||||||
if (availableMin != -1) {
|
if (availableMin != -1)
|
||||||
|
{
|
||||||
qualityModel.availableTotalTicks = availableMax - availableMin + 1
|
qualityModel.availableTotalTicks = availableMax - availableMin + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,16 +156,23 @@ Item
|
|||||||
qualityModel.qualitySliderAvailableMax = availableMax
|
qualityModel.qualitySliderAvailableMax = availableMax
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateSliderStepWidth (totalTicks) {
|
function calculateSliderStepWidth (totalTicks)
|
||||||
|
{
|
||||||
qualityModel.qualitySliderStepWidth = totalTicks != 0 ? Math.round((base.width * 0.55) / (totalTicks)) : 0
|
qualityModel.qualitySliderStepWidth = totalTicks != 0 ? Math.round((base.width * 0.55) / (totalTicks)) : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateSliderMargins (availableMin, availableMax, totalTicks) {
|
function calculateSliderMargins (availableMin, availableMax, totalTicks)
|
||||||
if (availableMin == -1 || (availableMin == 0 && availableMax == 0)) {
|
{
|
||||||
|
if (availableMin == -1 || (availableMin == 0 && availableMax == 0))
|
||||||
|
{
|
||||||
qualityModel.qualitySliderMarginRight = Math.round(base.width * 0.55)
|
qualityModel.qualitySliderMarginRight = Math.round(base.width * 0.55)
|
||||||
} else if (availableMin == availableMax) {
|
}
|
||||||
|
else if (availableMin == availableMax)
|
||||||
|
{
|
||||||
qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMin) * qualitySliderStepWidth)
|
qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMin) * qualitySliderStepWidth)
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMax) * qualitySliderStepWidth)
|
qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMax) * qualitySliderStepWidth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,16 +233,24 @@ Item
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
x: {
|
x:
|
||||||
|
{
|
||||||
// Make sure the text aligns correctly with each tick
|
// Make sure the text aligns correctly with each tick
|
||||||
if (qualityModel.totalTicks == 0) {
|
if (qualityModel.totalTicks == 0)
|
||||||
|
{
|
||||||
// If there is only one tick, align it centrally
|
// If there is only one tick, align it centrally
|
||||||
return Math.round(((base.width * 0.55) - width) / 2)
|
return Math.round(((base.width * 0.55) - width) / 2)
|
||||||
} else if (index == 0) {
|
}
|
||||||
|
else if (index == 0)
|
||||||
|
{
|
||||||
return Math.round(base.width * 0.55 / qualityModel.totalTicks) * index
|
return Math.round(base.width * 0.55 / qualityModel.totalTicks) * index
|
||||||
} else if (index == qualityModel.totalTicks) {
|
}
|
||||||
|
else if (index == qualityModel.totalTicks)
|
||||||
|
{
|
||||||
return Math.round(base.width * 0.55 / qualityModel.totalTicks) * index - width
|
return Math.round(base.width * 0.55 / qualityModel.totalTicks) * index - width
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return Math.round((base.width * 0.55 / qualityModel.totalTicks) * index - (width / 2))
|
return Math.round((base.width * 0.55 / qualityModel.totalTicks) * index - (width / 2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +317,8 @@ Item
|
|||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
id: rightArea
|
id: rightArea
|
||||||
width: {
|
width:
|
||||||
|
{
|
||||||
if(qualityModel.availableTotalTicks == 0)
|
if(qualityModel.availableTotalTicks == 0)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -299,8 +326,10 @@ Item
|
|||||||
}
|
}
|
||||||
height: parent.height
|
height: parent.height
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
x: {
|
x:
|
||||||
if (qualityModel.availableTotalTicks == 0) {
|
{
|
||||||
|
if (qualityModel.availableTotalTicks == 0)
|
||||||
|
{
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +339,8 @@ Item
|
|||||||
return totalGap
|
return totalGap
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea
|
||||||
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false
|
enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false
|
||||||
@ -373,13 +403,16 @@ Item
|
|||||||
style: SliderStyle
|
style: SliderStyle
|
||||||
{
|
{
|
||||||
//Draw Available line
|
//Draw Available line
|
||||||
groove: Rectangle {
|
groove: Rectangle
|
||||||
|
{
|
||||||
implicitHeight: 2 * screenScaleFactor
|
implicitHeight: 2 * screenScaleFactor
|
||||||
color: UM.Theme.getColor("quality_slider_available")
|
color: UM.Theme.getColor("quality_slider_available")
|
||||||
radius: Math.round(height / 2)
|
radius: Math.round(height / 2)
|
||||||
}
|
}
|
||||||
handle: Item {
|
handle: Item
|
||||||
Rectangle {
|
{
|
||||||
|
Rectangle
|
||||||
|
{
|
||||||
id: qualityhandleButton
|
id: qualityhandleButton
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color: UM.Theme.getColor("quality_slider_available")
|
color: UM.Theme.getColor("quality_slider_available")
|
||||||
@ -391,11 +424,14 @@ Item
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onValueChanged: {
|
onValueChanged:
|
||||||
|
{
|
||||||
// only change if an active machine is set and the slider is visible at all.
|
// only change if an active machine is set and the slider is visible at all.
|
||||||
if (Cura.MachineManager.activeMachine != null && visible) {
|
if (Cura.MachineManager.activeMachine != null && visible)
|
||||||
|
{
|
||||||
// prevent updating during view initializing. Trigger only if the value changed by user
|
// prevent updating during view initializing. Trigger only if the value changed by user
|
||||||
if (qualitySlider.value != qualityModel.qualitySliderActiveIndex && qualityModel.qualitySliderActiveIndex != -1) {
|
if (qualitySlider.value != qualityModel.qualitySliderActiveIndex && qualityModel.qualitySliderActiveIndex != -1)
|
||||||
|
{
|
||||||
// start updating with short delay
|
// start updating with short delay
|
||||||
qualitySliderChangeTimer.start()
|
qualitySliderChangeTimer.start()
|
||||||
}
|
}
|
||||||
@ -587,7 +623,8 @@ Item
|
|||||||
// same operation
|
// same operation
|
||||||
var active_mode = UM.Preferences.getValue("cura/active_mode")
|
var active_mode = UM.Preferences.getValue("cura/active_mode")
|
||||||
|
|
||||||
if (active_mode == 0 || active_mode == "simple") {
|
if (active_mode == 0 || active_mode == "simple")
|
||||||
|
{
|
||||||
Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue)
|
Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user