diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ecc724..76625a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,9 +56,7 @@ endif() initAll() -if (DOCTOR_PILL_GUI) - add_definitions(-DDOCTOR_PILL_GUI) -else() +if (NOT DOCTOR_PILL_GUI) set(DOCTOR_PILL_EXAMPLE OFF) endif() diff --git a/README.md b/README.md index c4ed4b5..1cd30fc 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,8 @@ For working with gui wrapper you need to initialize this library before include #### initialize the library (main.cpp) -``` cpp + +```cpp int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("QuasarApp"); @@ -129,6 +130,7 @@ int main(int argc, char *argv[]) { ```qml + import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Controls.Material 2.15 diff --git a/src/Library/CMakeLists.txt b/src/Library/CMakeLists.txt index c2df244..5e9df1d 100644 --- a/src/Library/CMakeLists.txt +++ b/src/Library/CMakeLists.txt @@ -35,13 +35,13 @@ 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") -set(global_file "${CMAKE_CURRENT_SOURCE_DIR}/doctorpill_global.h") -configure_file("${global_file}.in" ${global_file} @ONLY) - add_library(${PROJECT_NAME} ${ALL_SOURCES}) target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core ) +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(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Concurrent Qt${QT_VERSION_MAJOR}::Quick ) endif() @@ -65,3 +65,5 @@ prepareQM(${PROJECT_NAME} ${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") +configure_file("${global_file}.in" ${global_file} @ONLY) diff --git a/src/Library/DoctorPillModule/DoctorView.qml b/src/Library/DoctorPillModule/DoctorView.qml index 4ef412a..11af310 100644 --- a/src/Library/DoctorPillModule/DoctorView.qml +++ b/src/Library/DoctorPillModule/DoctorView.qml @@ -20,7 +20,7 @@ Page { horizontalAlignment: Label.AlignHCenter text: title font.pointSize: 20 - color: "#424242" + color: (Material.theme === Material.Light)? "#424242" : "#aaaaaa" wrapMode: Label.WordWrap visible: showTitle } @@ -127,6 +127,8 @@ Page { onClicked: { if (root.model) { root.model.diagnostic(); + } else { + console.warn("The DoctorView require model object.") } } } diff --git a/src/Library/doctorpill.cpp b/src/Library/doctorpill.cpp index a2f3495..360ed58 100644 --- a/src/Library/doctorpill.cpp +++ b/src/Library/doctorpill.cpp @@ -6,12 +6,12 @@ //# #include "doctorpill.h" -#ifdef DOCTOR_PILL_GUI +#ifdef DOCTOR_PILL_WITH_GUI #include <QQmlApplicationEngine> #endif namespace DP { -#ifdef DOCTOR_PILL_GUI +#ifdef DOCTOR_PILL_WITH_GUI bool init(QQmlApplicationEngine *engine) { if (!engine) @@ -28,14 +28,14 @@ bool init(QQmlApplicationEngine *engine) { return true; } -QString version() { - return DOCTOR_PILL_VERSION; -} - #else bool init() { return true; } #endif + +QString version() { + return DOCTOR_PILL_VERSION; +} } diff --git a/src/Library/doctorpill.h b/src/Library/doctorpill.h index 07093f4..762b165 100644 --- a/src/Library/doctorpill.h +++ b/src/Library/doctorpill.h @@ -11,7 +11,7 @@ #include "DoctorPillCore/doctor.h" #include "DoctorPillCore/doctortest.h" -#ifdef DOCTOR_PILL_GUI +#ifdef DOCTOR_PILL_WITH_GUI #include "DoctorPillGui/doctormodel.h" @@ -27,7 +27,7 @@ class QQmlApplicationEngine; */ namespace DP { -#ifdef DOCTOR_PILL_GUI +#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. diff --git a/src/Library/doctorpill_global.h.in b/src/Library/doctorpill_global.h.in index 44248cd..425bb25 100644 --- a/src/Library/doctorpill_global.h.in +++ b/src/Library/doctorpill_global.h.in @@ -17,6 +17,7 @@ #endif #define DOCTOR_PILL_VERSION "@DOCTOR_PILL_VERSION@" +#define @DOCTOR_PILL_DEFINE@ #endif //DoctorPill_GLOBAL_H