diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 27348bf0..0cfcf11a 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -5,6 +5,9 @@ project(example VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) +#设置版本号 +add_definitions(-DVERSION=1,2,9,0) + #获取文件路径分隔符(解决执行命令的时候有些平台会报错) file(TO_CMAKE_PATH "/" PATH_SEPARATOR) @@ -39,9 +42,16 @@ foreach(filepath ${RES_PATHS}) endforeach(filepath) #添加可执行文件 -qt_add_executable(example - ${sources_files} -) +if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + qt_add_executable(example + ${sources_files} + example.rc + ) +else () + qt_add_executable(example + ${sources_files} + ) +endif () #复制动态库到可执行文件同级目录下 if(WIN32) diff --git a/example/example.rc b/example/example.rc new file mode 100644 index 00000000..ed991b87 --- /dev/null +++ b/example/example.rc @@ -0,0 +1,42 @@ +#include + +IDI_ICON1 ICON "favicon.ico" + +#define STR(x) #x +#define VER_JOIN(a,b,c,d) STR(a.b.c.d) +#define VER_JOIN_(x) VER_JOIN x +#define VER_STR VER_JOIN_((VERSION)) + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VERSION +PRODUCTVERSION VERSION +FILEFLAGSMASK 0x3fL +#ifdef _DEBUG +FILEFLAGS VS_FF_DEBUG +#else +FILEFLAGS 0x0L +#endif +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Built by the FluentUI." + VALUE "CompanyName", "zhuzichu" + VALUE "FileDescription", "example" + VALUE "FileVersion", VER_STR + VALUE "InternalName", "" + VALUE "LegalCopyright", "Copyright (C) 2023" + VALUE "OriginalFilename", "" + VALUE "ProductName", "example" + VALUE "ProductVersion", VER_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END \ No newline at end of file diff --git a/example/favicon.ico b/example/favicon.ico new file mode 100644 index 00000000..dcb1c035 Binary files /dev/null and b/example/favicon.ico differ diff --git a/example/src/AppInfo.cpp b/example/src/AppInfo.cpp index 6618168b..90a985dd 100644 --- a/example/src/AppInfo.cpp +++ b/example/src/AppInfo.cpp @@ -1,11 +1,17 @@ #include "AppInfo.h" #include "lang/En.h" #include "lang/Zh.h" +#include + +#define STR(x) #x +#define VER_JOIN(a,b,c,d) STR(a.b.c.d) +#define VER_JOIN_(x) VER_JOIN x +#define VER_STR VER_JOIN_((VERSION)) AppInfo::AppInfo(QObject *parent) : QObject{parent} { - version("1.2.8"); + version(VER_STR); lang(new En()); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f5afa5a9..9d175e4d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,6 +4,9 @@ project(fluentui LANGUAGES CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) +#设置版本号 +add_definitions(-DVERSION=1,2,9,0) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/debug) else() @@ -39,7 +42,7 @@ qt_add_qml_module(fluentui OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/FluentUI VERSION 1.0 URI "FluentUI" - SOURCES ${sources_files} + SOURCES ${sources_files} fluentui.rc QML_FILES ${qml_files} RESOURCES ${resource_files} ) diff --git a/src/FluApp.h b/src/FluApp.h index effb68bf..5b173d62 100644 --- a/src/FluApp.h +++ b/src/FluApp.h @@ -40,7 +40,6 @@ public: Q_INVOKABLE void setFluApp(FluApp* val); Q_INVOKABLE void setFluTheme(FluTheme* val); Q_INVOKABLE void setFluColors(FluColors* val); - public: QMap wnds; static FluApp* fluApp; diff --git a/src/fluentui.rc b/src/fluentui.rc new file mode 100644 index 00000000..bd0cd5ef --- /dev/null +++ b/src/fluentui.rc @@ -0,0 +1,40 @@ +#include + +#define STR(x) #x +#define VER_JOIN(a,b,c,d) STR(a.b.c.d) +#define VER_JOIN_(x) VER_JOIN x +#define VER_STR VER_JOIN_((VERSION)) + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VERSION +PRODUCTVERSION VERSION +FILEFLAGSMASK 0x3fL +#ifdef _DEBUG +FILEFLAGS VS_FF_DEBUG +#else +FILEFLAGS 0x0L +#endif +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "FluentUI for QML." + VALUE "CompanyName", "zhuzichu" + VALUE "FileDescription", "fluentui" + VALUE "FileVersion", VER_STR + VALUE "InternalName", "" + VALUE "LegalCopyright", "Copyright (C) 2023" + VALUE "OriginalFilename", "" + VALUE "ProductName", "fluentui" + VALUE "ProductVersion", VER_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END \ No newline at end of file