This commit is contained in:
zhuzichu
2023-12-21 18:12:43 +08:00
parent 83a66b3f15
commit 217ceabbaa
17 changed files with 38 additions and 20 deletions

View File

@ -14,6 +14,7 @@ if (FLUENTUI_BUILD_STATIC_LIB)
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
endif()
#导入Qt相关依赖包
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick Qml)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick Qml)
@ -89,6 +90,7 @@ if(WIN32)
endif()
if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
#如果是Qt6.2版本以上则使用qt_add_libraryqt_add_qml_module函数添加资源文件
if(FLUENTUI_BUILD_STATIC_LIB)
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${CMAKE_BINARY_DIR}/FluentUI)
endif()
@ -106,6 +108,7 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
RESOURCE_PREFIX "/qt/qml"
)
else()
#如果是Qt6.2版本以下则使用add_qmlplugin函数添加资源文件这是个自定义的函数详情见.cmake/QmlPlugin.cmake
include(QmlPlugin)
add_qmlplugin(${PROJECT_NAME}
URI "FluentUI"
@ -120,6 +123,7 @@ endif()
target_compile_definitions(${PROJECT_NAME}
PRIVATE
#导入qrcode配置文件
HAVE_CONFIG_H
)

View File

@ -39,7 +39,7 @@ public:
void removeWindow(QQuickWindow* window);
private:
QMap<quint64, QQuickWindow*> _windows;
QObject* _application;
QObject* _application = nullptr;
};
#endif // FLUAPP_H

View File

@ -4,6 +4,7 @@
#include "FluRegister.h"
WindowLifecycle::WindowLifecycle(QObject *parent):QObject{parent}{
}
void WindowLifecycle::onCompleted(QQuickWindow* window){
@ -12,7 +13,10 @@ void WindowLifecycle::onCompleted(QQuickWindow* window){
}
void WindowLifecycle::onDestoryOnClose(){
FluApp::getInstance()->removeWindow(this->_window);
if(_window){
FluApp::getInstance()->removeWindow(this->_window);
_window = nullptr;
}
}
void WindowLifecycle::onDestruction(){

View File

@ -23,7 +23,7 @@ public:
Q_INVOKABLE void onDestoryOnClose();
Q_INVOKABLE QVariant createRegister(QQuickWindow* window,const QString& path);
private:
QQuickWindow* _window;
QQuickWindow* _window = nullptr;
};
#endif // WINDOWLIFECYCLE_H