1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00

Created new MainWindow QT Frontend

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
Ralf Ramsauer 2015-09-28 17:05:05 +02:00
parent 8f8d8a75b1
commit 9c7cc532fe
2 changed files with 59 additions and 7 deletions

View File

@ -11,8 +11,7 @@
#include "logger.h"
#include "response.h"
#include <QApplication>
#include "qrwidget.h"
#include "mainwindow.h"
// Info about doorlock-client version
const static std::string version =
@ -35,12 +34,13 @@ const int constexpr SOCKET_BUFFERLENGTH = 2048;
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)
{
if (qrWidget) {
qrWidget->setQRData(msg.token());
if (mainWindow) {
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.setApplicationName("doorlock-client");
qrWidget = std::unique_ptr<QRWidget>(new QRWidget);
qrWidget->showFullScreen();
mainWindow = std::unique_ptr<MainWindow>(new MainWindow);
int retval = app.exec();
run = false;

View 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