From 1246e6d1db57e2eea52905cdb50f375a72857142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Fri, 4 Sep 2015 22:49:13 +0100 Subject: [PATCH] Implement toggling countdown state. --- consolereader.cpp | 2 +- socket.cpp | 6 ++++++ socket.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/consolereader.cpp b/consolereader.cpp index 7182a2d..9cb9696 100644 --- a/consolereader.cpp +++ b/consolereader.cpp @@ -64,7 +64,7 @@ void ConsoleReader::run() (*sockets) [number]->setCountDown(countdown); break; case 'C': - (*sockets) [number]->setCountDown(countdown); + (*sockets) [number]->toggleCountDown(); break; case 'd': (*sockets) [number]->tableData(); diff --git a/socket.cpp b/socket.cpp index fe1c584..5ebf157 100644 --- a/socket.cpp +++ b/socket.cpp @@ -161,6 +161,12 @@ void Socket::setCountDown(uint16_t countdown) writeSocketData(socketName, remotePassword, timeZone, countdown); } +void Socket::toggleCountDown() +{ + countdownEnabled=!countdownEnabled; + writeSocketData(socketName, remotePassword, timeZone, countdown); +} + void Socket::writeSocketData(QByteArray socketName, QByteArray remotePassword, QByteArray timeZone, uint16_t countdown) { QByteArray countDown; diff --git a/socket.h b/socket.h index 89428b9..9f4bcc0 100644 --- a/socket.h +++ b/socket.h @@ -49,6 +49,7 @@ public: void changeSocketPassword(QString newPassword); void changeTimezone(int8_t newTimezone); void setCountDown(uint16_t countdown); + void toggleCountDown(); bool parseReply(QByteArray); QHostAddress ip;