Http Version - Added Alarm Button.
This commit is contained in:
parent
99bc9209af
commit
07bd73bb33
1 changed files with 163 additions and 25 deletions
105
Main.qml
105
Main.qml
|
|
@ -21,7 +21,8 @@ Window {
|
|||
property int distance_count_thres: 3
|
||||
property string mode: "http"
|
||||
property string status: "Initializing"
|
||||
|
||||
property string alarm_status_text: ""
|
||||
property var root_config: ({})
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
|
|
@ -91,11 +92,13 @@ Window {
|
|||
max_thres_input: 0
|
||||
}
|
||||
|
||||
|
||||
Text {
|
||||
id: status
|
||||
text: root.status
|
||||
id: alarm_status
|
||||
text: root.alarm_status_text
|
||||
visible: (root.alarm_status_text.length > 0 ) ? true : false
|
||||
anchors {
|
||||
bottom: connect_button.top
|
||||
bottom: status.top
|
||||
bottomMargin: 20
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
|
@ -104,32 +107,90 @@ Window {
|
|||
font.pointSize: root.font_normal_text_size
|
||||
}
|
||||
|
||||
ConnectButton {
|
||||
id: connect_button
|
||||
Text {
|
||||
id: status
|
||||
text: root.status
|
||||
anchors {
|
||||
bottom: button_base.top
|
||||
bottomMargin: 20
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
color: root.accent_color
|
||||
font.pointSize: root.font_normal_text_size
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: button_base
|
||||
color: "#00000000"
|
||||
width: parent.width / 1.5
|
||||
height: parent.height / 20
|
||||
width: parent.width / 4
|
||||
font_color: root.accent_color
|
||||
font_enlarged_text_size: root.font_enlarged_text_size
|
||||
font_normal_text_size: root.font_normal_text_size
|
||||
color: root.background_color
|
||||
accent_color: root.accent_color
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
bottom: parent.bottom
|
||||
bottomMargin: 50
|
||||
}
|
||||
onConnect: {
|
||||
if(connect_button.mode === 0)
|
||||
{
|
||||
requester.start();
|
||||
root.status = "Waiting to Send.";
|
||||
ConnectButton {
|
||||
id: connect_button
|
||||
width: parent.width / 2.1
|
||||
height: parent.height
|
||||
font_color: root.accent_color
|
||||
font_enlarged_text_size: root.font_enlarged_text_size
|
||||
font_normal_text_size: root.font_normal_text_size
|
||||
color: root.background_color
|
||||
accent_color: root.accent_color
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: 5
|
||||
bottom: parent.bottom
|
||||
bottomMargin: 5
|
||||
}
|
||||
else {
|
||||
root.status = "Stopped.";
|
||||
requester.stop();
|
||||
onConnect: {
|
||||
if(connect_button.mode === 0)
|
||||
{
|
||||
requester.start();
|
||||
root.status = "Waiting to Send.";
|
||||
}
|
||||
else {
|
||||
root.status = "Stopped.";
|
||||
requester.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConnectButton {
|
||||
id: start_alarm
|
||||
width: parent.width / 2.1
|
||||
height: parent.height
|
||||
font_color: root.accent_color
|
||||
font_enlarged_text_size: root.font_enlarged_text_size
|
||||
font_normal_text_size: root.font_normal_text_size
|
||||
color: root.background_color
|
||||
accent_color: root.accent_color
|
||||
text: "Start Alarm"
|
||||
text2: "Stop Alarm"
|
||||
anchors {
|
||||
left: connect_button.right
|
||||
leftMargin: 10
|
||||
bottom: parent.bottom
|
||||
bottomMargin: 5
|
||||
}
|
||||
onConnect: {
|
||||
if(start_alarm.mode === 0)
|
||||
{
|
||||
requester.startAlarm();
|
||||
root.alarm_status_text = "Started Alarm; Waiting for Trigger: " + root.root_config.alert + "%"
|
||||
}
|
||||
else {
|
||||
requester.stopAlarm();
|
||||
root.alarm_status_text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
RequestWorker {
|
||||
|
|
@ -162,6 +223,10 @@ Window {
|
|||
function setConfig(config) {
|
||||
tank.setConfig(config);
|
||||
requester.setConfig(config);
|
||||
root.root_config = config;
|
||||
}
|
||||
}
|
||||
onClosing: {
|
||||
requester.stopAlarm();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue