mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Stop the simulation also when the range slider is used. Reuse some code.
Contributes to CURA-5725.
This commit is contained in:
parent
1b1ca8a53b
commit
f965b66c87
2 changed files with 28 additions and 32 deletions
|
@ -36,16 +36,16 @@ Item {
|
|||
property bool pathsVisible: true
|
||||
property bool manuallyChanged: true // Indicates whether the value was changed manually or during simulation
|
||||
|
||||
function getHandleValueFromSliderHandle () {
|
||||
function getHandleValueFromSliderHandle() {
|
||||
return handle.getValue()
|
||||
}
|
||||
|
||||
function setHandleValue (value) {
|
||||
function setHandleValue(value) {
|
||||
handle.setValue(value)
|
||||
updateRangeHandle()
|
||||
}
|
||||
|
||||
function updateRangeHandle () {
|
||||
function updateRangeHandle() {
|
||||
rangeHandle.width = handle.x - sliderRoot.handleSize
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ Item {
|
|||
color: handleLabel.activeFocus ? sliderRoot.handleActiveColor : sliderRoot.handleColor
|
||||
visible: sliderRoot.pathsVisible
|
||||
|
||||
function onHandleDragged () {
|
||||
function onHandleDragged() {
|
||||
sliderRoot.manuallyChanged = true
|
||||
|
||||
// update the range handle
|
||||
|
@ -108,15 +108,21 @@ Item {
|
|||
}
|
||||
|
||||
// get the value based on the slider position
|
||||
function getValue () {
|
||||
function getValue() {
|
||||
var result = x / (sliderRoot.width - sliderRoot.handleSize)
|
||||
result = result * sliderRoot.maximumValue
|
||||
result = sliderRoot.roundValues ? Math.round(result) : result
|
||||
return result
|
||||
}
|
||||
|
||||
function setValueManually(value)
|
||||
{
|
||||
sliderRoot.manuallyChanged = true
|
||||
handle.setValue(value)
|
||||
}
|
||||
|
||||
// set the slider position based on the value
|
||||
function setValue (value) {
|
||||
function setValue(value) {
|
||||
// Normalize values between range, since using arrow keys will create out-of-the-range values
|
||||
value = sliderRoot.normalizeValue(value)
|
||||
|
||||
|
@ -130,16 +136,8 @@ Item {
|
|||
sliderRoot.updateRangeHandle()
|
||||
}
|
||||
|
||||
Keys.onRightPressed:
|
||||
{
|
||||
sliderRoot.manuallyChanged = true
|
||||
handleLabel.setValue(handleLabel.value + ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||
}
|
||||
Keys.onLeftPressed:
|
||||
{
|
||||
sliderRoot.manuallyChanged = true
|
||||
handleLabel.setValue(handleLabel.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||
}
|
||||
Keys.onRightPressed: handleLabel.setValue(handleLabel.value + ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||
Keys.onLeftPressed: handleLabel.setValue(handleLabel.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||
|
||||
// dragging
|
||||
MouseArea {
|
||||
|
@ -172,7 +170,7 @@ Item {
|
|||
maximumValue: sliderRoot.maximumValue
|
||||
value: sliderRoot.handleValue
|
||||
busy: UM.SimulationView.busy
|
||||
setValue: handle.setValue // connect callback functions
|
||||
setValue: handle.setValueManually // connect callback functions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue