mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 18:34:25 +01:00
Created new MainWindow QT Frontend
Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
parent
8f8d8a75b1
commit
9c7cc532fe
@ -11,8 +11,7 @@
|
|||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "response.h"
|
#include "response.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include "mainwindow.h"
|
||||||
#include "qrwidget.h"
|
|
||||||
|
|
||||||
// Info about doorlock-client version
|
// Info about doorlock-client version
|
||||||
const static std::string version =
|
const static std::string version =
|
||||||
@ -35,12 +34,13 @@ const int constexpr SOCKET_BUFFERLENGTH = 2048;
|
|||||||
|
|
||||||
static volatile bool run = true;
|
static volatile bool run = true;
|
||||||
|
|
||||||
static std::unique_ptr<QRWidget> qrWidget = nullptr;
|
std::unique_ptr<MainWindow> mainWindow = nullptr;
|
||||||
|
|
||||||
static void doorlock_update(const Clientmessage &msg)
|
static void doorlock_update(const Clientmessage &msg)
|
||||||
{
|
{
|
||||||
if (qrWidget) {
|
if (mainWindow) {
|
||||||
qrWidget->setQRData(msg.token());
|
mainWindow->setQRCode(QString::fromStdString(msg.token()));
|
||||||
|
mainWindow->setLabel(QString::fromStdString(msg.token()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,8 +51,7 @@ static int startGui(int argc, char** argv)
|
|||||||
app.setOrganizationName("Binary Kitchen");
|
app.setOrganizationName("Binary Kitchen");
|
||||||
app.setApplicationName("doorlock-client");
|
app.setApplicationName("doorlock-client");
|
||||||
|
|
||||||
qrWidget = std::unique_ptr<QRWidget>(new QRWidget);
|
mainWindow = std::unique_ptr<MainWindow>(new MainWindow);
|
||||||
qrWidget->showFullScreen();
|
|
||||||
|
|
||||||
int retval = app.exec();
|
int retval = app.exec();
|
||||||
run = false;
|
run = false;
|
||||||
|
53
doorlockd/src/mainwindow.h
Normal file
53
doorlockd/src/mainwindow.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#ifndef MAINWINDOW_H
|
||||||
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
#include "qrwidget.h"
|
||||||
|
|
||||||
|
class MainWindow : public QWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MainWindow() :
|
||||||
|
QWidget()
|
||||||
|
{
|
||||||
|
_qrWidget = new QRWidget;
|
||||||
|
|
||||||
|
_layout = new QVBoxLayout;
|
||||||
|
_layout->addWidget(_qrWidget);
|
||||||
|
|
||||||
|
_label = new QLabel;
|
||||||
|
_label->setText("Hello, world!");
|
||||||
|
|
||||||
|
QFont font("Times", 25, QFont::Bold);
|
||||||
|
_label->setFont(font);
|
||||||
|
_layout->addWidget(_label);
|
||||||
|
|
||||||
|
setLayout(_layout);
|
||||||
|
showFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow(const MainWindow&);
|
||||||
|
MainWindow& operator =(const MainWindow&);
|
||||||
|
|
||||||
|
void setQRCode(const QString &str)
|
||||||
|
{
|
||||||
|
_qrWidget->setQRData(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLabel(const QString &str)
|
||||||
|
{
|
||||||
|
_label->setText(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QRWidget* _qrWidget = { nullptr };
|
||||||
|
QVBoxLayout* _layout = { nullptr };
|
||||||
|
QLabel* _label = { nullptr };
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user