diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 2d992d3..acfb178 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 c320861..d4b07bd 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 140db14..c5e0fa8 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 0000000..b92411e --- /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 0000000..3285597 --- /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