From c846ae81a0ae718423485894efa7df0a28d499a4 Mon Sep 17 00:00:00 2001 From: luocai Date: Thu, 21 Nov 2024 09:31:41 +0800 Subject: [PATCH] show version for updater. --- OtaUpdate/CMakeLists.txt | 8 ++++++++ OtaUpdate/Configuration.h.in | 3 +++ OtaUpdate/main.cpp | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 OtaUpdate/Configuration.h.in diff --git a/OtaUpdate/CMakeLists.txt b/OtaUpdate/CMakeLists.txt index c28609a..b275837 100644 --- a/OtaUpdate/CMakeLists.txt +++ b/OtaUpdate/CMakeLists.txt @@ -1,9 +1,13 @@ +set(APPLICATION_NAME "掌静脉升级工具") + set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets SerialPort) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets SerialPort) +configure_file(Configuration.h.in Configuration.h) + set(PROJECT_SOURCES OtaUpdate.rc main.cpp Widget.cpp @@ -15,6 +19,10 @@ qt_add_executable(SmartLockerUpdater ${PROJECT_SOURCES} ) +target_include_directories(SmartLockerUpdater + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} +) + target_link_libraries(SmartLockerUpdater PRIVATE Peripheral PRIVATE Qt${QT_VERSION_MAJOR}::Widgets diff --git a/OtaUpdate/Configuration.h.in b/OtaUpdate/Configuration.h.in new file mode 100644 index 0000000..733e4b6 --- /dev/null +++ b/OtaUpdate/Configuration.h.in @@ -0,0 +1,3 @@ +#define APPLICATION_NAME "@APPLICATION_NAME@" +#define GIT_COMMIT_ID "@GIT_COMMIT_ID@" +#define APP_VERSION "@PROJECT_VERSION@" diff --git a/OtaUpdate/main.cpp b/OtaUpdate/main.cpp index 1ea3239..91f19a5 100644 --- a/OtaUpdate/main.cpp +++ b/OtaUpdate/main.cpp @@ -1,4 +1,5 @@ #include "BoostLog.h" +#include "Configuration.h" #include "Widget.h" #include #include @@ -7,11 +8,14 @@ int main(int argc, char *argv[]) { boost::log::initialize("logs/app"); QApplication a(argc, argv); + a.setApplicationName(APPLICATION_NAME); + a.setApplicationVersion(QString("v%1_%2 build: %3 %4").arg(APP_VERSION, GIT_COMMIT_ID, __DATE__, __TIME__)); + QFont font; font.setPointSize(16); a.setFont(font); Widget w; - w.setWindowTitle("掌静脉模组升级工具"); + w.setWindowTitle(QString("%1 %2").arg(a.applicationName()).arg(a.applicationVersion())); w.setMinimumWidth(520); w.setMinimumHeight(100); w.show();