Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "src/zxing-cpp"]
path = src/zxing-cpp
url = https://github.com/nu-book/zxing-cpp.git
[submodule "3rdParty/googletest"]
path = 3rdParty/googletest
url = https://github.com/google/googletest.git
1 change: 1 addition & 0 deletions 3rdParty/googletest
Submodule googletest added at 5a9c3f
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.16)
project(QmlBarcode LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt5 Qt6)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Multimedia Concurrent Quick REQUIRED)


set(BUILD_GMOCK OFF)
add_subdirectory(3rdParty/googletest)
add_subdirectory(src)
add_subdirectory(examples/QmlBarcodeReader)
add_subdirectory(examples/QmlBarcodeGenerator)
add_subdirectory(tests)
8 changes: 1 addition & 7 deletions examples/QmlBarcodeGenerator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#Check this file for any *_DIR variable definitions and other
include("cmake/Locations.cmake")

if(Qt${QT_VERSION_MAJOR} STREQUAL Qt5)
qt5_add_resources(RSCS qml.qrc)
else()
qt_add_resources(RSCS qml.qrc)
endif()

add_subdirectory(${LIB_DIR} ${CMAKE_BINARY_DIR}/SCodes)

if(ANDROID)

if(Qt${QT_VERSION_MAJOR} STREQUAL Qt5)
Expand Down Expand Up @@ -56,8 +51,7 @@ else()

endif()

target_link_libraries(${PROJECT_NAME} PRIVATE ${REQUIRED_QT_LIBS} SCodes)

target_link_libraries(${PROJECT_NAME} PRIVATE SCodes)

if(QT_VERSION_MAJOR EQUAL 6)
qt_import_qml_plugins(${PROJECT_NAME})
Expand Down
37 changes: 0 additions & 37 deletions examples/QmlBarcodeGenerator/cmake/Locations.cmake

This file was deleted.

8 changes: 1 addition & 7 deletions examples/QmlBarcodeReader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#Check this file for any *_DIR variable definitions and other
include("cmake/Locations.cmake")

if(Qt${QT_VERSION_MAJOR} STREQUAL Qt5)
qt5_add_resources(RSCS Qt5qml.qrc)
else()
qt_add_resources(RSCS Qt6qml.qrc)
endif()

add_subdirectory(${LIB_DIR} ${CMAKE_BINARY_DIR}/SCodes)

if(ANDROID)

if(Qt${QT_VERSION_MAJOR} STREQUAL Qt5)
Expand Down Expand Up @@ -54,8 +49,7 @@ else()

endif()

target_link_libraries(${PROJECT_NAME} PRIVATE ${REQUIRED_QT_LIBS} SCodes)

target_link_libraries(${PROJECT_NAME} PRIVATE SCodes)

if(QT_VERSION_MAJOR EQUAL 6)
qt_import_qml_plugins(${PROJECT_NAME})
Expand Down
37 changes: 0 additions & 37 deletions examples/QmlBarcodeReader/cmake/Locations.cmake

This file was deleted.

5 changes: 5 additions & 0 deletions src/SBarcodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ QColor SBarcodeGenerator::backgroundColor() const
return m_backgroundColor;
}

QString SBarcodeGenerator::generatedFilePath() const
{
return m_filePath;
}

void SBarcodeGenerator::setBackgroundColor(const QColor &backgroundColor)
{
if (m_backgroundColor == backgroundColor) {
Expand Down
6 changes: 6 additions & 0 deletions src/SBarcodeGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ class SBarcodeGenerator : public QQuickItem
*/
QColor backgroundColor() const;

/*!
* \brief Returns the full path to the last successfully generated barcode image (temp file).
* Exposed for unit tests only.
*/
QString generatedFilePath() const;

public slots:

/*!
Expand Down
6 changes: 3 additions & 3 deletions src/SBarcodeScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ QCamera *SBarcodeScanner::makeDefaultCamera()
auto defaultCamera = QMediaDevices::defaultVideoInput();
if (defaultCamera.isNull())
{
errorOccured("No default camera could be found on the system");
emit errorOccured("No default camera could be found on the system");
return nullptr;
}

auto camera = new QCamera(defaultCamera, this);
if (camera->error()) {
errorOccured("Error during camera initialization: " + camera->errorString());
emit errorOccured("Error during camera initialization: " + camera->errorString());
return nullptr;
}

Expand All @@ -109,7 +109,7 @@ QCamera *SBarcodeScanner::makeDefaultCamera()
}
if(supportedFormats.empty())
{
errorOccured("A default camera was found but it has no supported formats. The Camera may be wrongly configured.");
emit errorOccured("A default camera was found but it has no supported formats. The Camera may be wrongly configured.");
return nullptr;
}

Expand Down
17 changes: 17 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
project(SCodes_tests LANGUAGES CXX)
enable_testing()

file(GLOB_RECURSE SOURCES *.cpp)
add_executable(${PROJECT_NAME} ${SOURCES})

target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/googletest
)

target_link_libraries(${PROJECT_NAME} PRIVATE
SCodes
GTest::gtest
GTest::gtest_main
Qt6::Core
Qt6::Gui
)
6 changes: 6 additions & 0 deletions tests/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <gtest/gtest.h>

int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Loading