From 56681cb5a31af69d53aab4c4bd0ece0e9dd3cb9b Mon Sep 17 00:00:00 2001 From: zhuzihcu Date: Thu, 18 May 2023 14:55:28 +0800 Subject: [PATCH] update --- example/CMakeLists.txt | 11 ++++++++++- example/src/main.cpp | 12 ++++++++---- src/CMakeLists.txt | 2 +- src/FluGlobal.cpp | 17 +++++++++++++++++ src/FluGlobal.h | 13 +++++++++++++ 5 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 src/FluGlobal.cpp create mode 100644 src/FluGlobal.h diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 2d992d38..acfb178e 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -90,12 +90,21 @@ set_target_properties(example PROPERTIES WIN32_EXECUTABLE TRUE ) +#获取FluentUI插件库目录 +set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI) +find_library(FluentUI fluentuiplugin ${QML_PLUGIN_DIRECTORY}) + #链接库 target_link_libraries(example PRIVATE Qt6::Quick - fluentuiplugin FramelessHelper::Core FramelessHelper::Quick + ${FluentUI} +) + +target_include_directories( + example PRIVATE + ${QML_PLUGIN_DIRECTORY} ) #安装 diff --git a/example/src/main.cpp b/example/src/main.cpp index c3208619..d4b07bd9 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -6,14 +6,16 @@ #include #include #include +#include #include "lang/Lang.h" #include "AppInfo.h" #include "tool/IPC.h" FRAMELESSHELPER_USE_NAMESPACE -int main(int argc, char *argv[]) + int main(int argc, char *argv[]) { + FluentUI::preInit(); FramelessHelper::Quick::initialize(); //将样式设置为Basic,不然会导致组件显示异常 qputenv("QT_QUICK_CONTROLS_STYLE","Basic"); @@ -22,9 +24,10 @@ int main(int argc, char *argv[]) QGuiApplication::setApplicationName("FluentUI"); // QQuickWindow::setGraphicsApi(QSGRendererInterface::Software); QGuiApplication app(argc, argv); -// FramelessHelper::Core::setApplicationOSThemeAware(); -// FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); -// FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); + FluentUI::postInit(); + // FramelessHelper::Core::setApplicationOSThemeAware(); + // FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); + // FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); AppInfo* appInfo = new AppInfo(); IPC ipc(0); QString activeWindowEvent = "activeWindow"; @@ -41,6 +44,7 @@ int main(int argc, char *argv[]) } app.setQuitOnLastWindowClosed(false); QQmlApplicationEngine engine; + FluentUI::initEngine(&engine); FramelessHelper::Quick::registerTypes(&engine); QQmlContext * context = engine.rootContext(); Lang* lang = appInfo->lang(); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 140db143..c5e0fa8b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,7 +54,7 @@ qt_add_qml_module(fluentuiplugin URI "FluentUI" SOURCES ${sources_files} fluentui.rc QML_FILES ${qml_files} - RESOURCES ${resource_files} + RESOURCES ${resource_files} FluGlobal.h #支持designer DESIGNER_SUPPORTED ) diff --git a/src/FluGlobal.cpp b/src/FluGlobal.cpp new file mode 100644 index 00000000..b92411ea --- /dev/null +++ b/src/FluGlobal.cpp @@ -0,0 +1,17 @@ +#include "FluGlobal.h" + +#include + +namespace FluentUI { + +void preInit(){ + qDebug()<<"preInit"; +} +void postInit(){ + qDebug()<<"postInit"; +} +void initEngine(QQmlApplicationEngine* engine){ + qDebug()<<"initEngine"; +} + +} diff --git a/src/FluGlobal.h b/src/FluGlobal.h new file mode 100644 index 00000000..3285597f --- /dev/null +++ b/src/FluGlobal.h @@ -0,0 +1,13 @@ +#ifndef FLUGLOBAL_H +#define FLUGLOBAL_H + +#include +#include + +namespace FluentUI { + Q_DECL_EXPORT void preInit(); + Q_DECL_EXPORT void postInit(); + Q_DECL_EXPORT void initEngine(QQmlApplicationEngine* engine); +} + +#endif // FLUGLOBAL_H