From 82d1edc43ce7d6e82bd6067368407508ac1e9be8 Mon Sep 17 00:00:00 2001 From: zhuzichu Date: Sat, 22 Apr 2023 19:25:10 +0800 Subject: [PATCH] update --- example/example.pro | 5 +++++ example/src/main.cpp | 6 ++++++ src/FluApp.cpp | 2 ++ src/FluentUI.cpp | 5 +++++ src/FluentUI.h | 3 ++- src/NativeEventFilter.cpp | 2 ++ src/WindowHelper.cpp | 2 ++ 7 files changed, 24 insertions(+), 1 deletion(-) diff --git a/example/example.pro b/example/example.pro index f1942bcd..0aca3535 100644 --- a/example/example.pro +++ b/example/example.pro @@ -52,3 +52,8 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin mac: { QMAKE_INFO_PLIST = Info.plist } + +#### 如果你正在使用静态库,请将将下面的配置注释取消掉。 +#DEFINES += STATICLIB +#INCLUDEPATH += $$OUT_PWD/../bin/FluentUI/ +#LIBS += -L$$OUT_PWD/../bin/FluentUI/ -lFluentUI diff --git a/example/src/main.cpp b/example/src/main.cpp index c3580984..1e587db3 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -8,6 +8,9 @@ #include "AppInfo.h" #include "controller/ChatController.h" #include "tool/IPC.h" +#if defined(STATICLIB) +#include +#endif int main(int argc, char *argv[]) { @@ -38,6 +41,9 @@ int main(int argc, char *argv[]) } app.setQuitOnLastWindowClosed(false); QQmlApplicationEngine engine; +#if defined(STATICLIB) + FluentUI::initialize(&engine); +#endif qmlRegisterType("Controller",1,0,"ChatController"); QQmlContext * context = engine.rootContext(); Lang* lang = appInfo->lang(); diff --git a/src/FluApp.cpp b/src/FluApp.cpp index b7f8027f..9995bc3d 100644 --- a/src/FluApp.cpp +++ b/src/FluApp.cpp @@ -11,6 +11,8 @@ #include "Def.h" #ifdef Q_OS_WIN +#pragma comment(lib, "Dwmapi.lib") +#pragma comment(lib, "User32.lib") #include #include #include diff --git a/src/FluentUI.cpp b/src/FluentUI.cpp index 5c22888d..a4bae0fc 100644 --- a/src/FluentUI.cpp +++ b/src/FluentUI.cpp @@ -8,3 +8,8 @@ void FluentUI::registerTypes(const char *uri){ void FluentUI::initializeEngine(QQmlEngine *engine, const char *uri){ Fluent::getInstance()->initializeEngine(engine,uri); } + +void FluentUI::initialize(QQmlEngine *engine){ + Fluent::getInstance()->registerTypes(URI_STR); + Fluent::getInstance()->initializeEngine(engine,URI_STR); +} diff --git a/src/FluentUI.h b/src/FluentUI.h index 1636630d..bb74f12e 100644 --- a/src/FluentUI.h +++ b/src/FluentUI.h @@ -3,12 +3,13 @@ #include -class FluentUI +class Q_DECL_EXPORT FluentUI { public: static void registerTypes(const char *uri) ; static void initializeEngine(QQmlEngine *engine, const char *uri); + static void initialize(QQmlEngine *engine); }; #endif // FLUENTUI_H diff --git a/src/NativeEventFilter.cpp b/src/NativeEventFilter.cpp index 440210db..6ab6fb6c 100644 --- a/src/NativeEventFilter.cpp +++ b/src/NativeEventFilter.cpp @@ -2,6 +2,8 @@ #include "FluTheme.h" #include "FluApp.h" #ifdef Q_OS_WIN +#pragma comment(lib, "Dwmapi.lib") +#pragma comment(lib, "User32.lib") #include #include #endif diff --git a/src/WindowHelper.cpp b/src/WindowHelper.cpp index 964cc70e..1ff5d4c3 100644 --- a/src/WindowHelper.cpp +++ b/src/WindowHelper.cpp @@ -5,6 +5,8 @@ #include "FluTheme.h" #ifdef Q_OS_WIN +#pragma comment(lib, "Dwmapi.lib") +#pragma comment(lib, "User32.lib") #include #include #include