Skip to content

Commit

Permalink
Addition of WarningLabel QML type, to display a warning when a datalo…
Browse files Browse the repository at this point in the history
…g value is over a threshold
  • Loading branch information
malcom2073 committed Feb 14, 2014
1 parent 14dbb3d commit 235a282
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/core.pro
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,5 @@ OTHER_FILES += \
wizards/DecoderOffset.qml \
wizards/wizard.qml \
wizards/EngineConfig.qml \
wizards/ActualDecoderOffset.qml
wizards/ActualDecoderOffset.qml \
src/WarningLabel/WarningLabel.qml
62 changes: 62 additions & 0 deletions core/src/WarningLabel/WarningLabel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import Qt 4.7


Rectangle {
id: warninglabel
color:"red"
property bool flash: false
property string propertyMapProperty;
property string conditiontype;
property int conditionval;
property double conditionvalue;
property string message;
Timer {
id: flashertimer
interval: 500
repeat: true
running: false
onTriggered: {
//console.log("Wee:" + conditionvalue);
if (parent.flash)
{
parent.flash = false;
parent.color = "orange";
}
else
{
parent.flash = true;
parent.color = "red";
}
}
}
onConditionvalueChanged: {
//console.log("CCalue:" + conditionvalue);
if (conditiontype == "over")
{
//console.log("CValue:" + conditionvalue + conditionval);
if (conditionvalue > conditionval)
{
flashertimer.running = true;
warninglabel.visible = true;
}
else
{
flashertimer.running = false;
warninglabel.visible = false;
}
}
}
Component.onCompleted:
{
warninglabel.visible = false;
}

Text {
anchors.fill:parent
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.pointSize: 14
text: message;
}
}
18 changes: 17 additions & 1 deletion core/src/gauges.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Qt 4.7
import GaugeImage 0.1

import "WarningLabel"
Rectangle {
x:0
y:0
Expand Down Expand Up @@ -178,4 +178,20 @@ Rectangle {
}
}
}
Component.onCompleted: {

}

WarningLabel {
id: warning;
x: (parent.width / 2.0) - 200
width:200
y: (parent.height / 2.0) - 100
height:100
propertyMapProperty: "CHT";
conditiontype: "over";
conditionval: 215;
conditionvalue: propertyMap["CHT"];
message: "Warning!\nEngine is overheating!!!!!";
}
}

0 comments on commit 235a282

Please sign in to comment.