From cde0521d6f44bc8d422b4302afbd34356f30a00c Mon Sep 17 00:00:00 2001 From: Ralf Ramsauer Date: Wed, 30 Sep 2015 15:26:28 +0200 Subject: [PATCH] Added ui file for MainWindow --- doorlockd/CMakeLists.txt | 5 +++- doorlockd/client/mainwindow.cpp | 19 ++++++++++++++ doorlockd/client/mainwindow.h | 42 +++++++++--------------------- doorlockd/client/mainwindow.ui | 46 +++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 31 deletions(-) create mode 100644 doorlockd/client/mainwindow.cpp create mode 100644 doorlockd/client/mainwindow.ui diff --git a/doorlockd/CMakeLists.txt b/doorlockd/CMakeLists.txt index 2dfde31..168d2a6 100644 --- a/doorlockd/CMakeLists.txt +++ b/doorlockd/CMakeLists.txt @@ -81,7 +81,9 @@ set(DOORLOCK_CLIENT_SRCS client/qrwidget.cpp client/qrwidget.h client/doorlock-client.cpp - client/mainwindow.h) + client/mainwindow.h + client/mainwindow.cpp + client/mainwindow.ui) add_library(doorlock STATIC ${LIBDOORLOCK_SRCS}) target_link_libraries(doorlock jsoncpp ldap ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) @@ -91,6 +93,7 @@ target_link_libraries(doorlockd doorlock) add_executable(doorlock-client ${DOORLOCK_CLIENT_SRCS}) target_link_libraries(doorlock-client doorlock qrencode Qt5::Widgets) +target_include_directories(doorlock-client PRIVATE ${CMAKE_SOURCE_DIR}) install(TARGETS doorlockd DESTINATION sbin/) install(TARGETS doorlock-client DESTINATION bin/) diff --git a/doorlockd/client/mainwindow.cpp b/doorlockd/client/mainwindow.cpp new file mode 100644 index 0000000..8b45670 --- /dev/null +++ b/doorlockd/client/mainwindow.cpp @@ -0,0 +1,19 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QWidget(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::setQRCode(const std::string &token) +{ + ui->qrwidget->setQRData(token); +} diff --git a/doorlockd/client/mainwindow.h b/doorlockd/client/mainwindow.h index c7388f0..a78f3c1 100644 --- a/doorlockd/client/mainwindow.h +++ b/doorlockd/client/mainwindow.h @@ -1,42 +1,24 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include -#include -#include -#include +#include -#include "qrwidget.h" +namespace Ui { +class MainWindow; +} -class MainWindow : public QMainWindow +class MainWindow : public QWidget { + Q_OBJECT + public: - MainWindow() : - QMainWindow() - { - layout = new QHBoxLayout; + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); - _qrWidget = new QRWidget; - layout->addWidget(_qrWidget); - - QWidget* window = new QWidget; - window->setLayout(layout); - - setCentralWidget(window); - } - - MainWindow(const MainWindow&); - MainWindow& operator =(const MainWindow&); - - void setQRCode(const std::string &str) - { - _qrWidget->setQRData(str); - } + void setQRCode(const std::string &token); private: - - QHBoxLayout* layout = { nullptr }; - QRWidget* _qrWidget = { nullptr }; + Ui::MainWindow *ui; }; -#endif +#endif // MAINWINDOW_H diff --git a/doorlockd/client/mainwindow.ui b/doorlockd/client/mainwindow.ui new file mode 100644 index 0000000..5c0a37c --- /dev/null +++ b/doorlockd/client/mainwindow.ui @@ -0,0 +1,46 @@ + + + MainWindow + + + + 0 + 0 + 886 + 610 + + + + + 886 + 610 + + + + Form + + + + + + + + true + + + + + + + + + + QRWidget + QWidget +
client/qrwidget.h
+ 1 +
+
+ + +