diff --git a/doorlockd/client/mainwindow.cpp b/doorlockd/client/mainwindow.cpp index 54b6b13..a24336d 100644 --- a/doorlockd/client/mainwindow.cpp +++ b/doorlockd/client/mainwindow.cpp @@ -1,3 +1,5 @@ +#include "config.h" + #include "mainwindow.h" #include "ui_mainwindow.h" @@ -6,6 +8,9 @@ MainWindow::MainWindow(QWidget *parent) : ui(new Ui::MainWindow) { ui->setupUi(this); + + _greenLED(false); + _redLED(true); } MainWindow::~MainWindow() @@ -17,4 +22,28 @@ void MainWindow::setClientmessage(const Clientmessage &msg) { ui->qrwidget->setQRData(msg.token()); ui->tokenLabel->setText(QString::fromStdString(msg.token())); + + if (msg.isOpen()) { + _greenLED(true); + _redLED(false); + } else { + _greenLED(false); + _redLED(true); + } +} + +void MainWindow::_greenLED(const bool on) +{ + if (on) + ui->greenLED->setPixmap(QPixmap(IMAGE_LOCATION "led-green-on.png")); + else + ui->greenLED->setPixmap(QPixmap(IMAGE_LOCATION "led-green-off.png")); +} + +void MainWindow::_redLED(const bool on) +{ + if (on) + ui->redLED->setPixmap(QPixmap(IMAGE_LOCATION "led-red-on.png")); + else + ui->redLED->setPixmap(QPixmap(IMAGE_LOCATION "led-red-off.png")); } diff --git a/doorlockd/client/mainwindow.h b/doorlockd/client/mainwindow.h index c9d9ac7..1d12270 100644 --- a/doorlockd/client/mainwindow.h +++ b/doorlockd/client/mainwindow.h @@ -24,6 +24,9 @@ public: private: Ui::MainWindow *ui; + + void _greenLED(const bool on); + void _redLED(const bool on); }; #endif // MAINWINDOW_H diff --git a/doorlockd/client/mainwindow.ui b/doorlockd/client/mainwindow.ui index 7fd41a7..d424384 100644 --- a/doorlockd/client/mainwindow.ui +++ b/doorlockd/client/mainwindow.ui @@ -49,6 +49,31 @@ + + + + + + TextLabel + + + + + + + Qt::Vertical + + + + + + + TextLabel + + + + +