diff --git a/doorlockd/src/doorlock-client.cpp b/doorlockd/src/doorlock-client.cpp index d307cb4..e759aed 100644 --- a/doorlockd/src/doorlock-client.cpp +++ b/doorlockd/src/doorlock-client.cpp @@ -11,8 +11,7 @@ #include "logger.h" #include "response.h" -#include -#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 = nullptr; +std::unique_ptr 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(new QRWidget); - qrWidget->showFullScreen(); + mainWindow = std::unique_ptr(new MainWindow); int retval = app.exec(); run = false; diff --git a/doorlockd/src/mainwindow.h b/doorlockd/src/mainwindow.h new file mode 100644 index 0000000..5bdb561 --- /dev/null +++ b/doorlockd/src/mainwindow.h @@ -0,0 +1,53 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include + +#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