Skip to content

Commit

Permalink
Updates for changes to Qml Slider in Qt6
Browse files Browse the repository at this point in the history
minimumValue/maximumValue -> from/to
  • Loading branch information
DonLakeFlyer committed Dec 2, 2023
1 parent 22c1896 commit 0082c19
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/AutoPilotPlugins/APM/APMCameraSubComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ SetupPage {
gimbalSettingsLoader.sourceComponent = gimbalSettings
}
calcGimbalOutValues()
slide.minimumValue = 10
slide.maximumValue = 127
slide.from = 10
slide.to = 127
slide.value = slide._fact.value
slide._loadComplete = true
}
Expand Down
4 changes: 2 additions & 2 deletions src/FactSystem/FactControls/FactTextFieldSlider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Row {
}

Component.onCompleted: {
slide.minimumValue = fact.min
slide.maximumValue = fact.max
slide.from = fact.min
slide.to = fact.max
slide.value = fact.value
_loadComplete = true
}
Expand Down
12 changes: 6 additions & 6 deletions src/QmlControls/FactSliderPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Column {
style: SliderStyle {
tickmarks: Repeater {
id: repeater
model: control.stepSize > 0 ? 1 + (control.maximumValue - control.minimumValue) / control.stepSize : 0
model: control.stepSize > 0 ? 1 + (control.to - control.from) / control.stepSize : 0
property int unused: get()
function get() {
slider.handleWidth = styleData.handleWidth
Expand Down Expand Up @@ -128,17 +128,17 @@ Column {
anchors.right: parent.right
QGCLabel {
id: leftValueLabel
text: slider.minimumValue
text: slider.from
horizontalAlignment: Text.AlignLeft
}
Item {
QGCLabel {
visible: slider.value != slider.minimumValue && slider.value != slider.maximumValue
visible: slider.value != slider.from && slider.value != slider.to
text: Math.round(slider._fact.value*100000)/100000
x: getX()
function getX() {
var span = slider.maximumValue - slider.minimumValue
var x = slider.handleWidth / 2 + (slider.value-slider.minimumValue)/span * (slider.width-slider.handleWidth) - width / 2
var span = slider.to - slider.from
var x = slider.handleWidth / 2 + (slider.value-slider.from)/span * (slider.width-slider.handleWidth) - width / 2
// avoid overlapping text
var minX = leftValueLabel.x + leftValueLabel.width + _margins/2
if (x < minX) x = minX
Expand All @@ -150,7 +150,7 @@ Column {
}
QGCLabel {
id: rightValueLabel
text: slider.maximumValue
text: slider.to
Layout.alignment: Qt.AlignRight
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/QmlControls/QGCSlider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Slider {
width: control.zeroCentered ? centerIndicatorWidth : control.visualPosition
height: parent.height
property real zeroValuePosition: (Math.abs(control.minimumValue) / (control.maximumValue - control.minimumValue)) * parent.width
property real zeroValuePosition: (Math.abs(control.from) / (control.to - control.from)) * parent.width
property real zeroCenteredIndicatorStart: Math.min(control.visualPosition, zeroValuePosition)
property real zeroCenteredIndicatorStop: Math.max(control.visualPosition, zeroValuePosition)
property real centerIndicatorWidth: zeroCenteredIndicatorStop - zeroCenteredIndicatorStart
Expand Down Expand Up @@ -92,7 +92,7 @@ Slider {
property real _radius: ScreenTools.defaultFontPixelHeight / 2

Label {
text: control.value.toFixed( control.maximumValue <= 1 ? 1 : 0)
text: control.value.toFixed( control.to <= 1 ? 1 : 0)
visible: control.displayValue
anchors.centerIn: parent
font.family: ScreenTools.normalFontFamily
Expand Down

0 comments on commit 0082c19

Please sign in to comment.