From ffa27ffe5a2af78b8782c5254b96fe95e63c1168 Mon Sep 17 00:00:00 2001 From: EndrII Date: Sun, 23 Jan 2022 20:09:18 +0300 Subject: [PATCH] separate to gui and core libs --- .gitignore | 5 +- CMakeLists.txt | 7 +-- src/Core/CMakeLists.txt | 31 ++++++++++++ .../DoctorPillCore/doctor.cpp | 0 src/{Library => Core}/DoctorPillCore/doctor.h | 0 .../DoctorPillCore/doctortest.cpp | 0 .../DoctorPillCore/doctortest.h | 0 .../DoctorPillCore/ipill.cpp | 0 src/{Library => Core}/DoctorPillCore/ipill.h | 0 src/Core/doctorpill.cpp | 15 ++++++ src/Core/doctorpill.h | 26 ++++++++++ src/{Library => Core}/doctorpill_global.h.in | 1 - src/{Library => GUI}/CMakeLists.txt | 47 +++++++----------- .../DoctorPillGui/doctormodel.cpp | 0 .../DoctorPillGui/doctormodel.h | 3 +- .../DoctorPillModule/DoctorView.qml | 0 src/{Library => GUI}/DoctorPillModule/qmldir | 0 src/{Library => GUI}/DoctorPillRes.qrc | 0 src/GUI/doctorpill_gui_global.h.in | 20 ++++++++ .../doctorpill.cpp => GUI/doctorpillgui.cpp} | 16 +----- .../doctorpill.h => GUI/doctorpillgui.h} | 28 ++--------- src/{Library => GUI}/icons/Failed.png | Bin src/{Library => GUI}/icons/Found.png | Bin src/{Library => GUI}/icons/Solved.png | Bin src/{Library => GUI}/languages/de.ts | 0 src/{Library => GUI}/languages/en.ts | 0 src/{Library => GUI}/languages/es.ts | 0 src/{Library => GUI}/languages/fr.ts | 0 src/{Library => GUI}/languages/ja.ts | 0 src/{Library => GUI}/languages/pl.ts | 0 src/{Library => GUI}/languages/ru.ts | 0 src/{Library => GUI}/languages/tr.ts | 0 src/{Library => GUI}/languages/uk.ts | 0 src/{Library => GUI}/languages/zh.ts | 0 34 files changed, 123 insertions(+), 76 deletions(-) create mode 100644 src/Core/CMakeLists.txt rename src/{Library => Core}/DoctorPillCore/doctor.cpp (100%) rename src/{Library => Core}/DoctorPillCore/doctor.h (100%) rename src/{Library => Core}/DoctorPillCore/doctortest.cpp (100%) rename src/{Library => Core}/DoctorPillCore/doctortest.h (100%) rename src/{Library => Core}/DoctorPillCore/ipill.cpp (100%) rename src/{Library => Core}/DoctorPillCore/ipill.h (100%) create mode 100644 src/Core/doctorpill.cpp create mode 100644 src/Core/doctorpill.h rename src/{Library => Core}/doctorpill_global.h.in (94%) rename src/{Library => GUI}/CMakeLists.txt (53%) rename src/{Library => GUI}/DoctorPillGui/doctormodel.cpp (100%) rename src/{Library => GUI}/DoctorPillGui/doctormodel.h (97%) rename src/{Library => GUI}/DoctorPillModule/DoctorView.qml (100%) rename src/{Library => GUI}/DoctorPillModule/qmldir (100%) rename src/{Library => GUI}/DoctorPillRes.qrc (100%) create mode 100644 src/GUI/doctorpill_gui_global.h.in rename src/{Library/doctorpill.cpp => GUI/doctorpillgui.cpp} (74%) rename src/{Library/doctorpill.h => GUI/doctorpillgui.h} (58%) rename src/{Library => GUI}/icons/Failed.png (100%) rename src/{Library => GUI}/icons/Found.png (100%) rename src/{Library => GUI}/icons/Solved.png (100%) rename src/{Library => GUI}/languages/de.ts (100%) rename src/{Library => GUI}/languages/en.ts (100%) rename src/{Library => GUI}/languages/es.ts (100%) rename src/{Library => GUI}/languages/fr.ts (100%) rename src/{Library => GUI}/languages/ja.ts (100%) rename src/{Library => GUI}/languages/pl.ts (100%) rename src/{Library => GUI}/languages/ru.ts (100%) rename src/{Library => GUI}/languages/tr.ts (100%) rename src/{Library => GUI}/languages/uk.ts (100%) rename src/{Library => GUI}/languages/zh.ts (100%) diff --git a/.gitignore b/.gitignore index 4fcb243..7e86960 100644 --- a/.gitignore +++ b/.gitignore @@ -69,5 +69,6 @@ _deps # Configured files build.gradle AndroidManifest.xml -src/Example/Deploy/RENAME_ME.json -src/Library/doctorpill_global.h +src/Example/Deploy/DoctorPill.json +src/Core/doctorpill_global.h +src/GUI/doctorpill_gui_global.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 76625a3..a928537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,15 +53,16 @@ if (ANDROID OR IOS) endif() - initAll() +add_subdirectory(src/Core) + if (NOT DOCTOR_PILL_GUI) set(DOCTOR_PILL_EXAMPLE OFF) +else() + add_subdirectory(src/GUI) endif() -add_subdirectory(src/Library) - if (DOCTOR_PILL_EXAMPLE) add_subdirectory(src/Example) endif() diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt new file mode 100644 index 0000000..7f724e5 --- /dev/null +++ b/src/Core/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# Copyright (C) 2020-2022 QuasarApp. +# Distributed under the GPLv3 software license, see the accompanying +# Everyone is permitted to copy and distribute verbatim copies +# of this license document, but changing it is not allowed. +# + +cmake_minimum_required(VERSION 3.14) + +add_definitions(-DDOCTOR_PILL_LIBRARY) + +file(GLOB SOURCE_CPP + "*.cpp" + "DoctorPillCore/*.cpp" + "*.h" + "DoctorPillCore/*.h" +) + +set(ALL_SOURCES ${SOURCE_CPP}) + +set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/private") + +add_library(${PROJECT_NAME} ${ALL_SOURCES}) +target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core ) + +target_include_directories(${PROJECT_NAME} PUBLIC ${PUBLIC_INCUDE_DIR}) +target_include_directories(${PROJECT_NAME} PRIVATE ${PRIVATE_INCUDE_DIR}) + +set(global_file "${CMAKE_CURRENT_SOURCE_DIR}/doctorpill_global.h") +configure_file("${global_file}.in" ${global_file} @ONLY) diff --git a/src/Library/DoctorPillCore/doctor.cpp b/src/Core/DoctorPillCore/doctor.cpp similarity index 100% rename from src/Library/DoctorPillCore/doctor.cpp rename to src/Core/DoctorPillCore/doctor.cpp diff --git a/src/Library/DoctorPillCore/doctor.h b/src/Core/DoctorPillCore/doctor.h similarity index 100% rename from src/Library/DoctorPillCore/doctor.h rename to src/Core/DoctorPillCore/doctor.h diff --git a/src/Library/DoctorPillCore/doctortest.cpp b/src/Core/DoctorPillCore/doctortest.cpp similarity index 100% rename from src/Library/DoctorPillCore/doctortest.cpp rename to src/Core/DoctorPillCore/doctortest.cpp diff --git a/src/Library/DoctorPillCore/doctortest.h b/src/Core/DoctorPillCore/doctortest.h similarity index 100% rename from src/Library/DoctorPillCore/doctortest.h rename to src/Core/DoctorPillCore/doctortest.h diff --git a/src/Library/DoctorPillCore/ipill.cpp b/src/Core/DoctorPillCore/ipill.cpp similarity index 100% rename from src/Library/DoctorPillCore/ipill.cpp rename to src/Core/DoctorPillCore/ipill.cpp diff --git a/src/Library/DoctorPillCore/ipill.h b/src/Core/DoctorPillCore/ipill.h similarity index 100% rename from src/Library/DoctorPillCore/ipill.h rename to src/Core/DoctorPillCore/ipill.h diff --git a/src/Core/doctorpill.cpp b/src/Core/doctorpill.cpp new file mode 100644 index 0000000..d0fbcfb --- /dev/null +++ b/src/Core/doctorpill.cpp @@ -0,0 +1,15 @@ +//# +//# Copyright (C) 2021-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "doctorpill.h" + +namespace DP { + +QString version() { + return DOCTOR_PILL_VERSION; +} +} diff --git a/src/Core/doctorpill.h b/src/Core/doctorpill.h new file mode 100644 index 0000000..a82eec0 --- /dev/null +++ b/src/Core/doctorpill.h @@ -0,0 +1,26 @@ +//# +//# Copyright (C) 2021-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#ifndef DOCTOR_PILL_H +#define DOCTOR_PILL_H + +#include "DoctorPillCore/doctor.h" +#include "DoctorPillCore/doctortest.h" + +/** + * @brief DP This is base name space of the DoctorPill(DP) library. Please if you use the gui application and gui models then invoke the DP::init method before use this library. + */ +namespace DP { + + /** + * @brief version This method return string value of lib version + * @return string value of lib version. + */ + QString version(); +} + +#endif // DOCTOR_PILL_H diff --git a/src/Library/doctorpill_global.h.in b/src/Core/doctorpill_global.h.in similarity index 94% rename from src/Library/doctorpill_global.h.in rename to src/Core/doctorpill_global.h.in index 425bb25..44248cd 100644 --- a/src/Library/doctorpill_global.h.in +++ b/src/Core/doctorpill_global.h.in @@ -17,7 +17,6 @@ #endif #define DOCTOR_PILL_VERSION "@DOCTOR_PILL_VERSION@" -#define @DOCTOR_PILL_DEFINE@ #endif //DoctorPill_GLOBAL_H diff --git a/src/Library/CMakeLists.txt b/src/GUI/CMakeLists.txt similarity index 53% rename from src/Library/CMakeLists.txt rename to src/GUI/CMakeLists.txt index 5e9df1d..071e9de 100644 --- a/src/Library/CMakeLists.txt +++ b/src/GUI/CMakeLists.txt @@ -7,47 +7,34 @@ cmake_minimum_required(VERSION 3.14) -add_definitions(-DDOCTOR_PILL_LIBRARY) +add_definitions(-DDOCTOR_PILL_GUI_LIBRARY) -file(GLOB SOURCE_CPP +set(CURRENT_PROJECT ${PROJECT_NAME}GUI) + +file(GLOB SOURCE_CPP_GUI + "DoctorPillGui/*.cpp" + "DoctorPillGui/*.h" "*.cpp" - "DoctorPillCore/*.cpp" "*.h" - "DoctorPillCore/*.h" ) -if (DOCTOR_PILL_GUI) - file(GLOB SOURCE_CPP_GUI - "DoctorPillGui/*.cpp" - "DoctorPillGui/*.h" - - ) - - file(GLOB SOURCE_QRC - "*.qrc" - "DoctorPillCore/*.qrc" - ) - -endif() +file(GLOB SOURCE_QRC + "*.qrc" + "DoctorPillCore/*.qrc" +) set(ALL_SOURCES ${SOURCE_CPP} ${SOURCE_QRC} ${SOURCE_CPP_GUI}) set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/private") -add_library(${PROJECT_NAME} ${ALL_SOURCES}) -target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core ) +add_library(${CURRENT_PROJECT} ${ALL_SOURCES}) -set(DOCTOR_PILL_DEFINE "DOCTOR_PILL_WITHOUT_GUI") -if (DOCTOR_PILL_GUI) - set(DOCTOR_PILL_DEFINE "DOCTOR_PILL_WITH_GUI") +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Quick Concurrent REQUIRED) +target_link_libraries(${CURRENT_PROJECT} PUBLIC ${PROJECT_NAME} Qt${QT_VERSION_MAJOR}::Concurrent Qt${QT_VERSION_MAJOR}::Quick ) - find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Quick Concurrent REQUIRED) - target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Concurrent Qt${QT_VERSION_MAJOR}::Quick ) -endif() - -target_include_directories(${PROJECT_NAME} PUBLIC ${PUBLIC_INCUDE_DIR}) -target_include_directories(${PROJECT_NAME} PRIVATE ${PRIVATE_INCUDE_DIR}) +target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR}) +target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR}) set(LANGS ${CMAKE_CURRENT_SOURCE_DIR}/languages/en.ts @@ -61,9 +48,9 @@ set(LANGS ${CMAKE_CURRENT_SOURCE_DIR}/languages/en.ts ${CMAKE_CURRENT_SOURCE_DIR}/languages/es.ts ${CMAKE_CURRENT_SOURCE_DIR}/languages/pl.ts) -prepareQM(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/../ "${LANGS}") +prepareQM(${CURRENT_PROJECT} ${CMAKE_CURRENT_SOURCE_DIR}/../ "${LANGS}") set(QML_IMPORT_PATH ${QML_IMPORT_PATH} "${CMAKE_CURRENT_SOURCE_DIR}" CACHE STRING "" FORCE) -set(global_file "${CMAKE_CURRENT_SOURCE_DIR}/doctorpill_global.h") +set(global_file "${CMAKE_CURRENT_SOURCE_DIR}/doctorpill_gui_global.h") configure_file("${global_file}.in" ${global_file} @ONLY) diff --git a/src/Library/DoctorPillGui/doctormodel.cpp b/src/GUI/DoctorPillGui/doctormodel.cpp similarity index 100% rename from src/Library/DoctorPillGui/doctormodel.cpp rename to src/GUI/DoctorPillGui/doctormodel.cpp diff --git a/src/Library/DoctorPillGui/doctormodel.h b/src/GUI/DoctorPillGui/doctormodel.h similarity index 97% rename from src/Library/DoctorPillGui/doctormodel.h rename to src/GUI/DoctorPillGui/doctormodel.h index 3fd734b..d330bf4 100644 --- a/src/Library/DoctorPillGui/doctormodel.h +++ b/src/GUI/DoctorPillGui/doctormodel.h @@ -10,13 +10,14 @@ #include #include +#include namespace DP { /** * @brief The PillsModel class This is gui model of available pills. */ -class DOCTOR_PILL_EXPORT DoctorModel: public QAbstractListModel +class DOCTOR_PILL_GUI_EXPORT DoctorModel: public QAbstractListModel { Q_OBJECT diff --git a/src/Library/DoctorPillModule/DoctorView.qml b/src/GUI/DoctorPillModule/DoctorView.qml similarity index 100% rename from src/Library/DoctorPillModule/DoctorView.qml rename to src/GUI/DoctorPillModule/DoctorView.qml diff --git a/src/Library/DoctorPillModule/qmldir b/src/GUI/DoctorPillModule/qmldir similarity index 100% rename from src/Library/DoctorPillModule/qmldir rename to src/GUI/DoctorPillModule/qmldir diff --git a/src/Library/DoctorPillRes.qrc b/src/GUI/DoctorPillRes.qrc similarity index 100% rename from src/Library/DoctorPillRes.qrc rename to src/GUI/DoctorPillRes.qrc diff --git a/src/GUI/doctorpill_gui_global.h.in b/src/GUI/doctorpill_gui_global.h.in new file mode 100644 index 0000000..2f4db50 --- /dev/null +++ b/src/GUI/doctorpill_gui_global.h.in @@ -0,0 +1,20 @@ +//# +//# Copyright (C) 2018-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#ifndef DoctorPill_GUI_GLOBAL_H +#define DoctorPill_GUI_GLOBAL_H + +#include + +#if defined(DOCTOR_PILL_GUI_LIBRARY) +# define DOCTOR_PILL_GUI_EXPORT Q_DECL_EXPORT +#else +# define DOCTOR_PILL_GUI_EXPORT Q_DECL_IMPORT +#endif + +#endif //DoctorPill_GUI_GLOBAL_H + diff --git a/src/Library/doctorpill.cpp b/src/GUI/doctorpillgui.cpp similarity index 74% rename from src/Library/doctorpill.cpp rename to src/GUI/doctorpillgui.cpp index 360ed58..942163e 100644 --- a/src/Library/doctorpill.cpp +++ b/src/GUI/doctorpillgui.cpp @@ -5,13 +5,11 @@ //# of this license document, but changing it is not allowed. //# -#include "doctorpill.h" -#ifdef DOCTOR_PILL_WITH_GUI +#include "doctorpillgui.h" #include -#endif + namespace DP { -#ifdef DOCTOR_PILL_WITH_GUI bool init(QQmlApplicationEngine *engine) { if (!engine) @@ -28,14 +26,4 @@ bool init(QQmlApplicationEngine *engine) { return true; } -#else -bool init() { - return true; -} - -#endif - -QString version() { - return DOCTOR_PILL_VERSION; -} } diff --git a/src/Library/doctorpill.h b/src/GUI/doctorpillgui.h similarity index 58% rename from src/Library/doctorpill.h rename to src/GUI/doctorpillgui.h index 762b165..f564d4a 100644 --- a/src/Library/doctorpill.h +++ b/src/GUI/doctorpillgui.h @@ -5,14 +5,12 @@ //# of this license document, but changing it is not allowed. //# -#ifndef DOCTOR_PILL_H -#define DOCTOR_PILL_H +#ifndef DOCTOR_PILL_GUI_H +#define DOCTOR_PILL_GUI_H #include "DoctorPillCore/doctor.h" #include "DoctorPillCore/doctortest.h" -#ifdef DOCTOR_PILL_WITH_GUI - #include "DoctorPillGui/doctormodel.h" inline void initDoctorPillResources() { @@ -20,14 +18,9 @@ inline void initDoctorPillResources() { } class QQmlApplicationEngine; -#endif -/** - * @brief DP This is base name space of the DoctorPill(DP) library. Please if you use the gui application and gui models then invoke the DP::init method before use this library. - */ namespace DP { -#ifdef DOCTOR_PILL_WITH_GUI /** * @brief init This function initialize the qml gui classes of the DoctorPill library. * @note if you do not use GUI then this function do nothing. @@ -37,21 +30,6 @@ namespace DP { * @see DoctorModel */ bool DOCTOR_PILL_EXPORT init(QQmlApplicationEngine *engine); -#else -/** - * @brief init This function is empty wrapper for non gui build - * @return always return true. - * - * @see DoctorModel - */ - bool DOCTOR_PILL_EXPORT init(); -#endif - - /** - * @brief version This method return string value of lib version - * @return string value of lib version. - */ - QString version(); } -#endif // DOCTOR_PILL_H +#endif // DOCTOR_PILL_GUI_H diff --git a/src/Library/icons/Failed.png b/src/GUI/icons/Failed.png similarity index 100% rename from src/Library/icons/Failed.png rename to src/GUI/icons/Failed.png diff --git a/src/Library/icons/Found.png b/src/GUI/icons/Found.png similarity index 100% rename from src/Library/icons/Found.png rename to src/GUI/icons/Found.png diff --git a/src/Library/icons/Solved.png b/src/GUI/icons/Solved.png similarity index 100% rename from src/Library/icons/Solved.png rename to src/GUI/icons/Solved.png diff --git a/src/Library/languages/de.ts b/src/GUI/languages/de.ts similarity index 100% rename from src/Library/languages/de.ts rename to src/GUI/languages/de.ts diff --git a/src/Library/languages/en.ts b/src/GUI/languages/en.ts similarity index 100% rename from src/Library/languages/en.ts rename to src/GUI/languages/en.ts diff --git a/src/Library/languages/es.ts b/src/GUI/languages/es.ts similarity index 100% rename from src/Library/languages/es.ts rename to src/GUI/languages/es.ts diff --git a/src/Library/languages/fr.ts b/src/GUI/languages/fr.ts similarity index 100% rename from src/Library/languages/fr.ts rename to src/GUI/languages/fr.ts diff --git a/src/Library/languages/ja.ts b/src/GUI/languages/ja.ts similarity index 100% rename from src/Library/languages/ja.ts rename to src/GUI/languages/ja.ts diff --git a/src/Library/languages/pl.ts b/src/GUI/languages/pl.ts similarity index 100% rename from src/Library/languages/pl.ts rename to src/GUI/languages/pl.ts diff --git a/src/Library/languages/ru.ts b/src/GUI/languages/ru.ts similarity index 100% rename from src/Library/languages/ru.ts rename to src/GUI/languages/ru.ts diff --git a/src/Library/languages/tr.ts b/src/GUI/languages/tr.ts similarity index 100% rename from src/Library/languages/tr.ts rename to src/GUI/languages/tr.ts diff --git a/src/Library/languages/uk.ts b/src/GUI/languages/uk.ts similarity index 100% rename from src/Library/languages/uk.ts rename to src/GUI/languages/uk.ts diff --git a/src/Library/languages/zh.ts b/src/GUI/languages/zh.ts similarity index 100% rename from src/Library/languages/zh.ts rename to src/GUI/languages/zh.ts