Browse Source

re enabled gui

develop
Robin Thoni 7 years ago
parent
commit
2d90aa11b2

+ 1
- 1
CMakeLists.txt View File

31
 
31
 
32
 add_subdirectory(libnfc_cpptools)
32
 add_subdirectory(libnfc_cpptools)
33
 add_subdirectory(cli)
33
 add_subdirectory(cli)
34
-#add_subdirectory(gui)
34
+add_subdirectory(gui)
35
 
35
 
36
 find_package(GTest)
36
 find_package(GTest)
37
 if (GTEST_FOUND)
37
 if (GTEST_FOUND)

+ 3
- 2
gui/CMakeLists.txt View File

1
-include_directories(.)
2
-include_directories(. ../libnfc_cpptools)
1
+include_directories(
2
+        ${LIBNFC_CPPTOOLS_INCLUDE_PATH}
3
+)
3
 
4
 
4
 # Find includes in corresponding build directories
5
 # Find includes in corresponding build directories
5
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
6
 set(CMAKE_INCLUDE_CURRENT_DIR ON)

+ 2
- 2
gui/Core/LibNfcOperation.cpp View File

4
 
4
 
5
 #include "LibNfcOperation.h"
5
 #include "LibNfcOperation.h"
6
 
6
 
7
-LibNfcOperation::LibNfcOperation(QSharedPointer<LibNfcBusiness>& libNfc,
8
-                                 std::function<void(QSharedPointer<LibNfcBusiness>)> operation)
7
+LibNfcOperation::LibNfcOperation(QSharedPointer<LibNfc::Core::LibNfcContext>& libNfc,
8
+                                 std::function<void(QSharedPointer<LibNfc::Core::LibNfcContext>)> operation)
9
         : m_pLibNfc(libNfc)
9
         : m_pLibNfc(libNfc)
10
         , m_operation(operation)
10
         , m_operation(operation)
11
 {
11
 {

+ 8
- 8
gui/Core/LibNfcOperation.h View File

9
 #include <QtCore/QThread>
9
 #include <QtCore/QThread>
10
 #include <QtCore/QSharedPointer>
10
 #include <QtCore/QSharedPointer>
11
 
11
 
12
-#include <Business/LibNfcBusiness.h>
12
+#include <libnfc_cpptools/LibNfcContext.h>
13
 
13
 
14
 class LibNfcOperation : public QThread
14
 class LibNfcOperation : public QThread
15
 {
15
 {
16
     Q_OBJECT
16
     Q_OBJECT
17
 public:
17
 public:
18
     template<typename T>
18
     template<typename T>
19
-    static void runOperation(QSharedPointer<LibNfcBusiness> libNfc,
20
-                    std::function<Result<T>(QSharedPointer<LibNfcBusiness>)> operation,
21
-                    std::function<void(Result<T>)> callback);
19
+    static void runOperation(QSharedPointer<LibNfc::Core::LibNfcContext> libNfc,
20
+                    std::function<LibNfc::Utils::Result<T>(QSharedPointer<LibNfc::Core::LibNfcContext>)> operation,
21
+                    std::function<void(LibNfc::Utils::Result<T>)> callback);
22
 
22
 
23
 protected:
23
 protected:
24
     void run() override;
24
     void run() override;
27
 //    void operationFinished(Result<T> result);
27
 //    void operationFinished(Result<T> result);
28
 
28
 
29
 private:
29
 private:
30
-    explicit LibNfcOperation(QSharedPointer<LibNfcBusiness>& libNfc,
31
-                             std::function<void(QSharedPointer<LibNfcBusiness>)> operation);
30
+    explicit LibNfcOperation(QSharedPointer<LibNfc::Core::LibNfcContext>& libNfc,
31
+                             std::function<void(QSharedPointer<LibNfc::Core::LibNfcContext>)> operation);
32
 
32
 
33
-    QSharedPointer<LibNfcBusiness> m_pLibNfc;
33
+    QSharedPointer<LibNfc::Core::LibNfcContext> m_pLibNfc;
34
 
34
 
35
-    std::function<void(QSharedPointer<LibNfcBusiness>)> m_operation;
35
+    std::function<void(QSharedPointer<LibNfc::Core::LibNfcContext>)> m_operation;
36
 };
36
 };
37
 
37
 
38
 #endif //MIFARE_TOOLS_LIBNFCOPERATION_H
38
 #endif //MIFARE_TOOLS_LIBNFCOPERATION_H

+ 7
- 7
gui/Core/LibNfcOperation.hxx View File

8
 #include "LibNfcOperation.h"
8
 #include "LibNfcOperation.h"
9
 
9
 
10
 template<typename T>
10
 template<typename T>
11
-void LibNfcOperation::runOperation(QSharedPointer<LibNfcBusiness> libNfc,
12
-                          std::function<Result<T>(QSharedPointer<LibNfcBusiness>)> operation,
13
-                          std::function<void(Result<T>)> callback)
11
+void LibNfcOperation::runOperation(QSharedPointer<LibNfc::Core::LibNfcContext> libNfc,
12
+                          std::function<LibNfc::Utils::Result<T>(QSharedPointer<LibNfc::Core::LibNfcContext>)> operation,
13
+                          std::function<void(LibNfc::Utils::Result<T>)> callback)
14
 {
14
 {
15
-    Result<T>* result = new Result<T>();
16
-    auto nfcOperation = new LibNfcOperation(libNfc, [result, operation](QSharedPointer<LibNfcBusiness> libNfc)
15
+    LibNfc::Utils::Result<T>* result = nullptr;
16
+    auto nfcOperation = new LibNfcOperation(libNfc, [&result, operation](QSharedPointer<LibNfc::Core::LibNfcContext> libNfc)
17
     {
17
     {
18
         auto res = operation(libNfc);
18
         auto res = operation(libNfc);
19
-        *result = res;
19
+        result = new LibNfc::Utils::Result<T>(res);
20
     });
20
     });
21
-    connect(nfcOperation, &LibNfcOperation::finished, [result, nfcOperation, callback]()
21
+    connect(nfcOperation, &LibNfcOperation::finished, [&result, nfcOperation, callback]()
22
     {
22
     {
23
         nfcOperation->deleteLater();
23
         nfcOperation->deleteLater();
24
         callback(*result);
24
         callback(*result);

+ 5
- 5
gui/UI/MainWindow.cpp View File

18
 bool MainWindow::initLibNfc()
18
 bool MainWindow::initLibNfc()
19
 {
19
 {
20
     if (!m_pLibNfc) {
20
     if (!m_pLibNfc) {
21
-        m_pLibNfc.reset(new LibNfcBusiness());
21
+        m_pLibNfc.reset(new LibNfc::Core::LibNfcContext());
22
         auto initResult = m_pLibNfc->init();
22
         auto initResult = m_pLibNfc->init();
23
         if (!initResult) {
23
         if (!initResult) {
24
             showError(initResult);
24
             showError(initResult);
35
     }
35
     }
36
     m_pUi->pComboReaders->clear();
36
     m_pUi->pComboReaders->clear();
37
 
37
 
38
-    LibNfcOperation::runOperation<std::vector<std::shared_ptr<NfcDeviceBusiness>>>(m_pLibNfc, [](QSharedPointer<LibNfcBusiness> libNfc)
38
+    LibNfcOperation::runOperation<std::vector<std::shared_ptr<LibNfc::Core::NfcDevice>>>(m_pLibNfc, [](QSharedPointer<LibNfc::Core::LibNfcContext> libNfc)
39
                          {
39
                          {
40
-                             return (Result<std::vector<std::shared_ptr<NfcDeviceBusiness>>>) libNfc->getDevices();
41
-                         }, [this](Result<std::vector<std::shared_ptr<NfcDeviceBusiness>>> devicesResult)
40
+                             return (LibNfc::Utils::Result<std::vector<std::shared_ptr<LibNfc::Core::NfcDevice>>>) libNfc->getDevices();
41
+                         }, [this](LibNfc::Utils::Result<std::vector<std::shared_ptr<LibNfc::Core::NfcDevice>>> devicesResult)
42
     {
42
     {
43
         m_devices = devicesResult.getData();
43
         m_devices = devicesResult.getData();
44
         for (auto& device : m_devices) {
44
         for (auto& device : m_devices) {
59
 }
59
 }
60
 
60
 
61
 template<typename T>
61
 template<typename T>
62
-void MainWindow::showError(Result<T> result)
62
+void MainWindow::showError(LibNfc::Utils::Result<T> result)
63
 {
63
 {
64
     result.print();
64
     result.print();
65
     QMessageBox::critical(this, "LibNfc Error", QString("LibNfc error: %1").arg(result.getError().c_str()));
65
     QMessageBox::critical(this, "LibNfc Error", QString("LibNfc error: %1").arg(result.getError().c_str()));

+ 4
- 4
gui/UI/MainWindow.h View File

7
 
7
 
8
 
8
 
9
 #include <QtWidgets/QMainWindow>
9
 #include <QtWidgets/QMainWindow>
10
-#include <Business/LibNfcBusiness.h>
10
+#include <libnfc_cpptools/LibNfcContext.h>
11
 
11
 
12
 #include "ui_MainWindow.h"
12
 #include "ui_MainWindow.h"
13
 
13
 
22
 
22
 
23
     void refreshReaders();
23
     void refreshReaders();
24
 
24
 
25
-    template<typename T> void showError(Result<T> result);
25
+    template<typename T> void showError(LibNfc::Utils::Result<T> result);
26
 
26
 
27
 private:
27
 private:
28
     QScopedPointer<Ui_MainWindow> m_pUi;
28
     QScopedPointer<Ui_MainWindow> m_pUi;
29
 
29
 
30
-    QSharedPointer<LibNfcBusiness> m_pLibNfc;
30
+    QSharedPointer<LibNfc::Core::LibNfcContext> m_pLibNfc;
31
 
31
 
32
-    std::vector<std::shared_ptr<NfcDeviceBusiness>> m_devices;
32
+    std::vector<std::shared_ptr<LibNfc::Core::NfcDevice>> m_devices;
33
 };
33
 };
34
 
34
 
35
 
35
 

+ 4
- 1
gui/UI/MainWindow.ui View File

11
    </rect>
11
    </rect>
12
   </property>
12
   </property>
13
   <property name="windowTitle">
13
   <property name="windowTitle">
14
-   <string>MainWindow</string>
14
+   <string>LibNFC_cppTools</string>
15
   </property>
15
   </property>
16
   <widget class="QWidget" name="centralwidget">
16
   <widget class="QWidget" name="centralwidget">
17
    <layout class="QVBoxLayout" name="verticalLayout">
17
    <layout class="QVBoxLayout" name="verticalLayout">
39
            <verstretch>0</verstretch>
39
            <verstretch>0</verstretch>
40
           </sizepolicy>
40
           </sizepolicy>
41
          </property>
41
          </property>
42
+         <property name="sizeAdjustPolicy">
43
+          <enum>QComboBox::AdjustToContents</enum>
44
+         </property>
42
         </widget>
45
         </widget>
43
        </item>
46
        </item>
44
        <item>
47
        <item>

Loading…
Cancel
Save