Skip to content

Commit

Permalink
Ping360Visualizer: Makes vertical and horizontal flip mutually exclus…
Browse files Browse the repository at this point in the history
…ive for 360 sector

It's not possible to accomplish the same thing with ButtonGroup,
since there functionality depends of 3 variables changing how vertical flip works.
There is also the problem that when the button is not visible, the enabled component
of such control is also false, so it makes the onEnabled logic harder.
This approach uses the binding method to accomplish the same behavior.

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Aug 23, 2019
1 parent 520ea4e commit bb30eca
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions qml/Ping360Visualizer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,19 @@ Item {
Component {
id: displaySettings
GridLayout {
id: settingsLayout
anchors.fill: parent
columns: 5
rowSpacing: 5
columnSpacing: 5
property bool isFullCircle: true

// Sensor connections should be done inside component
// Components are local '.qml' descriptions, so it's not possible get outside connections
Connections {
target: ping
// We do not support vertical flips in sector view
onSectorSizeChanged: {
if(ping.sectorSize != 360) {
verticalFlipChB.checked = false
verticalFlipChB.enabled = false
} else {
verticalFlipChB.enabled = true
}
settingsLayout.isFullCircle = ping.sectorSize == 360
}
}

Expand All @@ -235,9 +231,17 @@ Item {
checked: false
Layout.columnSpan: 5
Layout.fillWidth: true
// We do not support vertical flips in sector view
enabled: settingsLayout.isFullCircle
onCheckStateChanged: {
waterfall.verticalFlip = checkState
}

// Disable vertical flip in sector view or when horizontal is selected
Binding on checked {
when: horizontalFlipChB.checked || !settingsLayout.isFullCircle
value: false
}
}

CheckBox {
Expand All @@ -249,6 +253,12 @@ Item {
onCheckStateChanged: {
waterfall.horizontalFlip = checkState
}

// Disable when vertical is selected
Binding on checked {
when: verticalFlipChB.checked
value: false
}
}

CheckBox {
Expand Down

0 comments on commit bb30eca

Please sign in to comment.