Skip to content

Commit

Permalink
Altitude properties are visually distinct
Browse files Browse the repository at this point in the history
  • Loading branch information
DonLakeFlyer committed Feb 18, 2016
1 parent a6cffd5 commit d04518d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/FlightMap/Widgets/ValuesWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ QGCFlickable {
qgcView.showDialog(propertyPicker, "Value Widget Setup", qgcView.showDialogDefaultWidth, StandardButton.Ok)
}

function listContains(list, value) {
for (var i=0; i<list.length; i++) {
if (list[i] === value) {
return true
}
}
return false
}

MouseArea {
anchors.fill: parent
onClicked: showPicker()
Expand All @@ -74,6 +83,7 @@ QGCFlickable {
width: _largeColumn.width

property Fact fact: _activeVehicle.getFact(modelData.replace("Vehicle.", ""))
property bool largeValue: _root.listContains(controller.altitudeProperties, fact.name)

QGCLabel {
width: parent.width
Expand All @@ -84,8 +94,8 @@ QGCFlickable {
QGCLabel {
width: parent.width
horizontalAlignment: Text.AlignHCenter
font.pixelSize: ScreenTools.largeFontPixelSize
font.weight: Font.DemiBold
font.pixelSize: ScreenTools.largeFontPixelSize * (largeValue ? 1.3 : 1.0)
font.weight: largeValue ? Font.ExtraBold : Font.Normal
color: textColor
text: fact.valueString
}
Expand Down Expand Up @@ -185,15 +195,6 @@ QGCFlickable {

property string propertyName: factGroupName + "." + modelData

function contains(list, value) {
for (var i=0; i<list.length; i++) {
if (list[i] === value) {
return true
}
}
return false
}

function removeFromList(list, value) {
var newList = []
for (var i=0; i<list.length; i++) {
Expand Down Expand Up @@ -236,14 +237,14 @@ QGCFlickable {
QGCCheckBox {
id: _addCheckBox
text: factGroup.getFact(modelData).shortDescription
checked: _largeCheckBox.checked || parent.contains(controller.smallValues, propertyName)
checked: _largeCheckBox.checked || listContains(controller.smallValues, propertyName)
onClicked: updateValues()
}

QGCCheckBox {
id: _largeCheckBox
text: "large"
checked: parent.contains(controller.largeValues, propertyName)
checked: listContains(controller.largeValues, propertyName)
enabled: _addCheckBox.checked
onClicked: updateValues()
}
Expand Down
2 changes: 2 additions & 0 deletions src/FlightMap/Widgets/ValuesWidgetController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ ValuesWidgetController::ValuesWidgetController(void)
_largeValues = settings.value(_largeValuesKey, largeDefaults).toStringList();
_smallValues = settings.value(_smallValuesKey, QStringList()).toStringList();

_altitudeProperties << "altitudeRelative" << "altitudeAMSL";

// Keep back compat for removed WGS84 value
if (_largeValues.contains ("Vehicle.altitudeWGS84")) {
setLargeValues(_largeValues.replaceInStrings("Vehicle.altitudeWGS84", "Vehicle.altitudeRelative"));
Expand Down
4 changes: 4 additions & 0 deletions src/FlightMap/Widgets/ValuesWidgetController.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ class ValuesWidgetController : public QObject
Q_PROPERTY(QStringList largeValues READ largeValues WRITE setLargeValues NOTIFY largeValuesChanged)
Q_PROPERTY(QStringList smallValues READ smallValues WRITE setSmallValues NOTIFY smallValuesChanged)

Q_PROPERTY(QStringList altitudeProperties READ altitudeProperties CONSTANT)

QStringList largeValues(void) const { return _largeValues; }
QStringList smallValues(void) const { return _smallValues; }
void setLargeValues(const QStringList& values);
void setSmallValues(const QStringList& values);
QStringList altitudeProperties(void) const { return _altitudeProperties; }

signals:
void largeValuesChanged(QStringList values);
Expand All @@ -48,6 +51,7 @@ class ValuesWidgetController : public QObject
private:
QStringList _largeValues;
QStringList _smallValues;
QStringList _altitudeProperties;

static const char* _groupKey;
static const char* _largeValuesKey;
Expand Down

0 comments on commit d04518d

Please sign in to comment.