Skip to content

Commit

Permalink
Use of ValueSlider instead of QGCSlider
Browse files Browse the repository at this point in the history
  • Loading branch information
Godeffroy committed Jan 15, 2025
1 parent 66bfdd0 commit d6ad519
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 44 deletions.
Binary file modified docs/assets/setup/Motors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 13 additions & 22 deletions src/AutoPilotPlugins/APM/APMMotorComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,34 @@ SetupPage {

Row {
Column {

QGCLabel {
id: labelThrottle
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Throttle") + " " + sliderThrottle.value + " " + qsTr("%")
}

Row {
id: motorSlider
enabled: safetySwitch.checked
spacing: ScreenTools.defaultFontPixelWidth * 4

QGCButton {
anchors.verticalCenter: parent.verticalCenter
id: minusMinusButton
id: minusButton
text: qsTr("-")
onClicked: sliderThrottle.value-=1
onClicked: sliderThrottle.setValue(sliderThrottle.value-1)
}

QGCSlider {
id: sliderThrottle
width: ScreenTools.defaultFontPixelHeight * _sliderWidth
orientation: Qt.Horizontal
anchors.verticalCenter: parent.verticalCenter
from: 0
to: 100
stepSize: 1
value: 0
live: false
displayValue: true
ValueSlider {
id: sliderThrottle
width: motorButtons.width - minusButton.width - plusButton.width - ScreenTools.defaultFontPixelWidth * 4 * 2
label: qsTr("Throttle")
from: 0
to: 100
majorTickStepSize: 5
decimalPlaces: 0
unitsString: qsTr("%")
}

QGCButton {
anchors.verticalCenter: parent.verticalCenter
id: plusButton
text: qsTr("+")
onClicked: sliderThrottle.value+=1
onClicked: sliderThrottle.setValue(sliderThrottle.value+1)
}
} // Row
} // Column
Expand Down Expand Up @@ -139,7 +130,7 @@ SetupPage {
id: safetySwitch
onClicked: {
if (!checked) {
sliderThrottle.value = 0
sliderThrottle.setValue(0);
}
}
}
Expand Down
35 changes: 13 additions & 22 deletions src/AutoPilotPlugins/Common/MotorComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,34 @@ SetupPage {

Row {
Column {

QGCLabel {
id: labelThrottle
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Throttle") + " " + sliderThrottle.value + " " + qsTr("%")
}

Row {
id: motorSlider
enabled: safetySwitch.checked
spacing: ScreenTools.defaultFontPixelWidth * 4

QGCButton {
anchors.verticalCenter: parent.verticalCenter
id: minusMinusButton
id: minusButton
text: qsTr("-")
onClicked: sliderThrottle.value-=1
onClicked: sliderThrottle.setValue(sliderThrottle.value-1)
}

QGCSlider {
id: sliderThrottle
width: ScreenTools.defaultFontPixelHeight * _sliderWidth
orientation: Qt.Horizontal
anchors.verticalCenter: parent.verticalCenter
from: 0
to: 100
stepSize: 1
value: 0
live: false
displayValue: true
ValueSlider {
id: sliderThrottle
width: motorButtons.width - minusButton.width - plusButton.width - ScreenTools.defaultFontPixelWidth * 4 * 2
label: qsTr("Throttle")
from: 0
to: 100
majorTickStepSize: 5
decimalPlaces: 0
unitsString: qsTr("%")
}

QGCButton {
anchors.verticalCenter: parent.verticalCenter
id: plusButton
text: qsTr("+")
onClicked: sliderThrottle.value+=1
onClicked: sliderThrottle.setValue(sliderThrottle.value+1)
}
} // Row
} // Column
Expand Down Expand Up @@ -139,7 +130,7 @@ SetupPage {
id: safetySwitch
onClicked: {
if (!checked) {
sliderThrottle.value = 0
sliderThrottle.setValue(0);
}
}
}
Expand Down

0 comments on commit d6ad519

Please sign in to comment.