1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 18:34:25 +01:00

Improved GUI

This commit is contained in:
Ralf Ramsauer 2015-10-05 23:59:18 +02:00
parent 70a4b3de03
commit 99ddc88c6b
3 changed files with 57 additions and 0 deletions

View File

@ -1,3 +1,5 @@
#include "config.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
@ -6,6 +8,9 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow) ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
_greenLED(false);
_redLED(true);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -17,4 +22,28 @@ void MainWindow::setClientmessage(const Clientmessage &msg)
{ {
ui->qrwidget->setQRData(msg.token()); ui->qrwidget->setQRData(msg.token());
ui->tokenLabel->setText(QString::fromStdString(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"));
} }

View File

@ -24,6 +24,9 @@ public:
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
void _greenLED(const bool on);
void _redLED(const bool on);
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -49,6 +49,31 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="greenLED">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="redLED">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">