mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-02 08:05:29 +08:00
Merge branch '1.7.5-dev'
This commit is contained in:
@ -10,18 +10,18 @@ set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
#判断FluentUI库类型
|
||||
if(FLUENTUI_BUILD_STATIC_LIB)
|
||||
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
#设置可执行文件输出目录
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
|
||||
|
||||
if(APPLE)
|
||||
if (APPLE)
|
||||
set(APPLICATION_DIR_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app/Contents/MacOS)
|
||||
else()
|
||||
else ()
|
||||
set(APPLICATION_DIR_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
#导入Qt相关依赖包
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick Svg Network)
|
||||
@ -32,46 +32,46 @@ find_program(QT_LUPDATE NAMES lupdate lupdate-qt6)
|
||||
find_program(QT_LRELEASE NAMES lrelease lrelease-qt6)
|
||||
file(GLOB TS_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.ts)
|
||||
add_custom_target(Script-UpdateTranslations
|
||||
COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${APPLICATION_DIR_PATH}/i18n
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_NAME}_en_US.qm ${PROJECT_NAME}_zh_CN.qm ${APPLICATION_DIR_PATH}/i18n
|
||||
SOURCES ${TS_FILE_PATHS}
|
||||
COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${APPLICATION_DIR_PATH}/i18n
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_NAME}_en_US.qm ${PROJECT_NAME}_zh_CN.qm ${APPLICATION_DIR_PATH}/i18n
|
||||
SOURCES ${TS_FILE_PATHS}
|
||||
)
|
||||
|
||||
##生成版本信息头文件
|
||||
set(HEADER_FILE_VERSION_PATH ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/Version.h)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/.cmake/Version.h.in
|
||||
${HEADER_FILE_VERSION_PATH}
|
||||
${CMAKE_SOURCE_DIR}/.cmake/Version.h.in
|
||||
${HEADER_FILE_VERSION_PATH}
|
||||
)
|
||||
|
||||
#遍历所有Cpp文件
|
||||
file(GLOB_RECURSE CPP_FILES *.cpp *.h)
|
||||
foreach(filepath ${CPP_FILES})
|
||||
foreach (filepath ${CPP_FILES})
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
|
||||
list(APPEND sources_files ${filename})
|
||||
endforeach(filepath)
|
||||
endforeach (filepath)
|
||||
|
||||
if(WIN32)
|
||||
if (WIN32)
|
||||
list(APPEND sources_files "src/app_dmp.h")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
#如果是Windows平台,则生成rc文件,还有inno setup脚本文件
|
||||
set(EXAMPLE_VERSION_RC_PATH "")
|
||||
if(WIN32)
|
||||
if (WIN32)
|
||||
set(EXAMPLE_VERSION_RC_PATH ${CMAKE_CURRENT_BINARY_DIR}/version_${PROJECT_NAME}.rc)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/.cmake/version_exe.rc.in
|
||||
${EXAMPLE_VERSION_RC_PATH}
|
||||
${CMAKE_SOURCE_DIR}/.cmake/version_exe.rc.in
|
||||
${EXAMPLE_VERSION_RC_PATH}
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/.cmake/InstallerScript.iss.in
|
||||
${CMAKE_SOURCE_DIR}/action-cli/InstallerScript.iss
|
||||
)
|
||||
endif()
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/.cmake/InstallerScript.iss.in
|
||||
${CMAKE_SOURCE_DIR}/package/InstallerScript.iss
|
||||
)
|
||||
endif ()
|
||||
|
||||
#加快qrc编译
|
||||
qt_add_big_resources(QRC_RESOURCES ${PROJECT_NAME}.qrc)
|
||||
@ -80,34 +80,34 @@ set_property(SOURCE ${PROJECT_NAME}.qrc PROPERTY SKIP_AUTORCC ON)
|
||||
list(APPEND sources_files ${QRC_RESOURCES})
|
||||
|
||||
#添加可执行文件
|
||||
if(WIN32)
|
||||
if (WIN32)
|
||||
list(APPEND sources_files ${EXAMPLE_VERSION_RC_PATH})
|
||||
endif()
|
||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
endif ()
|
||||
if (${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
qt_add_executable(${PROJECT_NAME}
|
||||
MANUAL_FINALIZATION
|
||||
${sources_files}
|
||||
MANUAL_FINALIZATION
|
||||
${sources_files}
|
||||
)
|
||||
else()
|
||||
else ()
|
||||
add_executable(${PROJECT_NAME}
|
||||
${sources_files}
|
||||
${sources_files}
|
||||
)
|
||||
endif()
|
||||
endif ()
|
||||
add_dependencies(${PROJECT_NAME} Script-UpdateTranslations)
|
||||
|
||||
#复制程序运行所需要的动态库
|
||||
if(WIN32)
|
||||
if(MSVC)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
if (WIN32)
|
||||
if (MSVC)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
file(GLOB_RECURSE 3RDPARTY_DLL_DIR ${CMAKE_SOURCE_DIR}/3rdparty/msvc/x86/*.dll)
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
file(GLOB_RECURSE 3RDPARTY_DLL_DIR ${CMAKE_SOURCE_DIR}/3rdparty/msvc/x64/*.dll)
|
||||
endif()
|
||||
elseif(MINGW)
|
||||
endif ()
|
||||
elseif (MINGW)
|
||||
file(GLOB_RECURSE 3RDPARTY_DLL_DIR ${CMAKE_SOURCE_DIR}/3rdparty/mingw/*.dll)
|
||||
endif()
|
||||
endif ()
|
||||
file(COPY ${3RDPARTY_DLL_DIR} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
#复制FluentUI源码到运行目录下,用于脚手架生成
|
||||
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/source/)
|
||||
@ -115,37 +115,37 @@ file(COPY ${CMAKE_SOURCE_DIR}/src/ DESTINATION ${APPLICATION_DIR_PATH}/source/)
|
||||
|
||||
#导入component头文件,不然通过QML_NAMED_ELEMENT生成的c++类会找不到头文件报错
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/component
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/component
|
||||
)
|
||||
|
||||
#如果是静态库则需要手动注册插件,导入FluentUI.h头文件
|
||||
if(FLUENTUI_BUILD_STATIC_LIB)
|
||||
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
#设置属性
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.${PROJECT_NAME}.com
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
MACOSX_BUNDLE TRUE
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.${PROJECT_NAME}.com
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
MACOSX_BUNDLE TRUE
|
||||
WIN32_EXECUTABLE TRUE
|
||||
)
|
||||
|
||||
#Release也支持日志打印代码位置
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
QT_MESSAGELOGCONTEXT
|
||||
PRIVATE
|
||||
QT_MESSAGELOGCONTEXT
|
||||
)
|
||||
|
||||
#目标文件链接库
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Svg
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
fluentuiplugin
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Svg
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
fluentuiplugin
|
||||
)
|
||||
|
||||
#添加部署脚本
|
||||
@ -153,23 +153,23 @@ if (CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
if (APPLE)
|
||||
find_program(QT_DEPLOY_QT NAMES macdeployqt)
|
||||
add_custom_target(Script-DeployRelease
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/dist
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_SOURCE_DIR}/dist
|
||||
COMMAND ${QT_DEPLOY_QT} ${CMAKE_SOURCE_DIR}/dist/${PROJECT_NAME}.app -qmldir=${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMENT "MacOs Deploying Qt Dependencies After Build........."
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/dist
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_SOURCE_DIR}/dist
|
||||
COMMAND ${QT_DEPLOY_QT} ${CMAKE_SOURCE_DIR}/dist/${PROJECT_NAME}.app -qmldir=${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMENT "MacOs Deploying Qt Dependencies After Build........."
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
if(WIN32)
|
||||
endif ()
|
||||
if (WIN32)
|
||||
find_program(QT_DEPLOY_QT NAMES windeployqt)
|
||||
add_custom_target(Script-DeployRelease
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/dist
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_SOURCE_DIR}/dist
|
||||
COMMAND ${QT_DEPLOY_QT} --qmldir=${CMAKE_CURRENT_LIST_DIR} --plugindir ${CMAKE_SOURCE_DIR}/dist/plugins --no-translations --compiler-runtime ${CMAKE_SOURCE_DIR}/dist/${PROJECT_NAME}.exe
|
||||
COMMENT "Windows Deploying Qt Dependencies After Build........."
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/dist
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_SOURCE_DIR}/dist
|
||||
COMMAND ${QT_DEPLOY_QT} --qmldir=${CMAKE_CURRENT_LIST_DIR} --plugindir ${CMAKE_SOURCE_DIR}/dist/plugins --no-translations --compiler-runtime ${CMAKE_SOURCE_DIR}/dist/${PROJECT_NAME}.exe
|
||||
COMMENT "Windows Deploying Qt Dependencies After Build........."
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif ()
|
||||
endif ()
|
||||
|
@ -127,7 +127,6 @@
|
||||
<file>qml/global/ItemsOriginal.qml</file>
|
||||
<file>qml/global/qmldir</file>
|
||||
<file>qml/page/T_Acrylic.qml</file>
|
||||
<file>qml/page/T_Awesome.qml</file>
|
||||
<file>qml/page/T_Badge.qml</file>
|
||||
<file>qml/page/T_BreadcrumbBar.qml</file>
|
||||
<file>qml/page/T_Buttons.qml</file>
|
||||
@ -181,7 +180,6 @@
|
||||
<file>qml/window/PageWindow.qml</file>
|
||||
<file>qml/page/T_StaggeredLayout.qml</file>
|
||||
<file>qml/page/T_Clip.qml</file>
|
||||
<file>qml/page/T_3D.qml</file>
|
||||
<file>qml/page/T_Network.qml</file>
|
||||
<file>qml/page/T_ShortcutPicker.qml</file>
|
||||
<file>qml/chart/T_BarChart.qml</file>
|
||||
@ -209,5 +207,8 @@
|
||||
<file>qml/page/T_GroupBox.qml</file>
|
||||
<file>res/image/bg_scenic.jpg</file>
|
||||
<file>qml/window/FluentInitializrWindow.qml</file>
|
||||
<file>qml/page/T_OpenGL.qml</file>
|
||||
<file>qml/page/T_Icons.qml</file>
|
||||
</qresource>
|
||||
<qresource prefix="/"/>
|
||||
</RCC>
|
||||
|
@ -87,22 +87,22 @@
|
||||
<context>
|
||||
<name>InitializrHelper</name>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="77"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="69"/>
|
||||
<source>The name cannot be empty</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="81"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="73"/>
|
||||
<source>The creation path cannot be empty</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="86"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="78"/>
|
||||
<source>The path does not exist</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="92"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="84"/>
|
||||
<source>%1 folder already exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -425,7 +425,7 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="367"/>
|
||||
<source>Awesome</source>
|
||||
<source>Icons</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
@ -475,42 +475,42 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="430"/>
|
||||
<source>QRCode</source>
|
||||
<source>OpenGL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="436"/>
|
||||
<source>Tour</source>
|
||||
<source>QRCode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="442"/>
|
||||
<source>Timeline</source>
|
||||
<source>Tour</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="448"/>
|
||||
<source>Captcha</source>
|
||||
<source>Timeline</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="454"/>
|
||||
<source>Captcha</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="460"/>
|
||||
<source>Network</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="461"/>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="467"/>
|
||||
<source>Remote Loader</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="475"/>
|
||||
<source>Hot Loader</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="481"/>
|
||||
<source>3D</source>
|
||||
<source>Hot Loader</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
@ -546,104 +546,104 @@
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="307"/>
|
||||
<source>Dark Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="83"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="91"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="87"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="95"/>
|
||||
<source>Quit</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="84"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="88"/>
|
||||
<source>Are you sure you want to exit the program?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="85"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="89"/>
|
||||
<source>Minimize</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="88"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="92"/>
|
||||
<source>Friendly Reminder</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="88"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="92"/>
|
||||
<source>FluentUI is hidden from the tray, click on the tray to activate the window again</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="92"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="336"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="96"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="340"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="103"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="107"/>
|
||||
<source>Open in Separate Window</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="200"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="204"/>
|
||||
<source>Click Time</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="210"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="214"/>
|
||||
<source>Search</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="301"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="305"/>
|
||||
<source>Finish</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="302"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="306"/>
|
||||
<source>Next</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="303"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="307"/>
|
||||
<source>Previous</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="307"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="311"/>
|
||||
<source>Dark Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="311"/>
|
||||
<source>Here you can switch to night mode.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="309"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="313"/>
|
||||
<source>Hide Easter eggs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="309"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="313"/>
|
||||
<source>Try a few more clicks!!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="333"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<source>Upgrade Tips</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="334"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="338"/>
|
||||
<source>FluentUI is currently up to date </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="334"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="338"/>
|
||||
<source> -- The current app version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="334"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="338"/>
|
||||
<source>
|
||||
Now go and download the new version?
|
||||
|
||||
@ -652,17 +652,17 @@ Updated content:
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="341"/>
|
||||
<source>OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="364"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="368"/>
|
||||
<source>The current version is already the latest</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="371"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="375"/>
|
||||
<source>The network is abnormal</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -769,29 +769,6 @@ Updated content:
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_Awesome</name>
|
||||
<message>
|
||||
<location filename="qml/page/T_Awesome.qml" line="9"/>
|
||||
<source>Awesome</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Awesome.qml" line="13"/>
|
||||
<source>Please enter a keyword</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Awesome.qml" line="20"/>
|
||||
<source>Search</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Awesome.qml" line="55"/>
|
||||
<source>You Copied </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_Badge</name>
|
||||
<message>
|
||||
@ -1107,46 +1084,6 @@ Updated content:
|
||||
<source>Click to Select a Color - ></source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="22"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="23"/>
|
||||
<source>OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="24"/>
|
||||
<source>Color Picker</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="25"/>
|
||||
<source>Edit Color</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="26"/>
|
||||
<source>Red</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="27"/>
|
||||
<source>Green</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="28"/>
|
||||
<source>Blue</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="29"/>
|
||||
<source>Opacity</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_ComboBox</name>
|
||||
@ -1361,26 +1298,49 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
|
||||
<context>
|
||||
<name>T_Home</name>
|
||||
<message>
|
||||
<location filename="qml/page/T_Home.qml" line="23"/>
|
||||
<location filename="qml/page/T_Home.qml" line="19"/>
|
||||
<source>FluentUI GitHub</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Home.qml" line="24"/>
|
||||
<location filename="qml/page/T_Home.qml" line="20"/>
|
||||
<source>The latest FluentUI controls and styles for your applications.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Home.qml" line="32"/>
|
||||
<location filename="qml/page/T_Home.qml" line="28"/>
|
||||
<source>FluentUI Initializr</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Home.qml" line="33"/>
|
||||
<location filename="qml/page/T_Home.qml" line="29"/>
|
||||
<source>FluentUI Initializr is a Tool that helps you create and customize Fluent UI projects with various options.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_Icons</name>
|
||||
<message>
|
||||
<location filename="qml/page/T_Icons.qml" line="9"/>
|
||||
<source>Icons</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Icons.qml" line="13"/>
|
||||
<source>Please enter a keyword</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Icons.qml" line="20"/>
|
||||
<source>Search</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Icons.qml" line="60"/>
|
||||
<source>You Copied </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_Image</name>
|
||||
<message>
|
||||
@ -1621,6 +1581,14 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_OpenGL</name>
|
||||
<message>
|
||||
<location filename="qml/page/T_OpenGL.qml" line="11"/>
|
||||
<source>OpenGL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_Pagination</name>
|
||||
<message>
|
||||
@ -1957,26 +1925,6 @@ Some contents...</source>
|
||||
<source>StatusLayout</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_StatusLayout.qml" line="63"/>
|
||||
<source>Loading...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_StatusLayout.qml" line="64"/>
|
||||
<source>Empty</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_StatusLayout.qml" line="65"/>
|
||||
<source>The page went wrong...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_StatusLayout.qml" line="66"/>
|
||||
<source>Reload</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_TabView</name>
|
||||
@ -2177,6 +2125,11 @@ Some contents...</source>
|
||||
<source>Open Animation</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Theme.qml" line="123"/>
|
||||
<source>Open Blur Window</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_TimePicker</name>
|
||||
@ -2376,13 +2329,23 @@ Some contents...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="44"/>
|
||||
<source>Total %1 data, %2 data currently displayed</source>
|
||||
<location filename="qml/page/T_TreeView.qml" line="183"/>
|
||||
<source>Title</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="48"/>
|
||||
<source>A total of %1 data items are selected</source>
|
||||
<location filename="qml/page/T_TreeView.qml" line="187"/>
|
||||
<source>Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="191"/>
|
||||
<source>Avatar</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="195"/>
|
||||
<source>Address</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
@ -87,22 +87,22 @@
|
||||
<context>
|
||||
<name>InitializrHelper</name>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="77"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="69"/>
|
||||
<source>The name cannot be empty</source>
|
||||
<translation type="unfinished">名称不能为空</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="81"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="73"/>
|
||||
<source>The creation path cannot be empty</source>
|
||||
<translation type="unfinished">创建路径不能为空</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="86"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="78"/>
|
||||
<source>The path does not exist</source>
|
||||
<translation type="unfinished">路径不存在</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="92"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="84"/>
|
||||
<source>%1 folder already exists</source>
|
||||
<translation type="unfinished">%1 文件夹已经存在</translation>
|
||||
</message>
|
||||
@ -425,7 +425,7 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="367"/>
|
||||
<source>Awesome</source>
|
||||
<source>Icons</source>
|
||||
<translation type="unfinished">图标</translation>
|
||||
</message>
|
||||
<message>
|
||||
@ -475,43 +475,47 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="430"/>
|
||||
<source>OpenGL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="436"/>
|
||||
<source>QRCode</source>
|
||||
<translation type="unfinished">二维码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="436"/>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="442"/>
|
||||
<source>Tour</source>
|
||||
<translation type="unfinished">游览</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="442"/>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="448"/>
|
||||
<source>Timeline</source>
|
||||
<translation type="unfinished">时间轴</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="448"/>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="454"/>
|
||||
<source>Captcha</source>
|
||||
<translation type="unfinished">验证码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="454"/>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="460"/>
|
||||
<source>Network</source>
|
||||
<translation type="unfinished">网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="461"/>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="467"/>
|
||||
<source>Remote Loader</source>
|
||||
<translation type="unfinished">远程加载</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="475"/>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="481"/>
|
||||
<source>Hot Loader</source>
|
||||
<translation type="unfinished">热加载</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="481"/>
|
||||
<source>3D</source>
|
||||
<translation type="unfinished">3D</translation>
|
||||
<translation type="obsolete">3D</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="487"/>
|
||||
@ -546,104 +550,104 @@
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="307"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="311"/>
|
||||
<source>Dark Mode</source>
|
||||
<translation type="unfinished">夜间模式</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="83"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="91"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="87"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="95"/>
|
||||
<source>Quit</source>
|
||||
<translation type="unfinished">退出</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="84"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="88"/>
|
||||
<source>Are you sure you want to exit the program?</source>
|
||||
<translation type="unfinished">您确定要退出程序吗</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="85"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="89"/>
|
||||
<source>Minimize</source>
|
||||
<translation type="unfinished">最小化</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="88"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="92"/>
|
||||
<source>Friendly Reminder</source>
|
||||
<translation type="unfinished">友情提示</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="88"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="92"/>
|
||||
<source>FluentUI is hidden from the tray, click on the tray to activate the window again</source>
|
||||
<translation type="unfinished">FluentUI 在托盘中处于隐藏状态,单击托盘以再次激活窗口</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="92"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="336"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="96"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="340"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished">取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="103"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="107"/>
|
||||
<source>Open in Separate Window</source>
|
||||
<translation type="unfinished">在独立窗口中打开</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="200"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="204"/>
|
||||
<source>Click Time</source>
|
||||
<translation type="unfinished">点击次数</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="210"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="214"/>
|
||||
<source>Search</source>
|
||||
<translation type="unfinished">搜索</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="301"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="305"/>
|
||||
<source>Finish</source>
|
||||
<translation type="unfinished">完成</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="302"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="306"/>
|
||||
<source>Next</source>
|
||||
<translation type="unfinished">下一步</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="303"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="307"/>
|
||||
<source>Previous</source>
|
||||
<translation type="unfinished">上一步</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="307"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="311"/>
|
||||
<source>Here you can switch to night mode.</source>
|
||||
<translation type="unfinished">在这里,您可以切换到夜间模式。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="309"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="313"/>
|
||||
<source>Hide Easter eggs</source>
|
||||
<translation type="unfinished">隐藏彩蛋</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="309"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="313"/>
|
||||
<source>Try a few more clicks!!</source>
|
||||
<translation type="unfinished">再试几下!!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="333"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<source>Upgrade Tips</source>
|
||||
<translation type="unfinished">升级提示</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="334"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="338"/>
|
||||
<source>FluentUI is currently up to date </source>
|
||||
<translation type="unfinished">FluentUI 目前最新版本 </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="334"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="338"/>
|
||||
<source> -- The current app version</source>
|
||||
<translation type="unfinished"> -- 当前应用版本</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="334"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="338"/>
|
||||
<source>
|
||||
Now go and download the new version?
|
||||
|
||||
@ -656,17 +660,17 @@ Updated content:
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="341"/>
|
||||
<source>OK</source>
|
||||
<translation type="unfinished">确定</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="364"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="368"/>
|
||||
<source>The current version is already the latest</source>
|
||||
<translation type="unfinished">当前版本已经是最新版本</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="371"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="375"/>
|
||||
<source>The network is abnormal</source>
|
||||
<translation type="unfinished">网络异常</translation>
|
||||
</message>
|
||||
@ -776,24 +780,20 @@ Updated content:
|
||||
<context>
|
||||
<name>T_Awesome</name>
|
||||
<message>
|
||||
<location filename="qml/page/T_Awesome.qml" line="9"/>
|
||||
<source>Awesome</source>
|
||||
<translation type="unfinished">图标</translation>
|
||||
<translation type="obsolete">图标</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Awesome.qml" line="13"/>
|
||||
<source>Please enter a keyword</source>
|
||||
<translation type="unfinished">请输入关键字</translation>
|
||||
<translation type="obsolete">请输入关键字</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Awesome.qml" line="20"/>
|
||||
<source>Search</source>
|
||||
<translation type="unfinished">搜索</translation>
|
||||
<translation type="obsolete">搜索</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Awesome.qml" line="55"/>
|
||||
<source>You Copied </source>
|
||||
<translation type="unfinished">您复制</translation>
|
||||
<translation type="obsolete">您复制</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -1112,44 +1112,36 @@ Updated content:
|
||||
<translation type="unfinished">点击选中颜色 - ></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="22"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished">取消</translation>
|
||||
<translation type="obsolete">取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="23"/>
|
||||
<source>OK</source>
|
||||
<translation type="unfinished">确定</translation>
|
||||
<translation type="obsolete">确定</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="24"/>
|
||||
<source>Color Picker</source>
|
||||
<translation type="unfinished">颜色选择器</translation>
|
||||
<translation type="obsolete">颜色选择器</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="25"/>
|
||||
<source>Edit Color</source>
|
||||
<translation type="unfinished">编辑颜色</translation>
|
||||
<translation type="obsolete">编辑颜色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="26"/>
|
||||
<source>Red</source>
|
||||
<translation type="unfinished">红色</translation>
|
||||
<translation type="obsolete">红色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="27"/>
|
||||
<source>Green</source>
|
||||
<translation type="unfinished">绿色</translation>
|
||||
<translation type="obsolete">绿色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="28"/>
|
||||
<source>Blue</source>
|
||||
<translation type="unfinished">蓝色</translation>
|
||||
<translation type="obsolete">蓝色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_ColorPicker.qml" line="29"/>
|
||||
<source>Opacity</source>
|
||||
<translation type="unfinished">透明度</translation>
|
||||
<translation type="obsolete">透明度</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -1392,26 +1384,49 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
|
||||
<context>
|
||||
<name>T_Home</name>
|
||||
<message>
|
||||
<location filename="qml/page/T_Home.qml" line="23"/>
|
||||
<location filename="qml/page/T_Home.qml" line="19"/>
|
||||
<source>FluentUI GitHub</source>
|
||||
<translation type="unfinished">FluentUI GitHub</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Home.qml" line="24"/>
|
||||
<location filename="qml/page/T_Home.qml" line="20"/>
|
||||
<source>The latest FluentUI controls and styles for your applications.</source>
|
||||
<translation type="unfinished">最新的 FluentUI 控件和样式</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Home.qml" line="32"/>
|
||||
<location filename="qml/page/T_Home.qml" line="28"/>
|
||||
<source>FluentUI Initializr</source>
|
||||
<translation type="unfinished">FluentUI脚手架</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Home.qml" line="33"/>
|
||||
<location filename="qml/page/T_Home.qml" line="29"/>
|
||||
<source>FluentUI Initializr is a Tool that helps you create and customize Fluent UI projects with various options.</source>
|
||||
<translation type="unfinished">FluentUI 脚手架是一个快速创建项目工具,可帮助您创建和自定义具有各种选项的 Fluent UI 项目</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_Icons</name>
|
||||
<message>
|
||||
<location filename="qml/page/T_Icons.qml" line="9"/>
|
||||
<source>Icons</source>
|
||||
<translation type="unfinished">图标</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Icons.qml" line="13"/>
|
||||
<source>Please enter a keyword</source>
|
||||
<translation type="unfinished">请输入关键字</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Icons.qml" line="20"/>
|
||||
<source>Search</source>
|
||||
<translation type="unfinished">搜索</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Icons.qml" line="60"/>
|
||||
<source>You Copied </source>
|
||||
<translation type="unfinished">您复制</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_Image</name>
|
||||
<message>
|
||||
@ -1660,6 +1675,14 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
|
||||
<translation type="unfinished">网络</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_OpenGL</name>
|
||||
<message>
|
||||
<location filename="qml/page/T_OpenGL.qml" line="11"/>
|
||||
<source>OpenGL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_Pagination</name>
|
||||
<message>
|
||||
@ -2029,24 +2052,20 @@ Some contents...</source>
|
||||
<translation type="unfinished">状态布局</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_StatusLayout.qml" line="63"/>
|
||||
<source>Loading...</source>
|
||||
<translation type="unfinished">正在加载...</translation>
|
||||
<translation type="obsolete">正在加载...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_StatusLayout.qml" line="64"/>
|
||||
<source>Empty</source>
|
||||
<translation type="unfinished">空空如也</translation>
|
||||
<translation type="obsolete">空空如也</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_StatusLayout.qml" line="65"/>
|
||||
<source>The page went wrong...</source>
|
||||
<translation type="unfinished">页面出错了...</translation>
|
||||
<translation type="obsolete">页面出错了...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_StatusLayout.qml" line="66"/>
|
||||
<source>Reload</source>
|
||||
<translation type="unfinished">重新加载</translation>
|
||||
<translation type="obsolete">重新加载</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -2248,6 +2267,11 @@ Some contents...</source>
|
||||
<source>Open Animation</source>
|
||||
<translation type="unfinished">开启动画</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Theme.qml" line="123"/>
|
||||
<source>Open Blur Window</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_TimePicker</name>
|
||||
@ -2459,14 +2483,32 @@ Some contents...</source>
|
||||
<translation type="unfinished">树</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="44"/>
|
||||
<source>Total %1 data, %2 data currently displayed</source>
|
||||
<translation type="unfinished">共计%1条数据,当前显示的%2条数据</translation>
|
||||
<translation type="obsolete">共计%1条数据,当前显示的%2条数据</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="48"/>
|
||||
<source>A total of %1 data items are selected</source>
|
||||
<translation type="unfinished">共计选中%1条数据</translation>
|
||||
<translation type="obsolete">共计选中%1条数据</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="183"/>
|
||||
<source>Title</source>
|
||||
<translation type="unfinished">标题</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="195"/>
|
||||
<source>Address</source>
|
||||
<translation type="unfinished">地址</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="191"/>
|
||||
<source>Avatar</source>
|
||||
<translation type="unfinished">头像</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_TreeView.qml" line="187"/>
|
||||
<source>Name</source>
|
||||
<translation type="unfinished">名称</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -364,9 +364,9 @@ FluObject{
|
||||
onTap: { navigationView.push(url) }
|
||||
}
|
||||
FluPaneItem{
|
||||
title: qsTr("Awesome")
|
||||
title: qsTr("Icons")
|
||||
menuDelegate: paneItemMenu
|
||||
url: "qrc:/example/qml/page/T_Awesome.qml"
|
||||
url: "qrc:/example/qml/page/T_Icons.qml"
|
||||
onTap: { navigationView.push(url) }
|
||||
}
|
||||
}
|
||||
@ -426,6 +426,12 @@ FluObject{
|
||||
FluPaneItemExpander{
|
||||
title: qsTr("Other")
|
||||
icon: FluentIcons.Shop
|
||||
FluPaneItem{
|
||||
title: qsTr("OpenGL")
|
||||
menuDelegate: paneItemMenu
|
||||
url: "qrc:/example/qml/page/T_OpenGL.qml"
|
||||
onTap: { navigationView.push(url) }
|
||||
}
|
||||
FluPaneItem{
|
||||
title: qsTr("QRCode")
|
||||
menuDelegate: paneItemMenu
|
||||
@ -477,12 +483,6 @@ FluObject{
|
||||
FluRouter.navigate("/hotload")
|
||||
}
|
||||
}
|
||||
FluPaneItem{
|
||||
title: qsTr("3D")
|
||||
menuDelegate: paneItemMenu
|
||||
url: "qrc:/example/qml/page/T_3D.qml"
|
||||
onTap: { navigationView.push(url) }
|
||||
}
|
||||
FluPaneItem{
|
||||
title: qsTr("Test Crash")
|
||||
onTapListener: function(){
|
||||
|
@ -1,116 +0,0 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Window 2.15
|
||||
import Qt3D.Core 2.15
|
||||
import Qt3D.Render 2.15
|
||||
import Qt3D.Input 2.12
|
||||
import Qt3D.Extras 2.15
|
||||
import QtQuick.Scene3D 2.15
|
||||
import Qt.labs.platform 1.1
|
||||
import FluentUI 1.0
|
||||
import "../component"
|
||||
|
||||
FluContentPage{
|
||||
|
||||
id:root
|
||||
title:"3D"
|
||||
|
||||
Scene3D{
|
||||
id:scene_3d
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
aspects: ["input", "logic"]
|
||||
cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
|
||||
Entity {
|
||||
Camera {
|
||||
id: camera
|
||||
projectionType: CameraLens.PerspectiveProjection
|
||||
fieldOfView: 22.5
|
||||
aspectRatio: scene_3d.width / scene_3d.height
|
||||
nearPlane: 1
|
||||
farPlane: 1000.0
|
||||
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
|
||||
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
|
||||
position: Qt.vector3d( 0.0, 0.0, 15.0 )
|
||||
}
|
||||
FirstPersonCameraController {
|
||||
linearSpeed: 100
|
||||
lookSpeed: 50
|
||||
camera: camera
|
||||
}
|
||||
components: [
|
||||
RenderSettings{
|
||||
activeFrameGraph: ForwardRenderer{
|
||||
clearColor: Qt.rgba(0,0,0,0);
|
||||
camera: camera
|
||||
}
|
||||
},
|
||||
InputSettings{}
|
||||
]
|
||||
Mesh {
|
||||
id: mesh
|
||||
source: "https://zhu-zichu.gitee.io/test.obj"
|
||||
}
|
||||
PhongMaterial {
|
||||
id: material
|
||||
ambient: color_picker.current
|
||||
}
|
||||
Transform{
|
||||
id:transform
|
||||
scale: 1.0
|
||||
translation: Qt.vector3d(0, 0, 0)
|
||||
rotation: fromEulerAngles(0, 0, 0)
|
||||
property real hAngle:0.0
|
||||
NumberAnimation on hAngle{
|
||||
from:0
|
||||
to:360.0
|
||||
duration: 5000
|
||||
loops: Animation.Infinite
|
||||
}
|
||||
matrix:{
|
||||
var m=Qt.matrix4x4();
|
||||
m.rotate(hAngle,Qt.vector3d(0,1,0));
|
||||
m.translate(Qt.vector3d(0,0,0));
|
||||
return m;
|
||||
}
|
||||
}
|
||||
Entity {
|
||||
id: entity
|
||||
components: [mesh, material,transform]
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout{
|
||||
RowLayout{
|
||||
spacing: 10
|
||||
Layout.topMargin: 20
|
||||
FluText{
|
||||
text:"tintColor:"
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
FluColorPicker{
|
||||
id:color_picker
|
||||
current: "gray"
|
||||
}
|
||||
}
|
||||
|
||||
FluButton{
|
||||
text:"选择obj资源"
|
||||
onClicked: {
|
||||
file_dialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: file_dialog
|
||||
nameFilters: ["Obj files (*.obj)"]
|
||||
folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
|
||||
onAccepted: {
|
||||
var fileUrl = file_dialog.currentFile
|
||||
mesh.source = fileUrl
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -18,16 +18,7 @@ FluScrollablePage{
|
||||
text: qsTr("Click to Select a Color - >")
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
FluColorPicker{
|
||||
cancelText: qsTr("Cancel")
|
||||
okText: qsTr("OK")
|
||||
titleText: qsTr("Color Picker")
|
||||
editText: qsTr("Edit Color")
|
||||
redText: qsTr("Red")
|
||||
greenText: qsTr("Green")
|
||||
blueText: qsTr("Blue")
|
||||
opacityText: qsTr("Opacity")
|
||||
}
|
||||
FluColorPicker{}
|
||||
}
|
||||
}
|
||||
CodeExpander{
|
||||
|
@ -12,10 +12,6 @@ FluScrollablePage{
|
||||
animationEnabled: false
|
||||
header: Item{}
|
||||
|
||||
FluentInitializrWindow{
|
||||
id:fluent_Initializr
|
||||
}
|
||||
|
||||
ListModel{
|
||||
id: model_header
|
||||
ListElement{
|
||||
|
@ -6,13 +6,13 @@ import FluentUI 1.0
|
||||
|
||||
FluContentPage {
|
||||
|
||||
title: qsTr("Awesome")
|
||||
title: qsTr("Icons")
|
||||
|
||||
FluTextBox{
|
||||
id:text_box
|
||||
id: text_box
|
||||
placeholderText: qsTr("Please enter a keyword")
|
||||
anchors{
|
||||
top:parent.top
|
||||
top: parent.top
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,47 +24,49 @@ FluContentPage {
|
||||
leftMargin: 14
|
||||
}
|
||||
onClicked: {
|
||||
grid_view.model = FluTheme.awesomeList(text_box.text)
|
||||
grid_view.model = FluApp.iconDatas(text_box.text)
|
||||
}
|
||||
}
|
||||
GridView{
|
||||
id:grid_view
|
||||
cellWidth: 80
|
||||
cellHeight: 80
|
||||
id: grid_view
|
||||
cellWidth: 110
|
||||
cellHeight: 110
|
||||
clip: true
|
||||
boundsBehavior: GridView.StopAtBounds
|
||||
model:FluTheme.awesomeList()
|
||||
model: FluApp.iconDatas()
|
||||
ScrollBar.vertical: FluScrollBar {}
|
||||
anchors{
|
||||
topMargin: 10
|
||||
top:text_box.bottom
|
||||
top: text_box.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
delegate: Item {
|
||||
width: 68
|
||||
height: 80
|
||||
width: 100
|
||||
height: 100
|
||||
FluIconButton{
|
||||
id:item_icon
|
||||
iconSource:modelData.icon
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
iconSource: modelData.icon
|
||||
iconSize: 30
|
||||
padding: 0
|
||||
verticalPadding: 0
|
||||
horizontalPadding: 0
|
||||
bottomPadding: 30
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
var text ="FluentIcons."+modelData.name;
|
||||
FluTools.clipText(text)
|
||||
showSuccess(qsTr("You Copied ")+text)
|
||||
}
|
||||
}
|
||||
FluText {
|
||||
id:item_name
|
||||
font.pixelSize: 10
|
||||
font.family: FluTextStyle.family
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: item_icon.bottom
|
||||
width:parent.width
|
||||
wrapMode: Text.WrapAnywhere
|
||||
text: modelData.name
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
FluText{
|
||||
width: parent.width
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
wrapMode: Text.WrapAnywhere
|
||||
text: modelData.name
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 60
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
example/qml/page/T_OpenGL.qml
Normal file
26
example/qml/page/T_OpenGL.qml
Normal file
@ -0,0 +1,26 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Window 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
import example 1.0
|
||||
import "../component"
|
||||
|
||||
FluContentPage{
|
||||
|
||||
title: qsTr("OpenGL")
|
||||
|
||||
FluFrame{
|
||||
anchors.fill: parent
|
||||
OpenGLItem{
|
||||
anchors.fill: parent
|
||||
SequentialAnimation on t {
|
||||
NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
|
||||
NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
|
||||
loops: Animation.Infinite
|
||||
running: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -60,12 +60,8 @@ FluScrollablePage{
|
||||
FluStatusLayout{
|
||||
id:status_view
|
||||
anchors.fill: parent
|
||||
loadingText: qsTr("Loading...")
|
||||
emptyText: qsTr("Empty")
|
||||
errorText: qsTr("The page went wrong...")
|
||||
errorButtonText: qsTr("Reload")
|
||||
onErrorClicked:{
|
||||
showError("Click Reload")
|
||||
status_view.statusMode = FluStatusLayoutType.Loading
|
||||
}
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
|
@ -13,7 +13,7 @@ FluScrollablePage{
|
||||
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 340
|
||||
Layout.preferredHeight: 408
|
||||
padding: 10
|
||||
|
||||
ColumnLayout{
|
||||
@ -119,6 +119,17 @@ FluScrollablePage{
|
||||
FluTheme.animationEnabled = !FluTheme.animationEnabled
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
text: qsTr("Open Blur Window")
|
||||
Layout.topMargin: 20
|
||||
}
|
||||
FluToggleSwitch{
|
||||
Layout.topMargin: 5
|
||||
checked: FluTheme.blurBehindWindowEnabled
|
||||
onClicked: {
|
||||
FluTheme.blurBehindWindowEnabled = !FluTheme.blurBehindWindowEnabled
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CodeExpander{
|
||||
|
@ -9,14 +9,33 @@ FluContentPage {
|
||||
|
||||
title: qsTr("TreeView")
|
||||
|
||||
|
||||
function treeData(){
|
||||
const dig = (path = '0', level = 4) => {
|
||||
const names = ["孙悟空", "猪八戒", "沙和尚", "唐僧","白骨夫人","金角大王","熊山君","黄风怪","银角大王"]
|
||||
function getRandomName(){
|
||||
var randomIndex = Math.floor(Math.random() * names.length)
|
||||
return names[randomIndex]
|
||||
}
|
||||
const addresses = ["傲来国界花果山水帘洞","傲来国界坎源山脏水洞","大唐国界黑风山黑风洞","大唐国界黄风岭黄风洞","大唐国界骷髅山白骨洞","宝象国界碗子山波月洞","宝象国界平顶山莲花洞","宝象国界压龙山压龙洞","乌鸡国界号山枯松涧火云洞","乌鸡国界衡阳峪黑水河河神府"]
|
||||
function getRandomAddresses(){
|
||||
var randomIndex = Math.floor(Math.random() * addresses.length)
|
||||
return addresses[randomIndex]
|
||||
}
|
||||
const avatars = ["qrc:/example/res/svg/avatar_1.svg", "qrc:/example/res/svg/avatar_2.svg", "qrc:/example/res/svg/avatar_3.svg", "qrc:/example/res/svg/avatar_4.svg","qrc:/example/res/svg/avatar_5.svg","qrc:/example/res/svg/avatar_6.svg","qrc:/example/res/svg/avatar_7.svg","qrc:/example/res/svg/avatar_8.svg","qrc:/example/res/svg/avatar_9.svg","qrc:/example/res/svg/avatar_10.svg","qrc:/example/res/svg/avatar_11.svg","qrc:/example/res/svg/avatar_12.svg"]
|
||||
function getRandomAvatar(){
|
||||
var randomIndex = Math.floor(Math.random() * avatars.length);
|
||||
return avatars[randomIndex];
|
||||
}
|
||||
const dig = (path = '0', level = 5) => {
|
||||
const list = [];
|
||||
for (let i = 0; i < 6; i += 1) {
|
||||
for (let i = 0; i < 4; i += 1) {
|
||||
const key = `${path}-${i}`;
|
||||
const treeNode = {
|
||||
title: key,
|
||||
key,
|
||||
_key: key,
|
||||
name: getRandomName(),
|
||||
avatar:tree_view.customItem(com_avatar,{avatar:getRandomAvatar()}),
|
||||
address: getRandomAddresses()
|
||||
};
|
||||
if (level > 0) {
|
||||
treeNode.children = dig(key, level - 1);
|
||||
@ -28,103 +47,159 @@ FluContentPage {
|
||||
return dig();
|
||||
}
|
||||
|
||||
Column{
|
||||
id: layout_column
|
||||
spacing: 12
|
||||
width: 300
|
||||
anchors{
|
||||
top:parent.top
|
||||
left: parent.left
|
||||
leftMargin: 10
|
||||
bottom:parent.bottom
|
||||
bottomMargin: 20
|
||||
}
|
||||
|
||||
FluText{
|
||||
text: qsTr("Total %1 data, %2 data currently displayed").arg(tree_view.count()).arg(tree_view.visibleCount())
|
||||
}
|
||||
|
||||
FluText{
|
||||
text: qsTr("A total of %1 data items are selected").arg(tree_view.selectionModel().length)
|
||||
}
|
||||
|
||||
RowLayout{
|
||||
spacing: 10
|
||||
FluText{
|
||||
text: "cellHeight:"
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
FluSlider{
|
||||
id: slider_cell_height
|
||||
value: 30
|
||||
from: 30
|
||||
to:100
|
||||
}
|
||||
}
|
||||
RowLayout{
|
||||
spacing: 10
|
||||
FluText{
|
||||
text: "depthPadding:"
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
FluSlider{
|
||||
id: slider_depth_padding
|
||||
value: 30
|
||||
from: 30
|
||||
to:100
|
||||
}
|
||||
}
|
||||
FluToggleSwitch{
|
||||
id: switch_showline
|
||||
text:"showLine"
|
||||
checked: false
|
||||
}
|
||||
FluToggleSwitch{
|
||||
id: switch_draggable
|
||||
text:"draggable"
|
||||
checked: false
|
||||
}
|
||||
FluToggleSwitch{
|
||||
id: switch_checkable
|
||||
text:"checkable"
|
||||
checked: false
|
||||
}
|
||||
FluButton{
|
||||
text: "all expand"
|
||||
onClicked: {
|
||||
tree_view.allExpand()
|
||||
}
|
||||
}
|
||||
FluButton{
|
||||
text: "all collapse"
|
||||
onClicked: {
|
||||
tree_view.allCollapse()
|
||||
Component{
|
||||
id:com_avatar
|
||||
Item{
|
||||
FluClip{
|
||||
anchors.centerIn: parent
|
||||
width: height
|
||||
height: parent.height/3*2
|
||||
radius: [height/2,height/2,height/2,height/2]
|
||||
Image{
|
||||
anchors.fill: parent
|
||||
source: {
|
||||
if(options && options.avatar){
|
||||
return options.avatar
|
||||
}
|
||||
return ""
|
||||
}
|
||||
sourceSize: Qt.size(80,80)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FluFrame{
|
||||
id:layout_controls
|
||||
anchors{
|
||||
left: layout_column.right
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
rightMargin: 5
|
||||
topMargin: 5
|
||||
bottomMargin: 5
|
||||
top: parent.top
|
||||
topMargin: 10
|
||||
}
|
||||
FluShadow{}
|
||||
FluTreeView{
|
||||
id:tree_view
|
||||
anchors.fill: parent
|
||||
cellHeight: slider_cell_height.value
|
||||
draggable:switch_draggable.checked
|
||||
showLine: switch_showline.checked
|
||||
checkable:switch_checkable.checked
|
||||
depthPadding: slider_depth_padding.value
|
||||
Component.onCompleted: {
|
||||
var data = treeData()
|
||||
dataSource = data
|
||||
height: 80
|
||||
clip: true
|
||||
Row{
|
||||
spacing: 12
|
||||
anchors{
|
||||
left: parent.left
|
||||
leftMargin: 10
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
Column{
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
RowLayout{
|
||||
spacing: 10
|
||||
FluText{
|
||||
text: "cellHeight:"
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
FluSlider{
|
||||
id: slider_cell_height
|
||||
value: 38
|
||||
from: 38
|
||||
to:100
|
||||
}
|
||||
}
|
||||
RowLayout{
|
||||
spacing: 10
|
||||
FluText{
|
||||
text: "depthPadding:"
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
FluSlider{
|
||||
id: slider_depth_padding
|
||||
value: 15
|
||||
from: 15
|
||||
to:100
|
||||
}
|
||||
}
|
||||
}
|
||||
Column{
|
||||
spacing: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
FluToggleSwitch{
|
||||
id: switch_showline
|
||||
text:"showLine"
|
||||
checked: false
|
||||
}
|
||||
FluToggleSwitch{
|
||||
id: switch_checkable
|
||||
text:"checkable"
|
||||
checked: false
|
||||
}
|
||||
}
|
||||
Column{
|
||||
spacing: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
FluButton{
|
||||
text: "all expand"
|
||||
onClicked: {
|
||||
tree_view.allExpand()
|
||||
}
|
||||
}
|
||||
FluButton{
|
||||
text: "all collapse"
|
||||
onClicked: {
|
||||
tree_view.allCollapse()
|
||||
}
|
||||
}
|
||||
}
|
||||
FluButton{
|
||||
text: "print selection model"
|
||||
onClicked: {
|
||||
var printData = []
|
||||
var data = tree_view.selectionModel();
|
||||
console.debug(data.length)
|
||||
for(var i = 0; i <= data.length-1 ; i++){
|
||||
const newObj = Object.assign({}, data[i].data);
|
||||
delete newObj["__parent"];
|
||||
delete newObj["children"];
|
||||
printData.push(newObj)
|
||||
}
|
||||
console.debug(JSON.stringify(printData))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FluTreeView{
|
||||
id:tree_view
|
||||
anchors{
|
||||
left: parent.left
|
||||
top: layout_controls.bottom
|
||||
topMargin: 10
|
||||
bottom: parent.bottom
|
||||
right: parent.right
|
||||
}
|
||||
cellHeight: slider_cell_height.value
|
||||
showLine: switch_showline.checked
|
||||
checkable:switch_checkable.checked
|
||||
depthPadding: slider_depth_padding.value
|
||||
onCurrentChanged: {
|
||||
showInfo(current.data.title)
|
||||
}
|
||||
columnSource:[
|
||||
{
|
||||
title: qsTr("Title"),
|
||||
dataIndex: 'title',
|
||||
width: 300
|
||||
},{
|
||||
title: qsTr("Name"),
|
||||
dataIndex: 'name',
|
||||
width: 100
|
||||
},{
|
||||
title: qsTr("Avatar"),
|
||||
dataIndex: 'avatar',
|
||||
width: 100
|
||||
},{
|
||||
title: qsTr("Address"),
|
||||
dataIndex: 'address',
|
||||
width: 200
|
||||
},
|
||||
]
|
||||
Component.onCompleted: {
|
||||
var data = treeData()
|
||||
dataSource = data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ FluWindowDialog {
|
||||
showError(message)
|
||||
}
|
||||
function onSuccess(path){
|
||||
FluTools.showFileInFolder(path+"/CMakeLists.txt")
|
||||
FluTools.showFileInFolder(path)
|
||||
window.close()
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ FluWindow {
|
||||
title: "FluentUI"
|
||||
width: 1000
|
||||
height: 680
|
||||
minimumWidth: 520
|
||||
minimumWidth: 1000
|
||||
minimumHeight: 200
|
||||
launchMode: FluWindowType.SingleTask
|
||||
fitsAppBarWindows: true
|
||||
@ -28,6 +28,10 @@ FluWindow {
|
||||
z:7
|
||||
}
|
||||
|
||||
FluentInitializrWindow{
|
||||
id:fluent_Initializr
|
||||
}
|
||||
|
||||
FluEvent{
|
||||
name: "checkUpdate"
|
||||
onTriggered: {
|
||||
|
@ -1,17 +1,15 @@
|
||||
#include "AppInfo.h"
|
||||
|
||||
#include <QQmlContext>
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
#include "Version.h"
|
||||
|
||||
AppInfo::AppInfo(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
: QObject{parent} {
|
||||
version(APPLICATION_VERSION);
|
||||
}
|
||||
|
||||
void AppInfo::testCrash(){
|
||||
[[maybe_unused]] void AppInfo::testCrash() {
|
||||
auto *crash = reinterpret_cast<volatile int *>(0);
|
||||
*crash = 0;
|
||||
}
|
||||
|
@ -1,20 +1,18 @@
|
||||
#ifndef APPINFO_H
|
||||
#define APPINFO_H
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include "stdafx.h"
|
||||
#include "singleton.h"
|
||||
|
||||
class AppInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString,version)
|
||||
class AppInfo : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString, version)
|
||||
private:
|
||||
explicit AppInfo(QObject *parent = nullptr);
|
||||
public:
|
||||
SINGLETON(AppInfo)
|
||||
Q_INVOKABLE void testCrash();
|
||||
};
|
||||
|
||||
#endif // APPINFO_H
|
||||
public:
|
||||
SINGLETON(AppInfo)
|
||||
|
||||
[[maybe_unused]] Q_INVOKABLE void testCrash();
|
||||
};
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef APP_DUMP_H
|
||||
#define APP_DUMP_H
|
||||
#pragma once
|
||||
|
||||
#include <Windows.h>
|
||||
#include <DbgHelp.h>
|
||||
@ -12,71 +11,69 @@
|
||||
|
||||
#pragma comment(lib, "Dbghelp.lib")
|
||||
|
||||
static void miniDumpWriteDump(HANDLE hProcess,DWORD ProcessId,HANDLE hFile,MINIDUMP_TYPE DumpType,CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam){
|
||||
typedef HRESULT (WINAPI* MiniDumpWriteDumpPtr)(HANDLE hProcess,DWORD ProcessId,HANDLE hFile,MINIDUMP_TYPE DumpType,CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
||||
static void
|
||||
miniDumpWriteDump(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam) {
|
||||
typedef HRESULT (WINAPI *MiniDumpWriteDumpPtr)(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
|
||||
CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
||||
HMODULE module = LoadLibraryW(L"Dbghelp.dll");
|
||||
if (module)
|
||||
{
|
||||
if (module) {
|
||||
MiniDumpWriteDumpPtr mini_dump_write_dump;
|
||||
mini_dump_write_dump= reinterpret_cast<MiniDumpWriteDumpPtr>(GetProcAddress(module, "MiniDumpWriteDump"));
|
||||
if (mini_dump_write_dump)
|
||||
{
|
||||
mini_dump_write_dump(hProcess,ProcessId,hFile,DumpType,ExceptionParam,UserStreamParam,CallbackParam);
|
||||
mini_dump_write_dump = reinterpret_cast<MiniDumpWriteDumpPtr>(GetProcAddress(module, "MiniDumpWriteDump"));
|
||||
if (mini_dump_write_dump) {
|
||||
mini_dump_write_dump(hProcess, ProcessId, hFile, static_cast<MINIDUMP_TYPE>(80), ExceptionParam, nullptr, CallbackParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CALLBACK MyMiniDumpCallback(PVOID, const PMINIDUMP_CALLBACK_INPUT input, PMINIDUMP_CALLBACK_OUTPUT output) {
|
||||
if (input == NULL || output == NULL)
|
||||
if (input == nullptr || output == nullptr)
|
||||
return FALSE;
|
||||
|
||||
BOOL ret = FALSE;
|
||||
switch (input->CallbackType) {
|
||||
case IncludeModuleCallback:
|
||||
case IncludeThreadCallback:
|
||||
case ThreadCallback:
|
||||
case ThreadExCallback:
|
||||
ret = TRUE;
|
||||
break;
|
||||
case ModuleCallback: {
|
||||
if (!(output->ModuleWriteFlags & ModuleReferencedByMemory)) {
|
||||
output->ModuleWriteFlags &= ~ModuleWriteModule;
|
||||
case IncludeModuleCallback:
|
||||
case IncludeThreadCallback:
|
||||
case ThreadCallback:
|
||||
case ThreadExCallback:
|
||||
ret = TRUE;
|
||||
break;
|
||||
case ModuleCallback: {
|
||||
if (!(output->ModuleWriteFlags & ModuleReferencedByMemory)) {
|
||||
output->ModuleWriteFlags &= ~ModuleWriteModule;
|
||||
}
|
||||
ret = TRUE;
|
||||
}
|
||||
ret = TRUE;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WriteDump(EXCEPTION_POINTERS* exp, const std::wstring& path) {
|
||||
HANDLE h = ::CreateFileW(path.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
void WriteDump(EXCEPTION_POINTERS *exp, const std::wstring &path) {
|
||||
HANDLE h = ::CreateFileW(path.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
MINIDUMP_EXCEPTION_INFORMATION info;
|
||||
info.ThreadId = ::GetCurrentThreadId();
|
||||
info.ExceptionPointers = exp;
|
||||
info.ClientPointers = FALSE;
|
||||
MINIDUMP_CALLBACK_INFORMATION mci;
|
||||
mci.CallbackRoutine = (MINIDUMP_CALLBACK_ROUTINE)MyMiniDumpCallback;
|
||||
mci.CallbackParam = 0;
|
||||
MINIDUMP_TYPE mdt = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory);
|
||||
miniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), h, mdt, &info, NULL, &mci);
|
||||
mci.CallbackRoutine = (MINIDUMP_CALLBACK_ROUTINE) MyMiniDumpCallback;
|
||||
mci.CallbackParam = nullptr;
|
||||
miniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), h, &info, &mci);
|
||||
::CloseHandle(h);
|
||||
}
|
||||
|
||||
LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS* exp) {
|
||||
const QString dumpFileName = QString("%1_%2.dmp").arg("crash",QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss"));
|
||||
const QString dumpDirPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)+"/dmp";
|
||||
LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS *exp) {
|
||||
const QString dumpFileName = QString("%1_%2.dmp").arg("crash", QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss"));
|
||||
const QString dumpDirPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/dmp";
|
||||
const QDir dumpDir(dumpDirPath);
|
||||
if(!dumpDir.exists()){
|
||||
if (!dumpDir.exists()) {
|
||||
dumpDir.mkpath(dumpDirPath);
|
||||
}
|
||||
QString dumpFilePath = dumpDir.filePath(dumpFileName);
|
||||
WriteDump(exp, dumpFilePath.toStdWString());
|
||||
QStringList arguments;
|
||||
arguments << "-crashed=" + dumpFilePath;
|
||||
QProcess::startDetached(qApp->applicationFilePath(), arguments);
|
||||
QProcess::startDetached(QGuiApplication::applicationFilePath(), arguments);
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
#endif // APP_DUMP_H
|
||||
}
|
@ -3,43 +3,43 @@
|
||||
#include <QQuickItemGrabResult>
|
||||
#include <QPainterPath>
|
||||
|
||||
CircularReveal::CircularReveal(QQuickItem* parent) : QQuickPaintedItem(parent)
|
||||
{
|
||||
CircularReveal::CircularReveal(QQuickItem *parent) : QQuickPaintedItem(parent) {
|
||||
_target = nullptr;
|
||||
_radius = 0;
|
||||
_anim = new QPropertyAnimation(this, "radius", this);
|
||||
setVisible(false);
|
||||
_anim->setDuration(333);
|
||||
_anim->setEasingCurve(QEasingCurve::OutCubic);
|
||||
connect(_anim, &QPropertyAnimation::finished,this,[=](){
|
||||
setVisible(false);
|
||||
connect(_anim, &QPropertyAnimation::finished, this, [=]() {
|
||||
update();
|
||||
setVisible(false);
|
||||
Q_EMIT animationFinished();
|
||||
});
|
||||
connect(this,&CircularReveal::radiusChanged,this,[=](){
|
||||
connect(this, &CircularReveal::radiusChanged, this, [=]() {
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
void CircularReveal::paint(QPainter* painter)
|
||||
{
|
||||
void CircularReveal::paint(QPainter *painter) {
|
||||
painter->save();
|
||||
painter->drawImage(QRect(0, 0, static_cast<int>(width()), static_cast<int>(height())), _source);
|
||||
QPainterPath path;
|
||||
path.moveTo(_center.x(),_center.y());
|
||||
path.addEllipse(QPointF(_center.x(),_center.y()), _radius, _radius);
|
||||
path.moveTo(_center.x(), _center.y());
|
||||
path.addEllipse(QPointF(_center.x(), _center.y()), _radius, _radius);
|
||||
painter->setCompositionMode(QPainter::CompositionMode_Clear);
|
||||
painter->fillPath(path, Qt::black);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void CircularReveal::start(int w,int h,const QPoint& center,int radius){
|
||||
[[maybe_unused]] void CircularReveal::start(int w, int h, const QPoint ¢er, int radius) {
|
||||
_anim->setStartValue(0);
|
||||
_anim->setEndValue(radius);
|
||||
_center = center;
|
||||
_grabResult = _target->grabToImage(QSize(w,h));
|
||||
_grabResult = _target->grabToImage(QSize(w, h));
|
||||
connect(_grabResult.data(), &QQuickItemGrabResult::ready, this, &CircularReveal::handleGrabResult);
|
||||
}
|
||||
|
||||
void CircularReveal::handleGrabResult(){
|
||||
void CircularReveal::handleGrabResult() {
|
||||
_grabResult.data()->image().swap(_source);
|
||||
update();
|
||||
setVisible(true);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef CIRCULARREVEAL_H
|
||||
#define CIRCULARREVEAL_H
|
||||
#pragma once
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QQuickPaintedItem>
|
||||
@ -7,23 +6,26 @@
|
||||
#include <QPropertyAnimation>
|
||||
#include "src/stdafx.h"
|
||||
|
||||
class CircularReveal : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QQuickItem*,target)
|
||||
Q_PROPERTY_AUTO(int,radius)
|
||||
class CircularReveal : public QQuickPaintedItem {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO_P(QQuickItem*, target)
|
||||
Q_PROPERTY_AUTO(int, radius)
|
||||
public:
|
||||
CircularReveal(QQuickItem* parent = nullptr);
|
||||
void paint(QPainter* painter) override;
|
||||
Q_INVOKABLE void start(int w,int h,const QPoint& center,int radius);
|
||||
explicit CircularReveal(QQuickItem *parent = nullptr);
|
||||
|
||||
void paint(QPainter *painter) override;
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void start(int w, int h, const QPoint ¢er, int radius);
|
||||
|
||||
Q_SIGNAL void imageChanged();
|
||||
|
||||
Q_SIGNAL void animationFinished();
|
||||
|
||||
Q_SLOT void handleGrabResult();
|
||||
|
||||
private:
|
||||
QPropertyAnimation* _anim = nullptr;
|
||||
QPropertyAnimation *_anim = nullptr;
|
||||
QImage _source;
|
||||
QPoint _center;
|
||||
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
||||
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
||||
};
|
||||
|
||||
#endif // CIRCULARREVEAL_H
|
||||
|
@ -1,24 +1,23 @@
|
||||
#include "FileWatcher.h"
|
||||
|
||||
FileWatcher::FileWatcher(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path){
|
||||
FileWatcher::FileWatcher(QObject *parent) : QObject{parent} {
|
||||
connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path) {
|
||||
Q_EMIT fileChanged();
|
||||
clean();
|
||||
_watcher.addPath(_path);
|
||||
});
|
||||
connect(this,&FileWatcher::pathChanged,this,[=](){
|
||||
connect(this, &FileWatcher::pathChanged, this, [=]() {
|
||||
clean();
|
||||
_watcher.addPath(_path.replace("file:///",""));
|
||||
_watcher.addPath(_path.replace("file:///", ""));
|
||||
});
|
||||
if(!_path.isEmpty()){
|
||||
if (!_path.isEmpty()) {
|
||||
_watcher.addPath(_path);
|
||||
}
|
||||
}
|
||||
|
||||
void FileWatcher::clean(){
|
||||
foreach (const QString &item, _watcher.files()) {
|
||||
void FileWatcher::clean() {
|
||||
for (int i = 0; i <= _watcher.files().size() - 1; ++i) {
|
||||
auto item = _watcher.files().at(i);
|
||||
_watcher.removePath(item);
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,21 @@
|
||||
#ifndef FILEWATCHER_H
|
||||
#define FILEWATCHER_H
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QtQml/qqml.h>
|
||||
#include "src/stdafx.h"
|
||||
|
||||
class FileWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString,path);
|
||||
class FileWatcher : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString, path);
|
||||
public:
|
||||
explicit FileWatcher(QObject *parent = nullptr);
|
||||
|
||||
Q_SIGNAL void fileChanged();
|
||||
|
||||
private:
|
||||
void clean();
|
||||
|
||||
private:
|
||||
QFileSystemWatcher _watcher;
|
||||
};
|
||||
|
||||
#endif // FILEWATCHER_H
|
||||
|
@ -3,16 +3,16 @@
|
||||
#include <QTimer>
|
||||
#include <QQuickWindow>
|
||||
|
||||
FpsItem::FpsItem()
|
||||
{
|
||||
QTimer *timer = new QTimer(this);
|
||||
connect(timer, &QTimer::timeout, this, [this]{
|
||||
FpsItem::FpsItem() {
|
||||
_fps = 0;
|
||||
auto *timer = new QTimer(this);
|
||||
connect(timer, &QTimer::timeout, this, [this] {
|
||||
fps(_frameCount);
|
||||
_frameCount = 0;
|
||||
});
|
||||
connect(this, &QQuickItem::windowChanged, this, [this]{
|
||||
if (window()){
|
||||
connect(window(), &QQuickWindow::afterRendering, this, [this]{ _frameCount++; }, Qt::DirectConnection);
|
||||
connect(this, &QQuickItem::windowChanged, this, [this] {
|
||||
if (window()) {
|
||||
connect(window(), &QQuickWindow::afterRendering, this, [this] { _frameCount++; }, Qt::DirectConnection);
|
||||
}
|
||||
});
|
||||
timer->start(1000);
|
||||
|
@ -1,19 +1,15 @@
|
||||
#ifndef FPSITEM_H
|
||||
#define FPSITEM_H
|
||||
#pragma once
|
||||
|
||||
#include <QQuickItem>
|
||||
#include "src/stdafx.h"
|
||||
|
||||
class FpsItem : public QQuickItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int,fps)
|
||||
class FpsItem : public QQuickItem {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int, fps)
|
||||
public:
|
||||
FpsItem();
|
||||
|
||||
private:
|
||||
int _frameCount = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // FPSITEM_H
|
||||
};
|
93
example/src/component/OpenGLItem.cpp
Normal file
93
example/src/component/OpenGLItem.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
#include "OpenGLItem.h"
|
||||
|
||||
#include <QOpenGLFramebufferObjectFormat>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
class FBORenderer : public QQuickFramebufferObject::Renderer, protected QOpenGLFunctions {
|
||||
public:
|
||||
explicit FBORenderer(const OpenGLItem *item);
|
||||
|
||||
void render() override;
|
||||
|
||||
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) override;
|
||||
|
||||
QOpenGLShaderProgram program;
|
||||
const OpenGLItem *item = nullptr;
|
||||
};
|
||||
|
||||
FBORenderer::FBORenderer(const OpenGLItem *item) {
|
||||
this->item = item;
|
||||
initializeOpenGLFunctions();
|
||||
program.addCacheableShaderFromSourceCode(QOpenGLShader::Vertex,
|
||||
"attribute highp vec4 vertices;"
|
||||
"varying highp vec2 coords;"
|
||||
"void main() {"
|
||||
" gl_Position = vertices;"
|
||||
" coords = vertices.xy;"
|
||||
"}");
|
||||
program.addCacheableShaderFromSourceCode(QOpenGLShader::Fragment,
|
||||
"uniform lowp float t;"
|
||||
"varying highp vec2 coords;"
|
||||
"void main() {"
|
||||
" lowp float i = 1. - (pow(abs(coords.x), 4.) + pow(abs(coords.y), 4.));"
|
||||
" i = smoothstep(t - 0.8, t + 0.8, i);"
|
||||
" i = floor(i * 20.) / 20.;"
|
||||
" gl_FragColor = vec4(coords * .5 + .5, i, i);"
|
||||
"}");
|
||||
|
||||
program.bindAttributeLocation("vertices", 0);
|
||||
program.link();
|
||||
}
|
||||
|
||||
QOpenGLFramebufferObject *FBORenderer::createFramebufferObject(const QSize &size) {
|
||||
QOpenGLFramebufferObjectFormat format;
|
||||
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
|
||||
format.setSamples(4);
|
||||
return new QOpenGLFramebufferObject(size, format);
|
||||
}
|
||||
|
||||
void FBORenderer::render() {
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
program.bind();
|
||||
program.enableAttributeArray(0);
|
||||
float values[] = {
|
||||
-1, -1,
|
||||
1, -1,
|
||||
-1, 1,
|
||||
1, 1
|
||||
};
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
program.setAttributeArray(0, GL_FLOAT, values, 2);
|
||||
program.setUniformValue("t", (float) item->t());
|
||||
glViewport(0, 0, qRound(item->width()), qRound(item->height()));
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
program.disableAttributeArray(0);
|
||||
program.release();
|
||||
}
|
||||
|
||||
|
||||
OpenGLItem::OpenGLItem(QQuickItem *parent) : QQuickFramebufferObject(parent) {
|
||||
setMirrorVertically(true);
|
||||
startTimer(1);
|
||||
}
|
||||
|
||||
void OpenGLItem::timerEvent(QTimerEvent *) {
|
||||
update();
|
||||
}
|
||||
|
||||
void OpenGLItem::setT(qreal t) {
|
||||
if (t == m_t)
|
||||
return;
|
||||
m_t = t;
|
||||
emit tChanged();
|
||||
}
|
||||
|
||||
|
||||
QQuickFramebufferObject::Renderer *OpenGLItem::createRenderer() const {
|
||||
return new FBORenderer(this);
|
||||
}
|
29
example/src/component/OpenGLItem.h
Normal file
29
example/src/component/OpenGLItem.h
Normal file
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtQuick/QQuickItem>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QQuickFramebufferObject>
|
||||
|
||||
class FBORenderer;
|
||||
|
||||
class OpenGLItem : public QQuickFramebufferObject, protected QOpenGLFunctions {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
|
||||
public:
|
||||
explicit OpenGLItem(QQuickItem *parent = nullptr);
|
||||
|
||||
[[nodiscard]] QQuickFramebufferObject::Renderer *createRenderer() const override;
|
||||
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
|
||||
[[nodiscard]] qreal t() const { return m_t; }
|
||||
|
||||
void setT(qreal t);
|
||||
|
||||
signals:
|
||||
|
||||
void tChanged();
|
||||
|
||||
private:
|
||||
qreal m_t{};
|
||||
};
|
@ -3,55 +3,47 @@
|
||||
#include <QDir>
|
||||
#include <QGuiApplication>
|
||||
|
||||
InitializrHelper::InitializrHelper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
[[maybe_unused]] InitializrHelper::InitializrHelper(QObject *parent) : QObject(parent) {
|
||||
|
||||
}
|
||||
|
||||
InitializrHelper::~InitializrHelper() = default;
|
||||
|
||||
bool InitializrHelper::copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists){
|
||||
QDir _formDir = fromDir;
|
||||
bool InitializrHelper::copyDir(const QDir &fromDir, const QDir &toDir, bool coverIfFileExists) {
|
||||
const QDir &_formDir = fromDir;
|
||||
QDir _toDir = toDir;
|
||||
if(!_toDir.exists())
|
||||
{
|
||||
if(!_toDir.mkdir(toDir.absolutePath()))
|
||||
if (!_toDir.exists()) {
|
||||
if (!_toDir.mkdir(toDir.absolutePath()))
|
||||
return false;
|
||||
}
|
||||
QFileInfoList fileInfoList = _formDir.entryInfoList();
|
||||
foreach(QFileInfo fileInfo, fileInfoList)
|
||||
{
|
||||
if(fileInfo.fileName() == "." || fileInfo.fileName() == "..")
|
||||
continue;
|
||||
if(fileInfo.isDir())
|
||||
{
|
||||
if(!copyDir(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()),true))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(coverIfFileExists && _toDir.exists(fileInfo.fileName()))
|
||||
{
|
||||
_toDir.remove(fileInfo.fileName());
|
||||
}
|
||||
if(!QFile::copy(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName())))
|
||||
{
|
||||
return false;
|
||||
foreach(QFileInfo fileInfo, fileInfoList) {
|
||||
if (fileInfo.fileName() == "." || fileInfo.fileName() == "..")
|
||||
continue;
|
||||
if (fileInfo.isDir()) {
|
||||
if (!copyDir(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()), true))
|
||||
return false;
|
||||
} else {
|
||||
if (coverIfFileExists && _toDir.exists(fileInfo.fileName())) {
|
||||
_toDir.remove(fileInfo.fileName());
|
||||
}
|
||||
if (!QFile::copy(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename...Args>
|
||||
void InitializrHelper::templateToFile(const QString& source,const QString& dest,Args &&...args){
|
||||
template<typename...Args>
|
||||
void InitializrHelper::templateToFile(const QString &source, const QString &dest, Args &&...args) {
|
||||
QFile file(source);
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&file);
|
||||
QString content = in.readAll().arg(std::forward<Args>(args)...);
|
||||
file.close();
|
||||
QDir outputDir = QFileInfo(dest).absoluteDir();
|
||||
if(!outputDir.exists()){
|
||||
if (!outputDir.exists()) {
|
||||
outputDir.mkpath(outputDir.absolutePath());
|
||||
}
|
||||
QFile outputFile(dest);
|
||||
@ -67,43 +59,43 @@ void InitializrHelper::templateToFile(const QString& source,const QString& dest,
|
||||
}
|
||||
}
|
||||
|
||||
void InitializrHelper::copyFile(const QString& source,const QString& dest){
|
||||
QFile::copy(source,dest);
|
||||
void InitializrHelper::copyFile(const QString &source, const QString &dest) {
|
||||
QFile::copy(source, dest);
|
||||
QFile::setPermissions(dest, QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther);
|
||||
}
|
||||
|
||||
void InitializrHelper::generate(const QString& name,const QString& path){
|
||||
if(name.isEmpty()){
|
||||
[[maybe_unused]] void InitializrHelper::generate(const QString &name, const QString &path) {
|
||||
if (name.isEmpty()) {
|
||||
error(tr("The name cannot be empty"));
|
||||
return;
|
||||
}
|
||||
if(path.isEmpty()){
|
||||
if (path.isEmpty()) {
|
||||
error(tr("The creation path cannot be empty"));
|
||||
return;
|
||||
}
|
||||
QDir projectRootDir(path);
|
||||
if(!projectRootDir.exists()){
|
||||
if (!projectRootDir.exists()) {
|
||||
error(tr("The path does not exist"));
|
||||
return;
|
||||
}
|
||||
QString projectPath = projectRootDir.filePath(name);
|
||||
QDir projectDir(projectPath);
|
||||
if(projectDir.exists()){
|
||||
if (projectDir.exists()) {
|
||||
error(tr("%1 folder already exists").arg(name));
|
||||
return;
|
||||
}
|
||||
projectDir.mkpath(projectPath);
|
||||
QDir fluentDir(projectDir.filePath("FluentUI"));
|
||||
copyDir(QDir(QGuiApplication::applicationDirPath()+"/source"),fluentDir);
|
||||
templateToFile(":/example/res/template/CMakeLists.txt.in",projectDir.filePath("CMakeLists.txt"),name);
|
||||
templateToFile(":/example/res/template/src/CMakeLists.txt.in",projectDir.filePath("src/CMakeLists.txt"),name);
|
||||
templateToFile(":/example/res/template/src/main.cpp.in",projectDir.filePath("src/main.cpp"),name);
|
||||
templateToFile(":/example/res/template/src/main.qml.in",projectDir.filePath("src/main.qml"),name);
|
||||
templateToFile(":/example/res/template/src/en_US.ts.in",projectDir.filePath("src/"+name+"_en_US.ts"),name);
|
||||
templateToFile(":/example/res/template/src/zh_CN.ts.in",projectDir.filePath("src/"+name+"_zh_CN.ts"),name);
|
||||
copyFile(":/example/res/template/src/App.qml.in",projectDir.filePath("src/App.qml"));
|
||||
copyFile(":/example/res/template/src/qml.qrc.in",projectDir.filePath("src/qml.qrc"));
|
||||
copyFile(":/example/res/template/src/logo.ico.in",projectDir.filePath("src/logo.ico"));
|
||||
copyFile(":/example/res/template/src/README.md.in",projectDir.filePath("src/README.md"));
|
||||
return this->success(projectPath);
|
||||
copyDir(QDir(QGuiApplication::applicationDirPath() + "/source"), fluentDir);
|
||||
templateToFile(":/example/res/template/CMakeLists.txt.in", projectDir.filePath("CMakeLists.txt"), name);
|
||||
templateToFile(":/example/res/template/src/CMakeLists.txt.in", projectDir.filePath("src/CMakeLists.txt"), name);
|
||||
templateToFile(":/example/res/template/src/main.cpp.in", projectDir.filePath("src/main.cpp"), name);
|
||||
templateToFile(":/example/res/template/src/main.qml.in", projectDir.filePath("src/main.qml"), name);
|
||||
templateToFile(":/example/res/template/src/en_US.ts.in", projectDir.filePath("src/" + name + "_en_US.ts"), name);
|
||||
templateToFile(":/example/res/template/src/zh_CN.ts.in", projectDir.filePath("src/" + name + "_zh_CN.ts"), name);
|
||||
copyFile(":/example/res/template/src/App.qml.in", projectDir.filePath("src/App.qml"));
|
||||
copyFile(":/example/res/template/src/qml.qrc.in", projectDir.filePath("src/qml.qrc"));
|
||||
copyFile(":/example/res/template/src/logo.ico.in", projectDir.filePath("src/logo.ico"));
|
||||
copyFile(":/example/res/template/src/README.md.in", projectDir.filePath("src/README.md"));
|
||||
return this->success(projectPath+"/CMakeLists.txt");
|
||||
}
|
||||
|
@ -1,26 +1,30 @@
|
||||
#ifndef INITIALIZRHELPER_H
|
||||
#define INITIALIZRHELPER_H
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QDir>
|
||||
#include "src/singleton.h"
|
||||
|
||||
class InitializrHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
class InitializrHelper : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
explicit InitializrHelper(QObject* parent = nullptr);
|
||||
bool copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists = true);
|
||||
void copyFile(const QString& source,const QString& dest);
|
||||
template <typename...Args>
|
||||
void templateToFile(const QString& source,const QString& dest,Args &&...args);
|
||||
public:
|
||||
SINGLETON(InitializrHelper)
|
||||
~InitializrHelper() override;
|
||||
Q_INVOKABLE void generate(const QString& name,const QString& path);
|
||||
Q_SIGNAL void error(const QString& message);
|
||||
Q_SIGNAL void success(const QString& path);
|
||||
};
|
||||
[[maybe_unused]] explicit InitializrHelper(QObject *parent = nullptr);
|
||||
|
||||
#endif // INITIALIZRHELPER_H
|
||||
bool copyDir(const QDir &fromDir, const QDir &toDir, bool coverIfFileExists = true);
|
||||
|
||||
static void copyFile(const QString &source, const QString &dest);
|
||||
|
||||
template<typename...Args>
|
||||
void templateToFile(const QString &source, const QString &dest, Args &&...args);
|
||||
|
||||
public:
|
||||
SINGLETON(InitializrHelper)
|
||||
|
||||
~InitializrHelper() override;
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void generate(const QString &name, const QString &path);
|
||||
|
||||
Q_SIGNAL void error(const QString &message);
|
||||
|
||||
Q_SIGNAL void success(const QString &path);
|
||||
};
|
||||
|
@ -11,8 +11,11 @@
|
||||
#include <QSettings>
|
||||
#include <QRegularExpression>
|
||||
#include "Version.h"
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <process.h>
|
||||
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -26,7 +29,7 @@
|
||||
#endif
|
||||
|
||||
static QString g_app = {};
|
||||
static QString g_file_path= {};
|
||||
static QString g_file_path = {};
|
||||
static bool g_logError = false;
|
||||
|
||||
static std::unique_ptr<QFile> g_logFile = nullptr;
|
||||
@ -35,15 +38,14 @@ static std::unique_ptr<QTextStream> g_logStream = nullptr;
|
||||
static int g_logLevel = 4;
|
||||
|
||||
std::map<QtMsgType, int> logLevelMap = {
|
||||
{QtFatalMsg,0},
|
||||
{QtCriticalMsg,1},
|
||||
{QtWarningMsg,2},
|
||||
{QtInfoMsg,3},
|
||||
{QtDebugMsg,4}
|
||||
{QtFatalMsg, 0},
|
||||
{QtCriticalMsg, 1},
|
||||
{QtWarningMsg, 2},
|
||||
{QtInfoMsg, 3},
|
||||
{QtDebugMsg, 4}
|
||||
};
|
||||
|
||||
QString Log::prettyProductInfoWrapper()
|
||||
{
|
||||
QString Log::prettyProductInfoWrapper() {
|
||||
auto productName = QSysInfo::prettyProductName();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
|
||||
#if defined(Q_OS_MACOS)
|
||||
@ -70,20 +72,17 @@ QString Log::prettyProductInfoWrapper()
|
||||
#endif
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
QSettings regKey {QString::fromUtf8("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), QSettings::NativeFormat};
|
||||
QSettings regKey{QString::fromUtf8(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion)"), QSettings::NativeFormat};
|
||||
if (regKey.contains(QString::fromUtf8("CurrentBuildNumber"))) {
|
||||
auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt();
|
||||
if (buildNumber > 0) {
|
||||
if (buildNumber < 9200) {
|
||||
productName = QString::fromUtf8("Windows 7 build %1").arg(buildNumber);
|
||||
}
|
||||
else if (buildNumber < 10240) {
|
||||
} else if (buildNumber < 10240) {
|
||||
productName = QString::fromUtf8("Windows 8 build %1").arg(buildNumber);
|
||||
}
|
||||
else if (buildNumber < 22000) {
|
||||
} else if (buildNumber < 22000) {
|
||||
productName = QString::fromUtf8("Windows 10 build %1").arg(buildNumber);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
productName = QString::fromUtf8("Windows 11 build %1").arg(buildNumber);
|
||||
}
|
||||
}
|
||||
@ -92,56 +91,55 @@ QString Log::prettyProductInfoWrapper()
|
||||
return productName;
|
||||
}
|
||||
|
||||
static inline void messageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message)
|
||||
{
|
||||
if(message == "Could not get the INetworkConnection instance for the adapter GUID."){
|
||||
static inline void messageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message) {
|
||||
if (message == "Could not get the INetworkConnection instance for the adapter GUID.") {
|
||||
return;
|
||||
}
|
||||
if(logLevelMap[type]>g_logLevel){
|
||||
if (logLevelMap[type] > g_logLevel) {
|
||||
return;
|
||||
}
|
||||
if (!message.isEmpty()) {
|
||||
QString levelName;
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
levelName = QStringLiteral("Debug");
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
levelName = QStringLiteral("Info");
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
levelName = QStringLiteral("Warning");
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
levelName = QStringLiteral("Critical");
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
levelName = QStringLiteral("Fatal");
|
||||
break;
|
||||
case QtDebugMsg:
|
||||
levelName = QStringLiteral("Debug");
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
levelName = QStringLiteral("Info");
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
levelName = QStringLiteral("Warning");
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
levelName = QStringLiteral("Critical");
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
levelName = QStringLiteral("Fatal");
|
||||
break;
|
||||
}
|
||||
QString fileAndLineLogStr;
|
||||
if(context.file){
|
||||
if (context.file) {
|
||||
std::string strFileTmp = context.file;
|
||||
const char* ptr = strrchr(strFileTmp.c_str(), '/');
|
||||
const char *ptr = strrchr(strFileTmp.c_str(), '/');
|
||||
if (nullptr != ptr) {
|
||||
char fn[512] = {0};
|
||||
sprintf(fn, "%s", ptr + 1);
|
||||
strFileTmp = fn;
|
||||
}
|
||||
const char* ptrTmp = strrchr(strFileTmp.c_str(), '\\');
|
||||
const char *ptrTmp = strrchr(strFileTmp.c_str(), '\\');
|
||||
if (nullptr != ptrTmp) {
|
||||
char fn[512] = {0};
|
||||
sprintf(fn, "%s", ptrTmp + 1);
|
||||
strFileTmp = fn;
|
||||
}
|
||||
fileAndLineLogStr = QString::fromStdString("[%1:%2]").arg(QString::fromStdString(strFileTmp),QString::number(context.line));
|
||||
fileAndLineLogStr = QString::fromStdString("[%1:%2]").arg(QString::fromStdString(strFileTmp), QString::number(context.line));
|
||||
}
|
||||
const QString finalMessage = QString::fromStdString("%1[%2]%3[%4]:%5").arg(
|
||||
QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss.zzz"),
|
||||
levelName,
|
||||
fileAndLineLogStr,
|
||||
QString::number(reinterpret_cast<quintptr>(QThread::currentThreadId())),
|
||||
message);
|
||||
QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss.zzz"),
|
||||
levelName,
|
||||
fileAndLineLogStr,
|
||||
QString::number(reinterpret_cast<quintptr>(QThread::currentThreadId())),
|
||||
message);
|
||||
if ((type == QtInfoMsg) || (type == QtDebugMsg)) {
|
||||
std::cout << qPrintable(finalMessage) << std::endl;
|
||||
} else {
|
||||
@ -168,8 +166,7 @@ static inline void messageHandler(const QtMsgType type, const QMessageLogContext
|
||||
}
|
||||
}
|
||||
|
||||
void Log::setup(char *argv[],const QString &app,int level)
|
||||
{
|
||||
void Log::setup(char *argv[], const QString &app, int level) {
|
||||
Q_ASSERT(!app.isEmpty());
|
||||
if (app.isEmpty()) {
|
||||
return;
|
||||
@ -182,30 +179,30 @@ void Log::setup(char *argv[],const QString &app,int level)
|
||||
QString applicationPath = QString::fromStdString(argv[0]);
|
||||
once = true;
|
||||
g_app = app;
|
||||
const QString logFileName = QString("%1_%2.log").arg(g_app,QDateTime::currentDateTime().toString("yyyyMMdd"));
|
||||
const QString logDirPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)+"/log";
|
||||
const QString logFileName = QString("%1_%2.log").arg(g_app, QDateTime::currentDateTime().toString("yyyyMMdd"));
|
||||
const QString logDirPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/log";
|
||||
const QDir logDir(logDirPath);
|
||||
if(!logDir.exists()){
|
||||
if (!logDir.exists()) {
|
||||
logDir.mkpath(logDirPath);
|
||||
}
|
||||
g_file_path = logDir.filePath(logFileName);
|
||||
qInstallMessageHandler(messageHandler);
|
||||
qInfo()<<"===================================================";
|
||||
qInfo()<<"[AppName]"<<g_app;
|
||||
qInfo()<<"[AppVersion]"<<APPLICATION_VERSION;
|
||||
qInfo()<<"[AppPath]"<<applicationPath;
|
||||
qInfo()<<"[QtVersion]"<<QT_VERSION_STR;
|
||||
qInfo() << "===================================================";
|
||||
qInfo() << "[AppName]" << g_app;
|
||||
qInfo() << "[AppVersion]" << APPLICATION_VERSION;
|
||||
qInfo() << "[AppPath]" << applicationPath;
|
||||
qInfo() << "[QtVersion]" << QT_VERSION_STR;
|
||||
#ifdef WIN32
|
||||
qInfo()<<"[ProcessId]"<<QString::number(_getpid());
|
||||
qInfo() << "[ProcessId]" << QString::number(_getpid());
|
||||
#else
|
||||
qInfo()<<"[ProcessId]"<<QString::number(getpid());
|
||||
#endif
|
||||
qInfo()<<"[GitHashCode]"<<COMMIT_HASH;
|
||||
qInfo()<<"[DeviceInfo]";
|
||||
qInfo()<<" [DeviceId]"<<QSysInfo::machineUniqueId();
|
||||
qInfo()<<" [Manufacturer]"<<prettyProductInfoWrapper();
|
||||
qInfo()<<" [CPU_ABI]"<<QSysInfo::currentCpuArchitecture();
|
||||
qInfo()<<"[LOG_LEVEL]"<<g_logLevel;
|
||||
qInfo()<<"[LOG_PATH]"<<g_file_path;
|
||||
qInfo()<<"===================================================";
|
||||
qInfo() << "[GitHashCode]" << COMMIT_HASH;
|
||||
qInfo() << "[DeviceInfo]";
|
||||
qInfo() << " [DeviceId]" << QSysInfo::machineUniqueId();
|
||||
qInfo() << " [Manufacturer]" << prettyProductInfoWrapper();
|
||||
qInfo() << " [CPU_ABI]" << QSysInfo::currentCpuArchitecture();
|
||||
qInfo() << "[LOG_LEVEL]" << g_logLevel;
|
||||
qInfo() << "[LOG_PATH]" << g_file_path;
|
||||
qInfo() << "===================================================";
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
namespace Log
|
||||
{
|
||||
namespace Log {
|
||||
QString prettyProductInfoWrapper();
|
||||
void setup(char *argv[], const QString &app,int level = 4);
|
||||
}
|
||||
|
||||
#endif // LOG_H
|
||||
void setup(char *argv[], const QString &app, int level = 4);
|
||||
}
|
@ -17,175 +17,174 @@
|
||||
#include <QCryptographicHash>
|
||||
#include <QEventLoop>
|
||||
#include <QGuiApplication>
|
||||
#include <utility>
|
||||
|
||||
NetworkCallable::NetworkCallable(QObject *parent):QObject{parent}{
|
||||
|
||||
NetworkCallable::NetworkCallable(QObject *parent) : QObject{parent} {
|
||||
|
||||
}
|
||||
|
||||
QString NetworkParams::method2String(){
|
||||
QString NetworkParams::method2String() const {
|
||||
switch (_method) {
|
||||
case METHOD_GET:
|
||||
return "GET";
|
||||
case METHOD_HEAD:
|
||||
return "HEAD";
|
||||
case METHOD_POST:
|
||||
return "POST";
|
||||
case METHOD_PUT:
|
||||
return "PUT";
|
||||
case METHOD_PATCH:
|
||||
return "PATCH";
|
||||
case METHOD_DELETE:
|
||||
return "DELETE";
|
||||
default:
|
||||
return "";
|
||||
case METHOD_GET:
|
||||
return "GET";
|
||||
case METHOD_HEAD:
|
||||
return "HEAD";
|
||||
case METHOD_POST:
|
||||
return "POST";
|
||||
case METHOD_PUT:
|
||||
return "PUT";
|
||||
case METHOD_PATCH:
|
||||
return "PATCH";
|
||||
case METHOD_DELETE:
|
||||
return "DELETE";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
int NetworkParams::getTimeout(){
|
||||
if(_timeout != -1){
|
||||
int NetworkParams::getTimeout() const {
|
||||
if (_timeout != -1) {
|
||||
return _timeout;
|
||||
}
|
||||
return Network::getInstance()->timeout();
|
||||
}
|
||||
|
||||
int NetworkParams::getRetry(){
|
||||
if(_retry != -1){
|
||||
int NetworkParams::getRetry() const {
|
||||
if (_retry != -1) {
|
||||
return _retry;
|
||||
}
|
||||
return Network::getInstance()->retry();
|
||||
}
|
||||
|
||||
bool NetworkParams::getOpenLog(){
|
||||
if(!_openLog.isNull()){
|
||||
bool NetworkParams::getOpenLog() const {
|
||||
if (!_openLog.isNull()) {
|
||||
return _openLog.toBool();
|
||||
}
|
||||
return Network::getInstance()->openLog();
|
||||
}
|
||||
|
||||
FluDownloadParam::FluDownloadParam(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
: QObject{parent} {
|
||||
}
|
||||
|
||||
FluDownloadParam::FluDownloadParam(QString destPath,bool append,QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
this->_destPath = destPath;
|
||||
FluDownloadParam::FluDownloadParam(QString destPath, bool append, QObject *parent)
|
||||
: QObject{parent} {
|
||||
this->_destPath = std::move(destPath);
|
||||
this->_append = append;
|
||||
}
|
||||
|
||||
NetworkParams::NetworkParams(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
NetworkParams::NetworkParams(QObject *parent) : QObject{parent} {
|
||||
_method = NetworkParams::Method::METHOD_GET;
|
||||
_type = NetworkParams::Type::TYPE_BODY;
|
||||
}
|
||||
|
||||
NetworkParams::NetworkParams(QString url,Type type,Method method,QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
NetworkParams::NetworkParams(QString url, Type type, Method method, QObject *parent)
|
||||
: QObject{parent} {
|
||||
this->_method = method;
|
||||
this->_url = url;
|
||||
this->_url = std::move(url);
|
||||
this->_type = type;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::add(QString key,QVariant val){
|
||||
_paramMap.insert(key,val);
|
||||
NetworkParams *NetworkParams::add(const QString &key, const QVariant &val) {
|
||||
_paramMap.insert(key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::addFile(QString key,QVariant val){
|
||||
_fileMap.insert(key,val);
|
||||
NetworkParams *NetworkParams::addFile(const QString &key, const QVariant &val) {
|
||||
_fileMap.insert(key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::addHeader(QString key,QVariant val){
|
||||
_headerMap.insert(key,val);
|
||||
NetworkParams *NetworkParams::addHeader(const QString &key, const QVariant &val) {
|
||||
_headerMap.insert(key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::addQuery(QString key,QVariant val){
|
||||
_queryMap.insert(key,val);
|
||||
NetworkParams *NetworkParams::addQuery(const QString &key, const QVariant &val) {
|
||||
_queryMap.insert(key, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::setBody(QString val){
|
||||
_body = val;
|
||||
NetworkParams *NetworkParams::setBody(QString val) {
|
||||
_body = std::move(val);
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::setTimeout(int val){
|
||||
NetworkParams *NetworkParams::setTimeout(int val) {
|
||||
_timeout = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::setRetry(int val){
|
||||
NetworkParams *NetworkParams::setRetry(int val) {
|
||||
_retry = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::setCacheMode(int val){
|
||||
NetworkParams *NetworkParams::setCacheMode(int val) {
|
||||
_cacheMode = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::toDownload(QString destPath,bool append){
|
||||
_downloadParam = new FluDownloadParam(destPath,append,this);
|
||||
NetworkParams *NetworkParams::toDownload(QString destPath, bool append) {
|
||||
_downloadParam = new FluDownloadParam(std::move(destPath), append, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::bind(QObject* target){
|
||||
NetworkParams *NetworkParams::bind(QObject *target) {
|
||||
_target = target;
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::openLog(QVariant val){
|
||||
_openLog = val;
|
||||
NetworkParams *NetworkParams::openLog(QVariant val) {
|
||||
_openLog = std::move(val);
|
||||
return this;
|
||||
}
|
||||
|
||||
QString NetworkParams::buildCacheKey(){
|
||||
QString NetworkParams::buildCacheKey() const {
|
||||
QJsonObject obj;
|
||||
obj.insert("url",_url);
|
||||
obj.insert("method",method2String());
|
||||
obj.insert("body",_body);
|
||||
obj.insert("query",QJsonDocument::fromVariant(_queryMap).object());
|
||||
obj.insert("param",QJsonDocument::fromVariant(_paramMap).object());
|
||||
obj.insert("header",QJsonDocument::fromVariant(_headerMap).object());
|
||||
obj.insert("file",QJsonDocument::fromVariant(_fileMap).object());
|
||||
if(_downloadParam){
|
||||
obj.insert("url", _url);
|
||||
obj.insert("method", method2String());
|
||||
obj.insert("body", _body);
|
||||
obj.insert("query", QJsonDocument::fromVariant(_queryMap).object());
|
||||
obj.insert("param", QJsonDocument::fromVariant(_paramMap).object());
|
||||
obj.insert("header", QJsonDocument::fromVariant(_headerMap).object());
|
||||
obj.insert("file", QJsonDocument::fromVariant(_fileMap).object());
|
||||
if (_downloadParam) {
|
||||
QJsonObject downObj;
|
||||
downObj.insert("destPath",_downloadParam->_destPath);
|
||||
downObj.insert("append",_downloadParam->_append);
|
||||
obj.insert("download",downObj);
|
||||
downObj.insert("destPath", _downloadParam->_destPath);
|
||||
downObj.insert("append", _downloadParam->_append);
|
||||
obj.insert("download", downObj);
|
||||
}
|
||||
QByteArray data = QJsonDocument(obj).toJson(QJsonDocument::Compact);
|
||||
return QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex();
|
||||
}
|
||||
|
||||
void NetworkParams::go(NetworkCallable* callable){
|
||||
void NetworkParams::go(NetworkCallable *callable) {
|
||||
QJSValueList data;
|
||||
data<<qjsEngine(callable)->newQObject(this);
|
||||
data << qjsEngine(callable)->newQObject(this);
|
||||
Network::getInstance()->_interceptor.call(data);
|
||||
if(_downloadParam){
|
||||
Network::getInstance()->handleDownload(this,callable);
|
||||
}else{
|
||||
Network::getInstance()->handle(this,callable);
|
||||
if (_downloadParam) {
|
||||
Network::getInstance()->handleDownload(this, callable);
|
||||
} else {
|
||||
Network::getInstance()->handle(this, callable);
|
||||
}
|
||||
}
|
||||
|
||||
void Network::handle(NetworkParams* params,NetworkCallable* c){
|
||||
void Network::handle(NetworkParams *params, NetworkCallable *c) {
|
||||
QPointer<NetworkCallable> callable(c);
|
||||
QThreadPool::globalInstance()->start([=](){
|
||||
if(!callable.isNull()){
|
||||
QThreadPool::globalInstance()->start([=]() {
|
||||
if (!callable.isNull()) {
|
||||
callable->start();
|
||||
}
|
||||
QString cacheKey = params->buildCacheKey();
|
||||
if(params->_cacheMode == NetworkType::CacheMode::FirstCacheThenRequest && cacheExists(cacheKey)){
|
||||
if(!callable.isNull()){
|
||||
if (params->_cacheMode == NetworkType::CacheMode::FirstCacheThenRequest && cacheExists(cacheKey)) {
|
||||
if (!callable.isNull()) {
|
||||
callable->cache(readCache(cacheKey));
|
||||
}
|
||||
}
|
||||
if(params->_cacheMode == NetworkType::CacheMode::IfNoneCacheRequest && cacheExists(cacheKey)){
|
||||
if(!callable.isNull()){
|
||||
if (params->_cacheMode == NetworkType::CacheMode::IfNoneCacheRequest && cacheExists(cacheKey)) {
|
||||
if (!callable.isNull()) {
|
||||
callable->cache(readCache(cacheKey));
|
||||
callable->finish();
|
||||
params->deleteLater();
|
||||
@ -195,131 +194,130 @@ void Network::handle(NetworkParams* params,NetworkCallable* c){
|
||||
QNetworkAccessManager manager;
|
||||
manager.setTransferTimeout(params->getTimeout());
|
||||
QEventLoop loop;
|
||||
connect(&manager,&QNetworkAccessManager::finished,&manager,[&loop](QNetworkReply *reply){loop.quit();});
|
||||
for (int i = 0; i < params->getRetry(); ++i) {
|
||||
connect(&manager, &QNetworkAccessManager::finished, &manager, [&loop](QNetworkReply *reply) { loop.quit(); });
|
||||
for (int i = 0; i <= params->getRetry() - 1; ++i) {
|
||||
QUrl url(params->_url);
|
||||
addQueryParam(&url,params->_queryMap);
|
||||
addQueryParam(&url, params->_queryMap);
|
||||
QNetworkRequest request(url);
|
||||
addHeaders(&request,params->_headerMap);
|
||||
QNetworkReply* reply;
|
||||
sendRequest(&manager,request,params,reply,i==0,callable);
|
||||
if(!QPointer<QGuiApplication>(qApp)){
|
||||
addHeaders(&request, params->_headerMap);
|
||||
QNetworkReply *reply;
|
||||
sendRequest(&manager, request, params, reply, i == 0, callable);
|
||||
if (!QPointer<QCoreApplication>(QGuiApplication::instance())) {
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
return;
|
||||
}
|
||||
auto abortCallable = [&loop,reply,&i,params]{
|
||||
if(reply){
|
||||
auto abortCallable = [reply, &i, params] {
|
||||
if (reply) {
|
||||
i = params->getRetry();
|
||||
reply->abort();
|
||||
}
|
||||
};
|
||||
QMetaObject::Connection conn_destroyed = {};
|
||||
QMetaObject::Connection conn_quit = {};
|
||||
if(params->_target){
|
||||
conn_destroyed = connect(params->_target,&QObject::destroyed,&manager,abortCallable);
|
||||
if (params->_target) {
|
||||
conn_destroyed = connect(params->_target, &QObject::destroyed, &manager, abortCallable);
|
||||
}
|
||||
conn_quit = connect(qApp,&QGuiApplication::aboutToQuit,&manager, abortCallable);
|
||||
conn_quit = connect(QGuiApplication::instance(), &QGuiApplication::aboutToQuit, &manager, abortCallable);
|
||||
loop.exec();
|
||||
if(conn_destroyed){
|
||||
if (conn_destroyed) {
|
||||
disconnect(conn_destroyed);
|
||||
}
|
||||
if(conn_quit){
|
||||
if (conn_quit) {
|
||||
disconnect(conn_quit);
|
||||
}
|
||||
QString response;
|
||||
if(params->_method == NetworkParams::METHOD_HEAD){
|
||||
if (params->_method == NetworkParams::METHOD_HEAD) {
|
||||
response = headerList2String(reply->rawHeaderPairs());
|
||||
}else{
|
||||
if(reply->isOpen()){
|
||||
} else {
|
||||
if (reply->isOpen()) {
|
||||
response = QString::fromUtf8(reply->readAll());
|
||||
}
|
||||
}
|
||||
int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if(httpStatus == 200){
|
||||
if(!callable.isNull()){
|
||||
if(params->_cacheMode != NetworkType::CacheMode::NoCache){
|
||||
saveResponse(cacheKey,response);
|
||||
if (httpStatus == 200) {
|
||||
if (!callable.isNull()) {
|
||||
if (params->_cacheMode != NetworkType::CacheMode::NoCache) {
|
||||
saveResponse(cacheKey, response);
|
||||
}
|
||||
callable->success(response);
|
||||
}
|
||||
printRequestEndLog(request,params,reply,response);
|
||||
printRequestEndLog(request, params, reply, response);
|
||||
break;
|
||||
}else{
|
||||
if(i == params->getRetry()-1){
|
||||
if(!callable.isNull()){
|
||||
if(params->_cacheMode == NetworkType::CacheMode::RequestFailedReadCache && cacheExists(cacheKey)){
|
||||
if(!callable.isNull()){
|
||||
} else {
|
||||
if (i == params->getRetry() - 1) {
|
||||
if (!callable.isNull()) {
|
||||
if (params->_cacheMode == NetworkType::CacheMode::RequestFailedReadCache && cacheExists(cacheKey)) {
|
||||
if (!callable.isNull()) {
|
||||
callable->cache(readCache(cacheKey));
|
||||
}
|
||||
}
|
||||
callable->error(httpStatus,reply->errorString(),response);
|
||||
callable->error(httpStatus, reply->errorString(), response);
|
||||
}
|
||||
printRequestEndLog(request,params,reply,response);
|
||||
printRequestEndLog(request, params, reply, response);
|
||||
}
|
||||
}
|
||||
reply->deleteLater();
|
||||
}
|
||||
params->deleteLater();
|
||||
if(!callable.isNull()){
|
||||
if (!callable.isNull()) {
|
||||
callable->finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Network::handleDownload(NetworkParams* params,NetworkCallable* c){
|
||||
void Network::handleDownload(NetworkParams *params, NetworkCallable *c) {
|
||||
QPointer<NetworkCallable> callable(c);
|
||||
QThreadPool::globalInstance()->start([=](){
|
||||
if(!callable.isNull()){
|
||||
QThreadPool::globalInstance()->start([=]() {
|
||||
if (!callable.isNull()) {
|
||||
callable->start();
|
||||
}
|
||||
QString cacheKey = params->buildCacheKey();
|
||||
QUrl url(params->_url);
|
||||
QNetworkAccessManager manager;
|
||||
manager.setTransferTimeout(params->getTimeout());
|
||||
addQueryParam(&url,params->_queryMap);
|
||||
addQueryParam(&url, params->_queryMap);
|
||||
QNetworkRequest request(url);
|
||||
addHeaders(&request,params->_headerMap);
|
||||
addHeaders(&request, params->_headerMap);
|
||||
QString cachePath = getCacheFilePath(cacheKey);
|
||||
QString destPath = params->_downloadParam->_destPath;
|
||||
QFile* destFile = new QFile(destPath);
|
||||
QFile* cacheFile = new QFile(cachePath);
|
||||
bool isOpen = false;
|
||||
qint64 seek = 0;
|
||||
if(cacheFile->exists() && destFile->exists() && params->_downloadParam->_append){
|
||||
auto *destFile = new QFile(destPath);
|
||||
auto *cacheFile = new QFile(cachePath);
|
||||
bool isOpen;
|
||||
qint64 seek;
|
||||
if (cacheFile->exists() && destFile->exists() && params->_downloadParam->_append) {
|
||||
QJsonObject cacheInfo = QJsonDocument::fromJson(readCache(cacheKey).toUtf8()).object();
|
||||
qint64 fileSize = cacheInfo.value("fileSize").toDouble();
|
||||
qint64 contentLength = cacheInfo.value("contentLength").toDouble();
|
||||
if(fileSize == contentLength && destFile->size() == contentLength){
|
||||
if(!callable.isNull()){
|
||||
callable->downloadProgress(fileSize,contentLength);
|
||||
qint64 fileSize = qRound(cacheInfo.value("fileSize").toDouble());
|
||||
qint64 contentLength = qRound(cacheInfo.value("contentLength").toDouble());
|
||||
if (fileSize == contentLength && destFile->size() == contentLength) {
|
||||
if (!callable.isNull()) {
|
||||
callable->downloadProgress(fileSize, contentLength);
|
||||
callable->success(destPath);
|
||||
callable->finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(fileSize==destFile->size()){
|
||||
if (fileSize == destFile->size()) {
|
||||
request.setRawHeader("Range", QString("bytes=%1-").arg(fileSize).toUtf8());
|
||||
seek = fileSize;
|
||||
isOpen = destFile->open(QIODevice::WriteOnly|QIODevice::Append);
|
||||
}else{
|
||||
isOpen = destFile->open(QIODevice::WriteOnly|QIODevice::Truncate);
|
||||
isOpen = destFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
||||
} else {
|
||||
isOpen = destFile->open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
}
|
||||
}else{
|
||||
isOpen = destFile->open(QIODevice::WriteOnly|QIODevice::Truncate);
|
||||
} else {
|
||||
isOpen = destFile->open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
}
|
||||
if(!isOpen){
|
||||
if(!callable.isNull()){
|
||||
callable->error(-1,"device not open","");
|
||||
if (!isOpen) {
|
||||
if (!callable.isNull()) {
|
||||
callable->error(-1, "device not open", "");
|
||||
callable->finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(params->_downloadParam->_append){
|
||||
if (!cacheFile->open(QIODevice::WriteOnly|QIODevice::Truncate))
|
||||
{
|
||||
if(!callable.isNull()){
|
||||
callable->error(-1,"cache file device not open","");
|
||||
if (params->_downloadParam->_append) {
|
||||
if (!cacheFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
if (!callable.isNull()) {
|
||||
callable->error(-1, "cache file device not open", "");
|
||||
callable->finish();
|
||||
}
|
||||
return;
|
||||
@ -329,73 +327,72 @@ void Network::handleDownload(NetworkParams* params,NetworkCallable* c){
|
||||
QNetworkReply *reply = manager.get(request);
|
||||
destFile->setParent(reply);
|
||||
cacheFile->setParent(reply);
|
||||
auto abortCallable = [&loop,reply,params]{
|
||||
if(reply){
|
||||
auto abortCallable = [reply] {
|
||||
if (reply) {
|
||||
reply->abort();
|
||||
}
|
||||
};
|
||||
connect(&manager,&QNetworkAccessManager::finished,&manager,[&loop](QNetworkReply *reply){loop.quit();});
|
||||
connect(qApp,&QGuiApplication::aboutToQuit,&manager, [&loop,reply](){reply->abort(),loop.quit();});
|
||||
connect(&manager, &QNetworkAccessManager::finished, &manager, [&loop](QNetworkReply *reply) { loop.quit(); });
|
||||
connect(QGuiApplication::instance(), &QGuiApplication::aboutToQuit, &manager, [&loop, reply]() { reply->abort(), loop.quit(); });
|
||||
QMetaObject::Connection conn_destroyed = {};
|
||||
QMetaObject::Connection conn_quit = {};
|
||||
if(params->_target){
|
||||
conn_destroyed = connect(params->_target,&QObject::destroyed,&manager,abortCallable);
|
||||
if (params->_target) {
|
||||
conn_destroyed = connect(params->_target, &QObject::destroyed, &manager, abortCallable);
|
||||
}
|
||||
conn_quit = connect(qApp,&QGuiApplication::aboutToQuit,&manager, abortCallable);
|
||||
connect(reply,&QNetworkReply::readyRead,reply,[reply,seek,destFile,cacheFile,callable]{
|
||||
if (!reply || !destFile || reply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
conn_quit = connect(QGuiApplication::instance(), &QGuiApplication::aboutToQuit, &manager, abortCallable);
|
||||
connect(reply, &QNetworkReply::readyRead, reply, [reply, seek, destFile, cacheFile, callable] {
|
||||
if (!reply || !destFile || reply->error() != QNetworkReply::NoError) {
|
||||
return;
|
||||
}
|
||||
QMap<QString, QVariant> downInfo;
|
||||
qint64 contentLength = reply->header(QNetworkRequest::ContentLengthHeader).toLongLong()+seek;
|
||||
downInfo.insert("contentLength",contentLength);
|
||||
qint64 contentLength = reply->header(QNetworkRequest::ContentLengthHeader).toLongLong() + seek;
|
||||
downInfo.insert("contentLength", contentLength);
|
||||
QString eTag = reply->header(QNetworkRequest::ETagHeader).toString();
|
||||
downInfo.insert("eTag",eTag);
|
||||
downInfo.insert("eTag", eTag);
|
||||
destFile->write(reply->readAll());
|
||||
destFile->flush();
|
||||
downInfo.insert("fileSize",destFile->size());
|
||||
if(cacheFile->isOpen()){
|
||||
downInfo.insert("fileSize", destFile->size());
|
||||
if (cacheFile->isOpen()) {
|
||||
cacheFile->resize(0);
|
||||
cacheFile->write(QJsonDocument::fromVariant(QVariant(downInfo)).toJson().toBase64());
|
||||
cacheFile->flush();
|
||||
}
|
||||
if(!callable.isNull()){
|
||||
callable->downloadProgress(destFile->size(),contentLength);
|
||||
if (!callable.isNull()) {
|
||||
callable->downloadProgress(destFile->size(), contentLength);
|
||||
}
|
||||
});
|
||||
loop.exec();
|
||||
int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if(httpStatus == 200){
|
||||
if(!callable.isNull()){
|
||||
if (httpStatus == 200) {
|
||||
if (!callable.isNull()) {
|
||||
callable->success(destPath);
|
||||
}
|
||||
printRequestEndLog(request,params,reply,destPath);
|
||||
}else{
|
||||
if(!callable.isNull()){
|
||||
callable->error(httpStatus,reply->errorString(),destPath);
|
||||
printRequestEndLog(request, params, reply, destPath);
|
||||
} else {
|
||||
if (!callable.isNull()) {
|
||||
callable->error(httpStatus, reply->errorString(), destPath);
|
||||
}
|
||||
printRequestEndLog(request,params,reply,destPath);
|
||||
printRequestEndLog(request, params, reply, destPath);
|
||||
}
|
||||
if(conn_destroyed){
|
||||
if (conn_destroyed) {
|
||||
disconnect(conn_destroyed);
|
||||
}
|
||||
if(conn_quit){
|
||||
if (conn_quit) {
|
||||
disconnect(conn_quit);
|
||||
}
|
||||
params->deleteLater();
|
||||
reply->deleteLater();
|
||||
if(!callable.isNull()){
|
||||
if (!callable.isNull()) {
|
||||
callable->finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QString Network::readCache(const QString& key){
|
||||
QString Network::readCache(const QString &key) {
|
||||
auto filePath = getCacheFilePath(key);
|
||||
QString result;
|
||||
QFile file(filePath);
|
||||
if(!file.exists()){
|
||||
if (!file.exists()) {
|
||||
return result;
|
||||
}
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
@ -405,27 +402,27 @@ QString Network::readCache(const QString& key){
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Network::cacheExists(const QString& key){
|
||||
bool Network::cacheExists(const QString &key) {
|
||||
return QFile(getCacheFilePath(key)).exists();
|
||||
}
|
||||
|
||||
QString Network::getCacheFilePath(const QString& key){
|
||||
QString Network::getCacheFilePath(const QString &key) {
|
||||
QDir cacheDir(_cacheDir);
|
||||
if(!cacheDir.exists()){
|
||||
if (!cacheDir.exists()) {
|
||||
cacheDir.mkpath(_cacheDir);
|
||||
}
|
||||
return cacheDir.absoluteFilePath(key);
|
||||
}
|
||||
|
||||
QString Network::headerList2String(const QList<QNetworkReply::RawHeaderPair>& data){
|
||||
QString Network::headerList2String(const QList<QNetworkReply::RawHeaderPair> &data) {
|
||||
QJsonObject object;
|
||||
for (auto it = data.constBegin(); it != data.constEnd(); ++it) {
|
||||
object.insert(QString(it->first),QString(it->second));
|
||||
object.insert(QString(it->first), QString(it->second));
|
||||
}
|
||||
return QJsonDocument(object).toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QString Network::map2String(const QMap<QString, QVariant>& map){
|
||||
QString Network::map2String(const QMap<QString, QVariant> &map) {
|
||||
QStringList parameters;
|
||||
for (auto it = map.constBegin(); it != map.constEnd(); ++it) {
|
||||
parameters << QString("%1=%2").arg(it.key(), it.value().toString());
|
||||
@ -433,244 +430,235 @@ QString Network::map2String(const QMap<QString, QVariant>& map){
|
||||
return parameters.join(" ");
|
||||
}
|
||||
|
||||
void Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable){
|
||||
void Network::sendRequest(QNetworkAccessManager *manager, QNetworkRequest request, NetworkParams *params, QNetworkReply *&reply, bool isFirst, const QPointer<NetworkCallable> &callable) {
|
||||
QByteArray verb = params->method2String().toUtf8();
|
||||
switch (params->_type) {
|
||||
case NetworkParams::TYPE_FORM:{
|
||||
bool isFormData = !params->_fileMap.isEmpty();
|
||||
if(isFormData){
|
||||
QHttpMultiPart *multiPart = new QHttpMultiPart();
|
||||
multiPart->setContentType(QHttpMultiPart::FormDataType);
|
||||
for (const auto& each : params->_paramMap.toStdMap())
|
||||
{
|
||||
QHttpPart part;
|
||||
part.setHeader(QNetworkRequest::ContentDispositionHeader, QString("form-data; name=\"%1\"").arg(each.first));
|
||||
part.setBody(each.second.toByteArray());
|
||||
multiPart->append(part);
|
||||
}
|
||||
for (const auto& each : params->_fileMap.toStdMap())
|
||||
{
|
||||
QString filePath = each.second.toString();
|
||||
QString name = each.first;
|
||||
QFile *file = new QFile(filePath);
|
||||
QString fileName = QFileInfo(filePath).fileName();
|
||||
file->open(QIODevice::ReadOnly);
|
||||
file->setParent(multiPart);
|
||||
QHttpPart part;
|
||||
part.setHeader(QNetworkRequest::ContentDispositionHeader, QString("form-data; name=\"%1\"; filename=\"%2\"").arg(name,fileName));
|
||||
part.setBodyDevice(file);
|
||||
multiPart->append(part);
|
||||
}
|
||||
reply = manager->sendCustomRequest(request,verb,multiPart);
|
||||
multiPart->setParent(reply);
|
||||
connect(reply,&QNetworkReply::uploadProgress,reply,[callable](qint64 bytesSent, qint64 bytesTotal){
|
||||
if(!callable.isNull() && bytesSent!=0 && bytesTotal!=0){
|
||||
Q_EMIT callable->uploadProgress(bytesSent,bytesTotal);
|
||||
case NetworkParams::TYPE_FORM: {
|
||||
bool isFormData = !params->_fileMap.isEmpty();
|
||||
if (isFormData) {
|
||||
auto *multiPart = new QHttpMultiPart();
|
||||
multiPart->setContentType(QHttpMultiPart::FormDataType);
|
||||
for (const auto &each: params->_paramMap.toStdMap()) {
|
||||
QHttpPart part;
|
||||
part.setHeader(QNetworkRequest::ContentDispositionHeader, QString("form-data; name=\"%1\"").arg(each.first));
|
||||
part.setBody(each.second.toByteArray());
|
||||
multiPart->append(part);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/x-www-form-urlencoded"));
|
||||
QString value;
|
||||
for (const auto& each : params->_paramMap.toStdMap())
|
||||
{
|
||||
value += QString("%1=%2").arg(each.first,each.second.toString());
|
||||
value += "&";
|
||||
for (const auto &each: params->_fileMap.toStdMap()) {
|
||||
QString filePath = each.second.toString();
|
||||
QString name = each.first;
|
||||
auto *file = new QFile(filePath);
|
||||
QString fileName = QFileInfo(filePath).fileName();
|
||||
file->open(QIODevice::ReadOnly);
|
||||
file->setParent(multiPart);
|
||||
QHttpPart part;
|
||||
part.setHeader(QNetworkRequest::ContentDispositionHeader, QString(R"(form-data; name="%1"; filename="%2")").arg(name, fileName));
|
||||
part.setBodyDevice(file);
|
||||
multiPart->append(part);
|
||||
}
|
||||
reply = manager->sendCustomRequest(request, verb, multiPart);
|
||||
multiPart->setParent(reply);
|
||||
connect(reply, &QNetworkReply::uploadProgress, reply, [callable](qint64 bytesSent, qint64 bytesTotal) {
|
||||
if (!callable.isNull() && bytesSent != 0 && bytesTotal != 0) {
|
||||
Q_EMIT callable->uploadProgress(bytesSent, bytesTotal);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/x-www-form-urlencoded"));
|
||||
QString value;
|
||||
for (const auto &each: params->_paramMap.toStdMap()) {
|
||||
value += QString("%1=%2").arg(each.first, each.second.toString());
|
||||
value += "&";
|
||||
}
|
||||
if (!params->_paramMap.isEmpty()) {
|
||||
value.chop(1);
|
||||
}
|
||||
QByteArray data = value.toUtf8();
|
||||
reply = manager->sendCustomRequest(request, verb, data);
|
||||
}
|
||||
if(!params->_paramMap.isEmpty()){
|
||||
value.chop(1);
|
||||
}
|
||||
QByteArray data = value.toUtf8();
|
||||
reply = manager->sendCustomRequest(request,verb,data);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NetworkParams::TYPE_JSON:{
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
|
||||
QJsonObject json;
|
||||
for (const auto& each : params->_paramMap.toStdMap())
|
||||
{
|
||||
json.insert(each.first,each.second.toJsonValue());
|
||||
}
|
||||
QByteArray data = QJsonDocument(json).toJson(QJsonDocument::Compact);
|
||||
reply = manager->sendCustomRequest(request,verb,data);
|
||||
break;
|
||||
}
|
||||
case NetworkParams::TYPE_JSONARRAY:{
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
|
||||
QJsonArray jsonArray;
|
||||
for (const auto& each : params->_paramMap.toStdMap())
|
||||
{
|
||||
case NetworkParams::TYPE_JSON: {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
|
||||
QJsonObject json;
|
||||
json.insert(each.first,each.second.toJsonValue());
|
||||
jsonArray.append(json);
|
||||
for (const auto &each: params->_paramMap.toStdMap()) {
|
||||
json.insert(each.first, each.second.toJsonValue());
|
||||
}
|
||||
QByteArray data = QJsonDocument(json).toJson(QJsonDocument::Compact);
|
||||
reply = manager->sendCustomRequest(request, verb, data);
|
||||
break;
|
||||
}
|
||||
QByteArray data = QJsonDocument(jsonArray).toJson(QJsonDocument::Compact);
|
||||
reply = manager->sendCustomRequest(request,params->method2String().toUtf8(),data);
|
||||
break;
|
||||
case NetworkParams::TYPE_JSONARRAY: {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
|
||||
QJsonArray jsonArray;
|
||||
for (const auto &each: params->_paramMap.toStdMap()) {
|
||||
QJsonObject json;
|
||||
json.insert(each.first, each.second.toJsonValue());
|
||||
jsonArray.append(json);
|
||||
}
|
||||
QByteArray data = QJsonDocument(jsonArray).toJson(QJsonDocument::Compact);
|
||||
reply = manager->sendCustomRequest(request, params->method2String().toUtf8(), data);
|
||||
break;
|
||||
}
|
||||
case NetworkParams::TYPE_BODY: {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("text/plain;charset=utf-8"));
|
||||
QByteArray data = params->_body.toUtf8();
|
||||
reply = manager->sendCustomRequest(request, verb, data);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
reply = manager->sendCustomRequest(request, verb);
|
||||
break;
|
||||
}
|
||||
case NetworkParams::TYPE_BODY:{
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("text/plain;charset=utf-8"));
|
||||
QByteArray data = params->_body.toUtf8();
|
||||
reply = manager->sendCustomRequest(request,verb,data);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
reply = manager->sendCustomRequest(request,verb);
|
||||
break;
|
||||
}
|
||||
if(isFirst){
|
||||
printRequestStartLog(request,params);
|
||||
if (isFirst) {
|
||||
printRequestStartLog(request, params);
|
||||
}
|
||||
}
|
||||
|
||||
void Network::printRequestStartLog(QNetworkRequest request,NetworkParams* params){
|
||||
if(!params->getOpenLog()){
|
||||
void Network::printRequestStartLog(const QNetworkRequest &request, NetworkParams *params) {
|
||||
if (!params->getOpenLog()) {
|
||||
return;
|
||||
}
|
||||
qDebug()<<"<------"<<qUtf8Printable(request.header(QNetworkRequest::UserAgentHeader).toString())<<"Request Start ------>";
|
||||
qDebug()<<qUtf8Printable(QString::fromStdString("<%1>").arg(params->method2String()))<<qUtf8Printable(params->_url);
|
||||
qDebug() << "<------" << qUtf8Printable(request.header(QNetworkRequest::UserAgentHeader).toString()) << "Request Start ------>";
|
||||
qDebug() << qUtf8Printable(QString::fromStdString("<%1>").arg(params->method2String())) << qUtf8Printable(params->_url);
|
||||
auto contentType = request.header(QNetworkRequest::ContentTypeHeader).toString();
|
||||
if(!contentType.isEmpty()){
|
||||
qDebug()<<qUtf8Printable(QString::fromStdString("<Header> %1=%2").arg("Content-Type",contentType));
|
||||
if (!contentType.isEmpty()) {
|
||||
qDebug() << qUtf8Printable(QString::fromStdString("<Header> %1=%2").arg("Content-Type", contentType));
|
||||
}
|
||||
QList<QByteArray> headers = request.rawHeaderList();
|
||||
for(const QByteArray& header:headers){
|
||||
qDebug()<<qUtf8Printable(QString::fromStdString("<Header> %1=%2").arg(header,request.rawHeader(header)));
|
||||
for (const QByteArray &header: headers) {
|
||||
qDebug() << qUtf8Printable(QString::fromStdString("<Header> %1=%2").arg(header, request.rawHeader(header)));
|
||||
}
|
||||
if(!params->_queryMap.isEmpty()){
|
||||
qDebug()<<"<Query>"<<qUtf8Printable(map2String(params->_queryMap));
|
||||
if (!params->_queryMap.isEmpty()) {
|
||||
qDebug() << "<Query>" << qUtf8Printable(map2String(params->_queryMap));
|
||||
}
|
||||
if(!params->_paramMap.isEmpty()){
|
||||
qDebug()<<"<Param>"<<qUtf8Printable(map2String(params->_paramMap));
|
||||
if (!params->_paramMap.isEmpty()) {
|
||||
qDebug() << "<Param>" << qUtf8Printable(map2String(params->_paramMap));
|
||||
}
|
||||
if(!params->_fileMap.isEmpty()){
|
||||
qDebug()<<"<File>"<<qUtf8Printable(map2String(params->_fileMap));
|
||||
if (!params->_fileMap.isEmpty()) {
|
||||
qDebug() << "<File>" << qUtf8Printable(map2String(params->_fileMap));
|
||||
}
|
||||
if(!params->_body.isEmpty()){
|
||||
qDebug()<<"<Body>"<<qUtf8Printable(params->_body);
|
||||
if (!params->_body.isEmpty()) {
|
||||
qDebug() << "<Body>" << qUtf8Printable(params->_body);
|
||||
}
|
||||
}
|
||||
|
||||
void Network::printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response){
|
||||
if(!params->getOpenLog()){
|
||||
void Network::printRequestEndLog(const QNetworkRequest &request, NetworkParams *params, QNetworkReply *&reply, const QString &response) {
|
||||
if (!params->getOpenLog()) {
|
||||
return;
|
||||
}
|
||||
qDebug()<<"<------"<<qUtf8Printable(request.header(QNetworkRequest::UserAgentHeader).toString())<<"Request End ------>";
|
||||
qDebug()<<qUtf8Printable(QString::fromStdString("<%1>").arg(params->method2String()))<<qUtf8Printable(params->_url);
|
||||
qDebug()<<"<Result>"<<qUtf8Printable(response);
|
||||
qDebug() << "<------" << qUtf8Printable(request.header(QNetworkRequest::UserAgentHeader).toString()) << "Request End ------>";
|
||||
qDebug() << qUtf8Printable(QString::fromStdString("<%1>").arg(params->method2String())) << qUtf8Printable(params->_url);
|
||||
qDebug() << "<Result>" << qUtf8Printable(response);
|
||||
}
|
||||
|
||||
void Network::saveResponse(QString key,QString response){
|
||||
void Network::saveResponse(const QString &key, const QString &response) {
|
||||
QSharedPointer<QFile> file(new QFile(getCacheFilePath(key)));
|
||||
QIODevice::OpenMode mode = QIODevice::WriteOnly|QIODevice::Truncate;
|
||||
if (!file->open(mode))
|
||||
{
|
||||
QIODevice::OpenMode mode = QIODevice::WriteOnly | QIODevice::Truncate;
|
||||
if (!file->open(mode)) {
|
||||
return;
|
||||
}
|
||||
file->write(response.toUtf8().toBase64());
|
||||
}
|
||||
|
||||
void Network::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers){
|
||||
request->setHeader(QNetworkRequest::UserAgentHeader,QString::fromStdString("Mozilla/5.0 %1/%2").arg(QGuiApplication::applicationName(),QGuiApplication::applicationVersion()));
|
||||
void Network::addHeaders(QNetworkRequest *request, const QMap<QString, QVariant> &headers) {
|
||||
request->setHeader(QNetworkRequest::UserAgentHeader, QString::fromStdString("Mozilla/5.0 %1/%2").arg(QGuiApplication::applicationName(), QGuiApplication::applicationVersion()));
|
||||
QMapIterator<QString, QVariant> iter(headers);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
request->setRawHeader(iter.key().toUtf8(), iter.value().toString().toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void Network::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){
|
||||
void Network::addQueryParam(QUrl *url, const QMap<QString, QVariant> ¶ms) {
|
||||
QMapIterator<QString, QVariant> iter(params);
|
||||
QUrlQuery urlQuery(*url);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
urlQuery.addQueryItem(iter.key(), iter.value().toString());
|
||||
}
|
||||
url->setQuery(urlQuery);
|
||||
}
|
||||
|
||||
Network::Network(QObject *parent): QObject{parent}
|
||||
{
|
||||
timeout(5000);
|
||||
retry(3);
|
||||
openLog(false);
|
||||
cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network"));
|
||||
Network::Network(QObject *parent) : QObject{parent} {
|
||||
_timeout = 5000;
|
||||
_retry = 3;
|
||||
_openLog = false;
|
||||
_cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network");
|
||||
}
|
||||
|
||||
NetworkParams* Network::get(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_NONE,NetworkParams::METHOD_GET,this);
|
||||
NetworkParams *Network::get(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_NONE, NetworkParams::METHOD_GET, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::head(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_NONE,NetworkParams::METHOD_HEAD,this);
|
||||
NetworkParams *Network::head(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_NONE, NetworkParams::METHOD_HEAD, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::postBody(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_POST,this);
|
||||
NetworkParams *Network::postBody(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_BODY, NetworkParams::METHOD_POST, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::putBody(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_PUT,this);
|
||||
NetworkParams *Network::putBody(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_BODY, NetworkParams::METHOD_PUT, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::patchBody(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_PATCH,this);
|
||||
NetworkParams *Network::patchBody(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_BODY, NetworkParams::METHOD_PATCH, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::deleteBody(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_DELETE,this);
|
||||
NetworkParams *Network::deleteBody(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_BODY, NetworkParams::METHOD_DELETE, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::postForm(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_POST,this);
|
||||
NetworkParams *Network::postForm(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_FORM, NetworkParams::METHOD_POST, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::putForm(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_PUT,this);
|
||||
NetworkParams *Network::putForm(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_FORM, NetworkParams::METHOD_PUT, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::patchForm(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_PATCH,this);
|
||||
NetworkParams *Network::patchForm(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_FORM, NetworkParams::METHOD_PATCH, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::deleteForm(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_DELETE,this);
|
||||
NetworkParams *Network::deleteForm(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_FORM, NetworkParams::METHOD_DELETE, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::postJson(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_POST,this);
|
||||
NetworkParams *Network::postJson(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_JSON, NetworkParams::METHOD_POST, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::putJson(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_PUT,this);
|
||||
NetworkParams *Network::putJson(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_JSON, NetworkParams::METHOD_PUT, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::patchJson(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_PATCH,this);
|
||||
NetworkParams *Network::patchJson(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_JSON, NetworkParams::METHOD_PATCH, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::deleteJson(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_DELETE,this);
|
||||
NetworkParams *Network::deleteJson(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_JSON, NetworkParams::METHOD_DELETE, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::postJsonArray(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_POST,this);
|
||||
NetworkParams *Network::postJsonArray(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_JSONARRAY, NetworkParams::METHOD_POST, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::putJsonArray(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_PUT,this);
|
||||
NetworkParams *Network::putJsonArray(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_JSONARRAY, NetworkParams::METHOD_PUT, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::patchJsonArray(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_PATCH,this);
|
||||
NetworkParams *Network::patchJsonArray(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_JSONARRAY, NetworkParams::METHOD_PATCH, this);
|
||||
}
|
||||
|
||||
NetworkParams* Network::deleteJsonArray(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_DELETE,this);
|
||||
NetworkParams *Network::deleteJsonArray(const QString &url) {
|
||||
return new NetworkParams(url, NetworkParams::TYPE_JSONARRAY, NetworkParams::METHOD_DELETE, this);
|
||||
}
|
||||
|
||||
void Network::setInterceptor(QJSValue interceptor){
|
||||
this->_interceptor = interceptor;
|
||||
void Network::setInterceptor(QJSValue interceptor) {
|
||||
this->_interceptor = std::move(interceptor);
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef NETWORK_H
|
||||
#define NETWORK_H
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
@ -12,56 +11,66 @@
|
||||
#include "src/singleton.h"
|
||||
|
||||
namespace NetworkType {
|
||||
Q_NAMESPACE
|
||||
enum CacheMode {
|
||||
NoCache = 0x0000,
|
||||
RequestFailedReadCache = 0x0001,
|
||||
IfNoneCacheRequest = 0x0002,
|
||||
FirstCacheThenRequest = 0x0004,
|
||||
};
|
||||
Q_ENUM_NS(CacheMode)
|
||||
QML_NAMED_ELEMENT(NetworkType)
|
||||
Q_NAMESPACE
|
||||
enum CacheMode {
|
||||
NoCache = 0x0000,
|
||||
RequestFailedReadCache = 0x0001,
|
||||
IfNoneCacheRequest = 0x0002,
|
||||
FirstCacheThenRequest = 0x0004,
|
||||
};
|
||||
|
||||
Q_ENUM_NS(CacheMode)
|
||||
|
||||
QML_NAMED_ELEMENT(NetworkType)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The NetworkCallable class
|
||||
*/
|
||||
class NetworkCallable : public QObject{
|
||||
Q_OBJECT
|
||||
class NetworkCallable : public QObject {
|
||||
Q_OBJECT
|
||||
QML_NAMED_ELEMENT(NetworkCallable)
|
||||
public:
|
||||
explicit NetworkCallable(QObject *parent = nullptr);
|
||||
|
||||
Q_SIGNAL void start();
|
||||
|
||||
Q_SIGNAL void finish();
|
||||
Q_SIGNAL void error(int status,QString errorString,QString result);
|
||||
|
||||
Q_SIGNAL void error(int status, QString errorString, QString result);
|
||||
|
||||
Q_SIGNAL void success(QString result);
|
||||
|
||||
Q_SIGNAL void cache(QString result);
|
||||
|
||||
Q_SIGNAL void uploadProgress(qint64 sent, qint64 total);
|
||||
|
||||
Q_SIGNAL void downloadProgress(qint64 recv, qint64 total);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The FluDownloadParam class
|
||||
*/
|
||||
class FluDownloadParam : public QObject{
|
||||
Q_OBJECT
|
||||
class FluDownloadParam : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FluDownloadParam(QObject *parent = nullptr);
|
||||
FluDownloadParam(QString destPath,bool append,QObject *parent = nullptr);
|
||||
|
||||
FluDownloadParam(QString destPath, bool append, QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
QString _destPath;
|
||||
bool _append;
|
||||
bool _append{};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The NetworkParams class
|
||||
*/
|
||||
class NetworkParams : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
class NetworkParams : public QObject {
|
||||
Q_OBJECT
|
||||
QML_NAMED_ELEMENT(NetworkParams)
|
||||
public:
|
||||
enum Method{
|
||||
enum Method {
|
||||
METHOD_GET,
|
||||
METHOD_HEAD,
|
||||
METHOD_POST,
|
||||
@ -69,35 +78,55 @@ public:
|
||||
METHOD_PATCH,
|
||||
METHOD_DELETE
|
||||
};
|
||||
enum Type{
|
||||
enum Type {
|
||||
TYPE_NONE,
|
||||
TYPE_FORM,
|
||||
TYPE_JSON,
|
||||
TYPE_JSONARRAY,
|
||||
TYPE_BODY
|
||||
};
|
||||
|
||||
explicit NetworkParams(QObject *parent = nullptr);
|
||||
NetworkParams(QString url,Type type,Method method,QObject *parent = nullptr);
|
||||
Q_INVOKABLE NetworkParams* addQuery(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* addHeader(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* add(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* addFile(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* setBody(QString val);
|
||||
Q_INVOKABLE NetworkParams* setTimeout(int val);
|
||||
Q_INVOKABLE NetworkParams* setRetry(int val);
|
||||
Q_INVOKABLE NetworkParams* setCacheMode(int val);
|
||||
Q_INVOKABLE NetworkParams* toDownload(QString destPath,bool append = false);
|
||||
Q_INVOKABLE NetworkParams* bind(QObject* target);
|
||||
Q_INVOKABLE NetworkParams* openLog(QVariant val);
|
||||
Q_INVOKABLE void go(NetworkCallable* result);
|
||||
QString buildCacheKey();
|
||||
QString method2String();
|
||||
int getTimeout();
|
||||
int getRetry();
|
||||
bool getOpenLog();
|
||||
|
||||
NetworkParams(QString url, Type type, Method method, QObject *parent = nullptr);
|
||||
|
||||
Q_INVOKABLE NetworkParams *addQuery(const QString &key, const QVariant &val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *addHeader(const QString &key, const QVariant &val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *add(const QString &key, const QVariant &val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *addFile(const QString &key, const QVariant &val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *setBody(QString val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *setTimeout(int val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *setRetry(int val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *setCacheMode(int val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *toDownload(QString destPath, bool append = false);
|
||||
|
||||
Q_INVOKABLE NetworkParams *bind(QObject *target);
|
||||
|
||||
Q_INVOKABLE NetworkParams *openLog(QVariant val);
|
||||
|
||||
Q_INVOKABLE void go(NetworkCallable *result);
|
||||
|
||||
QString buildCacheKey() const;
|
||||
|
||||
QString method2String() const;
|
||||
|
||||
int getTimeout() const;
|
||||
|
||||
int getRetry() const;
|
||||
|
||||
bool getOpenLog() const;
|
||||
|
||||
public:
|
||||
FluDownloadParam* _downloadParam = nullptr;
|
||||
QObject* _target = nullptr;
|
||||
FluDownloadParam *_downloadParam = nullptr;
|
||||
QObject *_target = nullptr;
|
||||
Method _method;
|
||||
Type _type;
|
||||
QString _url;
|
||||
@ -115,55 +144,88 @@ public:
|
||||
/**
|
||||
* @brief The Network class
|
||||
*/
|
||||
class Network : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int,timeout)
|
||||
Q_PROPERTY_AUTO(int,retry)
|
||||
Q_PROPERTY_AUTO(QString,cacheDir)
|
||||
Q_PROPERTY_AUTO(bool,openLog)
|
||||
class Network : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int, timeout)
|
||||
Q_PROPERTY_AUTO(int, retry)
|
||||
Q_PROPERTY_AUTO(QString, cacheDir)
|
||||
Q_PROPERTY_AUTO(bool, openLog)
|
||||
QML_NAMED_ELEMENT(Network)
|
||||
QML_SINGLETON
|
||||
|
||||
private:
|
||||
explicit Network(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(Network)
|
||||
static Network *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||
Q_INVOKABLE NetworkParams* get(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* head(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* postBody(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* putBody(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* patchBody(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* deleteBody(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* postForm(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* putForm(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* patchForm(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* deleteForm(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* postJson(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* putJson(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* patchJson(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* deleteJson(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* postJsonArray(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* putJsonArray(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* patchJsonArray(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* deleteJsonArray(const QString& url);
|
||||
SINGLETON(Network)
|
||||
|
||||
static Network *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) { return getInstance(); }
|
||||
|
||||
Q_INVOKABLE NetworkParams *get(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *head(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *postBody(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *putBody(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *patchBody(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *deleteBody(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *postForm(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *putForm(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *patchForm(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *deleteForm(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *postJson(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *putJson(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *patchJson(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *deleteJson(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *postJsonArray(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *putJsonArray(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *patchJsonArray(const QString &url);
|
||||
|
||||
Q_INVOKABLE NetworkParams *deleteJsonArray(const QString &url);
|
||||
|
||||
Q_INVOKABLE void setInterceptor(QJSValue interceptor);
|
||||
void handle(NetworkParams* params,NetworkCallable* result);
|
||||
void handleDownload(NetworkParams* params,NetworkCallable* result);
|
||||
|
||||
void handle(NetworkParams *params, NetworkCallable *result);
|
||||
|
||||
void handleDownload(NetworkParams *params, NetworkCallable *result);
|
||||
|
||||
private:
|
||||
void sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable);
|
||||
void addQueryParam(QUrl* url,const QMap<QString, QVariant>& params);
|
||||
void addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers);
|
||||
void saveResponse(QString key,QString response);
|
||||
QString readCache(const QString& key);
|
||||
bool cacheExists(const QString& key);
|
||||
QString getCacheFilePath(const QString& key);
|
||||
QString map2String(const QMap<QString, QVariant>& map);
|
||||
QString headerList2String(const QList<QNetworkReply::RawHeaderPair>& data);
|
||||
void printRequestStartLog(QNetworkRequest request,NetworkParams* params);
|
||||
void printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response);
|
||||
static void sendRequest(QNetworkAccessManager *manager, QNetworkRequest request, NetworkParams *params, QNetworkReply *&reply, bool isFirst, const QPointer<NetworkCallable> &callable);
|
||||
|
||||
static void addQueryParam(QUrl *url, const QMap<QString, QVariant> ¶ms);
|
||||
|
||||
static void addHeaders(QNetworkRequest *request, const QMap<QString, QVariant> &headers);
|
||||
|
||||
void saveResponse(const QString &key, const QString &response);
|
||||
|
||||
QString readCache(const QString &key);
|
||||
|
||||
bool cacheExists(const QString &key);
|
||||
|
||||
QString getCacheFilePath(const QString &key);
|
||||
|
||||
static QString headerList2String(const QList<QNetworkReply::RawHeaderPair> &data);
|
||||
|
||||
static void printRequestStartLog(const QNetworkRequest &request, NetworkParams *params);
|
||||
|
||||
static void printRequestEndLog(const QNetworkRequest &request, NetworkParams *params, QNetworkReply *&reply, const QString &response);
|
||||
|
||||
static QString map2String(const QMap<QString, QVariant> &map);
|
||||
|
||||
public:
|
||||
QJSValue _interceptor;
|
||||
};
|
||||
|
||||
#endif // Network_H
|
||||
|
@ -3,19 +3,17 @@
|
||||
#include <QDataStream>
|
||||
#include <QStandardPaths>
|
||||
|
||||
SettingsHelper::SettingsHelper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
SettingsHelper::SettingsHelper(QObject *parent) : QObject(parent) {
|
||||
|
||||
}
|
||||
|
||||
SettingsHelper::~SettingsHelper() = default;
|
||||
|
||||
void SettingsHelper::save(const QString& key,QVariant val)
|
||||
{
|
||||
void SettingsHelper::save(const QString &key, QVariant val) {
|
||||
m_settings->setValue(key, val);
|
||||
}
|
||||
|
||||
QVariant SettingsHelper::get(const QString& key,QVariant def){
|
||||
QVariant SettingsHelper::get(const QString &key, QVariant def) {
|
||||
QVariant data = m_settings->value(key);
|
||||
if (!data.isNull() && data.isValid()) {
|
||||
return data;
|
||||
@ -23,7 +21,7 @@ QVariant SettingsHelper::get(const QString& key,QVariant def){
|
||||
return def;
|
||||
}
|
||||
|
||||
void SettingsHelper::init(char *argv[]){
|
||||
void SettingsHelper::init(char *argv[]) {
|
||||
QString applicationPath = QString::fromStdString(argv[0]);
|
||||
const QFileInfo fileInfo(applicationPath);
|
||||
const QString iniFileName = fileInfo.completeBaseName() + ".ini";
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef SETTINGSHELPER_H
|
||||
#define SETTINGSHELPER_H
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtQml/qqml.h>
|
||||
@ -10,26 +9,35 @@
|
||||
#include <QDir>
|
||||
#include "src/singleton.h"
|
||||
|
||||
class SettingsHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
class SettingsHelper : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
explicit SettingsHelper(QObject* parent = nullptr);
|
||||
explicit SettingsHelper(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(SettingsHelper)
|
||||
SINGLETON(SettingsHelper)
|
||||
|
||||
~SettingsHelper() override;
|
||||
|
||||
void init(char *argv[]);
|
||||
Q_INVOKABLE void saveDarkMode(int darkModel){save("darkMode",darkModel);}
|
||||
Q_INVOKABLE int getDarkMode(){return get("darkMode",QVariant(0)).toInt();}
|
||||
Q_INVOKABLE void saveUseSystemAppBar(bool useSystemAppBar){save("useSystemAppBar",useSystemAppBar);}
|
||||
Q_INVOKABLE bool getUseSystemAppBar(){return get("useSystemAppBar",QVariant(false)).toBool();}
|
||||
Q_INVOKABLE void saveLanguage(QString language){save("language",language);}
|
||||
Q_INVOKABLE QString getLanguage(){return get("language",QVariant("en_US")).toString();}
|
||||
|
||||
Q_INVOKABLE void saveDarkMode(int darkModel) { save("darkMode", darkModel); }
|
||||
|
||||
Q_INVOKABLE int getDarkMode() { return get("darkMode", QVariant(0)).toInt(); }
|
||||
|
||||
Q_INVOKABLE void saveUseSystemAppBar(bool useSystemAppBar) { save("useSystemAppBar", useSystemAppBar); }
|
||||
|
||||
Q_INVOKABLE bool getUseSystemAppBar() { return get("useSystemAppBar", QVariant(false)).toBool(); }
|
||||
|
||||
Q_INVOKABLE void saveLanguage(const QString &language) { save("language", language); }
|
||||
|
||||
Q_INVOKABLE QString getLanguage() { return get("language", QVariant("en_US")).toString(); }
|
||||
|
||||
private:
|
||||
void save(const QString& key,QVariant val);
|
||||
QVariant get(const QString& key,QVariant def={});
|
||||
void save(const QString &key, QVariant val);
|
||||
|
||||
QVariant get(const QString &key, QVariant def = {});
|
||||
|
||||
private:
|
||||
QScopedPointer<QSettings> m_settings;
|
||||
};
|
||||
|
||||
#endif // SETTINGSHELPER_H
|
||||
|
@ -5,21 +5,20 @@
|
||||
|
||||
#include "SettingsHelper.h"
|
||||
|
||||
TranslateHelper::TranslateHelper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
_languages<<"en_US";
|
||||
_languages<<"zh_CN";
|
||||
[[maybe_unused]] TranslateHelper::TranslateHelper(QObject *parent) : QObject(parent) {
|
||||
_languages << "en_US";
|
||||
_languages << "zh_CN";
|
||||
_current = SettingsHelper::getInstance()->getLanguage();
|
||||
}
|
||||
|
||||
TranslateHelper::~TranslateHelper() = default;
|
||||
|
||||
void TranslateHelper::init(QQmlEngine* engine){
|
||||
void TranslateHelper::init(QQmlEngine *engine) {
|
||||
_engine = engine;
|
||||
_translator = new QTranslator(this);
|
||||
qApp->installTranslator(_translator);
|
||||
QString translatorPath = QGuiApplication::applicationDirPath()+"/i18n";
|
||||
if(_translator->load(QString::fromStdString("%1/example_%2.qm").arg(translatorPath,_current))){
|
||||
QGuiApplication::installTranslator(_translator);
|
||||
QString translatorPath = QGuiApplication::applicationDirPath() + "/i18n";
|
||||
if (_translator->load(QString::fromStdString("%1/example_%2.qm").arg(translatorPath, _current))) {
|
||||
_engine->retranslate();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef TRANSLATEHELPER_H
|
||||
#define TRANSLATEHELPER_H
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
@ -7,20 +6,21 @@
|
||||
#include "src/singleton.h"
|
||||
#include "src/stdafx.h"
|
||||
|
||||
class TranslateHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString,current)
|
||||
Q_PROPERTY_READONLY_AUTO(QStringList,languages)
|
||||
class TranslateHelper : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString, current)
|
||||
Q_PROPERTY_READONLY_AUTO(QStringList, languages)
|
||||
private:
|
||||
explicit TranslateHelper(QObject* parent = nullptr);
|
||||
public:
|
||||
SINGLETON(TranslateHelper)
|
||||
~TranslateHelper() override;
|
||||
void init(QQmlEngine* engine);
|
||||
private:
|
||||
QQmlEngine* _engine = nullptr;
|
||||
QTranslator* _translator = nullptr;
|
||||
};
|
||||
[[maybe_unused]] explicit TranslateHelper(QObject *parent = nullptr);
|
||||
|
||||
#endif // TRANSLATEHELPER_H
|
||||
public:
|
||||
SINGLETON(TranslateHelper)
|
||||
|
||||
~TranslateHelper() override;
|
||||
|
||||
void init(QQmlEngine *engine);
|
||||
|
||||
private:
|
||||
QQmlEngine *_engine = nullptr;
|
||||
QTranslator *_translator = nullptr;
|
||||
};
|
@ -14,6 +14,7 @@
|
||||
#include "src/component/CircularReveal.h"
|
||||
#include "src/component/FileWatcher.h"
|
||||
#include "src/component/FpsItem.h"
|
||||
#include "src/component/OpenGLItem.h"
|
||||
#include "src/helper/SettingsHelper.h"
|
||||
#include "src/helper/InitializrHelper.h"
|
||||
#include "src/helper/TranslateHelper.h"
|
||||
@ -53,7 +54,7 @@ int main(int argc, char *argv[])
|
||||
QGuiApplication::setOrganizationName("ZhuZiChu");
|
||||
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
|
||||
QGuiApplication::setApplicationName("FluentUI");
|
||||
QGuiApplication::setApplicationDisplayName("FluentUI Exmaple");
|
||||
QGuiApplication::setApplicationDisplayName("FluentUI Example");
|
||||
QGuiApplication::setApplicationVersion(APPLICATION_VERSION);
|
||||
QGuiApplication::setQuitOnLastWindowClosed(false);
|
||||
SettingsHelper::getInstance()->init(argv);
|
||||
@ -75,6 +76,9 @@ int main(int argc, char *argv[])
|
||||
qmlRegisterType<FpsItem>(uri, major, minor, "FpsItem");
|
||||
qmlRegisterType<NetworkCallable>(uri,major,minor,"NetworkCallable");
|
||||
qmlRegisterType<NetworkParams>(uri,major,minor,"NetworkParams");
|
||||
qmlRegisterType<OpenGLItem>(uri,major,minor,"OpenGLItem");
|
||||
qmlRegisterUncreatableMetaObject(NetworkType::staticMetaObject, uri, major, minor, "NetworkType", "Access to enums & flags only");
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
TranslateHelper::getInstance()->init(&engine);
|
||||
engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance());
|
||||
|
@ -1,18 +1,17 @@
|
||||
#ifndef SINGLETON_H
|
||||
#define SINGLETON_H
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief The Singleton class
|
||||
*/
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
class Singleton {
|
||||
public:
|
||||
static T* getInstance();
|
||||
static T *getInstance();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T* Singleton<T>::getInstance() {
|
||||
static T* instance = new T();
|
||||
template<typename T>
|
||||
T *Singleton<T>::getInstance() {
|
||||
static T *instance = new T();
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -23,5 +22,3 @@ private: \
|
||||
static Class* getInstance() { \
|
||||
return Singleton<Class>::getInstance(); \
|
||||
}
|
||||
|
||||
#endif // SINGLETON_H
|
||||
|
@ -1,37 +1,50 @@
|
||||
#ifndef STDAFX_H
|
||||
#define STDAFX_H
|
||||
#pragma once
|
||||
|
||||
#define Q_PROPERTY_AUTO(TYPE, M) \
|
||||
#define Q_PROPERTY_AUTO_P(TYPE, M) \
|
||||
Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(TYPE in_##M) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(TYPE in_##M) \
|
||||
{ \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
} \
|
||||
TYPE M() \
|
||||
TYPE M() \
|
||||
{ \
|
||||
return _##M; \
|
||||
return _##M; \
|
||||
} \
|
||||
private: \
|
||||
TYPE _##M; \
|
||||
private: \
|
||||
TYPE _##M;
|
||||
|
||||
#define Q_PROPERTY_AUTO(TYPE, M) \
|
||||
Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(const TYPE& in_##M) \
|
||||
{ \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
} \
|
||||
TYPE M() \
|
||||
{ \
|
||||
return _##M; \
|
||||
} \
|
||||
private: \
|
||||
TYPE _##M;
|
||||
|
||||
|
||||
#define Q_PROPERTY_READONLY_AUTO(TYPE, M) \
|
||||
#define Q_PROPERTY_READONLY_AUTO(TYPE, M) \
|
||||
Q_PROPERTY(TYPE M READ M NOTIFY M##Changed FINAL) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(TYPE in_##M) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(const TYPE& in_##M) \
|
||||
{ \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
} \
|
||||
TYPE M() \
|
||||
TYPE M() \
|
||||
{ \
|
||||
return _##M; \
|
||||
return _##M; \
|
||||
} \
|
||||
private: \
|
||||
TYPE _##M; \
|
||||
|
||||
#endif // STDAFX_H
|
||||
private: \
|
||||
TYPE _##M;
|
||||
|
Reference in New Issue
Block a user