TunerScreen: two green or red leds

This commit is contained in:
Louis-Joseph Fournier 2016-01-02 16:36:55 +01:00
parent 478b64ca8c
commit e270506117
5 changed files with 53 additions and 1 deletions

20
qml/Led.qml Normal file
View file

@ -0,0 +1,20 @@
import QtQuick 2.0
import QtGraphicalEffects 1.0
/**
* Led: a circle color
*/
RadialGradient {
property color led_color: "red"
gradient: Gradient {
GradientStop {
position: 0.0
color: led_color
}
GradientStop {
position: 0.5
color: "transparent"
}
}
}

View file

@ -18,7 +18,8 @@ Item {
property int note: 2
property int octave: 4
property double freq: 440
property double deviation: 0.1
property double deviation: 0.12
property bool found: true
}
TunerScreen {

View file

@ -18,6 +18,35 @@ Item {
// landscape / portrait
property bool is_portrait: height > width
// maximum absolute deviation to display green led
property double deviation_ok: 0.1
property color led_green: "green"
property color led_red: "red"
property bool dev_is_ok: Math.abs(tuner.deviation) <= deviation_ok
Led {
anchors.top: meter.top
anchors.left: meter.left
anchors.topMargin: meter.width / 24
anchors.leftMargin: anchors.topMargin
width: meter.width / 12
height: width
led_color: dev_is_ok ? led_green : led_red
visible: tuner.found && (dev_is_ok || tuner.deviation < 0)
}
Led {
anchors.top: meter.top
anchors.right: meter.right
anchors.topMargin: meter.width / 24
anchors.rightMargin: anchors.topMargin
width: meter.width / 12
height: width
led_color: dev_is_ok ? led_green : led_red
visible: tuner.found && (dev_is_ok || tuner.deviation > 0)
}
CircleMeter {
id: meter
theme: parent.theme

View file

@ -7,5 +7,6 @@
<file>CircleMeter.qml</file>
<file>ScaleToise.qml</file>
<file>Toise.qml</file>
<file>Led.qml</file>
</qresource>
</RCC>

View file

@ -6,5 +6,6 @@
<file>CircleMeter.qml</file>
<file>ScaleToise.qml</file>
<file>Toise.qml</file>
<file>Led.qml</file>
</qresource>
</RCC>