Skip to content

Commit

Permalink
GzSpinBox update
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Agüero <[email protected]>
  • Loading branch information
caguero committed Aug 5, 2024
1 parent 1f28e07 commit 7cf5f94
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 48 deletions.
11 changes: 5 additions & 6 deletions include/gz/gui/qml/GzCardSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Dialog {

GzSpinBox {
visible: !cardPane.anchored
to: cardPane.parent ? cardPane.parent.width - cardPane.width : from
maximumValue: cardPane.parent ? cardPane.parent.width - cardPane.width : minSize
onVisibleChanged: value = cardPane.x
onValueChanged: {
cardPane.x = value;
Expand All @@ -147,7 +147,7 @@ Dialog {
}
GzSpinBox {
visible: !cardPane.anchored
to: cardPane.parent ? cardPane.parent.height - cardPane.height : from
maximumValue: cardPane.parent ? cardPane.parent.height - cardPane.height : minSize
onVisibleChanged: value = cardPane.y
onValueChanged: {
cardPane.y = value;
Expand All @@ -159,7 +159,7 @@ Dialog {
}
GzSpinBox {
visible: !cardPane.anchored
to: 10000
maximumValue: 10000
onVisibleChanged: value = cardPane.z
onValueChanged: {
cardPane.z = value;
Expand All @@ -177,7 +177,7 @@ Dialog {
text: ""
}
GzSpinBox {
to: cardPane.parent ? cardPane.parent.width : from
maximumValue: cardPane.parent ? cardPane.parent.width : minSize
onVisibleChanged: {
if (cardPane)
value = cardPane.width
Expand All @@ -190,8 +190,7 @@ Dialog {
text: "Width"
}
GzSpinBox {
to: cardPane.parent ? cardPane.parent.height : from

maximumValue: cardPane.parent ? cardPane.parent.height : minSize
onVisibleChanged: {
if (cardPane)
value = cardPane.height
Expand Down
10 changes: 5 additions & 5 deletions include/gz/gui/qml/GzPose.qml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Item {
signal gzPoseSet(double _x, double _y, double _z, double _roll, double _pitch, double _yaw)

// Maximum spinbox value
property int spinMax: Number.MAX_VALUE
property double spinMax: Number.MAX_VALUE

// Expand/Collapse of this widget
property bool expand: true
Expand Down Expand Up @@ -119,10 +119,10 @@ Item {
GzSpinBox {
id: writableSpin
value: numberValue
from: -spinMax
to: spinMax
//decimals: gzHelper.getDecimals(writableSpin.width)
onValueChanged: {
minimumValue: -spinMax
maximumValue: spinMax
decimals: gzHelper.getDecimals(writableSpin.width)
onEditingFinished: {
gzPoseRoot.gzPoseSet(xItem.value, yItem.value, zItem.value,
rollItem.value, pitchItem.value, yawItem.value)
}
Expand Down
41 changes: 35 additions & 6 deletions include/gz/gui/qml/GzSpinBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,39 @@
import QtQuick
import QtQuick.Controls

SpinBox {
background: Rectangle {
implicitWidth: 70
implicitHeight: 40
border.color: "gray"
}
Item {
id: root
property int decimals: 2
property real value: 0.0
property real from: 0.0
property real to: 100.0
property alias minimumValue: root.from
property alias maximumValue: root.to
property real stepSize: 1.0
signal editingFinished(real _value)

SpinBox{
id: spinbox
property real factor: Math.pow(10, root.decimals)
stepSize: root.stepSize*factor
value: root.value*factor
to : root.to*factor
from : root.from*factor
editable: true

validator: DoubleValidator {
bottom: Math.min(spinbox.from, spinbox.to)
top: Math.max(spinbox.from, spinbox.to)
}

textFromValue: function(value, locale) {
return Number(value / factor).toLocaleString(locale, 'f', root.decimals)
}

valueFromText: function(text, locale) {
return Math.round(Number.fromLocaleString(locale, text) * factor)
}

onValueChanged: root.editingFinished(spinbox.value / spinbox.factor)
}
}
24 changes: 12 additions & 12 deletions src/plugins/GridConfig/GridConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ GridLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
id: verticalCellCount
to: Number.MAX_VALUE
from: 0
maximumValue: Number.MAX_VALUE
minimumValue: 0
value: 0
onValueChanged: GridConfig.UpdateVCellCount(verticalCellCount.value)
onEditingFinished: GridConfig.UpdateVCellCount(verticalCellCount.value)
}

Text {
Expand All @@ -129,10 +129,10 @@ GridLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
id: horizontalCellCount
to: Number.MAX_VALUE
from: 1
maximumValue: Number.MAX_VALUE
minimumValue: 1
value: 20
onValueChanged: GridConfig.UpdateHCellCount(horizontalCellCount.value)
onEditingFinished: GridConfig.UpdateHCellCount(horizontalCellCount.value)
}

Text {
Expand All @@ -153,12 +153,12 @@ GridLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
id: cellLength
to: Number.MAX_VALUE
from: 0
value: 1
//decimals: gzHelpers.getDecimals(cellLength.width)
stepSize: 1
onValueChanged: GridConfig.UpdateCellLength(cellLength.value)
maximumValue: Number.MAX_VALUE
minimumValue: 0
value: 1.00
decimals: gzHelpers.getDecimals(cellLength.width)
stepSize: 0.01
onEditingFinished: GridConfig.UpdateCellLength(cellLength.value)
}

Text {
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/PointCloud/PointCloud.qml
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ ColumnLayout {
GzSpinBox {
id: pointSizeSpin
value: PointCloud.pointSize
from: 1
minimumValue: 1
maximumValue: 1
decimals: 0
to: 1000
onValueChanged: {
onEditingFinished: {
PointCloud.SetPointSize(pointSizeSpin.value)
}
}
Expand Down
32 changes: 16 additions & 16 deletions src/plugins/Teleop/Teleop.qml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ ColumnLayout {
id: maxForwardVelField
Layout.fillWidth: true
value: maxForwardVel
to: 10000
from: 0
// decimals: 2
stepSize: 1
onValueChanged:{
maximumValue: 10000.0
minimumValue: 0.0
decimals: 2
stepSize: 0.10
onEditingFinished: {
Teleop.SetMaxForwardVel(value)
}
}
Expand All @@ -142,11 +142,11 @@ ColumnLayout {
id: maxVerticalVelField
Layout.fillWidth: true
value: maxVerticalVel
to: 10000
from: 0
// decimals: 2
stepSize: 1
onValueChanged:{
maximumValue: 10000.0
minimumValue: 0.0
decimals: 2
stepSize: 0.10
onEditingFinished:{
Teleop.SetMaxVerticalVel(value)
}
}
Expand All @@ -161,12 +161,12 @@ ColumnLayout {
id: maxYawVelField
Layout.fillWidth: true
value: maxYawVel
to: 10000
from: 0
// decimals: 2
stepSize: 1
onValueChanged:{
Teleop.SetMaxYawVel(value)
maximumValue: 10000.0
minimumValue: 0.0
decimals: 2
stepSize: 0.10
onEditingFinished:{
Teleop.SetMaxYawVel(1.0)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/WorldControl/WorldControl.qml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ RowLayout {
}

GzSpinBox {
to: 10000
maximumValue: 10000
Layout.alignment: Qt.AlignVCenter
value: 1
onValueChanged: {
Expand Down

0 comments on commit 7cf5f94

Please sign in to comment.