separate to gui and core libs

This commit is contained in:
Andrei Yankovich 2022-01-23 20:09:18 +03:00
parent 8c18da429a
commit ffa27ffe5a
34 changed files with 123 additions and 76 deletions

5
.gitignore vendored
View File

@ -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

View File

@ -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()

31
src/Core/CMakeLists.txt Normal file
View File

@ -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)

15
src/Core/doctorpill.cpp Normal file
View File

@ -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;
}
}

26
src/Core/doctorpill.h Normal file
View File

@ -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

View File

@ -17,7 +17,6 @@
#endif
#define DOCTOR_PILL_VERSION "@DOCTOR_PILL_VERSION@"
#define @DOCTOR_PILL_DEFINE@
#endif //DoctorPill_GLOBAL_H

View File

@ -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)

View File

@ -10,13 +10,14 @@
#include <QAbstractListModel>
#include <DoctorPillCore/doctor.h>
#include <doctorpill_gui_global.h>
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

View File

@ -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 <QtCore/qglobal.h>
#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

View File

@ -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 <QQmlApplicationEngine>
#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;
}
}

View File

@ -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

View File

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB