Skip to content

Commit

Permalink
[QgsQuick] Handle empty config for checkbox editor widget
Browse files Browse the repository at this point in the history
Use true/false instead of un/checkedState if empty
  • Loading branch information
vsklencar authored and wonder-sk committed Apr 25, 2019
1 parent cb9b3b4 commit 5b7e67a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/quickgui/plugin/editor/qgsquickcheckbox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Item {
height: customStyle.fields.height
id: checkBox
leftPadding: 0
checked: value == config['CheckedState']
checked: config['CheckedState'] ? value == config['CheckedState'] : value

indicator: Rectangle {
implicitWidth: customStyle.fields.height
Expand All @@ -60,13 +60,14 @@ Item {
}
}
onCheckedChanged: {
valueChanged( checked ? config['CheckedState'] : config['UncheckedState'], false )
valueChanged( checked ? (config['CheckedState'] ? config['CheckedState'] : true) :
(config['UncheckedState'] ? config['UncheckedState'] : false), false )
forceActiveFocus()
}

// Workaround to get a signal when the value has changed
onCurrentValueChanged: {
checked = currentValue == config['CheckedState']
checked = config['CheckedState'] ? currentValue == config['CheckedState'] : currentValue
}
}
}

0 comments on commit 5b7e67a

Please sign in to comment.