Some graphical improvements

This commit is contained in:
Dorian Zedler 2018-07-26 22:13:43 +02:00
parent 6873e8a952
commit 9001272ada
4 changed files with 23 additions and 43 deletions

View file

@ -9,7 +9,7 @@ Item {
property int size: 200 // The size of the circle in pixel
property real arcBegin: 0 // start arc angle in degree
property real arcEnd: 270 // end arc angle in degree
property real arcEnd: 1 // end arc angle in degree
property real arcOffset: 0 // rotation
property bool isPie: false // paint a pie instead of an arc
property bool showBackground: false // a full circle as a background of the arc
@ -20,7 +20,7 @@ Item {
property alias beginAnimation: animationArcBegin.enabled
property alias endAnimation: animationArcEnd.enabled
property int animationDuration: 20
property int animationDuration: 50
onArcBeginChanged: canvas.requestPaint()
onArcEndChanged: canvas.requestPaint()
@ -45,10 +45,12 @@ Item {
Behavior on opacity {
NumberAnimation {
duration: 100
duration: 200
}
}
Canvas {
id: canvas
anchors.fill: parent

View file

@ -9,15 +9,15 @@ Popup {
y: startButt.y
width: startButt.width
height: startButt.height
modal: false
enabled: false
modal: true
dim: false
enter: Transition {
NumberAnimation { properties: "scale"; from: 0; to: 1; duration: 500; easing.type: Easing.InCubic }
NumberAnimation { properties: "scale"; from: 0; to: 1; duration: 300; easing.type: Easing.InCubic }
}
exit: Transition {
NumberAnimation { properties: "scale"; from: 1; to: 0; duration: 500; easing.type: Easing.OutCubic }
NumberAnimation { properties: "scale"; from: 1; to: 0; duration: 300; easing.type: Easing.OutCubic }
}
function delay(delayTime, cb) {
@ -109,8 +109,9 @@ Popup {
}
onClicked: {
root.modal = true
root.closePolicy = Popup.NoAutoClose
connect_del.opacity = 0
prog.arcEnd = 0
prog.colorCircle = "grey"
prog.opacity = 1
prog.text = "connecting..."
@ -118,14 +119,11 @@ Popup {
connect_del.enabled = false
if(_cppBuzzerConn.connect()){
prog.arcEnd = 360
prog.colorCircle = "green"
prog.text = "success!"
}
else {
prog.arcEnd = 360
prog.colorCircle = "red"
prog.colorBackground = "red"
prog.text = "error!"
}
@ -140,7 +138,7 @@ Popup {
onTriggered: {
connect_del.enabled = true;
prog.opacity = 0;
root.modal = false;
connect_del.opacity = 1;
root.closePolicy = Popup.CloseOnPressOutside;
}
}

View file

@ -17,9 +17,10 @@ bool BuzzerConn::connect()
if(times[0] == 200.0){
this->connected = true;
this->latest_button_pressed = times[2];
for(int i=0;i<100;i++){
for(int i=0;i<=100;i++){
this->connection_progress = i;
if(!calcoffset()){
this->connection_progress = 100;
return(false);
}
}
@ -34,7 +35,9 @@ bool BuzzerConn::connect()
bool BuzzerConn::calcoffset()
{
QList<double> times = gettimes();
qDebug() << times[0];
if(times.length() != 3){
return(false);
}
if(times[0] == 200.0 && this->connected){
double offset = date->currentMSecsSinceEpoch() - times[1];
if(this->latest_offsets.length()>=100){
@ -46,12 +49,7 @@ bool BuzzerConn::calcoffset()
for(int i=0;i<latest_offsets.length();i++){
mem += latest_offsets[i];
}
//this->offset = mem / double(latest_offsets.length());
this->offset = latest_offsets[latest_offsets.length()-1];
// qDebug() << latest_offsets.length();
// qDebug() << this->latest_offsets;
// qDebug() << latest_offsets[latest_offsets.length()-1];
// qDebug() << mem / double(latest_offsets.length());
this->offset = mem / double(latest_offsets.length());
qDebug("%20f", this->offset);
return(true);
}

View file

@ -58,19 +58,15 @@ Window {
interval: 1
onTriggered: {
//root.stoppedTime = (root.last_button_pressed + root.buzzer_offset) - root.startTime
//console.log("STOPPED: "+root.stoppedTime)
//time.text = ( root.stoppedTime / 1000 ).toFixed(3) + " sec"
if(_cppBuzzerConn.buzzer_triggered()){
//the buzzer was pushed
root.buzzer_offset = _cppBuzzerConn.get("offset")
root.last_button_pressed = _cppBuzzerConn.get("lastpressed")
console.log(root.startTime);
console.log(root.buzzer_offset);
root.stoppedTime = (root.last_button_pressed + root.buzzer_offset) - root.startTime
time.text = ( root.stoppedTime / 1000 ).toFixed(3) + " sec"
console.log("STOPPED: "+root.stoppedTime)
root.state = "STOPPED"
//time.text = ( root.stoppedTime / 1000 ).toFixed(3) + " sec"
console.log("STOPPED: "+root.stoppedTime)
}
if(root.state === "RUNNING"){
running_refresh_timer.start()
@ -306,14 +302,7 @@ Window {
}
onClicked: {
if(settingsDialog.enabled === false){
settingsDialog.open()
settingsDialog.enabled = true
}
else {
settingsDialog.enabled = false
settingsDialog.close()
}
settingsDialog.open()
}
background: Rectangle {
@ -359,13 +348,6 @@ Window {
}
onClicked: {
var theUrl = "http://192.168.4.1";
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false );
xmlHttp.send( null );
console.log(xmlHttp.responseText)
}
background: Rectangle {