From eb82ca72e7e4b8947a199f0c49e4908b00c5209d Mon Sep 17 00:00:00 2001 From: EndrII Date: Tue, 23 Nov 2021 21:49:27 +0300 Subject: [PATCH] added libVersion method --- .gitignore | 3 +++ CMake | 2 +- CMakeLists.txt | 8 +++++++- notificationservice.cpp | 4 ++++ notificationservice.h | 5 +++++ notifyservice_global.h => notifyservice_global.h.in | 1 + 6 files changed, 21 insertions(+), 2 deletions(-) rename notifyservice_global.h => notifyservice_global.h.in (84%) diff --git a/.gitignore b/.gitignore index e4e3733..0a21a5d 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ CMakeLists.txt.user* CMakeFiles *_autogen cmake_install.cmake + +#cmake +notifyservice_global.h diff --git a/CMake b/CMake index cd05493..2acf202 160000 --- a/CMake +++ b/CMake @@ -1 +1 @@ -Subproject commit cd05493c3a43b04f26c3e3432df4283eb4509d8c +Subproject commit 2acf202cf167a89cac108620f1a541525766dbb8 diff --git a/CMakeLists.txt b/CMakeLists.txt index 608e503..84745bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,13 @@ set(LANGS ${CMAKE_CURRENT_SOURCE_DIR}/qmlNotify_languages/en.ts prepareQM( ${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} "${LANGS}") -setVersion(1 0 1) + +updateGitVars() +setVersion(1 0 ${GIT_COMMIT_COUNT}) + +set(QML_NOTIFY_VERSION 1.0.${GIT_COMMIT_COUNT}.${GIT_COMMIT_HASH}) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/notifyservice_global.h.in ${CMAKE_CURRENT_SOURCE_DIR}/notifyservice_global.h @ONLY) initAll() diff --git a/notificationservice.cpp b/notificationservice.cpp index 29668a9..79983dc 100644 --- a/notificationservice.cpp +++ b/notificationservice.cpp @@ -95,6 +95,10 @@ int NotificationService::setQuestion(const Listner& listner, return setQuestion(listner, NotificationData(title, text, img, code)); } +QString NotificationService::libVersion() { + return QML_NOTIFY_VERSION; +} + NotificationService *NotificationService::getService() { static auto service = new NotificationService; return service; diff --git a/notificationservice.h b/notificationservice.h index ceba927..d6b0a7e 100644 --- a/notificationservice.h +++ b/notificationservice.h @@ -101,6 +101,11 @@ public: const QString& img = "", int code = 0); + /** + * @brief libVersion This method return string value of the version of this library. + * @return string value of the version of this library. + */ + static QString libVersion(); /** * @brief getService This method return instance to notify service. diff --git a/notifyservice_global.h b/notifyservice_global.h.in similarity index 84% rename from notifyservice_global.h rename to notifyservice_global.h.in index ca3ff7b..99ff4a1 100644 --- a/notifyservice_global.h +++ b/notifyservice_global.h.in @@ -9,5 +9,6 @@ # define NOTIFYSERVICESHARED_EXPORT Q_DECL_IMPORT #endif +#define QML_NOTIFY_VERSION "@QML_NOTIFY_VERSION@" #endif // NOTIFYSERVICE_GLOBAL_H