diff --git a/CMakeLists.txt b/CMakeLists.txt index 67815a6e..f0402239 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,20 +13,10 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/.cmake/) include(GetGitRevisionDescription) option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON) -option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core) -set(QT_SDK_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../..") -cmake_path(SET QT_SDK_DIR NORMALIZE ${QT_SDK_DIR}) - -#设置QML插件输出目录,可以通过外部设置,如果外部没有设置就默认到\qml\FluentUI目录下 -set(FLUENTUI_QML_PLUGIN_DIRECTORY "" CACHE PATH "Path to FluentUI plugin") -if(NOT FLUENTUI_QML_PLUGIN_DIRECTORY) - set(FLUENTUI_QML_PLUGIN_DIRECTORY ${QT_SDK_DIR}/qml/FluentUI) -endif() - add_subdirectory(src) #Release也支持日志打印代码位置 diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 2fc602c1..c5909e20 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -39,13 +39,13 @@ endif() #国际化 find_program(QT_LUPDATE NAMES lupdate) find_program(QT_LRELEASE NAMES lrelease) -if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_en.qm) - execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_en.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) - execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_en.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) +if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_en_US.qm) + execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) + execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) endif () -if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_zh.qm) - execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_zh.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) - execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_zh.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) +if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_zh_CN.qm) + execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) + execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) endif () file(GLOB QM_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.qm) @@ -86,7 +86,7 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2") endforeach(filepath) #遍历所有资源文件 - file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.obj) + file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.in) foreach(filepath ${RES_PATHS}) string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) list(APPEND resource_files ${filename}) diff --git a/example/example.qrc b/example/example.qrc index c0cb851a..c0cd9886 100644 --- a/example/example.qrc +++ b/example/example.qrc @@ -198,5 +198,13 @@ qml/window/CrashWindow.qml qml/page/T_SplitLayout.qml qml/window/FluentInitalizrWindow.qml + res/template/CMakeLists.txt.in + res/template/App.qml.in + res/template/logo.ico.in + res/template/main.cpp.in + res/template/main.qml.in + res/template/qml.qrc.in + res/template/en_US.ts.in + res/template/zh_CN.ts.in diff --git a/example/example_en.ts b/example/example_en_US.ts similarity index 99% rename from example/example_en.ts rename to example/example_en_US.ts index dd51edfa..05838b2a 100644 --- a/example/example_en.ts +++ b/example/example_en_US.ts @@ -102,20 +102,25 @@ InitalizrHelper - + The name cannot be empty - + The creation path cannot be empty - + The path does not exist + + + %1 folder already exists + + ItemsFooter @@ -630,9 +635,9 @@ MainWindow - + - + Dark Mode @@ -670,87 +675,87 @@ - + - + Cancel - - + + Open in Separate Window - - + + Click Time - - + + Search + + + + Finish + + - Finish + Next - Next - - - - - Previous - - + + Here you can switch to night mode. - - + + Hide Easter eggs - - + + Try a few more clicks!! + + + + Upgrade Tips + + - Upgrade Tips - - - - - FluentUI is currently up to date - - + + -- The current app version - - + + Now go and download the new version? @@ -759,20 +764,20 @@ Updated content: - - + + OK - - + + The current version is already the latest - - + + The network is abnormal diff --git a/example/example_zh.ts b/example/example_zh_CN.ts similarity index 99% rename from example/example_zh.ts rename to example/example_zh_CN.ts index 5f7ba7f0..ae0df24e 100644 --- a/example/example_zh.ts +++ b/example/example_zh_CN.ts @@ -102,20 +102,25 @@ InitalizrHelper - + The name cannot be empty 名称不能为空 - + The creation path cannot be empty 创建路径不能为空 - + The path does not exist 路径不存在 + + + %1 folder already exists + + ItemsFooter @@ -630,9 +635,9 @@ MainWindow - + - + Dark Mode 夜间模式 @@ -670,87 +675,87 @@ - + - + Cancel 取消 - - + + Open in Separate Window 在独立窗口中打开 - - + + Click Time 点击次数 - - + + Search 搜索 - - + + Finish 完成 - - + + Next 下一步 - - + + Previous 上一步 - - + + Here you can switch to night mode. 在这里,您可以切换到夜间模式。 - - + + Hide Easter eggs 隐藏彩蛋 - - + + Try a few more clicks!! 再试几下!! - - + + Upgrade Tips 升级提示 - - + + FluentUI is currently up to date FluentUI 目前最新版本 - - + + -- The current app version -- 当前应用版本 - - + + Now go and download the new version? @@ -763,20 +768,20 @@ Updated content: - - + + OK 确定 - - + + The current version is already the latest 当前版本已经是最新版本 - - + + The network is abnormal 网络异常 diff --git a/example/qml-Qt6/window/FluentInitalizrWindow.qml b/example/qml-Qt6/window/FluentInitalizrWindow.qml index eb6e624c..5ef64459 100644 --- a/example/qml-Qt6/window/FluentInitalizrWindow.qml +++ b/example/qml-Qt6/window/FluentInitalizrWindow.qml @@ -12,7 +12,7 @@ FluWindow { width: 600 height: 400 fixSize: true - // modality: Qt.ApplicationModal + modality: Qt.ApplicationModal launchMode: FluWindowType.SingleTask showStayTop: false @@ -21,8 +21,9 @@ FluWindow { function onError(message){ showError(message) } - function onSuccess(){ - showSuccess("创建成功") + function onSuccess(path){ + FluTools.showFileInFolder(path+"/CMakeLists.txt") + window.close() } } diff --git a/example/qml/window/FluentInitalizrWindow.qml b/example/qml/window/FluentInitalizrWindow.qml index a3c5c527..f17330d6 100644 --- a/example/qml/window/FluentInitalizrWindow.qml +++ b/example/qml/window/FluentInitalizrWindow.qml @@ -12,7 +12,7 @@ FluWindow { width: 600 height: 400 fixSize: true - // modality: Qt.ApplicationModal + modality: Qt.ApplicationModal launchMode: FluWindowType.SingleTask showStayTop: false @@ -21,8 +21,9 @@ FluWindow { function onError(message){ showError(message) } - function onSuccess(){ - showSuccess("创建成功") + function onSuccess(path){ + FluTools.showFileInFolder(path+"/CMakeLists.txt") + window.close() } } diff --git a/example/res/template/App.qml.in b/example/res/template/App.qml.in new file mode 100644 index 00000000..c4c2b66c --- /dev/null +++ b/example/res/template/App.qml.in @@ -0,0 +1,17 @@ +import QtQuick 2.15 +import QtQuick.Window 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 +import FluentUI 1.0 + +Item { + id: app + Component.onCompleted: { + FluApp.init(app) + FluApp.windowIcon = "qrc:/logo.ico" + FluApp.routes = { + "/":"qrc:/main.qml", + } + FluApp.navigate("/") + } +} diff --git a/example/res/template/CMakeLists.txt.in b/example/res/template/CMakeLists.txt.in new file mode 100644 index 00000000..2d0ea5cf --- /dev/null +++ b/example/res/template/CMakeLists.txt.in @@ -0,0 +1,90 @@ +cmake_minimum_required(VERSION 3.20) + +project(%1 VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(APPLICATION_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/debug) +else() + set(APPLICATION_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/release) +endif() + +if(APPLE) + set(APPLICATION_REAL_PATH ${APPLICATION_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app/Contents/MacOS) +else() + set(APPLICATION_REAL_PATH ${APPLICATION_OUTPUT_DIRECTORY}) +endif() + +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick) + +find_program(QT_LUPDATE NAMES lupdate) +find_program(QT_LRELEASE NAMES lrelease) +if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_en_US.qm) + execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) + execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) +endif () +if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_zh_CN.qm) + execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) + execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) +endif () + +file(GLOB QM_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.qm) +file(COPY ${QM_FILE_PATHS} DESTINATION ${APPLICATION_REAL_PATH}/i18n) + + +set(PROJECT_SOURCES + main.cpp + qml.qrc +) + +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) + qt_add_executable(${PROJECT_NAME} + MANUAL_FINALIZATION + ${PROJECT_SOURCES} + ) +else() + add_executable(${PROJECT_NAME} + ${PROJECT_SOURCES} + ) +endif() + +set_target_properties(${PROJECT_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY_DEBUG "${APPLICATION_OUTPUT_DIRECTORY}" + RUNTIME_OUTPUT_DIRECTORY_RELEASE "${APPLICATION_OUTPUT_DIRECTORY}" +) + +target_link_libraries(${PROJECT_NAME} PRIVATE + Qt${QT_VERSION_MAJOR}::Core + Qt${QT_VERSION_MAJOR}::Quick + fluentuiplugin +) + +if(${QT_VERSION} VERSION_LESS 6.1.0) + set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.${PROJECT_NAME}) +endif() +set_target_properties(${PROJECT_NAME} PROPERTIES + ${BUNDLE_ID_OPTION} + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE TRUE + WIN32_EXECUTABLE TRUE +) + +add_subdirectory(FluentUI) + +include(GNUInstallDirs) +install(TARGETS ${PROJECT_NAME} + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +if(QT_VERSION_MAJOR EQUAL 6) + qt_import_qml_plugins(${PROJECT_NAME}) + qt_finalize_executable(${PROJECT_NAME}) +endif() diff --git a/example/res/template/en_US.ts.in b/example/res/template/en_US.ts.in new file mode 100644 index 00000000..aff54b38 --- /dev/null +++ b/example/res/template/en_US.ts.in @@ -0,0 +1,22 @@ + + + + + main + + + %1 + + + + + Welcome to FluentUI + + + + + Learn FluentUI + + + + diff --git a/example/res/template/logo.ico.in b/example/res/template/logo.ico.in new file mode 100644 index 00000000..dcb1c035 Binary files /dev/null and b/example/res/template/logo.ico.in differ diff --git a/example/res/template/main.cpp.in b/example/res/template/main.cpp.in new file mode 100644 index 00000000..65bb0c63 --- /dev/null +++ b/example/res/template/main.cpp.in @@ -0,0 +1,32 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif + QGuiApplication app(argc, argv); + + QTranslator translator; + const QStringList uiLanguages = QLocale::system().uiLanguages(); + for (const QString &locale : uiLanguages) { + const QString baseName = "%1_" + QLocale(locale).name(); + if (translator.load("./i18n/"+ baseName)) { + app.installTranslator(&translator); + break; + } + } + + QQmlApplicationEngine engine; + const QUrl url(QStringLiteral("qrc:/App.qml")); + QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, + &app, [url](QObject *obj, const QUrl &objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} diff --git a/example/res/template/main.qml.in b/example/res/template/main.qml.in new file mode 100644 index 00000000..8180a5fd --- /dev/null +++ b/example/res/template/main.qml.in @@ -0,0 +1,35 @@ +import QtQuick 2.15 +import QtQuick.Window 2.15 +import FluentUI 1.0 + +FluWindow { + width: 640 + height: 480 + minimumWidth: 320 + minimumHeight: 240 + title: qsTr("%1") + + Column{ + anchors.centerIn: parent + spacing: 15 + Image{ + width: 60 + height: 60 + source: "qrc:/logo.ico" + anchors.horizontalCenter: parent.horizontalCenter + } + FluText{ + text: qsTr("Welcome to FluentUI") + anchors.horizontalCenter: parent.horizontalCenter + font: FluTextStyle.Title + } + FluFilledButton{ + text: qsTr("Learn FluentUI") + anchors.horizontalCenter: parent.horizontalCenter + onClicked: { + Qt.openUrlExternally("https://space.bilibili.com/275661059") + } + } + } + +} diff --git a/example/res/template/qml.qrc.in b/example/res/template/qml.qrc.in new file mode 100644 index 00000000..3a518c68 --- /dev/null +++ b/example/res/template/qml.qrc.in @@ -0,0 +1,7 @@ + + + main.qml + App.qml + logo.ico + + diff --git a/example/res/template/zh_CN.ts.in b/example/res/template/zh_CN.ts.in new file mode 100644 index 00000000..86475ddd --- /dev/null +++ b/example/res/template/zh_CN.ts.in @@ -0,0 +1,22 @@ + + + + + main + + + %1 + %1 + + + + Welcome to FluentUI + 欢迎使用FluentUI + + + + Learn FluentUI + 学习FluentUI + + + diff --git a/example/src/helper/InitalizrHelper.cpp b/example/src/helper/InitalizrHelper.cpp index a22cdb25..74271b7e 100644 --- a/example/src/helper/InitalizrHelper.cpp +++ b/example/src/helper/InitalizrHelper.cpp @@ -1,6 +1,7 @@ #include "InitalizrHelper.h" #include +#include InitalizrHelper::InitalizrHelper(QObject *parent) : QObject(parent) { @@ -9,6 +10,63 @@ InitalizrHelper::InitalizrHelper(QObject *parent) : QObject(parent) InitalizrHelper::~InitalizrHelper() = default; +bool InitalizrHelper::copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists){ + QDir _formDir = fromDir; + QDir _toDir = toDir; + if(!_toDir.exists()) + { + if(!_toDir.mkdir(toDir.absolutePath())) + return false; + } + QFileInfoList fileInfoList = _formDir.entryInfoList(); + foreach(QFileInfo fileInfo, fileInfoList) + { + if(fileInfo.fileName() == "." || fileInfo.fileName() == "..") + continue; + if(fileInfo.isDir()) + { + if(!copyDir(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()),true)) + return false; + } + else + { + if(coverIfFileExists && _toDir.exists(fileInfo.fileName())) + { + _toDir.remove(fileInfo.fileName()); + } + if(!QFile::copy(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()))) + { + return false; + } + } + } + return true; +} + +template +void InitalizrHelper::templateToFile(const QString& source,const QString& dest,Args &&...args){ + QFile file(source); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&file); + QString content = in.readAll().arg(std::forward(args)...); + file.close(); + QFile outputFile(dest); + if (outputFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + QTextStream out(&outputFile); + out << content; + outputFile.close(); + } else { + qDebug() << "Failed to open output file."; + } + } else { + qDebug() << "Failed to open resource file."; + } +} + +void InitalizrHelper::copyFile(const QString& source,const QString& dest){ + QFile::copy(source,dest); + QFile::setPermissions(dest, QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther); +} void InitalizrHelper::generate(const QString& name,const QString& path){ if(name.isEmpty()){ @@ -19,10 +77,27 @@ void InitalizrHelper::generate(const QString& name,const QString& path){ error(tr("The creation path cannot be empty")); return; } - QDir projectDir(path); - if(!projectDir.exists()){ + QDir projectRootDir(path); + if(!projectRootDir.exists()){ error(tr("The path does not exist")); return; } - return success(); + QString projectPath = projectRootDir.filePath(name); + QDir projectDir(projectPath); + if(projectDir.exists()){ + error(tr("%1 folder already exists").arg(name)); + return; + } + projectDir.mkpath(projectPath); + QDir fluentDir(projectDir.filePath("FluentUI")); + copyDir(QDir(QGuiApplication::applicationDirPath()+"/source"),fluentDir); + templateToFile(":/example/res/template/CMakeLists.txt.in",projectDir.filePath("CMakeLists.txt"),name); + templateToFile(":/example/res/template/main.cpp.in",projectDir.filePath("main.cpp"),name); + templateToFile(":/example/res/template/main.qml.in",projectDir.filePath("main.qml"),name); + templateToFile(":/example/res/template/en_US.ts.in",projectDir.filePath(name+"_en_US.ts"),name); + templateToFile(":/example/res/template/zh_CN.ts.in",projectDir.filePath(name+"_zh_CN.ts"),name); + copyFile(":/example/res/template/App.qml.in",projectDir.filePath("App.qml")); + copyFile(":/example/res/template/qml.qrc.in",projectDir.filePath("qml.qrc")); + copyFile(":/example/res/template/logo.ico.in",projectDir.filePath("logo.ico")); + return this->success(projectPath); } diff --git a/example/src/helper/InitalizrHelper.h b/example/src/helper/InitalizrHelper.h index db19d83f..fbd63995 100644 --- a/example/src/helper/InitalizrHelper.h +++ b/example/src/helper/InitalizrHelper.h @@ -3,6 +3,7 @@ #include #include +#include #include "src/singleton.h" class InitalizrHelper : public QObject @@ -10,12 +11,16 @@ class InitalizrHelper : public QObject Q_OBJECT private: explicit InitalizrHelper(QObject* parent = nullptr); + bool copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists = true); + void copyFile(const QString& source,const QString& dest); + template + void templateToFile(const QString& source,const QString& dest,Args &&...args); public: SINGLETON(InitalizrHelper) ~InitalizrHelper() override; Q_INVOKABLE void generate(const QString& name,const QString& path); Q_SIGNAL void error(const QString& message); - Q_SIGNAL void success(); + Q_SIGNAL void success(const QString& path); }; #endif // INITALIZRHELPER_H diff --git a/example/src/helper/TranslateHelper.cpp b/example/src/helper/TranslateHelper.cpp index 3f62357f..7376bf20 100644 --- a/example/src/helper/TranslateHelper.cpp +++ b/example/src/helper/TranslateHelper.cpp @@ -7,8 +7,8 @@ TranslateHelper::TranslateHelper(QObject *parent) : QObject(parent) { - _languages<<"en"; - _languages<<"zh"; + _languages<<"en_US"; + _languages<<"zh_CN"; _current = SettingsHelper::getInstance()->getLanguage(); } diff --git a/src/.cmake/version_dll.rc.in b/src/.cmake/version_dll.rc.in index ed756918..a84e0db0 100644 --- a/src/.cmake/version_dll.rc.in +++ b/src/.cmake/version_dll.rc.in @@ -1,6 +1,13 @@ -1 VERSIONINFO - FILEVERSION ${GIT_TAG_WITH_COMMA},${GIT_COMMIT_COUNT} - PRODUCTVERSION ${GIT_TAG_WITH_COMMA},${GIT_COMMIT_COUNT} +#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_((FLUENTUI_VERSION)) + +VS_VERSION_INFO VERSIONINFO + FILEVERSION FLUENTUI_VERSION + PRODUCTVERSION FLUENTUI_VERSION FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -16,17 +23,17 @@ BEGIN BLOCK "080404b0" BEGIN VALUE "CompanyName", "ZhuZiChu" - VALUE "FileDescription", "${PROJECT_DESCRIPTION}" - VALUE "FileVersion", "${GIT_SEMVER}.${GIT_COMMIT_COUNT}" + VALUE "FileDescription", "https://github.com/zhuzichu520/FluentUI" + VALUE "FileVersion", VER_STR VALUE "InternalName", "${PROJECT_NAME}.dll" VALUE "LegalCopyright", "Copyright (C) 2023 ZhuZiChu. All rights reserved." VALUE "OriginalFilename", "${PROJECT_NAME}.dll" VALUE "ProductName", "${PROJECT_NAME}" - VALUE "ProductVersion", "${GIT_SEMVER}.0" + VALUE "ProductVersion", VER_STR END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x804, 1200 END -END \ No newline at end of file +END diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3f31c2b..a80bcc93 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,14 +12,29 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.cmake/) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +#设置版本号 +add_definitions(-DFLUENTUI_VERSION=1,6,9,0) + if (FLUENTUI_BUILD_STATIC_LIB) add_definitions(-DFLUENTUI_BUILD_STATIC_LIB) endif() +#编译参数设置 +option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF) + #导入Qt相关依赖包 find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick Qml) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick Qml) +set(QT_SDK_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../..") +cmake_path(SET QT_SDK_DIR NORMALIZE ${QT_SDK_DIR}) + +#设置QML插件输出目录,可以通过外部设置,如果外部没有设置就默认到\qml\FluentUI目录下 +set(FLUENTUI_QML_PLUGIN_DIRECTORY "" CACHE PATH "Path to FluentUI plugin") +if(NOT FLUENTUI_QML_PLUGIN_DIRECTORY) + set(FLUENTUI_QML_PLUGIN_DIRECTORY ${QT_SDK_DIR}/qml/FluentUI) +endif() + if(QT_VERSION VERSION_GREATER_EQUAL "6.3") qt_standard_project_setup() else()