From fea01cf50378138cb615bac367387fbde36464ee Mon Sep 17 00:00:00 2001 From: dorian Date: Sat, 27 Apr 2019 22:50:22 +0200 Subject: [PATCH] minor fixes and additions --- headers/baseconn.h | 3 +++ qml/main.qml | 5 +++-- sources/baseconn.cpp | 17 ++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/headers/baseconn.h b/headers/baseconn.h index 58ad337..cd24233 100644 --- a/headers/baseconn.h +++ b/headers/baseconn.h @@ -87,6 +87,9 @@ public slots: Q_INVOKABLE bool connectToHost(); //function to connect to the base station + Q_INVOKABLE bool init(); + Q_INVOKABLE void deInit(); + Q_INVOKABLE void closeConnection(); void gotError(QAbstractSocket::SocketError err); diff --git a/qml/main.qml b/qml/main.qml index 0fd6436..27cf705 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -129,9 +129,9 @@ Window { opacity: ( speedBackend.state < 3 ) ? 1:0 - width: parent.width * 0.8 + width: parent.width * 0.7 - text: "" + text: qsTr("Click Start to start") color: appTheme.style.textColor @@ -147,6 +147,7 @@ Window { Behavior on text { FadeAnimation{ target: topLa + fadeDuration: 200 } } } diff --git a/sources/baseconn.cpp b/sources/baseconn.cpp index e176f24..2120dc2 100644 --- a/sources/baseconn.cpp +++ b/sources/baseconn.cpp @@ -48,13 +48,26 @@ bool BaseConn::connectToHost() { // stop the timer as the connection has been established timer.stop(); connect(this->socket, &QTcpSocket::readyRead, this, &BaseConn::readyRead); - this->connection_progress = 100; + this->connection_progress = 50; + + if(!this->init()){ + this->closeConnection(); + return false; + } this->setState("connected"); return(true); } +bool BaseConn::init() { + return true; +} + +void BaseConn::deInit() { + this->connections.clear(); +} + void BaseConn::closeConnection() { this->connections = QVariantList({}); @@ -72,6 +85,8 @@ void BaseConn::closeConnection() default: socket->abort(); } + + this->deInit(); setState("disconnected"); // for(int i = 0; i < this->waitingRequests.length(); i++){ // this->waitingRequests[i].reply = "ERR_NOT_CONNECTED";