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

Binary file not shown.

Binary file not shown.

View File

@ -26,6 +26,7 @@ endif()
add_subdirectory(src)
#Release
target_compile_definitions(fluentuiplugin
PRIVATE
QT_MESSAGELOGCONTEXT

View File

@ -24,6 +24,7 @@ endif()
#
file(TO_CMAKE_PATH "/" PATH_SEPARATOR)
#Qt
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick Svg Network)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick Svg Network)
@ -51,22 +52,28 @@ endforeach(filepath)
if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
#qml
file(GLOB_RECURSE QML_PATHS *.qml)
file(GLOB_RECURSE QML_PATHS *.qml qmldir)
foreach(filepath ${QML_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
if(${filepath} MATCHES "Qt${QT_VERSION_MAJOR}/")
string(REPLACE "qml-Qt${QT_VERSION_MAJOR}" "qml" filealias ${filename})
if(${filepath} MATCHES "qml-Qt6")
string(REPLACE "qml-Qt6" "qml" filealias ${filename})
set_source_files_properties(${filename} PROPERTIES QT_RESOURCE_ALIAS ${filealias})
if(${filename} MATCHES "qmldir")
list(APPEND resource_files ${filename})
else()
list(APPEND qml_files ${filename})
endif()
endif()
endforeach(filepath)
#
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.obj qmldir)
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.obj)
foreach(filepath ${RES_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
message(${filename})
list(APPEND resource_files ${filename})
endforeach(filepath)
endif()
#Windowsrcinno setup
@ -95,20 +102,19 @@ else ()
)
endif ()
#
if(WIN32)
#
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(3RDPARTY_ARCH_DIR ${CMAKE_SOURCE_DIR}/3rdparty/Win_x86)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(3RDPARTY_ARCH_DIR ${CMAKE_SOURCE_DIR}/3rdparty/Win_x64)
endif()
if(MSVC)
set(DLLPATH ${3RDPARTY_ARCH_DIR}/msvc/*.dll)
elseif(MINGW)
set(DLLPATH ${3RDPARTY_ARCH_DIR}/mingw/*.dll)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(3RDPARTY_DLL_DIR ${CMAKE_SOURCE_DIR}/3rdparty/msvc/x86/*.dll)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(3RDPARTY_DLL_DIR ${CMAKE_SOURCE_DIR}/3rdparty/msvc/x64/*.dll)
endif()
string(REPLACE "/" ${PATH_SEPARATOR} DLLPATH "${DLLPATH}")
file(GLOB DLL_FILES ${DLLPATH})
elseif(MINGW)
set(3RDPARTY_DLL_DIR ${CMAKE_SOURCE_DIR}/3rdparty/mingw/*.dll)
endif()
string(REPLACE "/" ${PATH_SEPARATOR} 3RDPARTY_DLL_DIR "${3RDPARTY_DLL_DIR}")
file(GLOB DLL_FILES ${3RDPARTY_DLL_DIR})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${DLL_FILES}
@ -117,7 +123,7 @@ if(WIN32)
endif()
if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
#qml
#Qt6.2使qt_add_qml_module
qt_add_qml_module(example
URI "example"
VERSION 1.0
@ -126,10 +132,11 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
RESOURCE_PREFIX "/"
)
else()
#Qt6.2使qrc
target_include_directories(example PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_sources(example PRIVATE example.qrc)
target_sources(example PRIVATE example.qrc)
endif()
#component,QML_NAMED_ELEMENTc++
@ -153,11 +160,13 @@ set_target_properties(example PROPERTIES
WIN32_EXECUTABLE TRUE
)
#Release
target_compile_definitions(example
PRIVATE
QT_MESSAGELOGCONTEXT
)
#
target_link_libraries(example PRIVATE
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Svg

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(){
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