From f62a2f5b94a21477e3bce0120e2d6d5c503731ed Mon Sep 17 00:00:00 2001 From: dorian Date: Wed, 27 Mar 2019 22:26:59 +0100 Subject: [PATCH] minor chhanges, mostly cleanup --- qml/components/SimpleIndicator.qml | 2 +- sources/appsettings.cpp | 2 +- sources/baseconn.cpp | 52 ++++++++++++++++++------------ 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/qml/components/SimpleIndicator.qml b/qml/components/SimpleIndicator.qml index d77c17b..e4d8acd 100644 --- a/qml/components/SimpleIndicator.qml +++ b/qml/components/SimpleIndicator.qml @@ -23,7 +23,7 @@ Rectangle { property int set_height: parent.font.pixelSize * 1.4 implicitWidth: set_height * 1.84 implicitHeight: set_height - x: ready_del.width - width - ready_del.rightPadding + x: parent.width - width - parent.rightPadding y: parent.height / 2 - height / 2 radius: implicitHeight * 0.5 color: parent.checked ? "#17a81a" : "transparent" diff --git a/sources/appsettings.cpp b/sources/appsettings.cpp index 04a77b4..9713b14 100644 --- a/sources/appsettings.cpp +++ b/sources/appsettings.cpp @@ -31,7 +31,7 @@ AppSettings::AppSettings(QObject* parent) this->setDefaultSetting("at_marks_en", "false"); this->setDefaultSetting("at_marks_delay", 0); - this->setDefaultSetting("theme", "Default"); + this->setDefaultSetting("theme", "Light"); pGlobalAppSettings = this; } diff --git a/sources/baseconn.cpp b/sources/baseconn.cpp index 3a539b6..8107412 100644 --- a/sources/baseconn.cpp +++ b/sources/baseconn.cpp @@ -12,6 +12,7 @@ BaseConn::BaseConn(QObject *parent) : QObject(parent) this, SLOT(gotError(QAbstractSocket::SocketError))); this->nextConnectionId = 1; + this->connections = QVariantList({}); } bool BaseConn::connectToHost() { @@ -66,11 +67,11 @@ void BaseConn::closeConnection() socket->abort(); } setState("disconnected"); -// for(int i = 0; i < this->waitingRequests.length(); i++){ -// this->waitingRequests[i].reply = "ERR_NOT_CONNECTED"; -// this->waitingRequests[i].loop->quit(); -// return; -// } + // for(int i = 0; i < this->waitingRequests.length(); i++){ + // this->waitingRequests[i].reply = "ERR_NOT_CONNECTED"; + // this->waitingRequests[i].loop->quit(); + // return; + // } } void BaseConn::gotError(QAbstractSocket::SocketError err) @@ -79,21 +80,21 @@ void BaseConn::gotError(QAbstractSocket::SocketError err) QString strError = "unknown"; switch (err) { - case 0: - strError = "Connection was refused"; - break; - case 1: - strError = "Remote host closed the connection"; - this->closeConnection(); - break; - case 2: - strError = "Host address was not found"; - break; - case 5: - strError = "Connection timed out"; - break; - default: - strError = "Unknown error"; + case 0: + strError = "Connection was refused"; + break; + case 1: + strError = "Remote host closed the connection"; + this->closeConnection(); + break; + case 2: + strError = "Host address was not found"; + break; + case 5: + strError = "Connection timed out"; + break; + default: + strError = "Unknown error"; } emit gotError(strError); @@ -236,4 +237,15 @@ bool BaseConn::refreshConnections() { QVariant BaseConn::getConnections() { return(connections); + /* + "id": "id of the extention (int)", + "type": "type of the extention (can be: 'STARTPAD', 'TOPPAP')", + "name": "name of the extention", + "ip": "ip-adress of he extention (string)", + "state": "state of the extention (can be: 'disconnected', 'connecting', 'connected')" + */ + //QVariantMap conn = {{"id",0}, {"type","STARTPAD"}, {"name", "startpad1"}, {"ip", "192.168.4.11"}, {"state", "connected"}}; + //QVariantMap conn1 = {{"id",0}, {"type","TOPPAD"}, {"name", "buzzer1"}, {"ip", "192.168.4.10"}, {"state", "connected"}}; + //QVariantList conns = {conn, conn1}; + //return conns; }