Compare commits

...

82 Commits

Author SHA1 Message Date
2367c6978a update 2024-05-11 22:21:11 +08:00
6b941697b0 update 2024-05-11 21:45:45 +08:00
4997b991db update 2024-05-10 19:23:30 +08:00
cd3abc01e9 fix bug 2024-05-10 19:20:01 +08:00
e6c4b79298 Merge branch 'main' into 1.7.6-dev
# Conflicts:
#	src/Qt5/imports/FluentUI/Controls/FluRadioButtons.qml
#	src/Qt6/imports/FluentUI/Controls/FluRadioButtons.qml
2024-05-10 12:26:14 +08:00
f830d5a9bf Merge branch 'main' of https://github.com/zhuzichu520/FluentUI 2024-05-09 19:41:15 +08:00
ed49e3f6af Merge pull request #499 from gao-xiangyang/main
info提示语支持主动调用函数关闭,支持关闭所有info框的函数
2024-05-09 17:10:34 +05:30
9aa6615189 FluRadioButtons 组件支持 disabled、manuallyDisabled选项
disabled: true // 禁用所有FluRadioButton子组件
        manuallyDisabled: true // 是否指定每个FluRadioButton上的disabled选项
2024-05-08 21:10:00 +08:00
c36515f19c info提示语支持主动调用函数关闭,支持关闭所有info框的函数 2024-05-08 20:35:31 +08:00
402579f32a update 2024-05-08 18:58:22 +08:00
655eff4f62 update 2024-05-07 22:16:42 +08:00
b916221d9f update 2024-05-07 21:47:40 +08:00
4cca680029 update 2024-05-05 22:05:18 +08:00
fe2543ab4d fix bug 2024-05-05 22:03:41 +08:00
394a42cb94 update 2024-05-05 21:33:47 +08:00
ac253a3de5 fix bug 2024-05-05 20:32:48 +08:00
0d61e33ef1 update 2024-05-05 15:52:46 +08:00
132ab12c32 update 2024-05-05 00:06:01 +08:00
af270951da update 2024-05-04 23:56:20 +08:00
18685b17ec update 2024-05-03 16:56:40 +08:00
0eb4d9f346 update 2024-05-03 01:54:38 +08:00
8015dcc2f1 update 2024-05-02 23:52:30 +08:00
0b1755e9eb update 2024-05-01 01:11:25 +08:00
e471d5a230 update 2024-04-30 19:38:05 +08:00
f922978338 update 2024-04-30 19:27:57 +08:00
91bda2a22c update 2024-04-30 13:07:46 +08:00
6638fe2e06 update 2024-04-30 13:06:27 +08:00
bf001d99d2 update 2024-04-30 12:59:09 +08:00
30531079b5 update 2024-04-29 10:12:34 +08:00
a746bc2684 update 2024-04-28 21:05:43 +08:00
96a6d0e7fa update 2024-04-28 20:22:05 +08:00
c733f3c60e update 2024-04-28 18:38:37 +08:00
effd9f3058 update 2024-04-28 18:19:21 +08:00
d93aac3518 update 2024-04-28 15:56:37 +08:00
5f6745b630 udpate 2024-04-28 13:03:20 +08:00
4f202831b8 Merge branch 'main' of https://github.com/zhuzichu520/FluentUI 2024-04-28 10:51:29 +08:00
29cee84edd update 2024-04-28 10:51:13 +08:00
2d4e61445e Merge pull request #488 from yanhuacuo/path-for-insertRow
Add the functionality to insert new rows into the table
2024-04-28 10:47:28 +08:00
cc79854191 Merge pull request #489 from w-jt/main
FluPagination.qml 添加自定义控件,通过header和footer属性添加控件
2024-04-28 10:46:47 +08:00
500efa6298 添加自定义控件,通过header和footer属性添加控件
添加自定义控件,通过header和footer属性添加控件
2024-04-27 11:54:42 +08:00
355332da96 添加自定义控件,通过header和footer属性添加控件
添加自定义控件,通过header和footer属性添加控件
2024-04-27 11:53:57 +08:00
a0d662a8a5 添加自定义控件,通过header和footer属性添加控件
添加自定义控件,通过header和footer属性添加控件
2024-04-27 11:49:29 +08:00
aecc3fe3b4 添加自定义控件,通过header和footer属性添加控件
添加自定义控件,通过header和footer属性添加控件
2024-04-27 11:48:19 +08:00
3554fb99cd Add the functionality to insert new rows into the table 2024-04-27 09:40:37 +08:00
24fdff7e35 fix bug 2024-04-25 00:08:18 +08:00
d2fdd08604 update 2024-04-24 17:24:31 +08:00
1f5d6ce1aa update 2024-04-24 17:12:00 +08:00
5fd7c7d10e update 2024-04-24 10:37:15 +08:00
83507a6ed5 update 2024-04-24 09:57:28 +08:00
789d9164a1 Merge branch '1.7.5-dev' 2024-04-24 09:53:59 +08:00
cb44759978 update 2024-04-23 22:38:39 +08:00
04c52b1b25 fix bug 2024-04-23 21:19:32 +08:00
b8ef9169b9 update 2024-04-23 19:33:05 +08:00
c7de653ba2 update 2024-04-23 13:41:26 +08:00
2ddb7e3290 update 2024-04-23 00:32:15 +08:00
e8d79e3c7b update 2024-04-23 00:31:20 +08:00
bc4510077f update 2024-04-19 01:04:13 +08:00
179bc8b21f update 2024-04-19 00:42:35 +08:00
8fe4e3b047 update 2024-04-17 22:05:49 +08:00
a443f3a9ba update 2024-04-17 21:39:55 +08:00
1a0f2afee0 update 2024-04-17 15:11:14 +08:00
c9c737f2fc update 2024-04-16 12:36:41 +08:00
f0f00b9eba Merge pull request #483 from mariuszmaximus/main
fix for msys2
2024-04-15 12:39:47 +08:00
956f2e0ad0 fix for msys2 2024-04-14 19:38:52 +02:00
ecd13a9cca update 2024-04-15 00:11:41 +08:00
17bfff2346 update 2024-04-14 23:58:15 +08:00
295dcf02c4 update 2024-04-14 23:09:41 +08:00
f701f97756 update 2024-04-14 11:43:32 +08:00
2c4cf82f63 update 2024-04-13 22:00:15 +08:00
e8c47e0fd8 update 2024-04-13 21:30:23 +08:00
9296b18606 update 2024-04-13 10:51:24 +08:00
481e19c8cc update 2024-04-13 10:50:27 +08:00
44f7948df3 update 2024-04-12 16:50:49 +08:00
0ab315e258 update 2024-04-12 16:26:32 +08:00
44acdbcf7f update 2024-04-11 20:29:59 +08:00
3997daaa11 update 2024-04-11 19:18:37 +08:00
531f659e59 update 2024-04-11 15:27:15 +08:00
3f6ef13cd0 update 2024-04-11 15:09:47 +08:00
96fef84c2d update 2024-04-11 14:56:22 +08:00
a3f375c9ef update 2024-04-11 14:51:43 +08:00
6a31e86505 update 2024-04-09 20:53:52 +08:00
6ebd659e13 update 2024-04-04 22:47:07 +08:00
154 changed files with 10187 additions and 7482 deletions

View File

@ -91,14 +91,14 @@ jobs:
if: startsWith(github.event.ref, 'refs/tags/') if: startsWith(github.event.ref, 'refs/tags/')
uses: zhuzichu520/inno-setup-action@v1.0.1 uses: zhuzichu520/inno-setup-action@v1.0.1
with: with:
filepath: ./action-cli/InstallerScript.iss filepath: ./package/InstallerScript.iss
- name: uploadRelease - name: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/') if: startsWith(github.event.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./action-cli/installer.exe file: ./package/installer.exe
asset_name: ${{ env.fileName }}_${{ github.ref_name }}_${{ matrix.qt_arch }}_Qt${{ matrix.qt_ver }}.exe asset_name: ${{ env.fileName }}_${{ github.ref_name }}_${{ matrix.qt_arch }}_Qt${{ matrix.qt_ver }}.exe
tag: ${{ github.ref }} tag: ${{ github.ref }}
overwrite: true overwrite: true

View File

@ -78,14 +78,14 @@ jobs:
if: startsWith(github.event.ref, 'refs/tags/') if: startsWith(github.event.ref, 'refs/tags/')
uses: zhuzichu520/inno-setup-action@v1.0.1 uses: zhuzichu520/inno-setup-action@v1.0.1
with: with:
filepath: ./action-cli/InstallerScript.iss filepath: ./package/InstallerScript.iss
- name: uploadRelease - name: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/') if: startsWith(github.event.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./action-cli/installer.exe file: ./package/installer.exe
asset_name: ${{ env.fileName }}_${{ github.ref_name }}_${{ matrix.qt_arch }}_Qt${{ matrix.qt_ver }}.exe asset_name: ${{ env.fileName }}_${{ github.ref_name }}_${{ matrix.qt_arch }}_Qt${{ matrix.qt_ver }}.exe
tag: ${{ github.ref }} tag: ${{ github.ref }}
overwrite: true overwrite: true

View File

@ -85,14 +85,14 @@ jobs:
if: startsWith(github.event.ref, 'refs/tags/') if: startsWith(github.event.ref, 'refs/tags/')
uses: zhuzichu520/inno-setup-action@v1.0.1 uses: zhuzichu520/inno-setup-action@v1.0.1
with: with:
filepath: ./action-cli/InstallerScript.iss filepath: ./package/InstallerScript.iss
- name: uploadRelease - name: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/') if: startsWith(github.event.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./action-cli/installer.exe file: ./package/installer.exe
asset_name: ${{ env.fileName }}_${{ github.ref_name }}_${{ matrix.qt_arch }}_Qt${{ matrix.qt_ver }}.exe asset_name: ${{ env.fileName }}_${{ github.ref_name }}_${{ matrix.qt_arch }}_Qt${{ matrix.qt_ver }}.exe
tag: ${{ github.ref }} tag: ${{ github.ref }}
overwrite: true overwrite: true

4
.gitignore vendored
View File

@ -36,10 +36,8 @@ bin
build build
cmake-build-* cmake-build-*
.idea .idea
package
example/Version.h example/Version.h
action-cli
dist dist
*.qm *.qm

View File

@ -8,7 +8,7 @@ if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
endif () endif ()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/.cmake/) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake/)
include(GetGitRevisionDescription) include(GetGitRevisionDescription)

View File

@ -28,8 +28,8 @@ find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick Svg Network)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick Svg Network) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick Svg Network)
#添加国际化脚本 #添加国际化脚本
find_program(QT_LUPDATE NAMES lupdate) find_program(QT_LUPDATE NAMES lupdate lupdate-qt6)
find_program(QT_LRELEASE NAMES lrelease) find_program(QT_LRELEASE NAMES lrelease lrelease-qt6)
file(GLOB TS_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.ts) file(GLOB TS_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.ts)
add_custom_target(Script-UpdateTranslations 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}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
@ -69,7 +69,7 @@ if(WIN32)
) )
configure_file( configure_file(
${CMAKE_SOURCE_DIR}/.cmake/InstallerScript.iss.in ${CMAKE_SOURCE_DIR}/.cmake/InstallerScript.iss.in
${CMAKE_SOURCE_DIR}/action-cli/InstallerScript.iss ${CMAKE_SOURCE_DIR}/package/InstallerScript.iss
) )
endif () endif ()

View File

@ -127,7 +127,6 @@
<file>qml/global/ItemsOriginal.qml</file> <file>qml/global/ItemsOriginal.qml</file>
<file>qml/global/qmldir</file> <file>qml/global/qmldir</file>
<file>qml/page/T_Acrylic.qml</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_Badge.qml</file>
<file>qml/page/T_BreadcrumbBar.qml</file> <file>qml/page/T_BreadcrumbBar.qml</file>
<file>qml/page/T_Buttons.qml</file> <file>qml/page/T_Buttons.qml</file>
@ -181,7 +180,6 @@
<file>qml/window/PageWindow.qml</file> <file>qml/window/PageWindow.qml</file>
<file>qml/page/T_StaggeredLayout.qml</file> <file>qml/page/T_StaggeredLayout.qml</file>
<file>qml/page/T_Clip.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_Network.qml</file>
<file>qml/page/T_ShortcutPicker.qml</file> <file>qml/page/T_ShortcutPicker.qml</file>
<file>qml/chart/T_BarChart.qml</file> <file>qml/chart/T_BarChart.qml</file>
@ -209,5 +207,8 @@
<file>qml/page/T_GroupBox.qml</file> <file>qml/page/T_GroupBox.qml</file>
<file>res/image/bg_scenic.jpg</file> <file>res/image/bg_scenic.jpg</file>
<file>qml/window/FluentInitializrWindow.qml</file> <file>qml/window/FluentInitializrWindow.qml</file>
<file>qml/page/T_OpenGL.qml</file>
<file>qml/page/T_Icons.qml</file>
</qresource> </qresource>
<qresource prefix="/"/>
</RCC> </RCC>

View File

@ -87,22 +87,22 @@
<context> <context>
<name>InitializrHelper</name> <name>InitializrHelper</name>
<message> <message>
<location filename="src/helper/InitializrHelper.cpp" line="77"/> <location filename="src/helper/InitializrHelper.cpp" line="69"/>
<source>The name cannot be empty</source> <source>The name cannot be empty</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>The creation path cannot be empty</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>The path does not exist</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/helper/InitializrHelper.cpp" line="92"/> <location filename="src/helper/InitializrHelper.cpp" line="84"/>
<source>%1 folder already exists</source> <source>%1 folder already exists</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -425,7 +425,7 @@
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="367"/> <location filename="qml/global/ItemsOriginal.qml" line="367"/>
<source>Awesome</source> <source>Icons</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
@ -475,42 +475,42 @@
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="430"/> <location filename="qml/global/ItemsOriginal.qml" line="430"/>
<source>QRCode</source> <source>OpenGL</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="436"/> <location filename="qml/global/ItemsOriginal.qml" line="436"/>
<source>Tour</source> <source>QRCode</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="442"/> <location filename="qml/global/ItemsOriginal.qml" line="442"/>
<source>Timeline</source> <source>Tour</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="448"/> <location filename="qml/global/ItemsOriginal.qml" line="448"/>
<source>Captcha</source> <source>Timeline</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="454"/> <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> <source>Network</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="461"/> <location filename="qml/global/ItemsOriginal.qml" line="467"/>
<source>Remote Loader</source> <source>Remote Loader</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="qml/global/ItemsOriginal.qml" line="475"/>
<source>Hot Loader</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="481"/> <location filename="qml/global/ItemsOriginal.qml" line="481"/>
<source>3D</source> <source>Hot Loader</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
@ -546,104 +546,104 @@
<context> <context>
<name>MainWindow</name> <name>MainWindow</name>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="307"/> <location filename="qml/window/MainWindow.qml" line="87"/>
<source>Dark Mode</source> <location filename="qml/window/MainWindow.qml" line="95"/>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="83"/>
<location filename="qml/window/MainWindow.qml" line="91"/>
<source>Quit</source> <source>Quit</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>Are you sure you want to exit the program?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="85"/> <location filename="qml/window/MainWindow.qml" line="89"/>
<source>Minimize</source> <source>Minimize</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="88"/> <location filename="qml/window/MainWindow.qml" line="92"/>
<source>Friendly Reminder</source> <source>Friendly Reminder</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>FluentUI is hidden from the tray, click on the tray to activate the window again</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="92"/> <location filename="qml/window/MainWindow.qml" line="96"/>
<location filename="qml/window/MainWindow.qml" line="336"/> <location filename="qml/window/MainWindow.qml" line="340"/>
<source>Cancel</source> <source>Cancel</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="103"/> <location filename="qml/window/MainWindow.qml" line="107"/>
<source>Open in Separate Window</source> <source>Open in Separate Window</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="200"/> <location filename="qml/window/MainWindow.qml" line="204"/>
<source>Click Time</source> <source>Click Time</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="210"/> <location filename="qml/window/MainWindow.qml" line="214"/>
<source>Search</source> <source>Search</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="301"/> <location filename="qml/window/MainWindow.qml" line="305"/>
<source>Finish</source> <source>Finish</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="302"/> <location filename="qml/window/MainWindow.qml" line="306"/>
<source>Next</source> <source>Next</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="303"/> <location filename="qml/window/MainWindow.qml" line="307"/>
<source>Previous</source> <source>Previous</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>Here you can switch to night mode.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="309"/> <location filename="qml/window/MainWindow.qml" line="313"/>
<source>Hide Easter eggs</source> <source>Hide Easter eggs</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>Try a few more clicks!!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="333"/> <location filename="qml/window/MainWindow.qml" line="337"/>
<source>Upgrade Tips</source> <source>Upgrade Tips</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>FluentUI is currently up to date </source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="334"/> <location filename="qml/window/MainWindow.qml" line="338"/>
<source> -- The current app version</source> <source> -- The current app version</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="334"/> <location filename="qml/window/MainWindow.qml" line="338"/>
<source> <source>
Now go and download the new version Now go and download the new version
@ -652,17 +652,17 @@ Updated content:
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="337"/> <location filename="qml/window/MainWindow.qml" line="341"/>
<source>OK</source> <source>OK</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>The current version is already the latest</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="371"/> <location filename="qml/window/MainWindow.qml" line="375"/>
<source>The network is abnormal</source> <source>The network is abnormal</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -769,29 +769,6 @@ Updated content:
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </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> <context>
<name>T_Badge</name> <name>T_Badge</name>
<message> <message>
@ -1107,46 +1084,6 @@ Updated content:
<source>Click to Select a Color - &gt;</source> <source>Click to Select a Color - &gt;</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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>
<context> <context>
<name>T_ComboBox</name> <name>T_ComboBox</name>
@ -1336,51 +1273,75 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
</message> </message>
<message> <message>
<location filename="qml/page/T_GroupBox.qml" line="17"/> <location filename="qml/page/T_GroupBox.qml" line="17"/>
<location filename="qml/page/T_GroupBox.qml" line="27"/> <location filename="qml/page/T_GroupBox.qml" line="35"/>
<source>E-mail</source> <source>E-mail</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_GroupBox.qml" line="18"/> <location filename="qml/page/T_GroupBox.qml" line="18"/>
<location filename="qml/page/T_GroupBox.qml" line="28"/> <location filename="qml/page/T_GroupBox.qml" line="36"/>
<source>Calendar</source> <source>Calendar</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_GroupBox.qml" line="19"/> <location filename="qml/page/T_GroupBox.qml" line="19"/>
<location filename="qml/page/T_GroupBox.qml" line="29"/> <location filename="qml/page/T_GroupBox.qml" line="37"/>
<source>Contacts</source> <source>Contacts</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_GroupBox.qml" line="24"/> <location filename="qml/page/T_GroupBox.qml" line="24"/>
<source>RadioButton Group</source> <source>RadioButton Group</source>
<oldsource>RadioButton Group111111111111111111111111</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_GroupBox.qml" line="46"/>
<source>Disabled</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context> <context>
<name>T_Home</name> <name>T_Home</name>
<message> <message>
<location filename="qml/page/T_Home.qml" line="23"/> <location filename="qml/page/T_Home.qml" line="19"/>
<source>FluentUI GitHub</source> <source>FluentUI GitHub</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>The latest FluentUI controls and styles for your applications.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Home.qml" line="32"/> <location filename="qml/page/T_Home.qml" line="28"/>
<source>FluentUI Initializr</source> <source>FluentUI Initializr</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>FluentUI Initializr is a Tool that helps you create and customize Fluent UI projects with various options.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </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="51"/>
<source>You Copied </source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>T_Image</name> <name>T_Image</name>
<message> <message>
@ -1402,51 +1363,82 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="23"/> <location filename="qml/page/T_InfoBar.qml" line="27"/>
<source>Info</source> <source>Info</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="25"/> <location filename="qml/page/T_InfoBar.qml" line="29"/>
<location filename="qml/page/T_InfoBar.qml" line="49"/> <location filename="qml/page/T_InfoBar.qml" line="53"/>
<source>This is an InfoBar in the Info Style</source> <source>This is an InfoBar in the Info Style</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="29"/> <location filename="qml/page/T_InfoBar.qml" line="33"/>
<source>Warning</source> <source>Warning</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="31"/> <location filename="qml/page/T_InfoBar.qml" line="35"/>
<source>This is an InfoBar in the Warning Style</source> <source>This is an InfoBar in the Warning Style</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="37"/> <location filename="qml/page/T_InfoBar.qml" line="41"/>
<source>This is an InfoBar in the Error Style</source> <source>This is an InfoBar in the Error Style</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="43"/> <location filename="qml/page/T_InfoBar.qml" line="47"/>
<source>This is an InfoBar in the Success Style</source> <source>This is an InfoBar in the Success Style</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="47"/> <location filename="qml/page/T_InfoBar.qml" line="51"/>
<source>InfoBar that needs to be turned off manually</source> <source>InfoBar that needs to be turned off manually</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="49"/> <location filename="qml/page/T_InfoBar.qml" line="53"/>
<source>Manual shutdown is supported</source> <source>Manual shutdown is supported</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="qml/page/T_InfoBar.qml" line="59"/>
<source>Manually close the info message box</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_InfoBar.qml" line="64"/>
<location filename="qml/page/T_InfoBar.qml" line="74"/>
<location filename="qml/page/T_InfoBar.qml" line="84"/>
<source>close &apos;%1&apos;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_InfoBar.qml" line="64"/>
<location filename="qml/page/T_InfoBar.qml" line="74"/>
<location filename="qml/page/T_InfoBar.qml" line="84"/>
<source>show &apos;%1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_InfoBar.qml" line="70"/>
<location filename="qml/page/T_InfoBar.qml" line="80"/>
<location filename="qml/page/T_InfoBar.qml" line="90"/>
<source>This is an &apos;%1&apos;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_InfoBar.qml" line="94"/>
<source>clear all info</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>T_LineChart</name> <name>T_LineChart</name>
<message> <message>
<location filename="qml/chart/T_LineChart.qml" line="10"/> <location filename="qml/chart/T_LineChart.qml" line="11"/>
<source>Line Chart</source> <source>Line Chart</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1621,6 +1613,14 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </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> <context>
<name>T_Pagination</name> <name>T_Pagination</name>
<message> <message>
@ -1736,22 +1736,30 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
</message> </message>
<message> <message>
<location filename="qml/page/T_RadioButton.qml" line="38"/> <location filename="qml/page/T_RadioButton.qml" line="38"/>
<location filename="qml/page/T_RadioButton.qml" line="80"/> <location filename="qml/page/T_RadioButton.qml" line="79"/>
<location filename="qml/page/T_RadioButton.qml" line="130"/>
<location filename="qml/page/T_RadioButton.qml" line="181"/>
<source>Disabled</source> <source>Disabled</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_RadioButton.qml" line="63"/> <location filename="qml/page/T_RadioButton.qml" line="64"/>
<location filename="qml/page/T_RadioButton.qml" line="115"/>
<location filename="qml/page/T_RadioButton.qml" line="166"/>
<source>Radio Button_1</source> <source>Radio Button_1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_RadioButton.qml" line="67"/> <location filename="qml/page/T_RadioButton.qml" line="67"/>
<location filename="qml/page/T_RadioButton.qml" line="118"/>
<location filename="qml/page/T_RadioButton.qml" line="169"/>
<source>Radio Button_2</source> <source>Radio Button_2</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_RadioButton.qml" line="71"/> <location filename="qml/page/T_RadioButton.qml" line="70"/>
<location filename="qml/page/T_RadioButton.qml" line="121"/>
<location filename="qml/page/T_RadioButton.qml" line="172"/>
<source>Radio Button_3</source> <source>Radio Button_3</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1957,26 +1965,6 @@ Some contents...</source>
<source>StatusLayout</source> <source>StatusLayout</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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>
<context> <context>
<name>T_TabView</name> <name>T_TabView</name>
@ -2020,7 +2008,7 @@ Some contents...</source>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="177"/> <location filename="qml/page/T_TableView.qml" line="177"/>
<location filename="qml/page/T_TableView.qml" line="478"/> <location filename="qml/page/T_TableView.qml" line="509"/>
<source>Name</source> <source>Name</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -2040,60 +2028,70 @@ Some contents...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="337"/> <location filename="qml/page/T_TableView.qml" line="365"/>
<source>Age</source> <source>Age</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="412"/> <location filename="qml/page/T_TableView.qml" line="440"/>
<source>Clear All</source> <source>Clear All</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="473"/> <location filename="qml/page/T_TableView.qml" line="447"/>
<source>Avatar</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="491"/>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="498"/>
<source>Nickname</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="505"/>
<source>Long String</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="513"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="532"/>
<source>&lt;Previous</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="533"/>
<source>Next&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="419"/>
<source>Delete Selection</source> <source>Delete Selection</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="443"/> <location filename="qml/page/T_TableView.qml" line="470"/>
<source>Add a row of Data</source> <source>Add a row of Data</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="qml/page/T_TableView.qml" line="476"/>
<source>Insert a Row</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="483"/>
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="514"/>
<source>Avatar</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="528"/>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="536"/>
<source>Nickname</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="543"/>
<source>Long String</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="551"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="569"/>
<source>&lt;Previous</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="570"/>
<source>Next&gt;</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>T_Text</name> <name>T_Text</name>
@ -2177,6 +2175,11 @@ Some contents...</source>
<source>Open Animation</source> <source>Open Animation</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="qml/page/T_Theme.qml" line="123"/>
<source>Open Blur Window</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>T_TimePicker</name> <name>T_TimePicker</name>
@ -2240,12 +2243,12 @@ Some contents...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Timeline.qml" line="115"/> <location filename="qml/page/T_Timeline.qml" line="114"/>
<source>Append</source> <source>Append</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Timeline.qml" line="121"/> <location filename="qml/page/T_Timeline.qml" line="120"/>
<source>clear</source> <source>clear</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -2376,13 +2379,23 @@ Some contents...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="44"/> <location filename="qml/page/T_TreeView.qml" line="183"/>
<source>Total %1 data, %2 data currently displayed</source> <source>Title</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="48"/> <location filename="qml/page/T_TreeView.qml" line="187"/>
<source>A total of %1 data items are selected</source> <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> <translation type="unfinished"></translation>
</message> </message>
</context> </context>

View File

@ -87,22 +87,22 @@
<context> <context>
<name>InitializrHelper</name> <name>InitializrHelper</name>
<message> <message>
<location filename="src/helper/InitializrHelper.cpp" line="77"/> <location filename="src/helper/InitializrHelper.cpp" line="69"/>
<source>The name cannot be empty</source> <source>The name cannot be empty</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>The creation path cannot be empty</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>The path does not exist</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/helper/InitializrHelper.cpp" line="92"/> <location filename="src/helper/InitializrHelper.cpp" line="84"/>
<source>%1 folder already exists</source> <source>%1 folder already exists</source>
<translation type="unfinished">%1 </translation> <translation type="unfinished">%1 </translation>
</message> </message>
@ -425,7 +425,7 @@
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="367"/> <location filename="qml/global/ItemsOriginal.qml" line="367"/>
<source>Awesome</source> <source>Icons</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
@ -475,43 +475,47 @@
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="430"/> <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> <source>QRCode</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="436"/> <location filename="qml/global/ItemsOriginal.qml" line="442"/>
<source>Tour</source> <source>Tour</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="442"/> <location filename="qml/global/ItemsOriginal.qml" line="448"/>
<source>Timeline</source> <source>Timeline</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="448"/> <location filename="qml/global/ItemsOriginal.qml" line="454"/>
<source>Captcha</source> <source>Captcha</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="454"/> <location filename="qml/global/ItemsOriginal.qml" line="460"/>
<source>Network</source> <source>Network</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="461"/> <location filename="qml/global/ItemsOriginal.qml" line="467"/>
<source>Remote Loader</source> <source>Remote Loader</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="475"/> <location filename="qml/global/ItemsOriginal.qml" line="481"/>
<source>Hot Loader</source> <source>Hot Loader</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="481"/>
<source>3D</source> <source>3D</source>
<translation type="unfinished">3D</translation> <translation type="obsolete">3D</translation>
</message> </message>
<message> <message>
<location filename="qml/global/ItemsOriginal.qml" line="487"/> <location filename="qml/global/ItemsOriginal.qml" line="487"/>
@ -546,104 +550,104 @@
<context> <context>
<name>MainWindow</name> <name>MainWindow</name>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="307"/> <location filename="qml/window/MainWindow.qml" line="311"/>
<source>Dark Mode</source> <source>Dark Mode</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="83"/> <location filename="qml/window/MainWindow.qml" line="87"/>
<location filename="qml/window/MainWindow.qml" line="91"/> <location filename="qml/window/MainWindow.qml" line="95"/>
<source>Quit</source> <source>Quit</source>
<translation type="unfinished">退</translation> <translation type="unfinished">退</translation>
</message> </message>
<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> <source>Are you sure you want to exit the program?</source>
<translation type="unfinished">退</translation> <translation type="unfinished">退</translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="85"/> <location filename="qml/window/MainWindow.qml" line="89"/>
<source>Minimize</source> <source>Minimize</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="88"/> <location filename="qml/window/MainWindow.qml" line="92"/>
<source>Friendly Reminder</source> <source>Friendly Reminder</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>FluentUI is hidden from the tray, click on the tray to activate the window again</source>
<translation type="unfinished">FluentUI </translation> <translation type="unfinished">FluentUI </translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="92"/> <location filename="qml/window/MainWindow.qml" line="96"/>
<location filename="qml/window/MainWindow.qml" line="336"/> <location filename="qml/window/MainWindow.qml" line="340"/>
<source>Cancel</source> <source>Cancel</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="103"/> <location filename="qml/window/MainWindow.qml" line="107"/>
<source>Open in Separate Window</source> <source>Open in Separate Window</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="200"/> <location filename="qml/window/MainWindow.qml" line="204"/>
<source>Click Time</source> <source>Click Time</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="210"/> <location filename="qml/window/MainWindow.qml" line="214"/>
<source>Search</source> <source>Search</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="301"/> <location filename="qml/window/MainWindow.qml" line="305"/>
<source>Finish</source> <source>Finish</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="302"/> <location filename="qml/window/MainWindow.qml" line="306"/>
<source>Next</source> <source>Next</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="303"/> <location filename="qml/window/MainWindow.qml" line="307"/>
<source>Previous</source> <source>Previous</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>Here you can switch to night mode.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="309"/> <location filename="qml/window/MainWindow.qml" line="313"/>
<source>Hide Easter eggs</source> <source>Hide Easter eggs</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>Try a few more clicks!!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="333"/> <location filename="qml/window/MainWindow.qml" line="337"/>
<source>Upgrade Tips</source> <source>Upgrade Tips</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>FluentUI is currently up to date </source>
<translation type="unfinished">FluentUI </translation> <translation type="unfinished">FluentUI </translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="334"/> <location filename="qml/window/MainWindow.qml" line="338"/>
<source> -- The current app version</source> <source> -- The current app version</source>
<translation type="unfinished"> -- </translation> <translation type="unfinished"> -- </translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="334"/> <location filename="qml/window/MainWindow.qml" line="338"/>
<source> <source>
Now go and download the new version Now go and download the new version
@ -656,17 +660,17 @@ Updated content:
</translation> </translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="337"/> <location filename="qml/window/MainWindow.qml" line="341"/>
<source>OK</source> <source>OK</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>The current version is already the latest</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/window/MainWindow.qml" line="371"/> <location filename="qml/window/MainWindow.qml" line="375"/>
<source>The network is abnormal</source> <source>The network is abnormal</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -776,24 +780,20 @@ Updated content:
<context> <context>
<name>T_Awesome</name> <name>T_Awesome</name>
<message> <message>
<location filename="qml/page/T_Awesome.qml" line="9"/>
<source>Awesome</source> <source>Awesome</source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Awesome.qml" line="13"/>
<source>Please enter a keyword</source> <source>Please enter a keyword</source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Awesome.qml" line="20"/>
<source>Search</source> <source>Search</source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Awesome.qml" line="55"/>
<source>You Copied </source> <source>You Copied </source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
</context> </context>
<context> <context>
@ -1112,44 +1112,36 @@ Updated content:
<translation type="unfinished"> - &gt;</translation> <translation type="unfinished"> - &gt;</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_ColorPicker.qml" line="22"/>
<source>Cancel</source> <source>Cancel</source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_ColorPicker.qml" line="23"/>
<source>OK</source> <source>OK</source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_ColorPicker.qml" line="24"/>
<source>Color Picker</source> <source>Color Picker</source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_ColorPicker.qml" line="25"/>
<source>Edit Color</source> <source>Edit Color</source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_ColorPicker.qml" line="26"/>
<source>Red</source> <source>Red</source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_ColorPicker.qml" line="27"/>
<source>Green</source> <source>Green</source>
<translation type="unfinished">绿</translation> <translation type="obsolete">绿</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_ColorPicker.qml" line="28"/>
<source>Blue</source> <source>Blue</source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_ColorPicker.qml" line="29"/>
<source>Opacity</source> <source>Opacity</source>
<translation type="unfinished"></translation> <translation type="obsolete"></translation>
</message> </message>
</context> </context>
<context> <context>
@ -1367,51 +1359,79 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
</message> </message>
<message> <message>
<location filename="qml/page/T_GroupBox.qml" line="17"/> <location filename="qml/page/T_GroupBox.qml" line="17"/>
<location filename="qml/page/T_GroupBox.qml" line="27"/> <location filename="qml/page/T_GroupBox.qml" line="35"/>
<source>E-mail</source> <source>E-mail</source>
<translation type="unfinished">邮箱</translation> <translation type="unfinished">邮箱</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_GroupBox.qml" line="18"/> <location filename="qml/page/T_GroupBox.qml" line="18"/>
<location filename="qml/page/T_GroupBox.qml" line="28"/> <location filename="qml/page/T_GroupBox.qml" line="36"/>
<source>Calendar</source> <source>Calendar</source>
<translation type="unfinished">日历</translation> <translation type="unfinished">日历</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_GroupBox.qml" line="19"/> <location filename="qml/page/T_GroupBox.qml" line="19"/>
<location filename="qml/page/T_GroupBox.qml" line="29"/> <location filename="qml/page/T_GroupBox.qml" line="37"/>
<source>Contacts</source> <source>Contacts</source>
<translation type="unfinished">联系人</translation> <translation type="unfinished">联系人</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_GroupBox.qml" line="24"/> <location filename="qml/page/T_GroupBox.qml" line="24"/>
<source>RadioButton Group</source> <source>RadioButton Group</source>
<oldsource>RadioButton Group111111111111111111111111</oldsource>
<translation type="unfinished">单选框分组</translation> <translation type="unfinished">单选框分组</translation>
</message> </message>
<message>
<location filename="qml/page/T_GroupBox.qml" line="46"/>
<source>Disabled</source>
<translation type="unfinished">禁用</translation>
</message>
</context> </context>
<context> <context>
<name>T_Home</name> <name>T_Home</name>
<message> <message>
<location filename="qml/page/T_Home.qml" line="23"/> <location filename="qml/page/T_Home.qml" line="19"/>
<source>FluentUI GitHub</source> <source>FluentUI GitHub</source>
<translation type="unfinished">FluentUI GitHub</translation> <translation type="unfinished">FluentUI GitHub</translation>
</message> </message>
<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> <source>The latest FluentUI controls and styles for your applications.</source>
<translation type="unfinished">最新的 FluentUI 控件和样式</translation> <translation type="unfinished">最新的 FluentUI 控件和样式</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Home.qml" line="32"/> <location filename="qml/page/T_Home.qml" line="28"/>
<source>FluentUI Initializr</source> <source>FluentUI Initializr</source>
<translation type="unfinished">FluentUI脚手架</translation> <translation type="unfinished">FluentUI脚手架</translation>
</message> </message>
<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> <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> <translation type="unfinished">FluentUI 脚手架是一个快速创建项目工具,可帮助您创建和自定义具有各种选项的 Fluent UI 项目</translation>
</message> </message>
</context> </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>
<source>Search</source>
<translation type="obsolete">搜索</translation>
</message>
<message>
<location filename="qml/page/T_Icons.qml" line="51"/>
<source>You Copied </source>
<translation type="unfinished">您复制</translation>
</message>
</context>
<context> <context>
<name>T_Image</name> <name>T_Image</name>
<message> <message>
@ -1437,46 +1457,77 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
<translation type="unfinished">信息栏</translation> <translation type="unfinished">信息栏</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="23"/> <location filename="qml/page/T_InfoBar.qml" line="27"/>
<source>Info</source> <source>Info</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="25"/> <location filename="qml/page/T_InfoBar.qml" line="29"/>
<location filename="qml/page/T_InfoBar.qml" line="49"/> <location filename="qml/page/T_InfoBar.qml" line="53"/>
<source>This is an InfoBar in the Info Style</source> <source>This is an InfoBar in the Info Style</source>
<translation type="unfinished">这是一个Info样式的信息栏</translation> <translation type="unfinished">这是一个Info样式的信息栏</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="29"/> <location filename="qml/page/T_InfoBar.qml" line="33"/>
<source>Warning</source> <source>Warning</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="31"/> <location filename="qml/page/T_InfoBar.qml" line="35"/>
<source>This is an InfoBar in the Warning Style</source> <source>This is an InfoBar in the Warning Style</source>
<translation type="unfinished">这是一个Warning样式的信息栏</translation> <translation type="unfinished">这是一个Warning样式的信息栏</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="37"/> <location filename="qml/page/T_InfoBar.qml" line="41"/>
<source>This is an InfoBar in the Error Style</source> <source>This is an InfoBar in the Error Style</source>
<translation type="unfinished">这是一个Error样式的信息栏</translation> <translation type="unfinished">这是一个Error样式的信息栏</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="43"/> <location filename="qml/page/T_InfoBar.qml" line="47"/>
<source>This is an InfoBar in the Success Style</source> <source>This is an InfoBar in the Success Style</source>
<translation type="unfinished">这是一个Success样式的信息栏</translation> <translation type="unfinished">这是一个Success样式的信息栏</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="47"/> <location filename="qml/page/T_InfoBar.qml" line="51"/>
<source>InfoBar that needs to be turned off manually</source> <source>InfoBar that needs to be turned off manually</source>
<translation type="unfinished">需要手动关闭的信息栏</translation> <translation type="unfinished">需要手动关闭的信息栏</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_InfoBar.qml" line="49"/> <location filename="qml/page/T_InfoBar.qml" line="53"/>
<source>Manual shutdown is supported</source> <source>Manual shutdown is supported</source>
<translation type="unfinished">支持手动关闭</translation> <translation type="unfinished">支持手动关闭</translation>
</message> </message>
<message>
<location filename="qml/page/T_InfoBar.qml" line="59"/>
<source>Manually close the info message box</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_InfoBar.qml" line="64"/>
<location filename="qml/page/T_InfoBar.qml" line="74"/>
<location filename="qml/page/T_InfoBar.qml" line="84"/>
<source>close &apos;%1&apos;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_InfoBar.qml" line="64"/>
<location filename="qml/page/T_InfoBar.qml" line="74"/>
<location filename="qml/page/T_InfoBar.qml" line="84"/>
<source>show &apos;%1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_InfoBar.qml" line="70"/>
<location filename="qml/page/T_InfoBar.qml" line="80"/>
<location filename="qml/page/T_InfoBar.qml" line="90"/>
<source>This is an &apos;%1&apos;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_InfoBar.qml" line="94"/>
<source>clear all info</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Loading...</source> <source>Loading...</source>
<translation type="obsolete">加载中...</translation> <translation type="obsolete">加载中...</translation>
@ -1485,7 +1536,7 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
<context> <context>
<name>T_LineChart</name> <name>T_LineChart</name>
<message> <message>
<location filename="qml/chart/T_LineChart.qml" line="10"/> <location filename="qml/chart/T_LineChart.qml" line="11"/>
<source>Line Chart</source> <source>Line Chart</source>
<translation type="unfinished">线型图</translation> <translation type="unfinished">线型图</translation>
</message> </message>
@ -1660,6 +1711,14 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
<translation type="unfinished">网络</translation> <translation type="unfinished">网络</translation>
</message> </message>
</context> </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> <context>
<name>T_Pagination</name> <name>T_Pagination</name>
<message> <message>
@ -1785,22 +1844,30 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
</message> </message>
<message> <message>
<location filename="qml/page/T_RadioButton.qml" line="38"/> <location filename="qml/page/T_RadioButton.qml" line="38"/>
<location filename="qml/page/T_RadioButton.qml" line="80"/> <location filename="qml/page/T_RadioButton.qml" line="79"/>
<location filename="qml/page/T_RadioButton.qml" line="130"/>
<location filename="qml/page/T_RadioButton.qml" line="181"/>
<source>Disabled</source> <source>Disabled</source>
<translation type="unfinished">禁用</translation> <translation type="unfinished">禁用</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_RadioButton.qml" line="63"/> <location filename="qml/page/T_RadioButton.qml" line="64"/>
<location filename="qml/page/T_RadioButton.qml" line="115"/>
<location filename="qml/page/T_RadioButton.qml" line="166"/>
<source>Radio Button_1</source> <source>Radio Button_1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_RadioButton.qml" line="67"/> <location filename="qml/page/T_RadioButton.qml" line="67"/>
<location filename="qml/page/T_RadioButton.qml" line="118"/>
<location filename="qml/page/T_RadioButton.qml" line="169"/>
<source>Radio Button_2</source> <source>Radio Button_2</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_RadioButton.qml" line="71"/> <location filename="qml/page/T_RadioButton.qml" line="70"/>
<location filename="qml/page/T_RadioButton.qml" line="121"/>
<location filename="qml/page/T_RadioButton.qml" line="172"/>
<source>Radio Button_3</source> <source>Radio Button_3</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -2029,24 +2096,20 @@ Some contents...</source>
<translation type="unfinished">状态布局</translation> <translation type="unfinished">状态布局</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_StatusLayout.qml" line="63"/>
<source>Loading...</source> <source>Loading...</source>
<translation type="unfinished">正在加载...</translation> <translation type="obsolete">正在加载...</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_StatusLayout.qml" line="64"/>
<source>Empty</source> <source>Empty</source>
<translation type="unfinished">空空如也</translation> <translation type="obsolete">空空如也</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_StatusLayout.qml" line="65"/>
<source>The page went wrong...</source> <source>The page went wrong...</source>
<translation type="unfinished">页面出错了...</translation> <translation type="obsolete">页面出错了...</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_StatusLayout.qml" line="66"/>
<source>Reload</source> <source>Reload</source>
<translation type="unfinished">重新加载</translation> <translation type="obsolete">重新加载</translation>
</message> </message>
</context> </context>
<context> <context>
@ -2091,7 +2154,7 @@ Some contents...</source>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="177"/> <location filename="qml/page/T_TableView.qml" line="177"/>
<location filename="qml/page/T_TableView.qml" line="478"/> <location filename="qml/page/T_TableView.qml" line="509"/>
<source>Name</source> <source>Name</source>
<translation type="unfinished">名称</translation> <translation type="unfinished">名称</translation>
</message> </message>
@ -2111,57 +2174,67 @@ Some contents...</source>
<translation type="unfinished">全选</translation> <translation type="unfinished">全选</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="337"/> <location filename="qml/page/T_TableView.qml" line="365"/>
<source>Age</source> <source>Age</source>
<translation type="unfinished">年龄</translation> <translation type="unfinished">年龄</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="412"/> <location filename="qml/page/T_TableView.qml" line="440"/>
<source>Clear All</source> <source>Clear All</source>
<translation type="unfinished">清除所有</translation> <translation type="unfinished">清除所有</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="473"/> <location filename="qml/page/T_TableView.qml" line="476"/>
<source>Insert a Row</source>
<translation type="unfinished">插入一行</translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="483"/>
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
<translation type="unfinished">焦点未获取:请点击表格中的任意一项,作为插入的靶点!</translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="514"/>
<source>Avatar</source> <source>Avatar</source>
<translation type="unfinished">头像</translation> <translation type="unfinished">头像</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="491"/> <location filename="qml/page/T_TableView.qml" line="528"/>
<source>Address</source> <source>Address</source>
<translation type="unfinished">地址</translation> <translation type="unfinished">地址</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="498"/> <location filename="qml/page/T_TableView.qml" line="536"/>
<source>Nickname</source> <source>Nickname</source>
<translation type="unfinished">昵称</translation> <translation type="unfinished">昵称</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="505"/> <location filename="qml/page/T_TableView.qml" line="543"/>
<source>Long String</source> <source>Long String</source>
<translation type="unfinished">长字符串</translation> <translation type="unfinished">长字符串</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="513"/> <location filename="qml/page/T_TableView.qml" line="551"/>
<source>Options</source> <source>Options</source>
<translation type="unfinished">操作</translation> <translation type="unfinished">操作</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="532"/> <location filename="qml/page/T_TableView.qml" line="569"/>
<source>&lt;Previous</source> <source>&lt;Previous</source>
<translation type="unfinished">&lt;上一页</translation> <translation type="unfinished">&lt;上一页</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="533"/> <location filename="qml/page/T_TableView.qml" line="570"/>
<source>Next&gt;</source> <source>Next&gt;</source>
<translation type="unfinished">下一页&gt;</translation> <translation type="unfinished">下一页&gt;</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="419"/> <location filename="qml/page/T_TableView.qml" line="447"/>
<source>Delete Selection</source> <source>Delete Selection</source>
<translation type="unfinished">删除选中</translation> <translation type="unfinished">删除选中</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="443"/> <location filename="qml/page/T_TableView.qml" line="470"/>
<source>Add a row of Data</source> <source>Add a row of Data</source>
<translation type="unfinished">添加一行数据</translation> <translation type="unfinished">添加一行数据</translation>
</message> </message>
@ -2248,6 +2321,11 @@ Some contents...</source>
<source>Open Animation</source> <source>Open Animation</source>
<translation type="unfinished">开启动画</translation> <translation type="unfinished">开启动画</translation>
</message> </message>
<message>
<location filename="qml/page/T_Theme.qml" line="123"/>
<source>Open Blur Window</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>T_TimePicker</name> <name>T_TimePicker</name>
@ -2311,12 +2389,12 @@ Some contents...</source>
<translation type="unfinished">时间轴</translation> <translation type="unfinished">时间轴</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Timeline.qml" line="115"/> <location filename="qml/page/T_Timeline.qml" line="114"/>
<source>Append</source> <source>Append</source>
<translation type="unfinished">追加</translation> <translation type="unfinished">追加</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Timeline.qml" line="121"/> <location filename="qml/page/T_Timeline.qml" line="120"/>
<source>clear</source> <source>clear</source>
<translation type="unfinished">清空</translation> <translation type="unfinished">清空</translation>
</message> </message>
@ -2459,14 +2537,32 @@ Some contents...</source>
<translation type="unfinished">树</translation> <translation type="unfinished">树</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="44"/>
<source>Total %1 data, %2 data currently displayed</source> <source>Total %1 data, %2 data currently displayed</source>
<translation type="unfinished">共计%1条数据当前显示的%2条数据</translation> <translation type="obsolete">共计%1条数据当前显示的%2条数据</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TreeView.qml" line="48"/>
<source>A total of %1 data items are selected</source> <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> </message>
</context> </context>
<context> <context>

View File

@ -7,7 +7,9 @@ import "../component"
FluScrollablePage{ FluScrollablePage{
id: root
title: qsTr("Line Chart") title: qsTr("Line Chart")
property var data : []
FluFrame{ FluFrame{
Layout.preferredWidth: 500 Layout.preferredWidth: 500
@ -15,13 +17,14 @@ FluScrollablePage{
padding: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
id: chart
anchors.fill: parent anchors.fill: parent
chartType: 'line' chartType: 'line'
chartData: { return { chartData: { return {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{ datasets: [{
label: 'My First Dataset', label: 'My First Dataset',
data: [65, 59, 80, 81, 56, 55, 40], data: root.data,
fill: false, fill: false,
borderColor: 'rgb(75, 192, 192)', borderColor: 'rgb(75, 192, 192)',
tension: 0.1 tension: 0.1
@ -41,5 +44,20 @@ FluScrollablePage{
} }
} }
} }
Timer{
id: timer
interval: 300
repeat: true
onTriggered: {
root.data.push(Math.random()*100)
if(root.data.length>7){
root.data.shift()
}
chart.animateToNewData()
}
}
Component.onCompleted: {
timer.restart()
}
} }
} }

View File

@ -364,9 +364,9 @@ FluObject{
onTap: { navigationView.push(url) } onTap: { navigationView.push(url) }
} }
FluPaneItem{ FluPaneItem{
title: qsTr("Awesome") title: qsTr("Icons")
menuDelegate: paneItemMenu menuDelegate: paneItemMenu
url: "qrc:/example/qml/page/T_Awesome.qml" url: "qrc:/example/qml/page/T_Icons.qml"
onTap: { navigationView.push(url) } onTap: { navigationView.push(url) }
} }
} }
@ -426,6 +426,12 @@ FluObject{
FluPaneItemExpander{ FluPaneItemExpander{
title: qsTr("Other") title: qsTr("Other")
icon: FluentIcons.Shop icon: FluentIcons.Shop
FluPaneItem{
title: qsTr("OpenGL")
menuDelegate: paneItemMenu
url: "qrc:/example/qml/page/T_OpenGL.qml"
onTap: { navigationView.push(url) }
}
FluPaneItem{ FluPaneItem{
title: qsTr("QRCode") title: qsTr("QRCode")
menuDelegate: paneItemMenu menuDelegate: paneItemMenu
@ -477,12 +483,6 @@ FluObject{
FluRouter.navigate("/hotload") FluRouter.navigate("/hotload")
} }
} }
FluPaneItem{
title: qsTr("3D")
menuDelegate: paneItemMenu
url: "qrc:/example/qml/page/T_3D.qml"
onTap: { navigationView.push(url) }
}
FluPaneItem{ FluPaneItem{
title: qsTr("Test Crash") title: qsTr("Test Crash")
onTapListener: function(){ onTapListener: function(){

View File

@ -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
}
}
}

View File

@ -1,71 +0,0 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import FluentUI 1.0
FluContentPage {
title: qsTr("Awesome")
FluTextBox{
id:text_box
placeholderText: qsTr("Please enter a keyword")
anchors{
top:parent.top
}
}
FluFilledButton{
text: qsTr("Search")
anchors{
left: text_box.right
verticalCenter: text_box.verticalCenter
leftMargin: 14
}
onClicked: {
grid_view.model = FluTheme.awesomeList(text_box.text)
}
}
GridView{
id:grid_view
cellWidth: 80
cellHeight: 80
clip: true
boundsBehavior: GridView.StopAtBounds
model:FluTheme.awesomeList()
ScrollBar.vertical: FluScrollBar {}
anchors{
topMargin: 10
top:text_box.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
delegate: Item {
width: 68
height: 80
FluIconButton{
id:item_icon
iconSource:modelData.icon
anchors.horizontalCenter: parent.horizontalCenter
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
}
}
}
}

View File

@ -18,16 +18,7 @@ FluScrollablePage{
text: qsTr("Click to Select a Color - >") text: qsTr("Click to Select a Color - >")
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
FluColorPicker{ 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")
}
} }
} }
CodeExpander{ CodeExpander{

View File

@ -22,18 +22,37 @@ FluScrollablePage{
FluGroupBox { FluGroupBox {
title: qsTr("RadioButton Group") title: qsTr("RadioButton Group")
Layout.fillWidth: true
Layout.preferredHeight: 150
Layout.topMargin: 20
FluRadioButtons { FluRadioButtons {
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
spacing: 10 spacing: 10
disabled: radio_button_switch.checked
FluRadioButton { text: qsTr("E-mail") } FluRadioButton { text: qsTr("E-mail") }
FluRadioButton { text: qsTr("Calendar") } FluRadioButton { text: qsTr("Calendar") }
FluRadioButton { text: qsTr("Contacts") } FluRadioButton { text: qsTr("Contacts") }
} }
FluToggleSwitch{
id: radio_button_switch
anchors{
right: parent.right
verticalCenter: parent.verticalCenter
} }
text: qsTr("Disabled")
}
}
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 4 Layout.topMargin: 4
code:'FluGroupBox { code:`
FluGroupBox {
title: qsTr("CheckBox Group") title: qsTr("CheckBox Group")
ColumnLayout { ColumnLayout {
spacing: 10 spacing: 10
@ -42,7 +61,20 @@ FluScrollablePage{
FluCheckBox { text: qsTr("Calendar") } FluCheckBox { text: qsTr("Calendar") }
FluCheckBox { text: qsTr("Contacts") } FluCheckBox { text: qsTr("Contacts") }
} }
}' }
FluGroupBox {
title: qsTr("RadioButton Group")
FluRadioButtons {
spacing: 10
disabled: true // 禁用所有FluRadioButton子组件
manuallyDisabled: true // 是否指定每个FluRadioButton上的disabled选项
FluRadioButton { text: qsTr("E-mail") }
FluRadioButton { text: qsTr("Calendar") }
FluRadioButton { text: qsTr("Contacts") }
}
}
`
} }
} }

View File

@ -12,10 +12,6 @@ FluScrollablePage{
animationEnabled: false animationEnabled: false
header: Item{} header: Item{}
FluentInitializrWindow{
id:fluent_Initializr
}
ListModel{ ListModel{
id: model_header id: model_header
ListElement{ ListElement{

View File

@ -0,0 +1,64 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import FluentUI 1.0
FluContentPage {
title: qsTr("Icons")
FluTextBox{
id: text_box
placeholderText: qsTr("Please enter a keyword")
anchors{
top: parent.top
}
onTextChanged: {
grid_view.model = FluApp.iconData(text_box.text)
}
}
GridView{
id: grid_view
cellWidth: 110
cellHeight: 110
clip: true
boundsBehavior: GridView.StopAtBounds
model: FluApp.iconData()
ScrollBar.vertical: FluScrollBar {}
anchors{
topMargin: 10
top: text_box.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
delegate: Item {
width: 100
height: 100
FluIconButton{
id:item_icon
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{
width: parent.width
horizontalAlignment: Qt.AlignHCenter
wrapMode: Text.WrapAnywhere
text: modelData.name
anchors.top: parent.top
anchors.topMargin: 60
}
}
}
}
}

View File

@ -9,9 +9,13 @@ FluScrollablePage{
title: qsTr("InfoBar") title: qsTr("InfoBar")
property var info1
property var info2
property var info3
FluFrame{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 270 Layout.preferredHeight: 350
padding: 10 padding: 10
ColumnLayout{ ColumnLayout{
spacing: 14 spacing: 14
@ -49,6 +53,51 @@ FluScrollablePage{
showInfo(qsTr("This is an InfoBar in the Info Style"),0,qsTr("Manual shutdown is supported")) showInfo(qsTr("This is an InfoBar in the Info Style"),0,qsTr("Manual shutdown is supported"))
} }
} }
FluText{
wrapMode: Text.WrapAnywhere
width: parent.width
text: qsTr("Manually close the info message box")
}
Row{
spacing: 5
FluButton{
text: (info1 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info1")
onClicked: {
if(info1) {
info1.close()
return
}
info1 = showInfo(qsTr("This is an '%1'").arg("info1"), 0)
}
}
FluButton{
text: (info2 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info2")
onClicked: {
if(info2) {
info2.close()
return
}
info2 = showInfo(qsTr("This is an '%1'").arg("info2"), 0)
}
}
FluButton{
text: (info3 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info3")
onClicked: {
if(info3) {
info3.close()
return
}
info3 = showInfo(qsTr("This is an '%1'").arg("info3"), 0)
}
}
FluButton{
text: qsTr("clear all info")
onClicked: {
clearAllInfo()
}
}
}
FluButton{ FluButton{
text:"Loading" text:"Loading"
onClicked: { onClicked: {
@ -60,12 +109,17 @@ FluScrollablePage{
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -6
code:'showInfo(qsTr("This is an InfoBar in the Info Style")) code:`
showInfo(qsTr("This is an InfoBar in the Info Style"))
showWarning(qsTr("This is an InfoBar in the Warning Style")) showWarning(qsTr("This is an InfoBar in the Warning Style"))
showError(qsTr("This is an InfoBar in the Error Style")) showError(qsTr("This is an InfoBar in the Error Style"))
showSuccess(qsTr("This is an InfoBar in the Success Style"))' showSuccess(qsTr("This is an InfoBar in the Success Style"))
var info1 = showInfo(qsTr("This is an 'Info1'"), 0)
info1.close()
`
} }
} }

View 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
}
}
}
}

View File

@ -53,21 +53,20 @@ FluScrollablePage{
Layout.topMargin: 20 Layout.topMargin: 20
FluRadioButtons{ FluRadioButtons{
spacing: 8 spacing: 8
disabled: radio_button_switch2.checked
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
left: parent.left left: parent.left
} }
currentIndex: 1
FluRadioButton{ FluRadioButton{
disabled: radio_button_switch2.checked
text: qsTr("Radio Button_1") text: qsTr("Radio Button_1")
} }
FluRadioButton{ FluRadioButton{
disabled: radio_button_switch2.checked
text: qsTr("Radio Button_2") text: qsTr("Radio Button_2")
} }
FluRadioButton{ FluRadioButton{
disabled: radio_button_switch2.checked
text: qsTr("Radio Button_3") text: qsTr("Radio Button_3")
} }
} }
@ -97,4 +96,106 @@ FluScrollablePage{
}' }'
} }
FluFrame{
Layout.fillWidth: true
Layout.preferredHeight: 60
padding: 10
Layout.topMargin: 20
FluRadioButtons{
spacing: 8
anchors.verticalCenter: parent.verticalCenter
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
disabled: radio_button_switch3.checked
orientation: Qt.Horizontal
currentIndex: 1
FluRadioButton{
text: qsTr("Radio Button_1")
}
FluRadioButton{
text: qsTr("Radio Button_2")
}
FluRadioButton{
text: qsTr("Radio Button_3")
}
}
FluToggleSwitch{
id: radio_button_switch3
anchors{
right: parent.right
verticalCenter: parent.verticalCenter
}
text: qsTr("Disabled")
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -6
code:'FluRadioButtons{
spacing: 8
orientation: Qt.Horizontal
FluRadioButton{
text:"Radio Button_1"
}
FluRadioButton{
text:"Radio Button_2"
}
FluRadioButton{
text:"Radio Button_3"
}
}'
}
FluFrame{
Layout.fillWidth: true
Layout.preferredHeight: 100
padding: 10
Layout.topMargin: 20
FluRadioButtons{
spacing: 8
anchors.verticalCenter: parent.verticalCenter
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
disabled: radio_button_switch4.checked
currentIndex: -1
FluCheckBox{
text: qsTr("Radio Button_1")
}
FluCheckBox{
text: qsTr("Radio Button_2")
}
FluCheckBox{
text: qsTr("Radio Button_3")
}
}
FluToggleSwitch{
id: radio_button_switch4
anchors{
right: parent.right
verticalCenter: parent.verticalCenter
}
text: qsTr("Disabled")
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -6
code:'FluRadioButtons{
spacing: 8
FluCheckBox{
text:"Radio Button_1"
}
FluCheckBox{
text:"Radio Button_2"
}
FluCheckBox{
text:"Radio Button_3"
}
}'
}
} }

View File

@ -60,12 +60,8 @@ FluScrollablePage{
FluStatusLayout{ FluStatusLayout{
id:status_view id:status_view
anchors.fill: parent anchors.fill: parent
loadingText: qsTr("Loading...")
emptyText: qsTr("Empty")
errorText: qsTr("The page went wrong...")
errorButtonText: qsTr("Reload")
onErrorClicked:{ onErrorClicked:{
showError("Click Reload") status_view.statusMode = FluStatusLayoutType.Loading
} }
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent

View File

@ -13,7 +13,7 @@ FluContentPage{
property var dataSource : [] property var dataSource : []
property int sortType: 0 property int sortType: 0
property bool seletedAll: true property bool selectedAll: true
property string nameKeyword: "" property string nameKeyword: ""
onNameKeywordChanged: { onNameKeywordChanged: {
@ -32,11 +32,11 @@ FluContentPage{
onCheckBoxChanged: { onCheckBoxChanged: {
for(var i =0;i< table_view.rows ;i++){ for(var i =0;i< table_view.rows ;i++){
if(false === table_view.getRow(i).checkbox.options.checked){ if(false === table_view.getRow(i).checkbox.options.checked){
root.seletedAll = false root.selectedAll = false
return return
} }
} }
root.seletedAll = true root.selectedAll = true
} }
onSortTypeChanged: { onSortTypeChanged: {
@ -238,13 +238,15 @@ FluContentPage{
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
FluCheckBox{ FluCheckBox{
checked: true === root.seletedAll checked: true === root.selectedAll
animationEnabled: false animationEnabled: false
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
clickListener: function(){ clickListener: function(){
root.seletedAll = !root.seletedAll root.selectedAll = !root.selectedAll
var checked = root.seletedAll var checked = root.selectedAll
itemModel.display = table_view.customItem(com_column_checbox,{"checked":checked}) var columnModel = model.display
columnModel.title = table_view.customItem(com_column_checbox,{"checked":checked})
model.display = columnModel
for(var i =0;i< table_view.rows ;i++){ for(var i =0;i< table_view.rows ;i++){
var rowData = table_view.getRow(i) var rowData = table_view.getRow(i)
rowData.checkbox = table_view.customItem(com_checbox,{"checked":checked}) rowData.checkbox = table_view.customItem(com_checbox,{"checked":checked})
@ -271,7 +273,8 @@ FluContentPage{
} }
Component.onCompleted: { Component.onCompleted: {
currentIndex=["100","300","500","1000"].findIndex((element) => element === display) currentIndex=["100","300","500","1000"].findIndex((element) => element === display)
selectAll() textBox.forceActiveFocus()
textBox.selectAll()
} }
onCommit: { onCommit: {
editTextChaged(editText) editTextChaged(editText)
@ -280,6 +283,29 @@ FluContentPage{
} }
} }
Component{
id:com_auto_suggestbox
FluAutoSuggestBox {
id: textbox
anchors.fill: parent
focus: true
Component.onCompleted: {
var data = ["傲来国界花果山水帘洞","傲来国界坎源山脏水洞","大唐国界黑风山黑风洞","大唐国界黄风岭黄风洞","大唐国界骷髅山白骨洞","宝象国界碗子山波月洞","宝象国界平顶山莲花洞","宝象国界压龙山压龙洞","乌鸡国界号山枯松涧火云洞","乌鸡国界衡阳峪黑水河河神府"]
var result = data.map(function(item) {
return {title: item};
});
items = result
textbox.text= String(display)
forceActiveFocus()
selectAll()
}
onCommit: {
editTextChaged(textbox.text)
tableView.closeEditor()
}
}
}
Component{ Component{
id:com_avatar id:com_avatar
Item{ Item{
@ -323,7 +349,9 @@ FluContentPage{
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
custom_update_dialog.showDialog(options.title,function(text){ custom_update_dialog.showDialog(options.title,function(text){
itemModel.display = table_view.customItem(com_column_update_title,{"title":text}) var columnModel = model.display
columnModel.title = table_view.customItem(com_column_update_title,{"title":text})
model.display = columnModel
}) })
} }
} }
@ -421,15 +449,15 @@ FluContentPage{
var data = [] var data = []
var rows = [] var rows = []
for (var i = 0; i < table_view.rows; i++) { for (var i = 0; i < table_view.rows; i++) {
var item = table_view.getRow(i); var item = table_view.getRow(i)
rows.push(item) rows.push(item)
if (!item.checkbox.options.checked) { if (!item.checkbox.options.checked) {
data.push(item); data.push(item);
} }
} }
var sourceModel = table_view.sourceModel; var sourceModel = table_view.sourceModel
for (i = 0; i < sourceModel.rowCount; i++) { for (i = 0; i < sourceModel.rowCount; i++) {
var sourceItem = sourceModel.getRow(i); var sourceItem = sourceModel.getRow(i)
const foundItem = rows.find(item=> item._key === sourceItem._key) const foundItem = rows.find(item=> item._key === sourceItem._key)
if (!foundItem) { if (!foundItem) {
data.push(sourceItem); data.push(sourceItem);
@ -438,14 +466,24 @@ FluContentPage{
table_view.dataSource = data table_view.dataSource = data
} }
} }
FluButton{ FluButton{
text: qsTr("Add a row of Data") text: qsTr("Add a row of Data")
onClicked: { onClicked: {
table_view.appendRow(genTestObject()) table_view.appendRow(genTestObject())
} }
} }
FluButton{
text: qsTr("Insert a Row")
onClicked: {
var index = table_view.currentIndex()
if(index !== -1){
var testObj = genTestObject()
table_view.insertRow(index,testObj)
}else{
showWarning(qsTr("Focus not acquired: Please click any item in the form as the target for insertion!"))
}
}
}
} }
} }
@ -465,20 +503,19 @@ FluContentPage{
{ {
title: table_view.customItem(com_column_checbox,{checked:true}), title: table_view.customItem(com_column_checbox,{checked:true}),
dataIndex: 'checkbox', dataIndex: 'checkbox',
width:100, frozen: true
minimumWidth:100,
maximumWidth:100
},
{
title: table_view.customItem(com_column_update_title,{title:qsTr("Avatar")}),
dataIndex: 'avatar',
width:100
}, },
{ {
title: table_view.customItem(com_column_filter_name,{title:qsTr("Name")}), title: table_view.customItem(com_column_filter_name,{title:qsTr("Name")}),
dataIndex: 'name', dataIndex: 'name',
readOnly:true readOnly:true
}, },
{
title: table_view.customItem(com_column_update_title,{title:qsTr("Avatar")}),
dataIndex: 'avatar',
width:100,
frozen:true
},
{ {
title: table_view.customItem(com_column_sort_age,{sort:0}), title: table_view.customItem(com_column_sort_age,{sort:0}),
dataIndex: 'age', dataIndex: 'age',
@ -490,6 +527,7 @@ FluContentPage{
{ {
title: qsTr("Address"), title: qsTr("Address"),
dataIndex: 'address', dataIndex: 'address',
editDelegate: com_auto_suggestbox,
width:200, width:200,
minimumWidth:100, minimumWidth:100,
maximumWidth:250 maximumWidth:250
@ -513,8 +551,7 @@ FluContentPage{
title: qsTr("Options"), title: qsTr("Options"),
dataIndex: 'action', dataIndex: 'action',
width:160, width:160,
minimumWidth:160, frozen:true
maximumWidth:160
} }
] ]
} }
@ -566,7 +603,7 @@ FluContentPage{
return avatars[randomIndex]; return avatars[randomIndex];
} }
return { return {
checkbox: table_view.customItem(com_checbox,{checked:root.seletedAll}), checkbox: table_view.customItem(com_checbox,{checked:root.selectedAll}),
avatar:table_view.customItem(com_avatar,{avatar:getAvatar()}), avatar:table_view.customItem(com_avatar,{avatar:getAvatar()}),
name: getRandomName(), name: getRandomName(),
age:getRandomAge(), age:getRandomAge(),
@ -579,7 +616,7 @@ FluContentPage{
} }
} }
function loadData(page,count){ function loadData(page,count){
root.seletedAll = true root.selectedAll = true
const dataSource = [] const dataSource = []
for(var i=0;i<count;i++){ for(var i=0;i<count;i++){
dataSource.push(genTestObject()) dataSource.push(genTestObject())

View File

@ -13,7 +13,7 @@ FluScrollablePage{
FluFrame{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 340 Layout.preferredHeight: 408
padding: 10 padding: 10
ColumnLayout{ ColumnLayout{
@ -119,6 +119,17 @@ FluScrollablePage{
FluTheme.animationEnabled = !FluTheme.animationEnabled 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{ CodeExpander{

View File

@ -44,7 +44,6 @@ FluScrollablePage{
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
horizontalAlignment: isRight ? Qt.AlignRight : Qt.AlignLeft horizontalAlignment: isRight ? Qt.AlignRight : Qt.AlignLeft
text: modelData.text text: modelData.text
font.bold: true
linkColor: FluTheme.dark ? FluColors.Teal.lighter : FluColors.Teal.dark linkColor: FluTheme.dark ? FluColors.Teal.lighter : FluColors.Teal.dark
onLinkActivated: onLinkActivated:
(link)=> { (link)=> {

View File

@ -9,14 +9,33 @@ FluContentPage {
title: qsTr("TreeView") title: qsTr("TreeView")
function treeData(){ 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 = []; const list = [];
for (let i = 0; i < 6; i += 1) { for (let i = 0; i < 4; i += 1) {
const key = `${path}-${i}`; const key = `${path}-${i}`;
const treeNode = { const treeNode = {
title: key, title: key,
key, _key: key,
name: getRandomName(),
avatar:tree_view.customItem(com_avatar,{avatar:getRandomAvatar()}),
address: getRandomAddresses()
}; };
if (level > 0) { if (level > 0) {
treeNode.children = dig(key, level - 1); treeNode.children = dig(key, level - 1);
@ -28,26 +47,46 @@ FluContentPage {
return dig(); return dig();
} }
Column{ Component{
id: layout_column id:com_avatar
spacing: 12 Item{
width: 300 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{ anchors{
left: parent.left
right: parent.right
top: parent.top top: parent.top
topMargin: 10
}
height: 80
clip: true
Row{
spacing: 12
anchors{
left: parent.left left: parent.left
leftMargin: 10 leftMargin: 10
bottom:parent.bottom verticalCenter: parent.verticalCenter
bottomMargin: 20
} }
Column{
FluText{ anchors.verticalCenter: parent.verticalCenter
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{ RowLayout{
spacing: 10 spacing: 10
FluText{ FluText{
@ -56,8 +95,8 @@ FluContentPage {
} }
FluSlider{ FluSlider{
id: slider_cell_height id: slider_cell_height
value: 30 value: 38
from: 30 from: 38
to:100 to:100
} }
} }
@ -69,26 +108,29 @@ FluContentPage {
} }
FluSlider{ FluSlider{
id: slider_depth_padding id: slider_depth_padding
value: 30 value: 15
from: 30 from: 15
to:100 to:100
} }
} }
}
Column{
spacing: 8
anchors.verticalCenter: parent.verticalCenter
FluToggleSwitch{ FluToggleSwitch{
id: switch_showline id: switch_showline
text:"showLine" text:"showLine"
checked: false checked: false
} }
FluToggleSwitch{
id: switch_draggable
text:"draggable"
checked: false
}
FluToggleSwitch{ FluToggleSwitch{
id: switch_checkable id: switch_checkable
text:"checkable" text:"checkable"
checked: false checked: false
} }
}
Column{
spacing: 8
anchors.verticalCenter: parent.verticalCenter
FluButton{ FluButton{
text: "all expand" text: "all expand"
onClicked: { onClicked: {
@ -102,29 +144,62 @@ FluContentPage {
} }
} }
} }
FluFrame{ FluButton{
anchors{ text: "print selection model"
left: layout_column.right onClicked: {
top: parent.top var printData = []
bottom: parent.bottom var data = tree_view.selectionModel();
right: parent.right console.debug(data.length)
rightMargin: 5 for(var i = 0; i <= data.length-1 ; i++){
topMargin: 5 const newObj = Object.assign({}, data[i].data);
bottomMargin: 5 delete newObj["__parent"];
delete newObj["children"];
printData.push(newObj)
} }
FluShadow{} console.debug(JSON.stringify(printData))
}
}
}
}
FluTreeView{ FluTreeView{
id:tree_view id:tree_view
anchors.fill: parent anchors{
left: parent.left
top: layout_controls.bottom
topMargin: 10
bottom: parent.bottom
right: parent.right
}
cellHeight: slider_cell_height.value cellHeight: slider_cell_height.value
draggable:switch_draggable.checked
showLine: switch_showline.checked showLine: switch_showline.checked
checkable:switch_checkable.checked checkable:switch_checkable.checked
depthPadding: slider_depth_padding.value 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: { Component.onCompleted: {
var data = treeData() var data = treeData()
dataSource = data dataSource = data
} }
} }
} }
}

View File

@ -20,7 +20,7 @@ FluWindowDialog {
showError(message) showError(message)
} }
function onSuccess(path){ function onSuccess(path){
FluTools.showFileInFolder(path+"/CMakeLists.txt") FluTools.showFileInFolder(path)
window.close() window.close()
} }
} }

View File

@ -15,7 +15,7 @@ FluWindow {
title: "FluentUI" title: "FluentUI"
width: 1000 width: 1000
height: 680 height: 680
minimumWidth: 520 minimumWidth: 800
minimumHeight: 200 minimumHeight: 200
launchMode: FluWindowType.SingleTask launchMode: FluWindowType.SingleTask
fitsAppBarWindows: true fitsAppBarWindows: true
@ -28,6 +28,10 @@ FluWindow {
z:7 z:7
} }
FluentInitializrWindow{
id:fluent_Initializr
}
FluEvent{ FluEvent{
name: "checkUpdate" name: "checkUpdate"
onTriggered: { onTriggered: {

View File

@ -1,17 +1,15 @@
#include "AppInfo.h" #include "AppInfo.h"
#include <QQmlContext> #include <QQmlContext>
#include <QDebug>
#include <QGuiApplication> #include <QGuiApplication>
#include "Version.h" #include "Version.h"
AppInfo::AppInfo(QObject *parent) AppInfo::AppInfo(QObject *parent)
: QObject{parent} : QObject{parent} {
{
version(APPLICATION_VERSION); version(APPLICATION_VERSION);
} }
void AppInfo::testCrash(){ [[maybe_unused]] void AppInfo::testCrash() {
auto *crash = reinterpret_cast<volatile int *>(0); auto *crash = reinterpret_cast<volatile int *>(0);
*crash = 0; *crash = 0;
} }

View File

@ -1,20 +1,18 @@
#ifndef APPINFO_H #pragma once
#define APPINFO_H
#include <QObject> #include <QObject>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h" #include "singleton.h"
class AppInfo : public QObject class AppInfo : public QObject {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QString, version) Q_PROPERTY_AUTO(QString, version)
private: private:
explicit AppInfo(QObject *parent = nullptr); explicit AppInfo(QObject *parent = nullptr);
public: public:
SINGLETON(AppInfo) SINGLETON(AppInfo)
Q_INVOKABLE void testCrash();
};
#endif // APPINFO_H [[maybe_unused]] Q_INVOKABLE void testCrash();
};

View File

@ -1,5 +1,4 @@
#ifndef APP_DUMP_H #pragma once
#define APP_DUMP_H
#include <Windows.h> #include <Windows.h>
#include <DbgHelp.h> #include <DbgHelp.h>
@ -12,22 +11,22 @@
#pragma comment(lib, "Dbghelp.lib") #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){ static void
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); 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"); HMODULE module = LoadLibraryW(L"Dbghelp.dll");
if (module) if (module) {
{
MiniDumpWriteDumpPtr mini_dump_write_dump; MiniDumpWriteDumpPtr mini_dump_write_dump;
mini_dump_write_dump = reinterpret_cast<MiniDumpWriteDumpPtr>(GetProcAddress(module, "MiniDumpWriteDump")); mini_dump_write_dump = reinterpret_cast<MiniDumpWriteDumpPtr>(GetProcAddress(module, "MiniDumpWriteDump"));
if (mini_dump_write_dump) if (mini_dump_write_dump) {
{ mini_dump_write_dump(hProcess, ProcessId, hFile, static_cast<MINIDUMP_TYPE>(80), ExceptionParam, nullptr, CallbackParam);
mini_dump_write_dump(hProcess,ProcessId,hFile,DumpType,ExceptionParam,UserStreamParam,CallbackParam);
} }
} }
} }
BOOL CALLBACK MyMiniDumpCallback(PVOID, const PMINIDUMP_CALLBACK_INPUT input, PMINIDUMP_CALLBACK_OUTPUT output) { 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; return FALSE;
BOOL ret = FALSE; BOOL ret = FALSE;
@ -43,7 +42,8 @@ BOOL CALLBACK MyMiniDumpCallback(PVOID, const PMINIDUMP_CALLBACK_INPUT input, PM
output->ModuleWriteFlags &= ~ModuleWriteModule; output->ModuleWriteFlags &= ~ModuleWriteModule;
} }
ret = TRUE; ret = TRUE;
} break; }
break;
default: default:
break; break;
} }
@ -51,16 +51,15 @@ BOOL CALLBACK MyMiniDumpCallback(PVOID, const PMINIDUMP_CALLBACK_INPUT input, PM
} }
void WriteDump(EXCEPTION_POINTERS *exp, const std::wstring &path) { 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); 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; MINIDUMP_EXCEPTION_INFORMATION info;
info.ThreadId = ::GetCurrentThreadId(); info.ThreadId = ::GetCurrentThreadId();
info.ExceptionPointers = exp; info.ExceptionPointers = exp;
info.ClientPointers = FALSE; info.ClientPointers = FALSE;
MINIDUMP_CALLBACK_INFORMATION mci; MINIDUMP_CALLBACK_INFORMATION mci;
mci.CallbackRoutine = (MINIDUMP_CALLBACK_ROUTINE) MyMiniDumpCallback; mci.CallbackRoutine = (MINIDUMP_CALLBACK_ROUTINE) MyMiniDumpCallback;
mci.CallbackParam = 0; mci.CallbackParam = nullptr;
MINIDUMP_TYPE mdt = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory); miniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), h, &info, &mci);
miniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), h, mdt, &info, NULL, &mci);
::CloseHandle(h); ::CloseHandle(h);
} }
@ -75,8 +74,6 @@ LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS* exp) {
WriteDump(exp, dumpFilePath.toStdWString()); WriteDump(exp, dumpFilePath.toStdWString());
QStringList arguments; QStringList arguments;
arguments << "-crashed=" + dumpFilePath; arguments << "-crashed=" + dumpFilePath;
QProcess::startDetached(qApp->applicationFilePath(), arguments); QProcess::startDetached(QGuiApplication::applicationFilePath(), arguments);
return EXCEPTION_EXECUTE_HANDLER; return EXCEPTION_EXECUTE_HANDLER;
} }
#endif // APP_DUMP_H

View File

@ -3,12 +3,13 @@
#include <QQuickItemGrabResult> #include <QQuickItemGrabResult>
#include <QPainterPath> #include <QPainterPath>
CircularReveal::CircularReveal(QQuickItem* parent) : QQuickPaintedItem(parent) CircularReveal::CircularReveal(QQuickItem *parent) : QQuickPaintedItem(parent) {
{ _target = nullptr;
_radius = 0;
_anim = new QPropertyAnimation(this, "radius", this); _anim = new QPropertyAnimation(this, "radius", this);
setVisible(false);
_anim->setDuration(333); _anim->setDuration(333);
_anim->setEasingCurve(QEasingCurve::OutCubic); _anim->setEasingCurve(QEasingCurve::OutCubic);
setVisible(false);
connect(_anim, &QPropertyAnimation::finished, this, [=]() { connect(_anim, &QPropertyAnimation::finished, this, [=]() {
update(); update();
setVisible(false); setVisible(false);
@ -19,8 +20,7 @@ CircularReveal::CircularReveal(QQuickItem* parent) : QQuickPaintedItem(parent)
}); });
} }
void CircularReveal::paint(QPainter* painter) void CircularReveal::paint(QPainter *painter) {
{
painter->save(); painter->save();
painter->drawImage(QRect(0, 0, static_cast<int>(width()), static_cast<int>(height())), _source); painter->drawImage(QRect(0, 0, static_cast<int>(width()), static_cast<int>(height())), _source);
QPainterPath path; QPainterPath path;
@ -31,7 +31,7 @@ void CircularReveal::paint(QPainter* painter)
painter->restore(); 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 &center, int radius) {
_anim->setStartValue(0); _anim->setStartValue(0);
_anim->setEndValue(radius); _anim->setEndValue(radius);
_center = center; _center = center;

View File

@ -1,5 +1,4 @@
#ifndef CIRCULARREVEAL_H #pragma once
#define CIRCULARREVEAL_H
#include <QQuickItem> #include <QQuickItem>
#include <QQuickPaintedItem> #include <QQuickPaintedItem>
@ -7,23 +6,26 @@
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include "src/stdafx.h" #include "src/stdafx.h"
class CircularReveal : public QQuickPaintedItem class CircularReveal : public QQuickPaintedItem {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QQuickItem*,target) Q_PROPERTY_AUTO_P(QQuickItem*, target)
Q_PROPERTY_AUTO(int, radius) Q_PROPERTY_AUTO(int, radius)
public: public:
CircularReveal(QQuickItem* parent = nullptr); explicit CircularReveal(QQuickItem *parent = nullptr);
void paint(QPainter *painter) override; void paint(QPainter *painter) override;
Q_INVOKABLE void start(int w,int h,const QPoint& center,int radius);
[[maybe_unused]] Q_INVOKABLE void start(int w, int h, const QPoint &center, int radius);
Q_SIGNAL void imageChanged(); Q_SIGNAL void imageChanged();
Q_SIGNAL void animationFinished(); Q_SIGNAL void animationFinished();
Q_SLOT void handleGrabResult(); Q_SLOT void handleGrabResult();
private: private:
QPropertyAnimation *_anim = nullptr; QPropertyAnimation *_anim = nullptr;
QImage _source; QImage _source;
QPoint _center; QPoint _center;
QSharedPointer<QQuickItemGrabResult> _grabResult; QSharedPointer<QQuickItemGrabResult> _grabResult;
}; };
#endif // CIRCULARREVEAL_H

View File

@ -1,8 +1,6 @@
#include "FileWatcher.h" #include "FileWatcher.h"
FileWatcher::FileWatcher(QObject *parent) FileWatcher::FileWatcher(QObject *parent) : QObject{parent} {
: QObject{parent}
{
connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path) { connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path) {
Q_EMIT fileChanged(); Q_EMIT fileChanged();
clean(); clean();
@ -18,7 +16,8 @@ FileWatcher::FileWatcher(QObject *parent)
} }
void FileWatcher::clean() { void FileWatcher::clean() {
foreach (const QString &item, _watcher.files()) { for (int i = 0; i <= _watcher.files().size() - 1; ++i) {
auto item = _watcher.files().at(i);
_watcher.removePath(item); _watcher.removePath(item);
} }
} }

View File

@ -1,22 +1,21 @@
#ifndef FILEWATCHER_H #pragma once
#define FILEWATCHER_H
#include <QObject> #include <QObject>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
#include "src/stdafx.h" #include "src/stdafx.h"
class FileWatcher : public QObject class FileWatcher : public QObject {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QString, path); Q_PROPERTY_AUTO(QString, path);
public: public:
explicit FileWatcher(QObject *parent = nullptr); explicit FileWatcher(QObject *parent = nullptr);
Q_SIGNAL void fileChanged(); Q_SIGNAL void fileChanged();
private: private:
void clean(); void clean();
private: private:
QFileSystemWatcher _watcher; QFileSystemWatcher _watcher;
}; };
#endif // FILEWATCHER_H

View File

@ -3,9 +3,9 @@
#include <QTimer> #include <QTimer>
#include <QQuickWindow> #include <QQuickWindow>
FpsItem::FpsItem() FpsItem::FpsItem() {
{ _fps = 0;
QTimer *timer = new QTimer(this); auto *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, [this] { connect(timer, &QTimer::timeout, this, [this] {
fps(_frameCount); fps(_frameCount);
_frameCount = 0; _frameCount = 0;

View File

@ -1,11 +1,9 @@
#ifndef FPSITEM_H #pragma once
#define FPSITEM_H
#include <QQuickItem> #include <QQuickItem>
#include "src/stdafx.h" #include "src/stdafx.h"
class FpsItem : public QQuickItem class FpsItem : public QQuickItem {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(int, fps) Q_PROPERTY_AUTO(int, fps)
public: public:
@ -15,5 +13,3 @@ private:
int _frameCount = 0; int _frameCount = 0;
}; };
#endif // FPSITEM_H

View 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);
}

View 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{};
};

View File

@ -3,39 +3,31 @@
#include <QDir> #include <QDir>
#include <QGuiApplication> #include <QGuiApplication>
InitializrHelper::InitializrHelper(QObject *parent) : QObject(parent) [[maybe_unused]] InitializrHelper::InitializrHelper(QObject *parent) : QObject(parent) {
{
} }
InitializrHelper::~InitializrHelper() = default; InitializrHelper::~InitializrHelper() = default;
bool InitializrHelper::copyDir(const QDir &fromDir, const QDir &toDir, bool coverIfFileExists) { bool InitializrHelper::copyDir(const QDir &fromDir, const QDir &toDir, bool coverIfFileExists) {
QDir _formDir = fromDir; const QDir &_formDir = fromDir;
QDir _toDir = toDir; QDir _toDir = toDir;
if(!_toDir.exists()) if (!_toDir.exists()) {
{
if (!_toDir.mkdir(toDir.absolutePath())) if (!_toDir.mkdir(toDir.absolutePath()))
return false; return false;
} }
QFileInfoList fileInfoList = _formDir.entryInfoList(); QFileInfoList fileInfoList = _formDir.entryInfoList();
foreach(QFileInfo fileInfo, fileInfoList) foreach(QFileInfo fileInfo, fileInfoList) {
{
if (fileInfo.fileName() == "." || fileInfo.fileName() == "..") if (fileInfo.fileName() == "." || fileInfo.fileName() == "..")
continue; continue;
if(fileInfo.isDir()) if (fileInfo.isDir()) {
{
if (!copyDir(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()), true)) if (!copyDir(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()), true))
return false; return false;
} } else {
else if (coverIfFileExists && _toDir.exists(fileInfo.fileName())) {
{
if(coverIfFileExists && _toDir.exists(fileInfo.fileName()))
{
_toDir.remove(fileInfo.fileName()); _toDir.remove(fileInfo.fileName());
} }
if(!QFile::copy(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()))) if (!QFile::copy(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()))) {
{
return false; return false;
} }
} }
@ -72,7 +64,7 @@ void InitializrHelper::copyFile(const QString& source,const QString& dest){
QFile::setPermissions(dest, QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther); QFile::setPermissions(dest, QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther);
} }
void InitializrHelper::generate(const QString& name,const QString& path){ [[maybe_unused]] void InitializrHelper::generate(const QString &name, const QString &path) {
if (name.isEmpty()) { if (name.isEmpty()) {
error(tr("The name cannot be empty")); error(tr("The name cannot be empty"));
return; return;
@ -105,5 +97,5 @@ void InitializrHelper::generate(const QString& name,const QString& path){
copyFile(":/example/res/template/src/qml.qrc.in", projectDir.filePath("src/qml.qrc")); 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/logo.ico.in", projectDir.filePath("src/logo.ico"));
copyFile(":/example/res/template/src/README.md.in", projectDir.filePath("src/README.md")); copyFile(":/example/res/template/src/README.md.in", projectDir.filePath("src/README.md"));
return this->success(projectPath); return this->success(projectPath+"/CMakeLists.txt");
} }

View File

@ -1,26 +1,30 @@
#ifndef INITIALIZRHELPER_H #pragma once
#define INITIALIZRHELPER_H
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
#include <QDir> #include <QDir>
#include "src/singleton.h" #include "src/singleton.h"
class InitializrHelper : public QObject class InitializrHelper : public QObject {
{
Q_OBJECT Q_OBJECT
private: private:
explicit InitializrHelper(QObject* parent = nullptr); [[maybe_unused]] explicit InitializrHelper(QObject *parent = nullptr);
bool copyDir(const QDir &fromDir, const QDir &toDir, bool coverIfFileExists = true); bool copyDir(const QDir &fromDir, const QDir &toDir, bool coverIfFileExists = true);
void copyFile(const QString& source,const QString& dest);
static void copyFile(const QString &source, const QString &dest);
template<typename...Args> template<typename...Args>
void templateToFile(const QString &source, const QString &dest, Args &&...args); void templateToFile(const QString &source, const QString &dest, Args &&...args);
public: public:
SINGLETON(InitializrHelper) SINGLETON(InitializrHelper)
~InitializrHelper() override; ~InitializrHelper() override;
Q_INVOKABLE void generate(const QString& name,const QString& path);
[[maybe_unused]] Q_INVOKABLE void generate(const QString &name, const QString &path);
Q_SIGNAL void error(const QString &message); Q_SIGNAL void error(const QString &message);
Q_SIGNAL void success(const QString &path); Q_SIGNAL void success(const QString &path);
}; };
#endif // INITIALIZRHELPER_H

View File

@ -11,8 +11,11 @@
#include <QSettings> #include <QSettings>
#include <QRegularExpression> #include <QRegularExpression>
#include "Version.h" #include "Version.h"
#ifdef WIN32 #ifdef WIN32
#include <process.h> #include <process.h>
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -42,8 +45,7 @@ std::map<QtMsgType, int> logLevelMap = {
{QtDebugMsg, 4} {QtDebugMsg, 4}
}; };
QString Log::prettyProductInfoWrapper() QString Log::prettyProductInfoWrapper() {
{
auto productName = QSysInfo::prettyProductName(); auto productName = QSysInfo::prettyProductName();
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
#if defined(Q_OS_MACOS) #if defined(Q_OS_MACOS)
@ -70,20 +72,17 @@ QString Log::prettyProductInfoWrapper()
#endif #endif
#endif #endif
#if defined(Q_OS_WIN) #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"))) { if (regKey.contains(QString::fromUtf8("CurrentBuildNumber"))) {
auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt(); auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt();
if (buildNumber > 0) { if (buildNumber > 0) {
if (buildNumber < 9200) { if (buildNumber < 9200) {
productName = QString::fromUtf8("Windows 7 build %1").arg(buildNumber); 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); 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); productName = QString::fromUtf8("Windows 10 build %1").arg(buildNumber);
} } else {
else {
productName = QString::fromUtf8("Windows 11 build %1").arg(buildNumber); productName = QString::fromUtf8("Windows 11 build %1").arg(buildNumber);
} }
} }
@ -92,8 +91,7 @@ QString Log::prettyProductInfoWrapper()
return productName; return productName;
} }
static inline void messageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message) 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.") { if (message == "Could not get the INetworkConnection instance for the adapter GUID.") {
return; return;
} }
@ -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()); Q_ASSERT(!app.isEmpty());
if (app.isEmpty()) { if (app.isEmpty()) {
return; return;

View File

@ -1,11 +1,9 @@
#ifndef LOG_H #pragma once
#define LOG_H
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
namespace Log namespace Log {
{
QString prettyProductInfoWrapper(); QString prettyProductInfoWrapper();
void setup(char *argv[], const QString &app, int level = 4); void setup(char *argv[], const QString &app, int level = 4);
} }
#endif // LOG_H

View File

@ -17,12 +17,14 @@
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QEventLoop> #include <QEventLoop>
#include <QGuiApplication> #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) { switch (_method) {
case METHOD_GET: case METHOD_GET:
return "GET"; return "GET";
@ -41,21 +43,21 @@ QString NetworkParams::method2String(){
} }
} }
int NetworkParams::getTimeout(){ int NetworkParams::getTimeout() const {
if (_timeout != -1) { if (_timeout != -1) {
return _timeout; return _timeout;
} }
return Network::getInstance()->timeout(); return Network::getInstance()->timeout();
} }
int NetworkParams::getRetry(){ int NetworkParams::getRetry() const {
if (_retry != -1) { if (_retry != -1) {
return _retry; return _retry;
} }
return Network::getInstance()->retry(); return Network::getInstance()->retry();
} }
bool NetworkParams::getOpenLog(){ bool NetworkParams::getOpenLog() const {
if (!_openLog.isNull()) { if (!_openLog.isNull()) {
return _openLog.toBool(); return _openLog.toBool();
} }
@ -63,52 +65,49 @@ bool NetworkParams::getOpenLog(){
} }
FluDownloadParam::FluDownloadParam(QObject *parent) FluDownloadParam::FluDownloadParam(QObject *parent)
: QObject{parent} : QObject{parent} {
{
} }
FluDownloadParam::FluDownloadParam(QString destPath, bool append, QObject *parent) FluDownloadParam::FluDownloadParam(QString destPath, bool append, QObject *parent)
: QObject{parent} : QObject{parent} {
{ this->_destPath = std::move(destPath);
this->_destPath = destPath;
this->_append = append; this->_append = append;
} }
NetworkParams::NetworkParams(QObject *parent) NetworkParams::NetworkParams(QObject *parent) : QObject{parent} {
: QObject{parent} _method = NetworkParams::Method::METHOD_GET;
{ _type = NetworkParams::Type::TYPE_BODY;
} }
NetworkParams::NetworkParams(QString url, Type type, Method method, QObject *parent) NetworkParams::NetworkParams(QString url, Type type, Method method, QObject *parent)
: QObject{parent} : QObject{parent} {
{
this->_method = method; this->_method = method;
this->_url = url; this->_url = std::move(url);
this->_type = type; this->_type = type;
} }
NetworkParams* NetworkParams::add(QString key,QVariant val){ NetworkParams *NetworkParams::add(const QString &key, const QVariant &val) {
_paramMap.insert(key, val); _paramMap.insert(key, val);
return this; return this;
} }
NetworkParams* NetworkParams::addFile(QString key,QVariant val){ NetworkParams *NetworkParams::addFile(const QString &key, const QVariant &val) {
_fileMap.insert(key, val); _fileMap.insert(key, val);
return this; return this;
} }
NetworkParams* NetworkParams::addHeader(QString key,QVariant val){ NetworkParams *NetworkParams::addHeader(const QString &key, const QVariant &val) {
_headerMap.insert(key, val); _headerMap.insert(key, val);
return this; return this;
} }
NetworkParams* NetworkParams::addQuery(QString key,QVariant val){ NetworkParams *NetworkParams::addQuery(const QString &key, const QVariant &val) {
_queryMap.insert(key, val); _queryMap.insert(key, val);
return this; return this;
} }
NetworkParams *NetworkParams::setBody(QString val) { NetworkParams *NetworkParams::setBody(QString val) {
_body = val; _body = std::move(val);
return this; return this;
} }
@ -128,7 +127,7 @@ NetworkParams* NetworkParams::setCacheMode(int val){
} }
NetworkParams *NetworkParams::toDownload(QString destPath, bool append) { NetworkParams *NetworkParams::toDownload(QString destPath, bool append) {
_downloadParam = new FluDownloadParam(destPath,append,this); _downloadParam = new FluDownloadParam(std::move(destPath), append, this);
return this; return this;
} }
@ -138,11 +137,11 @@ NetworkParams* NetworkParams::bind(QObject* target){
} }
NetworkParams *NetworkParams::openLog(QVariant val) { NetworkParams *NetworkParams::openLog(QVariant val) {
_openLog = val; _openLog = std::move(val);
return this; return this;
} }
QString NetworkParams::buildCacheKey(){ QString NetworkParams::buildCacheKey() const {
QJsonObject obj; QJsonObject obj;
obj.insert("url", _url); obj.insert("url", _url);
obj.insert("method", method2String()); obj.insert("method", method2String());
@ -196,19 +195,19 @@ void Network::handle(NetworkParams* params,NetworkCallable* c){
manager.setTransferTimeout(params->getTimeout()); manager.setTransferTimeout(params->getTimeout());
QEventLoop loop; QEventLoop loop;
connect(&manager, &QNetworkAccessManager::finished, &manager, [&loop](QNetworkReply *reply) { loop.quit(); }); connect(&manager, &QNetworkAccessManager::finished, &manager, [&loop](QNetworkReply *reply) { loop.quit(); });
for (int i = 0; i < params->getRetry(); ++i) { for (int i = 0; i <= params->getRetry() - 1; ++i) {
QUrl url(params->_url); QUrl url(params->_url);
addQueryParam(&url, params->_queryMap); addQueryParam(&url, params->_queryMap);
QNetworkRequest request(url); QNetworkRequest request(url);
addHeaders(&request, params->_headerMap); addHeaders(&request, params->_headerMap);
QNetworkReply *reply; QNetworkReply *reply;
sendRequest(&manager, request, params, reply, i == 0, callable); sendRequest(&manager, request, params, reply, i == 0, callable);
if(!QPointer<QGuiApplication>(qApp)){ if (!QPointer<QCoreApplication>(QGuiApplication::instance())) {
reply->deleteLater(); reply->deleteLater();
reply = nullptr; reply = nullptr;
return; return;
} }
auto abortCallable = [&loop,reply,&i,params]{ auto abortCallable = [reply, &i, params] {
if (reply) { if (reply) {
i = params->getRetry(); i = params->getRetry();
reply->abort(); reply->abort();
@ -219,7 +218,7 @@ void Network::handle(NetworkParams* params,NetworkCallable* c){
if (params->_target) { if (params->_target) {
conn_destroyed = connect(params->_target, &QObject::destroyed, &manager, abortCallable); 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(); loop.exec();
if (conn_destroyed) { if (conn_destroyed) {
disconnect(conn_destroyed); disconnect(conn_destroyed);
@ -282,14 +281,14 @@ void Network::handleDownload(NetworkParams* params,NetworkCallable* c){
addHeaders(&request, params->_headerMap); addHeaders(&request, params->_headerMap);
QString cachePath = getCacheFilePath(cacheKey); QString cachePath = getCacheFilePath(cacheKey);
QString destPath = params->_downloadParam->_destPath; QString destPath = params->_downloadParam->_destPath;
QFile* destFile = new QFile(destPath); auto *destFile = new QFile(destPath);
QFile* cacheFile = new QFile(cachePath); auto *cacheFile = new QFile(cachePath);
bool isOpen = false; bool isOpen;
qint64 seek = 0; qint64 seek;
if (cacheFile->exists() && destFile->exists() && params->_downloadParam->_append) { if (cacheFile->exists() && destFile->exists() && params->_downloadParam->_append) {
QJsonObject cacheInfo = QJsonDocument::fromJson(readCache(cacheKey).toUtf8()).object(); QJsonObject cacheInfo = QJsonDocument::fromJson(readCache(cacheKey).toUtf8()).object();
qint64 fileSize = cacheInfo.value("fileSize").toDouble(); qint64 fileSize = qRound(cacheInfo.value("fileSize").toDouble());
qint64 contentLength = cacheInfo.value("contentLength").toDouble(); qint64 contentLength = qRound(cacheInfo.value("contentLength").toDouble());
if (fileSize == contentLength && destFile->size() == contentLength) { if (fileSize == contentLength && destFile->size() == contentLength) {
if (!callable.isNull()) { if (!callable.isNull()) {
callable->downloadProgress(fileSize, contentLength); callable->downloadProgress(fileSize, contentLength);
@ -316,8 +315,7 @@ void Network::handleDownload(NetworkParams* params,NetworkCallable* c){
return; return;
} }
if (params->_downloadParam->_append) { if (params->_downloadParam->_append) {
if (!cacheFile->open(QIODevice::WriteOnly|QIODevice::Truncate)) if (!cacheFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) {
{
if (!callable.isNull()) { if (!callable.isNull()) {
callable->error(-1, "cache file device not open", ""); callable->error(-1, "cache file device not open", "");
callable->finish(); callable->finish();
@ -329,22 +327,21 @@ void Network::handleDownload(NetworkParams* params,NetworkCallable* c){
QNetworkReply *reply = manager.get(request); QNetworkReply *reply = manager.get(request);
destFile->setParent(reply); destFile->setParent(reply);
cacheFile->setParent(reply); cacheFile->setParent(reply);
auto abortCallable = [&loop,reply,params]{ auto abortCallable = [reply] {
if (reply) { if (reply) {
reply->abort(); reply->abort();
} }
}; };
connect(&manager, &QNetworkAccessManager::finished, &manager, [&loop](QNetworkReply *reply) { loop.quit(); }); connect(&manager, &QNetworkAccessManager::finished, &manager, [&loop](QNetworkReply *reply) { loop.quit(); });
connect(qApp,&QGuiApplication::aboutToQuit,&manager, [&loop,reply](){reply->abort(),loop.quit();}); connect(QGuiApplication::instance(), &QGuiApplication::aboutToQuit, &manager, [&loop, reply]() { reply->abort(), loop.quit(); });
QMetaObject::Connection conn_destroyed = {}; QMetaObject::Connection conn_destroyed = {};
QMetaObject::Connection conn_quit = {}; QMetaObject::Connection conn_quit = {};
if (params->_target) { if (params->_target) {
conn_destroyed = connect(params->_target, &QObject::destroyed, &manager, abortCallable); 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);
connect(reply, &QNetworkReply::readyRead, reply, [reply, seek, destFile, cacheFile, callable] { connect(reply, &QNetworkReply::readyRead, reply, [reply, seek, destFile, cacheFile, callable] {
if (!reply || !destFile || reply->error() != QNetworkReply::NoError) if (!reply || !destFile || reply->error() != QNetworkReply::NoError) {
{
return; return;
} }
QMap<QString, QVariant> downInfo; QMap<QString, QVariant> downInfo;
@ -433,31 +430,29 @@ QString Network::map2String(const QMap<QString, QVariant>& map){
return parameters.join(" "); 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(); QByteArray verb = params->method2String().toUtf8();
switch (params->_type) { switch (params->_type) {
case NetworkParams::TYPE_FORM: { case NetworkParams::TYPE_FORM: {
bool isFormData = !params->_fileMap.isEmpty(); bool isFormData = !params->_fileMap.isEmpty();
if (isFormData) { if (isFormData) {
QHttpMultiPart *multiPart = new QHttpMultiPart(); auto *multiPart = new QHttpMultiPart();
multiPart->setContentType(QHttpMultiPart::FormDataType); multiPart->setContentType(QHttpMultiPart::FormDataType);
for (const auto& each : params->_paramMap.toStdMap()) for (const auto &each: params->_paramMap.toStdMap()) {
{
QHttpPart part; QHttpPart part;
part.setHeader(QNetworkRequest::ContentDispositionHeader, QString("form-data; name=\"%1\"").arg(each.first)); part.setHeader(QNetworkRequest::ContentDispositionHeader, QString("form-data; name=\"%1\"").arg(each.first));
part.setBody(each.second.toByteArray()); part.setBody(each.second.toByteArray());
multiPart->append(part); multiPart->append(part);
} }
for (const auto& each : params->_fileMap.toStdMap()) for (const auto &each: params->_fileMap.toStdMap()) {
{
QString filePath = each.second.toString(); QString filePath = each.second.toString();
QString name = each.first; QString name = each.first;
QFile *file = new QFile(filePath); auto *file = new QFile(filePath);
QString fileName = QFileInfo(filePath).fileName(); QString fileName = QFileInfo(filePath).fileName();
file->open(QIODevice::ReadOnly); file->open(QIODevice::ReadOnly);
file->setParent(multiPart); file->setParent(multiPart);
QHttpPart part; QHttpPart part;
part.setHeader(QNetworkRequest::ContentDispositionHeader, QString("form-data; name=\"%1\"; filename=\"%2\"").arg(name,fileName)); part.setHeader(QNetworkRequest::ContentDispositionHeader, QString(R"(form-data; name="%1"; filename="%2")").arg(name, fileName));
part.setBodyDevice(file); part.setBodyDevice(file);
multiPart->append(part); multiPart->append(part);
} }
@ -471,8 +466,7 @@ void Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request
} else { } else {
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/x-www-form-urlencoded")); request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/x-www-form-urlencoded"));
QString value; QString value;
for (const auto& each : params->_paramMap.toStdMap()) for (const auto &each: params->_paramMap.toStdMap()) {
{
value += QString("%1=%2").arg(each.first, each.second.toString()); value += QString("%1=%2").arg(each.first, each.second.toString());
value += "&"; value += "&";
} }
@ -487,8 +481,7 @@ void Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request
case NetworkParams::TYPE_JSON: { case NetworkParams::TYPE_JSON: {
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8")); request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
QJsonObject json; QJsonObject json;
for (const auto& each : params->_paramMap.toStdMap()) for (const auto &each: params->_paramMap.toStdMap()) {
{
json.insert(each.first, each.second.toJsonValue()); json.insert(each.first, each.second.toJsonValue());
} }
QByteArray data = QJsonDocument(json).toJson(QJsonDocument::Compact); QByteArray data = QJsonDocument(json).toJson(QJsonDocument::Compact);
@ -498,8 +491,7 @@ void Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request
case NetworkParams::TYPE_JSONARRAY: { case NetworkParams::TYPE_JSONARRAY: {
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8")); request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
QJsonArray jsonArray; QJsonArray jsonArray;
for (const auto& each : params->_paramMap.toStdMap()) for (const auto &each: params->_paramMap.toStdMap()) {
{
QJsonObject json; QJsonObject json;
json.insert(each.first, each.second.toJsonValue()); json.insert(each.first, each.second.toJsonValue());
jsonArray.append(json); jsonArray.append(json);
@ -523,7 +515,7 @@ void Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request
} }
} }
void Network::printRequestStartLog(QNetworkRequest request,NetworkParams* params){ void Network::printRequestStartLog(const QNetworkRequest &request, NetworkParams *params) {
if (!params->getOpenLog()) { if (!params->getOpenLog()) {
return; return;
} }
@ -551,7 +543,7 @@ void Network::printRequestStartLog(QNetworkRequest request,NetworkParams* params
} }
} }
void Network::printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response){ void Network::printRequestEndLog(const QNetworkRequest &request, NetworkParams *params, QNetworkReply *&reply, const QString &response) {
if (!params->getOpenLog()) { if (!params->getOpenLog()) {
return; return;
} }
@ -560,11 +552,10 @@ void Network::printRequestEndLog(QNetworkRequest request,NetworkParams* params,Q
qDebug() << "<Result>" << qUtf8Printable(response); 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))); QSharedPointer<QFile> file(new QFile(getCacheFilePath(key)));
QIODevice::OpenMode mode = QIODevice::WriteOnly | QIODevice::Truncate; QIODevice::OpenMode mode = QIODevice::WriteOnly | QIODevice::Truncate;
if (!file->open(mode)) if (!file->open(mode)) {
{
return; return;
} }
file->write(response.toUtf8().toBase64()); file->write(response.toUtf8().toBase64());
@ -573,8 +564,7 @@ void Network::saveResponse(QString key,QString response){
void Network::addHeaders(QNetworkRequest *request, const QMap<QString, QVariant> &headers) { 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())); request->setHeader(QNetworkRequest::UserAgentHeader, QString::fromStdString("Mozilla/5.0 %1/%2").arg(QGuiApplication::applicationName(), QGuiApplication::applicationVersion()));
QMapIterator<QString, QVariant> iter(headers); QMapIterator<QString, QVariant> iter(headers);
while (iter.hasNext()) while (iter.hasNext()) {
{
iter.next(); iter.next();
request->setRawHeader(iter.key().toUtf8(), iter.value().toString().toUtf8()); request->setRawHeader(iter.key().toUtf8(), iter.value().toString().toUtf8());
} }
@ -583,20 +573,18 @@ void Network::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>&
void Network::addQueryParam(QUrl *url, const QMap<QString, QVariant> &params) { void Network::addQueryParam(QUrl *url, const QMap<QString, QVariant> &params) {
QMapIterator<QString, QVariant> iter(params); QMapIterator<QString, QVariant> iter(params);
QUrlQuery urlQuery(*url); QUrlQuery urlQuery(*url);
while (iter.hasNext()) while (iter.hasNext()) {
{
iter.next(); iter.next();
urlQuery.addQueryItem(iter.key(), iter.value().toString()); urlQuery.addQueryItem(iter.key(), iter.value().toString());
} }
url->setQuery(urlQuery); url->setQuery(urlQuery);
} }
Network::Network(QObject *parent): QObject{parent} Network::Network(QObject *parent) : QObject{parent} {
{ _timeout = 5000;
timeout(5000); _retry = 3;
retry(3); _openLog = false;
openLog(false); _cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network");
cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network"));
} }
NetworkParams *Network::get(const QString &url) { NetworkParams *Network::get(const QString &url) {
@ -672,5 +660,5 @@ NetworkParams* Network::deleteJsonArray(const QString& url){
} }
void Network::setInterceptor(QJSValue interceptor) { void Network::setInterceptor(QJSValue interceptor) {
this->_interceptor = interceptor; this->_interceptor = std::move(interceptor);
} }

View File

@ -1,5 +1,4 @@
#ifndef NETWORK_H #pragma once
#define NETWORK_H
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
@ -19,7 +18,9 @@ enum CacheMode {
IfNoneCacheRequest = 0x0002, IfNoneCacheRequest = 0x0002,
FirstCacheThenRequest = 0x0004, FirstCacheThenRequest = 0x0004,
}; };
Q_ENUM_NS(CacheMode) Q_ENUM_NS(CacheMode)
QML_NAMED_ELEMENT(NetworkType) QML_NAMED_ELEMENT(NetworkType)
} }
@ -31,12 +32,19 @@ class NetworkCallable : public QObject{
QML_NAMED_ELEMENT(NetworkCallable) QML_NAMED_ELEMENT(NetworkCallable)
public: public:
explicit NetworkCallable(QObject *parent = nullptr); explicit NetworkCallable(QObject *parent = nullptr);
Q_SIGNAL void start(); Q_SIGNAL void start();
Q_SIGNAL void finish(); 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 success(QString result);
Q_SIGNAL void cache(QString result); Q_SIGNAL void cache(QString result);
Q_SIGNAL void uploadProgress(qint64 sent, qint64 total); Q_SIGNAL void uploadProgress(qint64 sent, qint64 total);
Q_SIGNAL void downloadProgress(qint64 recv, qint64 total); Q_SIGNAL void downloadProgress(qint64 recv, qint64 total);
}; };
@ -47,17 +55,18 @@ class FluDownloadParam : public QObject{
Q_OBJECT Q_OBJECT
public: public:
explicit FluDownloadParam(QObject *parent = nullptr); explicit FluDownloadParam(QObject *parent = nullptr);
FluDownloadParam(QString destPath, bool append, QObject *parent = nullptr); FluDownloadParam(QString destPath, bool append, QObject *parent = nullptr);
public: public:
QString _destPath; QString _destPath;
bool _append; bool _append{};
}; };
/** /**
* @brief The NetworkParams class * @brief The NetworkParams class
*/ */
class NetworkParams : public QObject class NetworkParams : public QObject {
{
Q_OBJECT Q_OBJECT
QML_NAMED_ELEMENT(NetworkParams) QML_NAMED_ELEMENT(NetworkParams)
public: public:
@ -76,25 +85,45 @@ public:
TYPE_JSONARRAY, TYPE_JSONARRAY,
TYPE_BODY TYPE_BODY
}; };
explicit NetworkParams(QObject *parent = nullptr); explicit NetworkParams(QObject *parent = nullptr);
NetworkParams(QString url, Type type, Method method, 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 *addQuery(const QString &key, const QVariant &val);
Q_INVOKABLE NetworkParams* add(QString key,QVariant val);
Q_INVOKABLE NetworkParams* addFile(QString key,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 *setBody(QString val);
Q_INVOKABLE NetworkParams *setTimeout(int val); Q_INVOKABLE NetworkParams *setTimeout(int val);
Q_INVOKABLE NetworkParams *setRetry(int val); Q_INVOKABLE NetworkParams *setRetry(int val);
Q_INVOKABLE NetworkParams *setCacheMode(int val); Q_INVOKABLE NetworkParams *setCacheMode(int val);
Q_INVOKABLE NetworkParams *toDownload(QString destPath, bool append = false); Q_INVOKABLE NetworkParams *toDownload(QString destPath, bool append = false);
Q_INVOKABLE NetworkParams *bind(QObject *target); Q_INVOKABLE NetworkParams *bind(QObject *target);
Q_INVOKABLE NetworkParams *openLog(QVariant val); Q_INVOKABLE NetworkParams *openLog(QVariant val);
Q_INVOKABLE void go(NetworkCallable *result); Q_INVOKABLE void go(NetworkCallable *result);
QString buildCacheKey();
QString method2String(); QString buildCacheKey() const;
int getTimeout();
int getRetry(); QString method2String() const;
bool getOpenLog();
int getTimeout() const;
int getRetry() const;
bool getOpenLog() const;
public: public:
FluDownloadParam *_downloadParam = nullptr; FluDownloadParam *_downloadParam = nullptr;
QObject *_target = nullptr; QObject *_target = nullptr;
@ -115,8 +144,7 @@ public:
/** /**
* @brief The Network class * @brief The Network class
*/ */
class Network : public QObject class Network : public QObject {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(int, timeout) Q_PROPERTY_AUTO(int, timeout)
Q_PROPERTY_AUTO(int, retry) Q_PROPERTY_AUTO(int, retry)
@ -124,46 +152,80 @@ class Network : public QObject
Q_PROPERTY_AUTO(bool, openLog) Q_PROPERTY_AUTO(bool, openLog)
QML_NAMED_ELEMENT(Network) QML_NAMED_ELEMENT(Network)
QML_SINGLETON QML_SINGLETON
private: private:
explicit Network(QObject *parent = nullptr); explicit Network(QObject *parent = nullptr);
public: public:
SINGLETON(Network) SINGLETON(Network)
static Network *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) { return getInstance(); } static Network *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) { return getInstance(); }
Q_INVOKABLE NetworkParams *get(const QString &url); Q_INVOKABLE NetworkParams *get(const QString &url);
Q_INVOKABLE NetworkParams *head(const QString &url); Q_INVOKABLE NetworkParams *head(const QString &url);
Q_INVOKABLE NetworkParams *postBody(const QString &url); Q_INVOKABLE NetworkParams *postBody(const QString &url);
Q_INVOKABLE NetworkParams *putBody(const QString &url); Q_INVOKABLE NetworkParams *putBody(const QString &url);
Q_INVOKABLE NetworkParams *patchBody(const QString &url); Q_INVOKABLE NetworkParams *patchBody(const QString &url);
Q_INVOKABLE NetworkParams *deleteBody(const QString &url); Q_INVOKABLE NetworkParams *deleteBody(const QString &url);
Q_INVOKABLE NetworkParams *postForm(const QString &url); Q_INVOKABLE NetworkParams *postForm(const QString &url);
Q_INVOKABLE NetworkParams *putForm(const QString &url); Q_INVOKABLE NetworkParams *putForm(const QString &url);
Q_INVOKABLE NetworkParams *patchForm(const QString &url); Q_INVOKABLE NetworkParams *patchForm(const QString &url);
Q_INVOKABLE NetworkParams *deleteForm(const QString &url); Q_INVOKABLE NetworkParams *deleteForm(const QString &url);
Q_INVOKABLE NetworkParams *postJson(const QString &url); Q_INVOKABLE NetworkParams *postJson(const QString &url);
Q_INVOKABLE NetworkParams *putJson(const QString &url); Q_INVOKABLE NetworkParams *putJson(const QString &url);
Q_INVOKABLE NetworkParams *patchJson(const QString &url); Q_INVOKABLE NetworkParams *patchJson(const QString &url);
Q_INVOKABLE NetworkParams *deleteJson(const QString &url); Q_INVOKABLE NetworkParams *deleteJson(const QString &url);
Q_INVOKABLE NetworkParams *postJsonArray(const QString &url); Q_INVOKABLE NetworkParams *postJsonArray(const QString &url);
Q_INVOKABLE NetworkParams *putJsonArray(const QString &url); Q_INVOKABLE NetworkParams *putJsonArray(const QString &url);
Q_INVOKABLE NetworkParams *patchJsonArray(const QString &url); Q_INVOKABLE NetworkParams *patchJsonArray(const QString &url);
Q_INVOKABLE NetworkParams *deleteJsonArray(const QString &url); Q_INVOKABLE NetworkParams *deleteJsonArray(const QString &url);
Q_INVOKABLE void setInterceptor(QJSValue interceptor); Q_INVOKABLE void setInterceptor(QJSValue interceptor);
void handle(NetworkParams *params, NetworkCallable *result); void handle(NetworkParams *params, NetworkCallable *result);
void handleDownload(NetworkParams *params, NetworkCallable *result); void handleDownload(NetworkParams *params, NetworkCallable *result);
private: private:
void sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable); static void sendRequest(QNetworkAccessManager *manager, QNetworkRequest request, NetworkParams *params, QNetworkReply *&reply, bool isFirst, const QPointer<NetworkCallable> &callable);
void addQueryParam(QUrl* url,const QMap<QString, QVariant>& params);
void addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers); static void addQueryParam(QUrl *url, const QMap<QString, QVariant> &params);
void saveResponse(QString key,QString response);
static void addHeaders(QNetworkRequest *request, const QMap<QString, QVariant> &headers);
void saveResponse(const QString &key, const QString &response);
QString readCache(const QString &key); QString readCache(const QString &key);
bool cacheExists(const QString &key); bool cacheExists(const QString &key);
QString getCacheFilePath(const QString &key); QString getCacheFilePath(const QString &key);
QString map2String(const QMap<QString, QVariant>& map);
QString headerList2String(const QList<QNetworkReply::RawHeaderPair>& data); static 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 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: public:
QJSValue _interceptor; QJSValue _interceptor;
}; };
#endif // Network_H

View File

@ -3,15 +3,13 @@
#include <QDataStream> #include <QDataStream>
#include <QStandardPaths> #include <QStandardPaths>
SettingsHelper::SettingsHelper(QObject *parent) : QObject(parent) SettingsHelper::SettingsHelper(QObject *parent) : QObject(parent) {
{
} }
SettingsHelper::~SettingsHelper() = default; SettingsHelper::~SettingsHelper() = default;
void SettingsHelper::save(const QString& key,QVariant val) void SettingsHelper::save(const QString &key, QVariant val) {
{
m_settings->setValue(key, val); m_settings->setValue(key, val);
} }

View File

@ -1,5 +1,4 @@
#ifndef SETTINGSHELPER_H #pragma once
#define SETTINGSHELPER_H
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
@ -10,26 +9,35 @@
#include <QDir> #include <QDir>
#include "src/singleton.h" #include "src/singleton.h"
class SettingsHelper : public QObject class SettingsHelper : public QObject {
{
Q_OBJECT Q_OBJECT
private: private:
explicit SettingsHelper(QObject *parent = nullptr); explicit SettingsHelper(QObject *parent = nullptr);
public: public:
SINGLETON(SettingsHelper) SINGLETON(SettingsHelper)
~SettingsHelper() override; ~SettingsHelper() override;
void init(char *argv[]); void init(char *argv[]);
Q_INVOKABLE void saveDarkMode(int darkModel) { save("darkMode", darkModel); } Q_INVOKABLE void saveDarkMode(int darkModel) { save("darkMode", darkModel); }
Q_INVOKABLE int getDarkMode() { return get("darkMode", QVariant(0)).toInt(); } Q_INVOKABLE int getDarkMode() { return get("darkMode", QVariant(0)).toInt(); }
Q_INVOKABLE void saveUseSystemAppBar(bool useSystemAppBar) { save("useSystemAppBar", useSystemAppBar); } Q_INVOKABLE void saveUseSystemAppBar(bool useSystemAppBar) { save("useSystemAppBar", useSystemAppBar); }
Q_INVOKABLE bool getUseSystemAppBar() { return get("useSystemAppBar", QVariant(false)).toBool(); } Q_INVOKABLE bool getUseSystemAppBar() { return get("useSystemAppBar", QVariant(false)).toBool(); }
Q_INVOKABLE void saveLanguage(QString language){save("language",language);}
Q_INVOKABLE void saveLanguage(const QString &language) { save("language", language); }
Q_INVOKABLE QString getLanguage() { return get("language", QVariant("en_US")).toString(); } Q_INVOKABLE QString getLanguage() { return get("language", QVariant("en_US")).toString(); }
private: private:
void save(const QString &key, QVariant val); void save(const QString &key, QVariant val);
QVariant get(const QString &key, QVariant def = {}); QVariant get(const QString &key, QVariant def = {});
private: private:
QScopedPointer<QSettings> m_settings; QScopedPointer<QSettings> m_settings;
}; };
#endif // SETTINGSHELPER_H

View File

@ -5,8 +5,7 @@
#include "SettingsHelper.h" #include "SettingsHelper.h"
TranslateHelper::TranslateHelper(QObject *parent) : QObject(parent) [[maybe_unused]] TranslateHelper::TranslateHelper(QObject *parent) : QObject(parent) {
{
_languages << "en_US"; _languages << "en_US";
_languages << "zh_CN"; _languages << "zh_CN";
_current = SettingsHelper::getInstance()->getLanguage(); _current = SettingsHelper::getInstance()->getLanguage();
@ -17,7 +16,7 @@ TranslateHelper::~TranslateHelper() = default;
void TranslateHelper::init(QQmlEngine *engine) { void TranslateHelper::init(QQmlEngine *engine) {
_engine = engine; _engine = engine;
_translator = new QTranslator(this); _translator = new QTranslator(this);
qApp->installTranslator(_translator); QGuiApplication::installTranslator(_translator);
QString translatorPath = QGuiApplication::applicationDirPath() + "/i18n"; QString translatorPath = QGuiApplication::applicationDirPath() + "/i18n";
if (_translator->load(QString::fromStdString("%1/example_%2.qm").arg(translatorPath, _current))) { if (_translator->load(QString::fromStdString("%1/example_%2.qm").arg(translatorPath, _current))) {
_engine->retranslate(); _engine->retranslate();

View File

@ -1,5 +1,4 @@
#ifndef TRANSLATEHELPER_H #pragma once
#define TRANSLATEHELPER_H
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
@ -7,20 +6,21 @@
#include "src/singleton.h" #include "src/singleton.h"
#include "src/stdafx.h" #include "src/stdafx.h"
class TranslateHelper : public QObject class TranslateHelper : public QObject {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QString, current) Q_PROPERTY_AUTO(QString, current)
Q_PROPERTY_READONLY_AUTO(QStringList, languages) Q_PROPERTY_READONLY_AUTO(QStringList, languages)
private: private:
explicit TranslateHelper(QObject* parent = nullptr); [[maybe_unused]] explicit TranslateHelper(QObject *parent = nullptr);
public: public:
SINGLETON(TranslateHelper) SINGLETON(TranslateHelper)
~TranslateHelper() override; ~TranslateHelper() override;
void init(QQmlEngine *engine); void init(QQmlEngine *engine);
private: private:
QQmlEngine *_engine = nullptr; QQmlEngine *_engine = nullptr;
QTranslator *_translator = nullptr; QTranslator *_translator = nullptr;
}; };
#endif // TRANSLATEHELPER_H

View File

@ -14,6 +14,7 @@
#include "src/component/CircularReveal.h" #include "src/component/CircularReveal.h"
#include "src/component/FileWatcher.h" #include "src/component/FileWatcher.h"
#include "src/component/FpsItem.h" #include "src/component/FpsItem.h"
#include "src/component/OpenGLItem.h"
#include "src/helper/SettingsHelper.h" #include "src/helper/SettingsHelper.h"
#include "src/helper/InitializrHelper.h" #include "src/helper/InitializrHelper.h"
#include "src/helper/TranslateHelper.h" #include "src/helper/TranslateHelper.h"
@ -53,7 +54,7 @@ int main(int argc, char *argv[])
QGuiApplication::setOrganizationName("ZhuZiChu"); QGuiApplication::setOrganizationName("ZhuZiChu");
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io"); QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
QGuiApplication::setApplicationName("FluentUI"); QGuiApplication::setApplicationName("FluentUI");
QGuiApplication::setApplicationDisplayName("FluentUI Exmaple"); QGuiApplication::setApplicationDisplayName("FluentUI Example");
QGuiApplication::setApplicationVersion(APPLICATION_VERSION); QGuiApplication::setApplicationVersion(APPLICATION_VERSION);
QGuiApplication::setQuitOnLastWindowClosed(false); QGuiApplication::setQuitOnLastWindowClosed(false);
SettingsHelper::getInstance()->init(argv); SettingsHelper::getInstance()->init(argv);
@ -75,6 +76,9 @@ int main(int argc, char *argv[])
qmlRegisterType<FpsItem>(uri, major, minor, "FpsItem"); qmlRegisterType<FpsItem>(uri, major, minor, "FpsItem");
qmlRegisterType<NetworkCallable>(uri,major,minor,"NetworkCallable"); qmlRegisterType<NetworkCallable>(uri,major,minor,"NetworkCallable");
qmlRegisterType<NetworkParams>(uri,major,minor,"NetworkParams"); 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; QQmlApplicationEngine engine;
TranslateHelper::getInstance()->init(&engine); TranslateHelper::getInstance()->init(&engine);
engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance()); engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance());

View File

@ -1,5 +1,4 @@
#ifndef SINGLETON_H #pragma once
#define SINGLETON_H
/** /**
* @brief The Singleton class * @brief The Singleton class
@ -23,5 +22,3 @@ private: \
static Class* getInstance() { \ static Class* getInstance() { \
return Singleton<Class>::getInstance(); \ return Singleton<Class>::getInstance(); \
} }
#endif // SINGLETON_H

View File

@ -1,7 +1,6 @@
#ifndef STDAFX_H #pragma once
#define STDAFX_H
#define Q_PROPERTY_AUTO(TYPE, M) \ #define Q_PROPERTY_AUTO_P(TYPE, M) \
Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed) \ Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed) \
public: \ public: \
Q_SIGNAL void M##Changed(); \ Q_SIGNAL void M##Changed(); \
@ -15,14 +14,13 @@ Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed)
return _##M; \ return _##M; \
} \ } \
private: \ private: \
TYPE _##M; \ TYPE _##M;
#define Q_PROPERTY_AUTO(TYPE, M) \
#define Q_PROPERTY_READONLY_AUTO(TYPE, M) \ Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed) \
Q_PROPERTY(TYPE M READ M NOTIFY M##Changed FINAL) \
public: \ public: \
Q_SIGNAL void M##Changed(); \ Q_SIGNAL void M##Changed(); \
void M(TYPE in_##M) \ void M(const TYPE& in_##M) \
{ \ { \
_##M = in_##M; \ _##M = in_##M; \
Q_EMIT M##Changed(); \ Q_EMIT M##Changed(); \
@ -32,6 +30,21 @@ Q_PROPERTY(TYPE M READ M NOTIFY M##Changed FINAL)
return _##M; \ return _##M; \
} \ } \
private: \ private: \
TYPE _##M; \ TYPE _##M;
#endif // STDAFX_H
#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(const TYPE& in_##M) \
{ \
_##M = in_##M; \
Q_EMIT M##Changed(); \
} \
TYPE M() \
{ \
return _##M; \
} \
private: \
TYPE _##M;

View File

@ -13,7 +13,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
#设置版本号 #设置版本号
add_definitions(-DFLUENTUI_VERSION=1,7,4,0) add_definitions(-DFLUENTUI_VERSION=1,7,5,0)
if (FLUENTUI_BUILD_STATIC_LIB) if (FLUENTUI_BUILD_STATIC_LIB)
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB) add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
@ -24,7 +24,7 @@ option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
#导入Qt相关依赖包 #导入Qt相关依赖包
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick Qml) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick Qml)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick Qml) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick)
set(QT_SDK_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../..") set(QT_SDK_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../..")
cmake_path(SET QT_SDK_DIR NORMALIZE ${QT_SDK_DIR}) cmake_path(SET QT_SDK_DIR NORMALIZE ${QT_SDK_DIR})
@ -59,7 +59,7 @@ file(GLOB QM_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.qm)
file(COPY ${QM_FILE_PATHS} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/Qt${QT_VERSION_MAJOR}/imports/FluentUI/i18n") file(COPY ${QM_FILE_PATHS} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/Qt${QT_VERSION_MAJOR}/imports/FluentUI/i18n")
#遍历所有Cpp文件 #遍历所有Cpp文件
file(GLOB_RECURSE CPP_FILES *.cpp *.h) file(GLOB_RECURSE CPP_FILES *.cpp *.h *.cxx)
foreach (filepath ${CPP_FILES}) foreach (filepath ${CPP_FILES})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND sources_files ${filename}) list(APPEND sources_files ${filename})
@ -143,11 +143,7 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
RESOURCE_PREFIX "/qt/qml" RESOURCE_PREFIX "/qt/qml"
) )
else () else ()
#加快qrc编译 qt_add_resources(QRC_RESOURCES Qt5/imports/fluentui.qrc)
set(QRC_FILE Qt5/imports/fluentui.qrc)
qt_add_big_resources(QRC_RESOURCES ${QRC_FILE})
list(APPEND QRC_RESOURCES ${QRC_FILE})
set_property(SOURCE ${QRC_FILE} PROPERTY SKIP_AUTORCC ON)
#如果是Qt6.2版本以下则使用add_qmlplugin函数添加资源文件这是个自定义的函数详情见.cmake/QmlPlugin.cmake #如果是Qt6.2版本以下则使用add_qmlplugin函数添加资源文件这是个自定义的函数详情见.cmake/QmlPlugin.cmake
include(QmlPlugin) include(QmlPlugin)
add_qmlplugin(${PROJECT_NAME} add_qmlplugin(${PROJECT_NAME}
@ -184,5 +180,15 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::Qml Qt${QT_VERSION_MAJOR}::Qml
) )
if ((${QT_VERSION_MAJOR} LESS_EQUAL 6) AND (CMAKE_BUILD_TYPE MATCHES "Release"))
find_program(QML_PLUGIN_DUMP NAMES qmlplugindump)
add_custom_target(Script-Generate-QmlTypes
COMMAND ${QML_PLUGIN_DUMP} -nonrelocatable FluentUI 1.0 ${CMAKE_CURRENT_BINARY_DIR} > ${CMAKE_CURRENT_SOURCE_DIR}/Qt5/imports/FluentUI/plugins.qmltypes
COMMENT "Generate qmltypes........."
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Qt5/imports/FluentUI/plugins.qmltypes
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
#安装 #安装
install(DIRECTORY ${FLUENTUI_QML_PLUGIN_DIRECTORY} DESTINATION ${CMAKE_INSTALL_PREFIX}/imports) install(DIRECTORY ${FLUENTUI_QML_PLUGIN_DIRECTORY} DESTINATION ${CMAKE_INSTALL_PREFIX}/imports)

View File

@ -1 +0,0 @@
#include "Def.h"

1444
src/Def.h

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,4 @@
#ifndef FLUACCENTCOLOR_H #pragma once
#define FLUACCENTCOLOR_H
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
@ -9,9 +8,9 @@
/** /**
* @brief The FluAccentColor class * @brief The FluAccentColor class
*/ */
class FluAccentColor : public QObject class FluAccentColor : public QObject {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QColor, darkest) Q_PROPERTY_AUTO(QColor, darkest)
Q_PROPERTY_AUTO(QColor, darker) Q_PROPERTY_AUTO(QColor, darker)
Q_PROPERTY_AUTO(QColor, dark) Q_PROPERTY_AUTO(QColor, dark)
@ -23,5 +22,3 @@ class FluAccentColor : public QObject
public: public:
explicit FluAccentColor(QObject *parent = nullptr); explicit FluAccentColor(QObject *parent = nullptr);
}; };
#endif // FLUACCENTCOLOR_H

View File

@ -1,27 +1,26 @@
#include "FluApp.h" #include "FluApp.h"
#include <QQmlEngine>
#include <QGuiApplication> #include <QGuiApplication>
#include <QQmlContext>
#include <QQuickItem> #include <QQuickItem>
#include <QTimer> #include <QTimer>
#include <QUuid> #include <QUuid>
#include <QFontDatabase> #include <QFontDatabase>
#include <QClipboard> #include <QClipboard>
#include <QTranslator> #include <QTranslator>
#include <utility>
#include "FluentIconDef.h"
FluApp::FluApp(QObject *parent) : QObject{parent} { FluApp::FluApp(QObject *parent) : QObject{parent} {
useSystemAppBar(false); _useSystemAppBar = false;
} }
FluApp::~FluApp(){ FluApp::~FluApp() = default;
}
void FluApp::init(QObject *target, QLocale locale) { void FluApp::init(QObject *target, QLocale locale) {
_locale = locale; _locale = std::move(locale);
_engine = qmlEngine(target); _engine = qmlEngine(target);
_translator = new QTranslator(this); _translator = new QTranslator(this);
qApp->installTranslator(_translator); QGuiApplication::installTranslator(_translator);
const QStringList uiLanguages = _locale.uiLanguages(); const QStringList uiLanguages = _locale.uiLanguages();
for (const QString &name: uiLanguages) { for (const QString &name: uiLanguages) {
const QString baseName = "fluentui_" + QLocale(name).name(); const QString baseName = "fluentui_" + QLocale(name).name();
@ -31,3 +30,19 @@ void FluApp::init(QObject *target,QLocale locale){
} }
} }
} }
[[maybe_unused]] QJsonArray FluApp::iconData(const QString &keyword) {
QJsonArray arr;
QMetaEnum enumType = Fluent_Icons::staticMetaObject.enumerator(Fluent_Icons::staticMetaObject.indexOfEnumerator("Fluent_IconType"));
for (int i = 0; i <= enumType.keyCount() - 1; ++i) {
QString name = enumType.key(i);
int icon = enumType.value(i);
if (keyword.isEmpty() || name.contains(keyword)) {
QJsonObject obj;
obj.insert("name", name);
obj.insert("icon", icon);
arr.append(obj);
}
}
return arr;
}

View File

@ -1,5 +1,4 @@
#ifndef FLUAPP_H #pragma once
#define FLUAPP_H
#include <QObject> #include <QObject>
#include <QWindow> #include <QWindow>
@ -9,30 +8,37 @@
#include <QQmlEngine> #include <QQmlEngine>
#include <QTranslator> #include <QTranslator>
#include <QQuickWindow> #include <QQuickWindow>
#include <QJsonArray>
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h" #include "singleton.h"
/** /**
* @brief The FluApp class * @brief The FluApp class
*/ */
class FluApp : public QObject class FluApp : public QObject {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(bool,useSystemAppBar);
Q_PROPERTY_AUTO(QString,windowIcon); Q_PROPERTY_AUTO(bool, useSystemAppBar)
Q_PROPERTY_AUTO(QLocale,locale); Q_PROPERTY_AUTO(QString, windowIcon)
Q_PROPERTY_AUTO(QLocale, locale)
QML_NAMED_ELEMENT(FluApp) QML_NAMED_ELEMENT(FluApp)
QML_SINGLETON QML_SINGLETON
private: private:
explicit FluApp(QObject *parent = nullptr); explicit FluApp(QObject *parent = nullptr);
~FluApp();
~FluApp() override;
public: public:
SINGLETON(FluApp) SINGLETON(FluApp)
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
static FluApp *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
Q_INVOKABLE void init(QObject *target, QLocale locale = QLocale::system()); Q_INVOKABLE void init(QObject *target, QLocale locale = QLocale::system());
[[maybe_unused]] Q_INVOKABLE static QJsonArray iconData(const QString &keyword = "");
private: private:
QQmlEngine *_engine; QQmlEngine *_engine{};
QTranslator *_translator = nullptr; QTranslator *_translator = nullptr;
}; };
#endif // FLUAPP_H

View File

@ -3,14 +3,20 @@
#include <QChar> #include <QChar>
#include <QPainter> #include <QPainter>
#include <QRandomGenerator> #include <QRandomGenerator>
#include <qmath.h>
int generaNumber(int number) {
return QRandomGenerator::global()->bounded(0, number);
}
FluCaptcha::FluCaptcha(QQuickItem *parent) : QQuickPaintedItem(parent) { FluCaptcha::FluCaptcha(QQuickItem *parent) : QQuickPaintedItem(parent) {
ignoreCase(true); _ignoreCase = false;
QFont fontStype; QFont fontStyle;
fontStype.setPixelSize(28); #ifdef Q_OS_WIN
fontStype.setBold(true); fontStyle.setFamily("微软雅黑");
font(fontStype); #endif
fontStyle.setPixelSize(28);
fontStyle.setBold(true);
font(fontStyle);
setWidth(180); setWidth(180);
setHeight(80); setHeight(80);
refresh(); refresh();
@ -21,55 +27,42 @@ void FluCaptcha::paint(QPainter* painter){
painter->fillRect(boundingRect().toRect(), QColor(255, 255, 255, 255)); painter->fillRect(boundingRect().toRect(), QColor(255, 255, 255, 255));
QPen pen; QPen pen;
painter->setFont(_font); painter->setFont(_font);
for(int i=0;i<100;i++) for (int i = 0; i < 100; i++) {
{ pen = QPen(QColor(generaNumber(256), generaNumber(256), generaNumber(256)));
pen = QPen(QColor(_generaNumber(256),_generaNumber(256),_generaNumber(256)));
painter->setPen(pen); painter->setPen(pen);
painter->drawPoint(_generaNumber(180),_generaNumber(80)); painter->drawPoint(generaNumber(180), generaNumber(80));
} }
for(int i=0;i<5;i++) for (int i = 0; i < 5; i++) {
{ pen = QPen(QColor(generaNumber(256), generaNumber(256), generaNumber(256)));
pen = QPen(QColor(_generaNumber(256),_generaNumber(256),_generaNumber(256)));
painter->setPen(pen); painter->setPen(pen);
painter->drawLine(_generaNumber(180),_generaNumber(80),_generaNumber(180),_generaNumber(80)); painter->drawLine(generaNumber(180), generaNumber(80), generaNumber(180), generaNumber(80));
} }
for(int i=0;i<4;i++) for (int i = 0; i < 4; i++) {
{ pen = QPen(QColor(generaNumber(255), generaNumber(255), generaNumber(255)));
pen = QPen(QColor(_generaNumber(255),_generaNumber(255),_generaNumber(255)));
painter->setPen(pen); painter->setPen(pen);
painter->drawText(15+35*i,10+_generaNumber(15),30,40,Qt::AlignCenter, QString(_code[i])); painter->drawText(15 + 35 * i, 10 + generaNumber(15), 30, 40, Qt::AlignCenter, QString(_code[i]));
} }
painter->restore(); painter->restore();
} }
int FluCaptcha::_generaNumber(int number){
return QRandomGenerator::global()->bounded(0,number);
}
void FluCaptcha::refresh() { void FluCaptcha::refresh() {
this->_code.clear(); this->_code.clear();
for(int i = 0;i < 4;++i) for (int i = 0; i < 4; ++i) {
{ int num = generaNumber(3);
int num = _generaNumber(3); if (num == 0) {
if(num == 0) this->_code += QString::number(generaNumber(10));
{ } else if (num == 1) {
this->_code += QString::number(_generaNumber(10));
}
else if(num == 1)
{
int temp = 'A'; int temp = 'A';
this->_code += static_cast<QChar>(temp + _generaNumber(26)); this->_code += static_cast<QChar>(temp + generaNumber(26));
} } else if (num == 2) {
else if(num == 2)
{
int temp = 'a'; int temp = 'a';
this->_code += static_cast<QChar>(temp + _generaNumber(26)); this->_code += static_cast<QChar>(temp + generaNumber(26));
} }
} }
update(); update();
} }
bool FluCaptcha::verify(const QString& code){ [[maybe_unused]] bool FluCaptcha::verify(const QString &code) {
if (_ignoreCase) { if (_ignoreCase) {
return this->_code.toUpper() == code.toUpper(); return this->_code.toUpper() == code.toUpper();
} }

View File

@ -1,5 +1,4 @@
#ifndef FLUCAPTCHA_H #pragma once
#define FLUCAPTCHA_H
#include <QQuickItem> #include <QQuickItem>
#include <QQuickPaintedItem> #include <QQuickPaintedItem>
@ -9,21 +8,22 @@
/** /**
* @brief The FluCaptcha class * @brief The FluCaptcha class
*/ */
class FluCaptcha : public QQuickPaintedItem class FluCaptcha : public QQuickPaintedItem {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QFont, font); Q_PROPERTY_AUTO(QFont, font);
Q_PROPERTY_AUTO(bool, ignoreCase); Q_PROPERTY_AUTO(bool, ignoreCase);
QML_NAMED_ELEMENT(FluCaptcha) QML_NAMED_ELEMENT(FluCaptcha)
private:
int _generaNumber(int number);
public: public:
explicit FluCaptcha(QQuickItem *parent = nullptr); explicit FluCaptcha(QQuickItem *parent = nullptr);
void paint(QPainter *painter) override; void paint(QPainter *painter) override;
Q_INVOKABLE void refresh(); Q_INVOKABLE void refresh();
Q_INVOKABLE bool verify(const QString& code);
[[maybe_unused]] Q_INVOKABLE bool verify(const QString &code);
private: private:
QString _code; QString _code;
}; };
#endif // FLUCAPTCHA_H

View File

@ -2,34 +2,33 @@
#include "FluTools.h" #include "FluTools.h"
FluColors::FluColors(QObject *parent) : QObject{parent} { FluColors::FluColors(QObject *parent) : QObject{parent} {
Transparent(QColor(0, 0, 0, 0)); _Transparent = QColor(0, 0, 0, 0);
Black(QColor(0, 0, 0)); _Black = QColor(0, 0, 0);
White(QColor(255, 255, 255)); _White = QColor(255, 255, 255);
Grey10(QColor(250, 249, 248)); _Grey10 = QColor(250, 249, 248);
Grey20(QColor(243, 242, 241)); _Grey20 = QColor(243, 242, 241);
Grey30(QColor(237, 235, 233)); _Grey30 = QColor(237, 235, 233);
Grey40(QColor(225, 223, 221)); _Grey40 = QColor(225, 223, 221);
Grey50(QColor(210, 208, 206)); _Grey50 = QColor(210, 208, 206);
Grey60(QColor(200, 198, 196)); _Grey60 = QColor(200, 198, 196);
Grey70(QColor(190, 185, 184)); _Grey70 = QColor(190, 185, 184);
Grey80(QColor(179, 176, 173)); _Grey80 = QColor(179, 176, 173);
Grey90(QColor(161, 159, 157)); _Grey90 = QColor(161, 159, 157);
Grey100(QColor(151, 149, 146)); _Grey100 = QColor(151, 149, 146);
Grey110(QColor(138, 136, 134)); _Grey110 = QColor(138, 136, 134);
Grey120(QColor(121, 119, 117)); _Grey120 = QColor(121, 119, 117);
Grey130(QColor(96, 94, 92)); _Grey130 = QColor(96, 94, 92);
Grey140(QColor(72, 70, 68)); _Grey140 = QColor(72, 70, 68);
Grey150(QColor(59, 58, 57)); _Grey150 = QColor(59, 58, 57);
Grey160(QColor(50, 49, 48)); _Grey160 = QColor(50, 49, 48);
Grey170(QColor(41, 40, 39)); _Grey170 = QColor(41, 40, 39);
Grey180(QColor(37, 36, 35)); _Grey180 = QColor(37, 36, 35);
Grey190(QColor(32, 31, 30)); _Grey190 = QColor(32, 31, 30);
Grey200(QColor(27, 26, 25)); _Grey200 = QColor(27, 26, 25);
Grey210(QColor(22, 21, 20)); _Grey210 = QColor(22, 21, 20);
Grey220(QColor(17, 16, 15)); _Grey220 = QColor(17, 16, 15);
auto yellow = new FluAccentColor(this);
FluAccentColor *yellow = new FluAccentColor(this);
yellow->darkest(QColor(249, 168, 37)); yellow->darkest(QColor(249, 168, 37));
yellow->darker(QColor(251, 192, 45)); yellow->darker(QColor(251, 192, 45));
yellow->dark(QColor(253, 212, 53)); yellow->dark(QColor(253, 212, 53));
@ -37,9 +36,9 @@ FluColors::FluColors(QObject *parent):QObject{parent}{
yellow->light(QColor(255, 238, 88)); yellow->light(QColor(255, 238, 88));
yellow->lighter(QColor(255, 241, 118)); yellow->lighter(QColor(255, 241, 118));
yellow->lightest(QColor(255, 245, 155)); yellow->lightest(QColor(255, 245, 155));
Yellow(yellow); _Yellow = yellow;
FluAccentColor *orange = new FluAccentColor(this); auto orange = new FluAccentColor(this);
orange->darkest(QColor(153, 61, 7)); orange->darkest(QColor(153, 61, 7));
orange->darker(QColor(172, 68, 8)); orange->darker(QColor(172, 68, 8));
orange->dark(QColor(209, 88, 10)); orange->dark(QColor(209, 88, 10));
@ -47,9 +46,9 @@ FluColors::FluColors(QObject *parent):QObject{parent}{
orange->light(QColor(248, 122, 48)); orange->light(QColor(248, 122, 48));
orange->lighter(QColor(249, 145, 84)); orange->lighter(QColor(249, 145, 84));
orange->lightest(QColor(250, 192, 106)); orange->lightest(QColor(250, 192, 106));
Orange(orange); _Orange = orange;
FluAccentColor *red = new FluAccentColor(this); auto red = new FluAccentColor(this);
red->darkest(QColor(143, 10, 21)); red->darkest(QColor(143, 10, 21));
red->darker(QColor(162, 11, 24)); red->darker(QColor(162, 11, 24));
red->dark(QColor(185, 13, 28)); red->dark(QColor(185, 13, 28));
@ -57,9 +56,9 @@ FluColors::FluColors(QObject *parent):QObject{parent}{
red->light(QColor(236, 64, 79)); red->light(QColor(236, 64, 79));
red->lighter(QColor(238, 88, 101)); red->lighter(QColor(238, 88, 101));
red->lightest(QColor(240, 107, 118)); red->lightest(QColor(240, 107, 118));
Red(red); _Red = red;
FluAccentColor *magenta = new FluAccentColor(this); auto magenta = new FluAccentColor(this);
magenta->darkest(QColor(111, 0, 79)); magenta->darkest(QColor(111, 0, 79));
magenta->darker(QColor(160, 7, 108)); magenta->darker(QColor(160, 7, 108));
magenta->dark(QColor(181, 13, 125)); magenta->dark(QColor(181, 13, 125));
@ -67,9 +66,9 @@ FluColors::FluColors(QObject *parent):QObject{parent}{
magenta->light(QColor(234, 77, 168)); magenta->light(QColor(234, 77, 168));
magenta->lighter(QColor(238, 110, 193)); magenta->lighter(QColor(238, 110, 193));
magenta->lightest(QColor(241, 140, 213)); magenta->lightest(QColor(241, 140, 213));
Magenta(magenta); _Magenta = magenta;
FluAccentColor *purple = new FluAccentColor(this); auto purple = new FluAccentColor(this);
purple->darkest(QColor(44, 15, 118)); purple->darkest(QColor(44, 15, 118));
purple->darker(QColor(61, 15, 153)); purple->darker(QColor(61, 15, 153));
purple->dark(QColor(78, 17, 174)); purple->dark(QColor(78, 17, 174));
@ -77,9 +76,9 @@ FluColors::FluColors(QObject *parent):QObject{parent}{
purple->light(QColor(123, 76, 157)); purple->light(QColor(123, 76, 157));
purple->lighter(QColor(141, 110, 189)); purple->lighter(QColor(141, 110, 189));
purple->lightest(QColor(158, 142, 217)); purple->lightest(QColor(158, 142, 217));
Purple(purple); _Purple = purple;
FluAccentColor *blue = new FluAccentColor(this); auto blue = new FluAccentColor(this);
blue->darkest(QColor(0, 74, 131)); blue->darkest(QColor(0, 74, 131));
blue->darker(QColor(0, 84, 148)); blue->darker(QColor(0, 84, 148));
blue->dark(QColor(0, 102, 180)); blue->dark(QColor(0, 102, 180));
@ -87,9 +86,9 @@ FluColors::FluColors(QObject *parent):QObject{parent}{
blue->light(QColor(38, 140, 220)); blue->light(QColor(38, 140, 220));
blue->lighter(QColor(76, 160, 224)); blue->lighter(QColor(76, 160, 224));
blue->lightest(QColor(96, 171, 228)); blue->lightest(QColor(96, 171, 228));
Blue(blue); _Blue = blue;
FluAccentColor *teal = new FluAccentColor(this); auto teal = new FluAccentColor(this);
teal->darkest(QColor(0, 110, 91)); teal->darkest(QColor(0, 110, 91));
teal->darker(QColor(0, 124, 103)); teal->darker(QColor(0, 124, 103));
teal->dark(QColor(0, 151, 125)); teal->dark(QColor(0, 151, 125));
@ -97,9 +96,9 @@ FluColors::FluColors(QObject *parent):QObject{parent}{
teal->light(QColor(38, 189, 164)); teal->light(QColor(38, 189, 164));
teal->lighter(QColor(77, 201, 180)); teal->lighter(QColor(77, 201, 180));
teal->lightest(QColor(96, 207, 188)); teal->lightest(QColor(96, 207, 188));
Teal(teal); _Teal = teal;
FluAccentColor *green = new FluAccentColor(this); auto green = new FluAccentColor(this);
green->darkest(QColor(9, 76, 9)); green->darkest(QColor(9, 76, 9));
green->darker(QColor(12, 93, 12)); green->darker(QColor(12, 93, 12));
green->dark(QColor(14, 111, 14)); green->dark(QColor(14, 111, 14));
@ -107,17 +106,17 @@ FluColors::FluColors(QObject *parent):QObject{parent}{
green->light(QColor(39, 137, 57)); green->light(QColor(39, 137, 57));
green->lighter(QColor(76, 156, 76)); green->lighter(QColor(76, 156, 76));
green->lightest(QColor(106, 173, 106)); green->lightest(QColor(106, 173, 106));
Green(green); _Green = green;
} }
FluAccentColor* FluColors::createAccentColor(QColor primaryColor){ [[maybe_unused]] FluAccentColor *FluColors::createAccentColor(const QColor &primaryColor) {
FluAccentColor *accentColor = new FluAccentColor(this); auto accentColor = new FluAccentColor(this);
accentColor->darkest(FluTools::getInstance()->withOpacity(primaryColor,0.7));
accentColor->darker(FluTools::getInstance()->withOpacity(primaryColor,0.8));
accentColor->dark(FluTools::getInstance()->withOpacity(primaryColor,0.9));
accentColor->normal(primaryColor); accentColor->normal(primaryColor);
accentColor->dark(FluTools::getInstance()->withOpacity(primaryColor, 0.9));
accentColor->light(FluTools::getInstance()->withOpacity(primaryColor, 0.9)); accentColor->light(FluTools::getInstance()->withOpacity(primaryColor, 0.9));
accentColor->lighter(FluTools::getInstance()->withOpacity(primaryColor,0.8)); accentColor->darker(FluTools::getInstance()->withOpacity(accentColor->dark(), 0.8));
accentColor->lightest(FluTools::getInstance()->withOpacity(primaryColor,0.7)); accentColor->lighter(FluTools::getInstance()->withOpacity(accentColor->light(), 0.8));
accentColor->darkest(FluTools::getInstance()->withOpacity(accentColor->darker(), 0.7));
accentColor->lightest(FluTools::getInstance()->withOpacity(accentColor->lighter(), 0.7));
return accentColor; return accentColor;
} }

View File

@ -1,5 +1,4 @@
#ifndef FLUCOLORS_H #pragma once
#define FLUCOLORS_H
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
@ -11,9 +10,9 @@
/** /**
* @brief The FluColors class * @brief The FluColors class
*/ */
class FluColors : public QObject class FluColors : public QObject {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QColor, Transparent); Q_PROPERTY_AUTO(QColor, Transparent);
Q_PROPERTY_AUTO(QColor, Black); Q_PROPERTY_AUTO(QColor, Black);
Q_PROPERTY_AUTO(QColor, White); Q_PROPERTY_AUTO(QColor, White);
@ -39,22 +38,24 @@ class FluColors : public QObject
Q_PROPERTY_AUTO(QColor, Grey200); Q_PROPERTY_AUTO(QColor, Grey200);
Q_PROPERTY_AUTO(QColor, Grey210); Q_PROPERTY_AUTO(QColor, Grey210);
Q_PROPERTY_AUTO(QColor, Grey220); Q_PROPERTY_AUTO(QColor, Grey220);
Q_PROPERTY_AUTO(FluAccentColor*,Yellow); Q_PROPERTY_AUTO_P(FluAccentColor*, Yellow);
Q_PROPERTY_AUTO(FluAccentColor*,Orange); Q_PROPERTY_AUTO_P(FluAccentColor*, Orange);
Q_PROPERTY_AUTO(FluAccentColor*,Red); Q_PROPERTY_AUTO_P(FluAccentColor*, Red);
Q_PROPERTY_AUTO(FluAccentColor*,Magenta); Q_PROPERTY_AUTO_P(FluAccentColor*, Magenta);
Q_PROPERTY_AUTO(FluAccentColor*,Purple); Q_PROPERTY_AUTO_P(FluAccentColor*, Purple);
Q_PROPERTY_AUTO(FluAccentColor*,Blue); Q_PROPERTY_AUTO_P(FluAccentColor*, Blue);
Q_PROPERTY_AUTO(FluAccentColor*,Teal); Q_PROPERTY_AUTO_P(FluAccentColor*, Teal);
Q_PROPERTY_AUTO(FluAccentColor*,Green); Q_PROPERTY_AUTO_P(FluAccentColor*, Green);
QML_NAMED_ELEMENT(FluColors) QML_NAMED_ELEMENT(FluColors)
QML_SINGLETON QML_SINGLETON
private: private:
explicit FluColors(QObject *parent = nullptr); explicit FluColors(QObject *parent = nullptr);
public: public:
SINGLETON(FluColors) SINGLETON(FluColors)
Q_INVOKABLE FluAccentColor* createAccentColor(QColor primaryColor);
static FluColors *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
};
#endif // FLUCOLORS_H [[maybe_unused]] Q_INVOKABLE FluAccentColor *createAccentColor(const QColor &primaryColor);
static FluColors *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
};

View File

@ -4,70 +4,94 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QScreen> #include <QScreen>
#include <QDateTime> #include <QDateTime>
#include "FluTools.h"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#pragma comment (lib, "user32.lib") #pragma comment (lib, "user32.lib")
#pragma comment (lib, "dwmapi.lib") #pragma comment (lib, "dwmapi.lib")
#include <windows.h> #include <windows.h>
#include <windowsx.h> #include <windowsx.h>
#include <dwmapi.h> #include <dwmapi.h>
static inline QByteArray qtNativeEventType()
{ static inline QByteArray qtNativeEventType() {
static const auto result = "windows_generic_MSG"; static const auto result = "windows_generic_MSG";
return result; return result;
} }
static inline bool isCompositionEnabled() { static inline bool isCompositionEnabled() {
typedef HRESULT (WINAPI *DwmIsCompositionEnabledPtr)(BOOL *pfEnabled); typedef HRESULT (WINAPI *DwmIsCompositionEnabledPtr)(BOOL *pfEnabled);
HMODULE module = ::LoadLibraryW(L"dwmapi.dll"); HMODULE module = ::LoadLibraryW(L"dwmapi.dll");
if (module) if (module) {
{
BOOL composition_enabled = false; BOOL composition_enabled = false;
DwmIsCompositionEnabledPtr dwm_is_composition_enabled; DwmIsCompositionEnabledPtr dwm_is_composition_enabled;
dwm_is_composition_enabled = reinterpret_cast<DwmIsCompositionEnabledPtr>(::GetProcAddress(module, "DwmIsCompositionEnabled")); dwm_is_composition_enabled = reinterpret_cast<DwmIsCompositionEnabledPtr>(::GetProcAddress(module, "DwmIsCompositionEnabled"));
if (dwm_is_composition_enabled) if (dwm_is_composition_enabled) {
{
dwm_is_composition_enabled(&composition_enabled); dwm_is_composition_enabled(&composition_enabled);
} }
return composition_enabled; return composition_enabled;
} }
return false; return false;
} }
static inline void setShadow(HWND hwnd) {
const MARGINS shadow = {1, 0, 0, 0};
typedef HRESULT (WINAPI *DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset);
HMODULE module = LoadLibraryW(L"dwmapi.dll");
if (module) {
DwmExtendFrameIntoClientAreaPtr dwm_extendframe_into_client_area_;
dwm_extendframe_into_client_area_ = reinterpret_cast<DwmExtendFrameIntoClientAreaPtr>(GetProcAddress(module, "DwmExtendFrameIntoClientArea"));
if (dwm_extendframe_into_client_area_) {
dwm_extendframe_into_client_area_(hwnd, &shadow);
}
}
}
#endif #endif
FluFrameless::FluFrameless(QQuickItem *parent) bool containsCursorToItem(QQuickItem *item) {
: QQuickItem{parent} if (!item || !item->isVisible()) {
{ return false;
appbar(nullptr); }
maximizeButton(nullptr); auto point = item->window()->mapFromGlobal(QCursor::pos());
minimizedButton(nullptr); auto rect = QRectF(item->mapToItem(item->window()->contentItem(), QPointF(0, 0)), item->size());
closeButton(nullptr); if (rect.contains(point)) {
topmost(false); return true;
disabled(false); }
return false;
} }
FluFrameless::~FluFrameless(){ FluFrameless::FluFrameless(QQuickItem *parent) : QQuickItem{parent} {
_fixSize = false;
_appbar = nullptr;
_maximizeButton = nullptr;
_minimizedButton = nullptr;
_closeButton = nullptr;
_topmost = false;
_disabled = false;
_isWindows11OrGreater = FluTools::getInstance()->isWindows11OrGreater();
} }
void FluFrameless::onDestruction(){ FluFrameless::~FluFrameless() = default;
qApp->removeNativeEventFilter(this);
[[maybe_unused]] void FluFrameless::onDestruction() {
QGuiApplication::instance()->removeNativeEventFilter(this);
} }
void FluFrameless::componentComplete() { void FluFrameless::componentComplete() {
if (_disabled) { if (_disabled) {
return; return;
} }
int w = window()->width();
int h = window()->height();
_current = window()->winId(); _current = window()->winId();
window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint); window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
if(QQuickWindow::sceneGraphBackend() == "software"){
window()->setFlag(Qt::FramelessWindowHint,false);
}
#endif
if (!_fixSize) { if (!_fixSize) {
window()->setFlag(Qt::WindowMaximizeButtonHint); window()->setFlag(Qt::WindowMaximizeButtonHint);
} }
window()->installEventFilter(this); window()->installEventFilter(this);
qApp->installNativeEventFilter(this); QGuiApplication::instance()->installNativeEventFilter(this);
if (_maximizeButton) { if (_maximizeButton) {
setHitTestVisible(_maximizeButton); setHitTestVisible(_maximizeButton);
} }
@ -81,86 +105,107 @@ void FluFrameless::componentComplete(){
HWND hwnd = reinterpret_cast<HWND>(window()->winId()); HWND hwnd = reinterpret_cast<HWND>(window()->winId());
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE); DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
if (_fixSize) { if (_fixSize) {
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME); #if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
for (int i = 0; i < qApp->screens().count(); ++i) { ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);;
connect( qApp->screens().at(i),&QScreen::logicalDotsPerInchChanged,this,[=]{ #else
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
#endif
for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) {
connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] {
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED); SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
}); });
} }
} else { } else {
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME); ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
#else
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
#endif
} }
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
connect(window(), &QQuickWindow::screenChanged, this, [hwnd] { connect(window(), &QQuickWindow::screenChanged, this, [hwnd] {
::SetWindowPos(hwnd,0,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER); ::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); ::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
}); });
if (!window()->property("_hideShadow").toBool()) {
setShadow(hwnd);
}
#endif #endif
h = qRound(h + _appbar->height());
if (_fixSize) {
window()->setMaximumSize(QSize(w, h));
window()->setMinimumSize(QSize(w, h));
}
window()->resize(QSize(w, h));
connect(this, &FluFrameless::topmostChanged, this, [this] { connect(this, &FluFrameless::topmostChanged, this, [this] {
_setWindowTopmost(topmost()); _setWindowTopmost(topmost());
}); });
_setWindowTopmost(topmost()); _setWindowTopmost(topmost());
} }
bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result){ [[maybe_unused]] bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if ((eventType != qtNativeEventType()) || !message) { if ((eventType != qtNativeEventType()) || !message) {
return false; return false;
} }
const auto msg = static_cast<const MSG *>(message); const auto msg = static_cast<const MSG *>(message);
const HWND hwnd = msg->hwnd; auto hwnd = msg->hwnd;
if (!hwnd || !msg) { if (!hwnd) {
return false; return false;
} }
const qint64 wid = reinterpret_cast<qint64>(hwnd); const quint64 wid = reinterpret_cast<qint64>(hwnd);
if (wid != _current) { if (wid != _current) {
return false; return false;
} }
const UINT uMsg = msg->message; const auto uMsg = msg->message;
const WPARAM wParam = msg->wParam; const auto wParam = msg->wParam;
const LPARAM lParam = msg->lParam; const auto lParam = msg->lParam;
static QPoint offsetXY;
if (uMsg == WM_WINDOWPOSCHANGING) { if (uMsg == WM_WINDOWPOSCHANGING) {
WINDOWPOS* wp = reinterpret_cast<WINDOWPOS*>(lParam); auto *wp = reinterpret_cast<WINDOWPOS *>(lParam);
if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0) if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0) {
{
wp->flags |= SWP_NOCOPYBITS; wp->flags |= SWP_NOCOPYBITS;
*result = ::DefWindowProcW(hwnd, uMsg, wParam, lParam); *result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(::DefWindowProcW(hwnd, uMsg, wParam, lParam));
return true; return true;
} }
return false; return false;
}else if(uMsg == WM_NCCALCSIZE){ } else if (uMsg == WM_NCCALCSIZE && wParam == TRUE) {
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]); const auto clientRect = &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0];
const LONG originalTop = clientRect->top; const LONG originalTop = clientRect->top;
const LONG originalLeft = clientRect->left; const LONG originalLeft = clientRect->left;
const LONG originalRight = clientRect->right;
const LONG originalBottom = clientRect->bottom; const LONG originalBottom = clientRect->bottom;
const LONG originalRight = clientRect->right;
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam); const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) { if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
*result = hitTestResult; *result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
return true; return true;
} }
int offsetSize = 0; #if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
clientRect->top = originalTop;
clientRect->bottom = originalBottom;
clientRect->left = originalLeft;
clientRect->right = originalRight;
#else
bool isMaximum = ::IsZoomed(hwnd); bool isMaximum = ::IsZoomed(hwnd);
offsetXY = QPoint(abs(clientRect->left - originalLeft),abs(clientRect->top - originalTop)); if (isMaximum) {
if(isMaximum || _isFullScreen()){ auto geometry = window()->screen()->geometry();
offsetSize = 0; auto offsetX = qAbs(geometry.left()-originalLeft);
auto offsetY = qAbs(geometry.top()-originalTop);
clientRect->top = originalTop + offsetY;
clientRect->bottom = originalBottom - offsetY;
clientRect->left = originalLeft + offsetX;
clientRect->right = originalRight - offsetX;
} else { } else {
offsetSize = 1; clientRect->top = originalTop;
} clientRect->bottom = originalBottom;
if(!isCompositionEnabled()){ clientRect->left = originalLeft;
offsetSize = 0; clientRect->right = originalRight;
}
if (!isMaximum || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) {
clientRect->top = originalTop + offsetSize;
clientRect->bottom = originalBottom - offsetSize;
clientRect->left = originalLeft + offsetSize;
clientRect->right = originalRight - offsetSize;
} }
#endif
_setMaximizeHovered(false); _setMaximizeHovered(false);
*result = WVR_REDRAW; *result = WVR_REDRAW;
return true; return true;
} else if (uMsg == WM_NCHITTEST) { } else if (uMsg == WM_NCHITTEST) {
if (_isWindows11OrGreater) {
if (_hitMaximizeButton()) { if (_hitMaximizeButton()) {
if (*result == HTNOWHERE) { if (*result == HTNOWHERE) {
*result = HTZOOM; *result = HTZOOM;
@ -170,6 +215,7 @@ bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message,
} }
_setMaximizeHovered(false); _setMaximizeHovered(false);
_setMaximizePressed(false); _setMaximizePressed(false);
}
*result = 0; *result = 0;
POINT nativeGlobalPos{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; POINT nativeGlobalPos{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
POINT nativeLocalPos = nativeGlobalPos; POINT nativeLocalPos = nativeGlobalPos;
@ -211,62 +257,85 @@ bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message,
} }
*result = HTCLIENT; *result = HTCLIENT;
return true; return true;
}else if(uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN){ } else if (uMsg == WM_NCPAINT) {
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
*result = FALSE;
return true;
#else
if (isCompositionEnabled()) {
return false;
}
*result = FALSE;
return true;
#endif
} else if (uMsg == WM_NCACTIVATE) {
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
*result = TRUE;
return true;
#else
if (isCompositionEnabled()) {
return false;
}
*result = TRUE;
return true;
#endif
} else if (uMsg == WM_GETMINMAXINFO) {
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
auto *minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
auto pixelRatio = window()->devicePixelRatio();
auto geometry = window()->screen()->availableGeometry();
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
minmaxInfo->ptMaxPosition.x = rect.left;
minmaxInfo->ptMaxPosition.y = rect.top;
minmaxInfo->ptMaxSize.x = qRound(geometry.width() * pixelRatio);
minmaxInfo->ptMaxSize.y = qRound(geometry.height() * pixelRatio);
#endif
return false;
} else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) {
if (_hitMaximizeButton()) { if (_hitMaximizeButton()) {
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QGuiApplication::sendEvent(_maximizeButton, &event); QGuiApplication::sendEvent(_maximizeButton, &event);
_setMaximizePressed(true); _setMaximizePressed(true);
return true; return true;
} }
}else if(uMsg == WM_NCLBUTTONUP || uMsg == WM_NCRBUTTONUP){ } else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONUP || uMsg == WM_NCRBUTTONUP)) {
if (_hitMaximizeButton()) { if (_hitMaximizeButton()) {
QMouseEvent event = QMouseEvent(QEvent::MouseButtonRelease, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QMouseEvent event = QMouseEvent(QEvent::MouseButtonRelease, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QGuiApplication::sendEvent(_maximizeButton, &event); QGuiApplication::sendEvent(_maximizeButton, &event);
_setMaximizePressed(false); _setMaximizePressed(false);
return true; return true;
} }
}else if(uMsg == WM_NCPAINT){
*result = FALSE;
return true;
}else if(uMsg == WM_NCACTIVATE){
*result = ::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
return true;
}else if(uMsg == WM_GETMINMAXINFO){
MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
auto pixelRatio = window()->devicePixelRatio();
auto geometry = window()->screen()->availableGeometry();
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
minmaxInfo->ptMaxPosition.x = rect.left - offsetXY.x();
minmaxInfo->ptMaxPosition.y = rect.top - offsetXY.x();
minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2;
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2;
return false;
} else if (uMsg == WM_NCRBUTTONDOWN) { } else if (uMsg == WM_NCRBUTTONDOWN) {
if (wParam == HTCAPTION) { if (wParam == HTCAPTION) {
_showSystemMenu(QCursor::pos()); auto pos = window()->position();
auto offset = window()->mapFromGlobal(QCursor::pos());
_showSystemMenu(QPoint(pos.x() + offset.x(), pos.y() + offset.y()));
} }
} else if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN) { } else if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN) {
const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0)); const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0));
const bool spacePressed = ((wParam == VK_SPACE) || (::GetKeyState(VK_SPACE) < 0)); const bool spacePressed = ((wParam == VK_SPACE) || (::GetKeyState(VK_SPACE) < 0));
if (altPressed && spacePressed) { if (altPressed && spacePressed) {
auto pos = window()->position(); auto pos = window()->position();
_showSystemMenu(QPoint(pos.x(),pos.y()+_appbar->height())); _showSystemMenu(QPoint(pos.x(), qRound(pos.y() + _appbar->height())));
} }
} else if (uMsg == WM_SYSCOMMAND) { } else if (uMsg == WM_SYSCOMMAND) {
if (wParam == SC_MINIMIZE) { if (wParam == SC_MINIMIZE) {
if (window()->transientParent()) { if (window()->transientParent()) {
window()->transientParent()->showMinimized(); auto _hwnd = reinterpret_cast<HWND>(window()->transientParent()->winId());
::ShowWindow(_hwnd, 2);
} else { } else {
window()->showMinimized(); auto _hwnd = reinterpret_cast<HWND>(window()->winId());
::ShowWindow(_hwnd, 2);
} }
return true; return true;
} }
return false; return false;
} }
return false; return false;
#endif #else
return false; return false;
#endif
} }
bool FluFrameless::_isMaximized() { bool FluFrameless::_isMaximized() {
@ -279,10 +348,17 @@ bool FluFrameless::_isFullScreen(){
void FluFrameless::_showSystemMenu(QPoint point) { void FluFrameless::_showSystemMenu(QPoint point) {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
QScreen *screen = window()->screen();
if (!screen) {
screen = QGuiApplication::primaryScreen();
}
if (!screen) {
return;
}
const QPoint origin = screen->geometry().topLeft();
auto nativePos = QPointF(QPointF(point - origin) * window()->devicePixelRatio()).toPoint() + origin;
HWND hwnd = reinterpret_cast<HWND>(window()->winId()); HWND hwnd = reinterpret_cast<HWND>(window()->winId());
DWORD style = ::GetWindowLongPtr(hwnd,GWL_STYLE); auto hMenu = ::GetSystemMenu(hwnd, FALSE);
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
const HMENU hMenu = ::GetSystemMenu(hwnd, FALSE);
if (_isMaximized() || _isFullScreen()) { if (_isMaximized() || _isFullScreen()) {
::EnableMenuItem(hMenu, SC_MOVE, MFS_DISABLED); ::EnableMenuItem(hMenu, SC_MOVE, MFS_DISABLED);
::EnableMenuItem(hMenu, SC_RESTORE, MFS_ENABLED); ::EnableMenuItem(hMenu, SC_RESTORE, MFS_ENABLED);
@ -297,52 +373,45 @@ void FluFrameless::_showSystemMenu(QPoint point){
::EnableMenuItem(hMenu, SC_SIZE, MFS_DISABLED); ::EnableMenuItem(hMenu, SC_SIZE, MFS_DISABLED);
::EnableMenuItem(hMenu, SC_MAXIMIZE, MFS_DISABLED); ::EnableMenuItem(hMenu, SC_MAXIMIZE, MFS_DISABLED);
} }
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), point.x()*window()->devicePixelRatio(), point.y()*window()->devicePixelRatio(), 0, hwnd, nullptr); const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), nativePos.x(),
if (result != FALSE) { nativePos.y(), 0, hwnd, nullptr);
if (result) {
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0); ::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
} }
::SetWindowLongPtr(hwnd, GWL_STYLE, style &~ WS_SYSMENU);
#endif #endif
} }
bool FluFrameless::_containsCursorToItem(QQuickItem* item){
if(!item || !item->isVisible()){
return false;
}
auto point = QCursor::pos();
auto rect = QRectF(item->mapToGlobal(QPoint(0,0)),item->size());
if(point.x()>rect.x() && point.x()<(rect.x()+rect.width()) && point.y()>rect.y() && point.y()<(rect.y()+rect.height())){
return true;
}
return false;
}
bool FluFrameless::_hitAppBar() { bool FluFrameless::_hitAppBar() {
foreach (auto item, _hitTestList) { for (int i = 0; i <= _hitTestList.size() - 1; ++i) {
if(_containsCursorToItem(item)){ auto item = _hitTestList.at(i);
if (containsCursorToItem(item)) {
return false; return false;
} }
} }
if(_containsCursorToItem(_appbar)){ if (containsCursorToItem(_appbar)) {
return true; return true;
} }
return false; return false;
} }
bool FluFrameless::_hitMaximizeButton() { bool FluFrameless::_hitMaximizeButton() {
if(_containsCursorToItem(_maximizeButton)){ if (containsCursorToItem(_maximizeButton)) {
return true; return true;
} }
return false; return false;
} }
void FluFrameless::_setMaximizePressed(bool val) { void FluFrameless::_setMaximizePressed(bool val) {
if(_maximizeButton){
_maximizeButton->setProperty("down", val); _maximizeButton->setProperty("down", val);
} }
}
void FluFrameless::_setMaximizeHovered(bool val) { void FluFrameless::_setMaximizeHovered(bool val) {
if(_maximizeButton){
_maximizeButton->setProperty("hover", val); _maximizeButton->setProperty("hover", val);
} }
}
void FluFrameless::_updateCursor(int edges) { void FluFrameless::_updateCursor(int edges) {
switch (edges) { switch (edges) {
@ -365,10 +434,12 @@ void FluFrameless::_updateCursor(int edges){
case Qt::LeftEdge | Qt::BottomEdge: case Qt::LeftEdge | Qt::BottomEdge:
window()->setCursor(Qt::SizeBDiagCursor); window()->setCursor(Qt::SizeBDiagCursor);
break; break;
default:
break;
} }
} }
void FluFrameless::showFullScreen(){ [[maybe_unused]] void FluFrameless::showFullScreen() {
window()->showFullScreen(); window()->showFullScreen();
} }
@ -377,16 +448,21 @@ void FluFrameless::showMaximized(){
HWND hwnd = reinterpret_cast<HWND>(window()->winId()); HWND hwnd = reinterpret_cast<HWND>(window()->winId());
::ShowWindow(hwnd, 3); ::ShowWindow(hwnd, 3);
#else #else
window()->showMaximized(); window()->setVisibility(QQuickWindow::Maximized);
#endif #endif
} }
void FluFrameless::showMinimized(){ [[maybe_unused]] void FluFrameless::showMinimized() {
window()->showMinimized(); #ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
::ShowWindow(hwnd, 2);
#else
window()->setVisibility(QQuickWindow::Minimized);
#endif
} }
void FluFrameless::showNormal() { void FluFrameless::showNormal() {
window()->showNormal(); window()->setVisibility(QQuickWindow::Windowed);
} }
void FluFrameless::setHitTestVisible(QQuickItem *val) { void FluFrameless::setHitTestVisible(QQuickItem *val) {
@ -395,7 +471,6 @@ void FluFrameless::setHitTestVisible(QQuickItem* val){
} }
} }
void FluFrameless::_setWindowTopmost(bool topmost) { void FluFrameless::_setWindowTopmost(bool topmost) {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window()->winId()); HWND hwnd = reinterpret_cast<HWND>(window()->winId());

View File

@ -1,9 +1,9 @@
#ifndef FLUFRAMELESS_H #pragma once
#define FLUFRAMELESS_H
#include <QObject> #include <QObject>
#include <QQuickItem> #include <QQuickItem>
#include <QAbstractNativeEventFilter> #include <QAbstractNativeEventFilter>
#include <QQmlProperty>
#include "stdafx.h" #include "stdafx.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
@ -15,47 +15,64 @@ using QT_ENTER_EVENT_TYPE = QEvent;
#endif #endif
class FluFrameless : public QQuickItem,QAbstractNativeEventFilter class FluFrameless : public QQuickItem, QAbstractNativeEventFilter {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QQuickItem*,appbar) Q_PROPERTY_AUTO_P(QQuickItem*, appbar)
Q_PROPERTY_AUTO_P(QQuickItem*, maximizeButton)
Q_PROPERTY_AUTO_P(QQuickItem*, minimizedButton)
Q_PROPERTY_AUTO_P(QQuickItem*, closeButton)
Q_PROPERTY_AUTO(bool, topmost) Q_PROPERTY_AUTO(bool, topmost)
Q_PROPERTY_AUTO(QQuickItem*,maximizeButton)
Q_PROPERTY_AUTO(QQuickItem*,minimizedButton)
Q_PROPERTY_AUTO(QQuickItem*,closeButton)
Q_PROPERTY_AUTO(bool, disabled) Q_PROPERTY_AUTO(bool, disabled)
Q_PROPERTY_AUTO(bool, fixSize) Q_PROPERTY_AUTO(bool, fixSize)
QML_NAMED_ELEMENT(FluFrameless) QML_NAMED_ELEMENT(FluFrameless)
public: public:
explicit FluFrameless(QQuickItem *parent = nullptr); explicit FluFrameless(QQuickItem *parent = nullptr);
~FluFrameless();
~FluFrameless() override;
void componentComplete() override; void componentComplete() override;
bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
Q_INVOKABLE void showFullScreen(); [[maybe_unused]] bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
[[maybe_unused]] Q_INVOKABLE void showFullScreen();
Q_INVOKABLE void showMaximized(); Q_INVOKABLE void showMaximized();
Q_INVOKABLE void showMinimized();
[[maybe_unused]] Q_INVOKABLE void showMinimized();
Q_INVOKABLE void showNormal(); Q_INVOKABLE void showNormal();
Q_INVOKABLE void setHitTestVisible(QQuickItem *); Q_INVOKABLE void setHitTestVisible(QQuickItem *);
Q_INVOKABLE void onDestruction();
[[maybe_unused]] Q_INVOKABLE void onDestruction();
protected: protected:
bool eventFilter(QObject *obj, QEvent *event) override; bool eventFilter(QObject *obj, QEvent *event) override;
private: private:
bool _isFullScreen(); bool _isFullScreen();
bool _isMaximized(); bool _isMaximized();
void _updateCursor(int edges); void _updateCursor(int edges);
void _setWindowTopmost(bool topmost); void _setWindowTopmost(bool topmost);
void _showSystemMenu(QPoint point); void _showSystemMenu(QPoint point);
bool _containsCursorToItem(QQuickItem* item);
bool _hitAppBar(); bool _hitAppBar();
bool _hitMaximizeButton(); bool _hitMaximizeButton();
void _setMaximizePressed(bool val); void _setMaximizePressed(bool val);
void _setMaximizeHovered(bool val); void _setMaximizeHovered(bool val);
private: private:
qint64 _current; quint64 _current = 0;
int _edges = 0; int _edges = 0;
int _margins = 8; int _margins = 8;
qint64 _clickTimer = 0; quint64 _clickTimer = 0;
bool _isWindows11OrGreater = false;
QList<QPointer<QQuickItem>> _hitTestList; QList<QPointer<QQuickItem>> _hitTestList;
}; };
#endif // FLUFRAMELESS_H

View File

@ -3,9 +3,9 @@
#include "qrcode/qrencode.h" #include "qrcode/qrencode.h"
FluQrCodeItem::FluQrCodeItem(QQuickItem *parent) : QQuickPaintedItem(parent) { FluQrCodeItem::FluQrCodeItem(QQuickItem *parent) : QQuickPaintedItem(parent) {
color(QColor(0,0,0,255)); _color = QColor(0, 0, 0, 255);
bgColor(QColor(255,255,255,255)); _bgColor = QColor(255, 255, 255, 255);
size(100); _size = 100;
setWidth(_size); setWidth(_size);
setHeight(_size); setHeight(_size);
connect(this, &FluQrCodeItem::textChanged, this, [=] { update(); }); connect(this, &FluQrCodeItem::textChanged, this, [=] { update(); });
@ -18,7 +18,6 @@ FluQrCodeItem::FluQrCodeItem(QQuickItem* parent):QQuickPaintedItem(parent){
}); });
} }
void FluQrCodeItem::paint(QPainter *painter) { void FluQrCodeItem::paint(QPainter *painter) {
if (_text.isEmpty()) { if (_text.isEmpty()) {
return; return;
@ -28,8 +27,8 @@ void FluQrCodeItem::paint(QPainter* painter){
} }
painter->save(); painter->save();
QRcode *qrcode = QRcode_encodeString(_text.toUtf8().constData(), 2, QR_ECLEVEL_Q, QR_MODE_8, 1); QRcode *qrcode = QRcode_encodeString(_text.toUtf8().constData(), 2, QR_ECLEVEL_Q, QR_MODE_8, 1);
qint32 w = width(); auto w = qint32(width());
qint32 h = height(); auto h = qint32(height());
qint32 qrcodeW = qrcode->width > 0 ? qrcode->width : 1; qint32 qrcodeW = qrcode->width > 0 ? qrcode->width : 1;
double scaleX = (double) w / (double) qrcodeW; double scaleX = (double) w / (double) qrcodeW;
double scaleY = (double) h / (double) qrcodeW; double scaleY = (double) h / (double) qrcodeW;
@ -39,13 +38,10 @@ void FluQrCodeItem::paint(QPainter* painter){
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.drawRect(0, 0, w, h); p.drawRect(0, 0, w, h);
p.setBrush(_color); p.setBrush(_color);
for (qint32 y = 0; y < qrcodeW; y++) for (qint32 y = 0; y < qrcodeW; y++) {
{ for (qint32 x = 0; x < qrcodeW; x++) {
for (qint32 x = 0; x < qrcodeW; x++)
{
unsigned char b = qrcode->data[y * qrcodeW + x]; unsigned char b = qrcode->data[y * qrcodeW + x];
if (b & 0x01) if (b & 0x01) {
{
QRectF r(x * scaleX, y * scaleY, scaleX, scaleY); QRectF r(x * scaleX, y * scaleY, scaleX, scaleY);
p.drawRects(&r, 1); p.drawRects(&r, 1);
} }

View File

@ -1,5 +1,4 @@
#ifndef FLUQRCODEITEM_H #pragma once
#define FLUQRCODEITEM_H
#include <QQuickItem> #include <QQuickItem>
#include <QQuickPaintedItem> #include <QQuickPaintedItem>
@ -9,9 +8,9 @@
/** /**
* @brief The FluQrCodeItem class * @brief The FluQrCodeItem class
*/ */
class FluQrCodeItem : public QQuickPaintedItem class FluQrCodeItem : public QQuickPaintedItem {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QString, text) Q_PROPERTY_AUTO(QString, text)
Q_PROPERTY_AUTO(QColor, color) Q_PROPERTY_AUTO(QColor, color)
Q_PROPERTY_AUTO(QColor, bgColor) Q_PROPERTY_AUTO(QColor, bgColor)
@ -19,7 +18,6 @@ class FluQrCodeItem : public QQuickPaintedItem
QML_NAMED_ELEMENT(FluQrCodeItem) QML_NAMED_ELEMENT(FluQrCodeItem)
public: public:
explicit FluQrCodeItem(QQuickItem *parent = nullptr); explicit FluQrCodeItem(QQuickItem *parent = nullptr);
void paint(QPainter *painter) override; void paint(QPainter *painter) override;
}; };
#endif // FLUQRCODEITEM_H

View File

@ -1,5 +1,4 @@
#ifndef FLURECTANGLE_H #pragma once
#define FLURECTANGLE_H
#include <QQuickItem> #include <QQuickItem>
#include <QQuickPaintedItem> #include <QQuickPaintedItem>
@ -9,15 +8,13 @@
/** /**
* @brief The FluRectangle class * @brief The FluRectangle class
*/ */
class FluRectangle : public QQuickPaintedItem class FluRectangle : public QQuickPaintedItem {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QColor, color) Q_PROPERTY_AUTO(QColor, color)
Q_PROPERTY_AUTO(QList<int>, radius) Q_PROPERTY_AUTO(QList<int>, radius)
QML_NAMED_ELEMENT(FluRectangle) QML_NAMED_ELEMENT(FluRectangle)
public: public:
explicit FluRectangle(QQuickItem *parent = nullptr); explicit FluRectangle(QQuickItem *parent = nullptr);
void paint(QPainter *painter) override; void paint(QPainter *painter) override;
}; };
#endif // FLURECTANGLE_H

63
src/FluTableModel.cpp Normal file
View File

@ -0,0 +1,63 @@
#include "FluTableModel.h"
FluTableModel::FluTableModel(QObject *parent) : QAbstractTableModel{parent} {
}
int FluTableModel::rowCount(const QModelIndex &parent) const {
return _rows.count();
}
int FluTableModel::columnCount(const QModelIndex &parent) const {
return this->_columnSource.size();
}
QVariant FluTableModel::data(const QModelIndex &index, int role) const {
switch (role) {
case FluTableModel::RowModel:
return QVariant::fromValue(_rows.at(index.row()));
case FluTableModel::ColumnModel:
return QVariant::fromValue(_columnSource.at(index.column()));
default:
break;
}
return {};
}
QHash<int, QByteArray> FluTableModel::roleNames() const {
return {
{FluTableModel::RowModel, "rowModel"},
{FluTableModel::ColumnModel, "columnModel"}
};
}
void FluTableModel::clear() {
beginResetModel();
this->_rows.clear();
endResetModel();
}
QVariant FluTableModel::getRow(int rowIndex) {
return _rows.at(rowIndex);
}
void FluTableModel::setRow(int rowIndex, QVariant row) {
_rows.replace(rowIndex, row.toMap());
Q_EMIT dataChanged(index(rowIndex, 0), index(rowIndex, columnCount() - 1));
}
void FluTableModel::insertRow(int rowIndex, QVariant row) {
beginInsertRows(QModelIndex(), rowIndex, rowIndex);
_rows.insert(rowIndex, row.toMap());
endInsertRows();
}
void FluTableModel::removeRow(int rowIndex, int rows) {
beginRemoveRows(QModelIndex(), rowIndex, rowIndex + rows - 1);
_rows = _rows.mid(0, rowIndex) + _rows.mid(rowIndex + rows);
endRemoveRows();
}
void FluTableModel::appendRow(QVariant row) {
insertRow(rowCount(), row);
}

46
src/FluTableModel.h Normal file
View File

@ -0,0 +1,46 @@
#ifndef FLUTABLEMODEL_H
#define FLUTABLEMODEL_H
#include <QObject>
#include <QAbstractItemModel>
#include <QtQml/qqml.h>
#include "stdafx.h"
class FluTableModel : public QAbstractTableModel {
Q_OBJECT
Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource)
Q_PROPERTY_AUTO(QList<QVariantMap>, rows)
Q_PROPERTY(int rowCount READ rowCount CONSTANT)
QML_NAMED_ELEMENT(FluTableModel)
public:
enum TableModelRoles {
RowModel = 0x0101,
ColumnModel = 0x0102
};
explicit FluTableModel(QObject *parent = nullptr);
[[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override;
[[nodiscard]] int columnCount(const QModelIndex &parent = {}) const override;
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE void clear();
Q_INVOKABLE QVariant getRow(int rowIndex);
Q_INVOKABLE void setRow(int rowIndex, QVariant row);
Q_INVOKABLE void insertRow(int rowIndex, QVariant row);
Q_INVOKABLE void removeRow(int rowIndex, int rows = 1);
Q_INVOKABLE void appendRow(QVariant row);
};
#endif // FLUTABLEMODEL_H

View File

@ -2,12 +2,9 @@
#include <QJSValueList> #include <QJSValueList>
FluTableSortProxyModel::FluTableSortProxyModel(QSortFilterProxyModel *parent) FluTableSortProxyModel::FluTableSortProxyModel(QSortFilterProxyModel *parent) : QSortFilterProxyModel{parent} {
: QSortFilterProxyModel {parent}
{
_model = nullptr;
connect(this, &FluTableSortProxyModel::modelChanged, this, [=] { connect(this, &FluTableSortProxyModel::modelChanged, this, [=] {
setSourceModel(this->model()); setSourceModel(this->model().value<QAbstractTableModel *>());
}); });
} }
@ -41,7 +38,7 @@ bool FluTableSortProxyModel::lessThan(const QModelIndex &source_left, const QMod
} }
} }
void FluTableSortProxyModel::setComparator(QJSValue comparator){ [[maybe_unused]] void FluTableSortProxyModel::setComparator(const QJSValue &comparator) {
int column = 0; int column = 0;
if (comparator.isUndefined()) { if (comparator.isUndefined()) {
column = -1; column = -1;
@ -54,22 +51,25 @@ void FluTableSortProxyModel::setComparator(QJSValue comparator){
} }
} }
void FluTableSortProxyModel::setFilter(QJSValue filter){ [[maybe_unused]] void FluTableSortProxyModel::setFilter(const QJSValue &filter) {
this->_filter = filter; this->_filter = filter;
invalidateFilter(); invalidateFilter();
} }
QVariant FluTableSortProxyModel::getRow(int rowIndex){ [[maybe_unused]] QVariant FluTableSortProxyModel::getRow(int rowIndex) {
QVariant result; QVariant result;
QMetaObject::invokeMethod(_model, "getRow",Q_RETURN_ARG(QVariant, result),Q_ARG(int, mapToSource(index(rowIndex,0)).row())); QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "getRow", Q_RETURN_ARG(QVariant, result), Q_ARG(int, mapToSource(index(rowIndex, 0)).row()));
return result; return result;
} }
void FluTableSortProxyModel::setRow(int rowIndex,QVariant val){ [[maybe_unused]] void FluTableSortProxyModel::setRow(int rowIndex, const QVariant &val) {
QMetaObject::invokeMethod(_model, "setRow",Q_ARG(int, mapToSource(index(rowIndex,0)).row()),Q_ARG(QVariant,val)); QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "setRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(QVariant, val));
} }
void FluTableSortProxyModel::removeRow(int rowIndex,int rows){ [[maybe_unused]] void FluTableSortProxyModel::insertRow(int rowIndex, const QVariant &val) {
QMetaObject::invokeMethod(_model, "removeRow",Q_ARG(int, mapToSource(index(rowIndex,0)).row()),Q_ARG(int,rows)); QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "insertRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(QVariant, val));
} }
[[maybe_unused]] void FluTableSortProxyModel::removeRow(int rowIndex, int rows) {
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "removeRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(int, rows));
}

View File

@ -1,5 +1,4 @@
#ifndef FLUTABLESORTPROXYMODEL_H #pragma once
#define FLUTABLESORTPROXYMODEL_H
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QAbstractTableModel> #include <QAbstractTableModel>
@ -7,24 +6,32 @@
#include <QJSValue> #include <QJSValue>
#include "stdafx.h" #include "stdafx.h"
class FluTableSortProxyModel : public QSortFilterProxyModel class FluTableSortProxyModel : public QSortFilterProxyModel {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QAbstractTableModel*,model) Q_PROPERTY_AUTO_P(QVariant, model)
QML_NAMED_ELEMENT(FluTableSortProxyModel) QML_NAMED_ELEMENT(FluTableSortProxyModel)
public: public:
explicit FluTableSortProxyModel(QSortFilterProxyModel *parent = nullptr); explicit FluTableSortProxyModel(QSortFilterProxyModel *parent = nullptr);
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool filterAcceptsColumn(int sourceColumn, const QModelIndex &sourceParent) const override; bool filterAcceptsColumn(int sourceColumn, const QModelIndex &sourceParent) const override;
bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override; bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override;
Q_INVOKABLE QVariant getRow(int rowIndex);
Q_INVOKABLE void setRow(int rowIndex,QVariant val); [[maybe_unused]] Q_INVOKABLE QVariant getRow(int rowIndex);
Q_INVOKABLE void removeRow(int rowIndex,int rows);
Q_INVOKABLE void setComparator(QJSValue comparator); [[maybe_unused]] Q_INVOKABLE void setRow(int rowIndex, const QVariant &val);
Q_INVOKABLE void setFilter(QJSValue filter);
[[maybe_unused]] Q_INVOKABLE void insertRow(int rowIndex, const QVariant &val);
[[maybe_unused]] Q_INVOKABLE void removeRow(int rowIndex, int rows);
[[maybe_unused]] Q_INVOKABLE void setComparator(const QJSValue &comparator);
[[maybe_unused]] Q_INVOKABLE void setFilter(const QJSValue &filter);
private: private:
QJSValue _filter; QJSValue _filter;
QJSValue _comparator; QJSValue _comparator;
}; };
#endif // FLUTABLESORTPROXYMODEL_H

View File

@ -1,5 +1,4 @@
#ifndef FLUTEXTSTYLE_H #pragma once
#define FLUTEXTSTYLE_H
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
@ -10,8 +9,7 @@
/** /**
* @brief The FluTextStyle class * @brief The FluTextStyle class
*/ */
class FluTextStyle : public QObject class FluTextStyle : public QObject {
{
Q_OBJECT Q_OBJECT
public: public:
Q_PROPERTY_AUTO(QString, family) Q_PROPERTY_AUTO(QString, family)
@ -24,11 +22,12 @@ public:
Q_PROPERTY_AUTO(QFont, Display); Q_PROPERTY_AUTO(QFont, Display);
QML_NAMED_ELEMENT(FluTextStyle) QML_NAMED_ELEMENT(FluTextStyle)
QML_SINGLETON QML_SINGLETON
private: private:
explicit FluTextStyle(QObject *parent = nullptr); explicit FluTextStyle(QObject *parent = nullptr);
public: public:
SINGLETON(FluTextStyle) SINGLETON(FluTextStyle)
static FluTextStyle *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
};
#endif // FLUTEXTSTYLE_H static FluTextStyle *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
};

View File

@ -2,21 +2,38 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QPalette> #include <QPalette>
#include <QImage>
#include <QThreadPool>
#include "Def.h" #include "Def.h"
#include "FluColors.h" #include "FluColors.h"
#include "FluTools.h"
bool systemDark() {
QPalette palette = QGuiApplication::palette();
QColor color = palette.color(QPalette::Window).rgb();
return color.red() * 0.2126 + color.green() * 0.7152 + color.blue() * 0.0722 <= 255.0f / 2;
}
FluTheme::FluTheme(QObject *parent) : QObject{parent} { FluTheme::FluTheme(QObject *parent) : QObject{parent} {
_accentColor = FluColors::getInstance()->Blue();
_darkMode = FluThemeType::DarkMode::Light;
_nativeText = false;
_animationEnabled = true;
_systemDark = systemDark();
_desktopImagePath = "";
_blurBehindWindowEnabled = false;
QGuiApplication::instance()->installEventFilter(this);
refreshColors();
connect(this, &FluTheme::darkModeChanged, this, [=] { connect(this, &FluTheme::darkModeChanged, this, [=] {
Q_EMIT darkChanged(); Q_EMIT darkChanged();
}); });
connect(this, &FluTheme::darkChanged, this, [=] { refreshColors(); }); connect(this, &FluTheme::darkChanged, this, [=] { refreshColors(); });
connect(this, &FluTheme::accentColorChanged, this, [=] { refreshColors(); }); connect(this, &FluTheme::accentColorChanged, this, [=] { refreshColors(); });
accentColor(FluColors::getInstance()->Blue()); connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path) {
darkMode(FluThemeType::DarkMode::Light); Q_EMIT desktopImagePathChanged();
nativeText(false); });
animationEnabled(true); connect(this, &FluTheme::blurBehindWindowEnabledChanged, this, [=] { checkUpdateDesktopImage(); });
_systemDark = systemDark(); startTimer(1000);
qApp->installEventFilter(this);
} }
void FluTheme::refreshColors() { void FluTheme::refreshColors() {
@ -30,15 +47,15 @@ void FluTheme::refreshColors(){
fontSecondaryColor(isDark ? QColor(222, 222, 222, 255) : QColor(102, 102, 102, 255)); fontSecondaryColor(isDark ? QColor(222, 222, 222, 255) : QColor(102, 102, 102, 255));
fontTertiaryColor(isDark ? QColor(200, 200, 200, 255) : QColor(153, 153, 153, 255)); fontTertiaryColor(isDark ? QColor(200, 200, 200, 255) : QColor(153, 153, 153, 255));
itemNormalColor(isDark ? QColor(255, 255, 255, 0) : QColor(0, 0, 0, 0)); itemNormalColor(isDark ? QColor(255, 255, 255, 0) : QColor(0, 0, 0, 0));
itemHoverColor(isDark ? QColor(255,255,255,255*0.06) : QColor(0,0,0,255*0.03)); frameColor(isDark ? QColor(56, 56, 56, qRound(255 * 0.8)) : QColor(243, 243, 243, qRound(255 * 0.8)));
itemPressColor(isDark ? QColor(255,255,255,255*0.09) : QColor(0,0,0,255*0.06)); frameActiveColor(isDark ? QColor(48, 48, 48, qRound(255 * 0.8)) : QColor(255, 255, 255, qRound(255 * 0.8)));
itemCheckColor(isDark ? QColor(255,255,255,255*0.12) : QColor(0,0,0,255*0.09)); itemHoverColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.06)) : QColor(0, 0, 0, qRound(255 * 0.03)));
itemPressColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.09)) : QColor(0, 0, 0, qRound(255 * 0.06)));
itemCheckColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.12)) : QColor(0, 0, 0, qRound(255 * 0.09)));
} }
bool FluTheme::eventFilter(QObject *obj, QEvent *event){ bool FluTheme::eventFilter(QObject *, QEvent *event) {
Q_UNUSED(obj); if (event->type() == QEvent::ApplicationPaletteChange || event->type() == QEvent::ThemeChange) {
if (event->type() == QEvent::ApplicationPaletteChange || event->type() == QEvent::ThemeChange)
{
_systemDark = systemDark(); _systemDark = systemDark();
Q_EMIT darkChanged(); Q_EMIT darkChanged();
event->accept(); event->accept();
@ -47,36 +64,34 @@ bool FluTheme::eventFilter(QObject *obj, QEvent *event){
return false; return false;
} }
QJsonArray FluTheme::awesomeList(const QString& keyword){ bool FluTheme::dark() const {
QJsonArray arr;
QMetaEnum enumType = Fluent_Awesome::staticMetaObject.enumerator(Fluent_Awesome::staticMetaObject.indexOfEnumerator("Fluent_AwesomeType"));
for(int i=0; i < enumType.keyCount(); ++i){
QString name = enumType.key(i);
int icon = enumType.value(i);
if(keyword.isEmpty() || name.contains(keyword)){
QJsonObject obj;
obj.insert("name",name);
obj.insert("icon",icon);
arr.append(obj);
}
}
return arr;
}
bool FluTheme::systemDark(){
QPalette palette = qApp->palette();
QColor color = palette.color(QPalette::Window).rgb();
return !(color.red() * 0.2126 + color.green() * 0.7152 + color.blue() * 0.0722 > 255 / 2);
}
bool FluTheme::dark(){
if (_darkMode == FluThemeType::DarkMode::Dark) { if (_darkMode == FluThemeType::DarkMode::Dark) {
return true; return true;
}else if(_darkMode == FluThemeType::DarkMode::Light){
return false;
} else if (_darkMode == FluThemeType::DarkMode::System) { } else if (_darkMode == FluThemeType::DarkMode::System) {
return _systemDark; return _systemDark;
} else { } else {
return false; return false;
} }
} }
void FluTheme::checkUpdateDesktopImage() {
if (!_blurBehindWindowEnabled) {
return;
}
QThreadPool::globalInstance()->start([=]() {
_mutex.lock();
auto path = FluTools::getInstance()->getWallpaperFilePath();
if (_desktopImagePath != path) {
if (!_desktopImagePath.isEmpty()) {
_watcher.removePath(_desktopImagePath);
}
desktopImagePath(path);
_watcher.addPath(path);
}
_mutex.unlock();
});
}
void FluTheme::timerEvent(QTimerEvent *event) {
checkUpdateDesktopImage();
}

View File

@ -1,11 +1,13 @@
#ifndef FLUTHEME_H #pragma once
#define FLUTHEME_H
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonObject> #include <QJsonObject>
#include <QColor> #include <QColor>
#include <QTimer>
#include <QFileSystemWatcher>
#include <QMutex>
#include "FluAccentColor.h" #include "FluAccentColor.h"
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h" #include "singleton.h"
@ -13,11 +15,10 @@
/** /**
* @brief The FluTheme class * @brief The FluTheme class
*/ */
class FluTheme : public QObject class FluTheme : public QObject {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool dark READ dark NOTIFY darkChanged) Q_PROPERTY(bool dark READ dark NOTIFY darkChanged)
Q_PROPERTY_AUTO(FluAccentColor*,accentColor); Q_PROPERTY_AUTO_P(FluAccentColor*, accentColor);
Q_PROPERTY_AUTO(QColor, primaryColor); Q_PROPERTY_AUTO(QColor, primaryColor);
Q_PROPERTY_AUTO(QColor, backgroundColor); Q_PROPERTY_AUTO(QColor, backgroundColor);
Q_PROPERTY_AUTO(QColor, dividerColor); Q_PROPERTY_AUTO(QColor, dividerColor);
@ -27,27 +28,43 @@ class FluTheme : public QObject
Q_PROPERTY_AUTO(QColor, fontSecondaryColor); Q_PROPERTY_AUTO(QColor, fontSecondaryColor);
Q_PROPERTY_AUTO(QColor, fontTertiaryColor); Q_PROPERTY_AUTO(QColor, fontTertiaryColor);
Q_PROPERTY_AUTO(QColor, itemNormalColor); Q_PROPERTY_AUTO(QColor, itemNormalColor);
Q_PROPERTY_AUTO(QColor, frameColor);
Q_PROPERTY_AUTO(QColor, frameActiveColor);
Q_PROPERTY_AUTO(QColor, itemHoverColor); Q_PROPERTY_AUTO(QColor, itemHoverColor);
Q_PROPERTY_AUTO(QColor, itemPressColor); Q_PROPERTY_AUTO(QColor, itemPressColor);
Q_PROPERTY_AUTO(QColor, itemCheckColor); Q_PROPERTY_AUTO(QColor, itemCheckColor);
Q_PROPERTY_AUTO(QString, desktopImagePath);
Q_PROPERTY_AUTO(int, darkMode); Q_PROPERTY_AUTO(int, darkMode);
Q_PROPERTY_AUTO(bool, nativeText); Q_PROPERTY_AUTO(bool, nativeText);
Q_PROPERTY_AUTO(bool, animationEnabled); Q_PROPERTY_AUTO(bool, animationEnabled);
Q_PROPERTY_AUTO(bool, blurBehindWindowEnabled);
QML_NAMED_ELEMENT(FluTheme) QML_NAMED_ELEMENT(FluTheme)
QML_SINGLETON QML_SINGLETON
private: private:
explicit FluTheme(QObject *parent = nullptr); explicit FluTheme(QObject *parent = nullptr);
bool eventFilter(QObject *obj, QEvent *event);
bool systemDark(); bool eventFilter(QObject *obj, QEvent *event) override;
void refreshColors(); void refreshColors();
protected:
void timerEvent(QTimerEvent *event) override;
void checkUpdateDesktopImage();
public: public:
SINGLETON(FluTheme) SINGLETON(FluTheme)
Q_INVOKABLE QJsonArray awesomeList(const QString& keyword = "");
Q_SIGNAL void darkChanged(); Q_SIGNAL void darkChanged();
static FluTheme *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
bool dark(); static FluTheme *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
bool dark() const;
private: private:
bool _systemDark; bool _systemDark;
QFileSystemWatcher _watcher;
QMutex _mutex;
}; };
#endif // FLUTHEME_H

View File

@ -16,6 +16,14 @@
#include <QDateTime> #include <QDateTime>
#include <QSettings> #include <QSettings>
#ifdef Q_OS_WIN
#pragma comment (lib, "user32.lib")
#include <windows.h>
#include <windowsx.h>
#endif
FluTools::FluTools(QObject *parent) : QObject{parent} { FluTools::FluTools(QObject *parent) : QObject{parent} {
} }
@ -75,21 +83,20 @@ int FluTools::qtMinor(){
} }
void FluTools::setQuitOnLastWindowClosed(bool val) { void FluTools::setQuitOnLastWindowClosed(bool val) {
qApp->setQuitOnLastWindowClosed(val); QGuiApplication::setQuitOnLastWindowClosed(val);
} }
void FluTools::setOverrideCursor(Qt::CursorShape shape) { void FluTools::setOverrideCursor(Qt::CursorShape shape) {
qApp->setOverrideCursor(QCursor(shape)); QGuiApplication::setOverrideCursor(QCursor(shape));
} }
void FluTools::restoreOverrideCursor() { void FluTools::restoreOverrideCursor() {
qApp->restoreOverrideCursor(); QGuiApplication::restoreOverrideCursor();
} }
void FluTools::deleteLater(QObject *p) { void FluTools::deleteLater(QObject *p) {
if (p) { if (p) {
p->deleteLater(); p->deleteLater();
p = nullptr;
} }
} }
@ -108,11 +115,11 @@ QString FluTools::html2PlantText(const QString& html){
} }
QRect FluTools::getVirtualGeometry() { QRect FluTools::getVirtualGeometry() {
return qApp->primaryScreen()->virtualGeometry(); return QGuiApplication::primaryScreen()->virtualGeometry();
} }
QString FluTools::getApplicationDirPath() { QString FluTools::getApplicationDirPath() {
return qApp->applicationDirPath(); return QGuiApplication::applicationDirPath();
} }
QUrl FluTools::getUrlByFilePath(const QString &path) { QUrl FluTools::getUrlByFilePath(const QString &path) {
@ -124,33 +131,33 @@ QColor FluTools::withOpacity(const QColor& color,qreal opacity){
return QColor::fromRgba((alpha << 24) | (color.rgba() & 0xffffff)); return QColor::fromRgba((alpha << 24) | (color.rgba() & 0xffffff));
} }
QString FluTools::md5(QString text){ QString FluTools::md5(const QString &text) {
return QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Md5).toHex(); return QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Md5).toHex();
} }
QString FluTools::toBase64(QString text){ QString FluTools::toBase64(const QString &text) {
return text.toUtf8().toBase64(); return text.toUtf8().toBase64();
} }
QString FluTools::fromBase64(QString text){ QString FluTools::fromBase64(const QString &text) {
return QByteArray::fromBase64(text.toUtf8()); return QByteArray::fromBase64(text.toUtf8());
} }
bool FluTools::removeDir(QString dirPath){ bool FluTools::removeDir(const QString &dirPath) {
QDir qDir(dirPath); QDir qDir(dirPath);
return qDir.removeRecursively(); return qDir.removeRecursively();
} }
bool FluTools::removeFile(QString filePath){ bool FluTools::removeFile(const QString &filePath) {
QFile file(filePath); QFile file(filePath);
return file.remove(); return file.remove();
} }
QString FluTools::sha256(QString text){ QString FluTools::sha256(const QString &text) {
return QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Sha256).toHex(); return QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Sha256).toHex();
} }
void FluTools::showFileInFolder(QString path){ void FluTools::showFileInFolder(const QString &path) {
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
QProcess::startDetached("explorer.exe", {"/select,", QDir::toNativeSeparators(path)}); QProcess::startDetached("explorer.exe", {"/select,", QDir::toNativeSeparators(path)});
#endif #endif
@ -184,11 +191,11 @@ QIcon FluTools::windowIcon(){
int FluTools::cursorScreenIndex() { int FluTools::cursorScreenIndex() {
int screenIndex = 0; int screenIndex = 0;
int screenCount = qApp->screens().count(); int screenCount = QGuiApplication::screens().count();
if (screenCount > 1) { if (screenCount > 1) {
QPoint pos = QCursor::pos(); QPoint pos = QCursor::pos();
for (int i = 0; i < screenCount; ++i) { for (int i = 0; i <= screenCount - 1; ++i) {
if (qApp->screens().at(i)->geometry().contains(pos)) { if (QGuiApplication::screens().at(i)->geometry().contains(pos)) {
screenIndex = i; screenIndex = i;
break; break;
} }
@ -199,7 +206,7 @@ int FluTools::cursorScreenIndex(){
int FluTools::windowBuildNumber() { int FluTools::windowBuildNumber() {
#if defined(Q_OS_WIN) #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"))) { if (regKey.contains(QString::fromUtf8("CurrentBuildNumber"))) {
auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt(); auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt();
return buildNumber; return buildNumber;
@ -245,3 +252,66 @@ bool FluTools::isWindows10OrGreater(){
QRect FluTools::desktopAvailableGeometry(QQuickWindow *window) { QRect FluTools::desktopAvailableGeometry(QQuickWindow *window) {
return window->screen()->availableGeometry(); return window->screen()->availableGeometry();
} }
QString FluTools::getWallpaperFilePath() {
#if defined(Q_OS_WIN)
wchar_t path[MAX_PATH] = {};
if (::SystemParametersInfoW(SPI_GETDESKWALLPAPER, MAX_PATH, path, FALSE) == FALSE) {
return {};
}
return QString::fromWCharArray(path);
#elif defined(Q_OS_LINUX)
auto type = QSysInfo::productType();
if (type == "uos") {
QProcess process;
QStringList args;
args << "--session";
args << "--type=method_call";
args << "--print-reply";
args << "--dest=com.deepin.wm";
args << "/com/deepin/wm";
args << "com.deepin.wm.GetCurrentWorkspaceBackgroundForMonitor";
args << QString("string:'%1'").arg(currentTimestamp());
process.start("dbus-send", args);
process.waitForFinished();
QByteArray result = process.readAllStandardOutput().trimmed();
int startIndex = result.indexOf("file:///");
if (startIndex != -1) {
auto path = result.mid(startIndex + 7, result.length() - startIndex - 8);
return path;
}
}
#elif defined(Q_OS_MACOS)
QProcess process;
QStringList args;
args << "-e";
args << R"(tell application "Finder" to get POSIX path of (desktop picture as alias))";
process.start("osascript", args);
process.waitForFinished();
QByteArray result = process.readAllStandardOutput().trimmed();
if(result.isEmpty()){
return "/System/Library/CoreServices/DefaultDesktop.heic";
}
return result;
#else
return {};
#endif
}
QColor FluTools::imageMainColor(const QImage &image, double bright) {
int step = 20;
int t = 0;
int r = 0, g = 0, b = 0;
for (int i = 0; i < image.width(); i += step) {
for (int j = 0; j < image.height(); j += step) {
if (image.valid(i, j)) {
t++;
QColor c = image.pixel(i, j);
r += c.red();
b += c.blue();
g += c.green();
}
}
}
return QColor(int(bright * r / t) > 255 ? 255 : int(bright * r / t), int(bright * g / t) > 255 ? 255 : int(bright * g / t), int(bright * b / t) > 255 ? 255 : int(bright * b / t));
}

View File

@ -1,5 +1,4 @@
#ifndef FLUTOOLS_H #pragma once
#define FLUTOOLS_H
#include <QObject> #include <QObject>
#include <QFile> #include <QFile>
@ -11,51 +10,90 @@
/** /**
* @brief The FluTools class * @brief The FluTools class
*/ */
class FluTools : public QObject class FluTools : public QObject {
{
Q_OBJECT Q_OBJECT
QML_NAMED_ELEMENT(FluTools) QML_NAMED_ELEMENT(FluTools)
QML_SINGLETON QML_SINGLETON
private: private:
explicit FluTools(QObject *parent = nullptr); explicit FluTools(QObject *parent = nullptr);
public: public:
SINGLETON(FluTools) SINGLETON(FluTools)
static FluTools *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE int qtMajor();
Q_INVOKABLE int qtMinor();
Q_INVOKABLE bool isMacos();
Q_INVOKABLE bool isLinux();
Q_INVOKABLE bool isWin();
Q_INVOKABLE void clipText(const QString& text);
Q_INVOKABLE QString uuid();
Q_INVOKABLE QString readFile(const QString& fileName);
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
Q_INVOKABLE void restoreOverrideCursor();
Q_INVOKABLE QString html2PlantText(const QString& html);
Q_INVOKABLE QString toLocalPath(const QUrl& url);
Q_INVOKABLE void deleteLater(QObject *p);
Q_INVOKABLE QString getFileNameByUrl(const QUrl& url);
Q_INVOKABLE QRect getVirtualGeometry();
Q_INVOKABLE QString getApplicationDirPath();
Q_INVOKABLE QUrl getUrlByFilePath(const QString& path);
Q_INVOKABLE QColor withOpacity(const QColor&,qreal alpha);
Q_INVOKABLE QString md5(QString text);
Q_INVOKABLE QString sha256(QString text);
Q_INVOKABLE QString toBase64(QString text);
Q_INVOKABLE QString fromBase64(QString text);
Q_INVOKABLE bool removeDir(QString dirPath);
Q_INVOKABLE bool removeFile(QString filePath);
Q_INVOKABLE void showFileInFolder(QString path);
Q_INVOKABLE bool isSoftware();
Q_INVOKABLE qint64 currentTimestamp();
Q_INVOKABLE QPoint cursorPos();
Q_INVOKABLE QIcon windowIcon();
Q_INVOKABLE int cursorScreenIndex();
Q_INVOKABLE int windowBuildNumber();
Q_INVOKABLE bool isWindows11OrGreater();
Q_INVOKABLE bool isWindows10OrGreater();
Q_INVOKABLE QRect desktopAvailableGeometry(QQuickWindow* window);
};
#endif // FLUTOOLS_H static FluTools *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
Q_INVOKABLE int qtMajor();
Q_INVOKABLE int qtMinor();
Q_INVOKABLE bool isMacos();
Q_INVOKABLE bool isLinux();
Q_INVOKABLE bool isWin();
Q_INVOKABLE void clipText(const QString &text);
Q_INVOKABLE QString uuid();
Q_INVOKABLE QString readFile(const QString &fileName);
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
Q_INVOKABLE void restoreOverrideCursor();
Q_INVOKABLE QString html2PlantText(const QString &html);
Q_INVOKABLE QString toLocalPath(const QUrl &url);
Q_INVOKABLE void deleteLater(QObject *p);
Q_INVOKABLE QString getFileNameByUrl(const QUrl &url);
Q_INVOKABLE QRect getVirtualGeometry();
Q_INVOKABLE QString getApplicationDirPath();
Q_INVOKABLE QUrl getUrlByFilePath(const QString &path);
Q_INVOKABLE QColor withOpacity(const QColor &, qreal alpha);
Q_INVOKABLE QString md5(const QString &text);
Q_INVOKABLE QString sha256(const QString &text);
Q_INVOKABLE QString toBase64(const QString &text);
Q_INVOKABLE QString fromBase64(const QString &text);
Q_INVOKABLE bool removeDir(const QString &dirPath);
Q_INVOKABLE bool removeFile(const QString &filePath);
Q_INVOKABLE void showFileInFolder(const QString &path);
Q_INVOKABLE bool isSoftware();
Q_INVOKABLE qint64 currentTimestamp();
Q_INVOKABLE QPoint cursorPos();
Q_INVOKABLE QIcon windowIcon();
Q_INVOKABLE int cursorScreenIndex();
Q_INVOKABLE int windowBuildNumber();
Q_INVOKABLE bool isWindows11OrGreater();
Q_INVOKABLE bool isWindows10OrGreater();
Q_INVOKABLE QRect desktopAvailableGeometry(QQuickWindow *window);
Q_INVOKABLE QString getWallpaperFilePath();
Q_INVOKABLE QColor imageMainColor(const QImage &image, double bright = 1);
};

View File

@ -5,45 +5,40 @@
FluTreeNode::FluTreeNode(QObject *parent) : QObject{parent} { FluTreeNode::FluTreeNode(QObject *parent) : QObject{parent} {
} }
FluTreeModel::FluTreeModel(QObject *parent): QAbstractItemModel{parent}{ FluTreeModel::FluTreeModel(QObject *parent) : QAbstractTableModel{parent} {
dataSourceSize(0); _dataSourceSize = 0;
}
QModelIndex FluTreeModel::parent(const QModelIndex &child) const{
return QModelIndex();
}
QModelIndex FluTreeModel::index(int row, int column,const QModelIndex &parent) const{
if (!hasIndex(row, column, parent) || parent.isValid())
return QModelIndex();
return createIndex(row, column, _rows.at(row));
} }
int FluTreeModel::rowCount(const QModelIndex &parent) const { int FluTreeModel::rowCount(const QModelIndex &parent) const {
return _rows.count(); return _rows.count();
}; }
int FluTreeModel::columnCount(const QModelIndex &parent) const { int FluTreeModel::columnCount(const QModelIndex &parent) const {
return 1;; return this->_columnSource.size();
}; }
QVariant FluTreeModel::data(const QModelIndex &index, int role) const { QVariant FluTreeModel::data(const QModelIndex &index, int role) const {
switch (role) { switch (role) {
case Qt::DisplayRole: case TreeModelRoles::RowModel:
return QVariant::fromValue(_rows.at(index.row())); return QVariant::fromValue(_rows.at(index.row()));
case TreeModelRoles::ColumnModel:
return QVariant::fromValue(_columnSource.at(index.column()));
default: default:
break; break;
} }
return QVariant(); return {};
}; }
QHash<int, QByteArray> FluTreeModel::roleNames() const { QHash<int, QByteArray> FluTreeModel::roleNames() const {
return { {Qt::DisplayRole, "dataModel"} }; return {
{TreeModelRoles::RowModel, "rowModel"},
{TreeModelRoles::ColumnModel, "columnModel"}
}; };
}
void FluTreeModel::setData(QList<FluTreeNode *> data) { void FluTreeModel::setData(QList<FluTreeNode *> data) {
beginResetModel(); beginResetModel();
_rows = data; _rows = std::move(data);
endResetModel(); endResetModel();
} }
@ -59,9 +54,9 @@ void FluTreeModel::removeRows(int row,int count){
endRemoveRows(); endRemoveRows();
} }
void FluTreeModel::insertRows(int row,QList<FluTreeNode*> data){ void FluTreeModel::insertRows(int row, const QList<FluTreeNode *> &data) {
if (row < 0 || row > _rows.size() || data.size() == 0) if (row < 0 || row > _rows.size() || data.empty())
return;; return;
beginInsertRows(QModelIndex(), row, row + data.size() - 1); beginInsertRows(QModelIndex(), row, row + data.size() - 1);
QList<FluTreeNode *> firstPart = _rows.mid(0, row); QList<FluTreeNode *> firstPart = _rows.mid(0, row);
QList<FluTreeNode *> secondPart = _rows.mid(row); QList<FluTreeNode *> secondPart = _rows.mid(row);
@ -76,6 +71,11 @@ QObject* FluTreeModel::getRow(int row){
return _rows.at(row); return _rows.at(row);
} }
void FluTreeModel::setRow(int row, QVariantMap data) {
_rows.at(row)->_data = std::move(data);
Q_EMIT dataChanged(index(row, 0), index(row, columnCount() - 1));
}
void FluTreeModel::checkRow(int row, bool checked) { void FluTreeModel::checkRow(int row, bool checked) {
auto itemData = _rows.at(row); auto itemData = _rows.at(row);
if (itemData->hasChildren()) { if (itemData->hasChildren()) {
@ -102,15 +102,7 @@ void FluTreeModel::checkRow(int row,bool checked){
itemData->_checked = checked; itemData->_checked = checked;
} }
Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0)); Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0));
QList<FluTreeNode*> data;
foreach (auto item, _dataSource) {
if(!item->hasChildren()){
if(item->_checked){
data.append(item);
}
}
}
selectionModel(data);
} }
void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) { void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) {
@ -124,11 +116,10 @@ void FluTreeModel::setDataSource(QList<QMap<QString,QVariant>> data){
while (data.count() > 0) { while (data.count() > 0) {
auto item = data.at(data.count() - 1); auto item = data.at(data.count() - 1);
data.pop_back(); data.pop_back();
FluTreeNode* node = new FluTreeNode(this); auto *node = new FluTreeNode(this);
node->_title = item.value("title").toString();
node->_key = item.value("key").toString();
node->_depth = item.value("__depth").toInt(); node->_depth = item.value("__depth").toInt();
node->_parent = item.value("__parent").value<FluTreeNode *>(); node->_parent = item.value("__parent").value<FluTreeNode *>();
node->_data = item;
node->_isExpanded = true; node->_isExpanded = true;
if (node->_parent) { if (node->_parent) {
node->_parent->_children.append(node); node->_parent->_children.append(node);
@ -141,9 +132,9 @@ void FluTreeModel::setDataSource(QList<QMap<QString,QVariant>> data){
QList<QVariant> children = item.value("children").toList(); QList<QVariant> children = item.value("children").toList();
if (!children.isEmpty()) { if (!children.isEmpty()) {
std::reverse(children.begin(), children.end()); std::reverse(children.begin(), children.end());
for (int i = 0; i < children.count(); ++i) { for (int i = 0; i <= children.count() - 1; ++i) {
auto child = children.at(i).toMap(); auto child = children.at(i).toMap();
child.insert("__depth",item.value("__depth").toInt(0)+1); child.insert("__depth", item.value("__depth").toInt(nullptr) + 1);
child.insert("__parent", QVariant::fromValue(node)); child.insert("__parent", QVariant::fromValue(node));
data.append(child); data.append(child);
} }
@ -201,110 +192,6 @@ void FluTreeModel::expand(int row){
insertRows(row + 1, insertData); insertRows(row + 1, insertData);
} }
void FluTreeModel::dragAndDrop(int dragIndex,int dropIndex,bool isDropTopArea){
if(dropIndex>_rows.count() || dropIndex<0){
return;
}
auto dragItem = _rows[dragIndex];
auto dropItem = _rows[dropIndex];
int targetIndex;
if(dropIndex > dragIndex){
if(isDropTopArea){
targetIndex = dropIndex;
}else{
targetIndex = dropIndex+1;
}
}else{
if(isDropTopArea){
targetIndex = dropIndex;
}else{
targetIndex = dropIndex+1;
}
}
if (!beginMoveRows(QModelIndex(), dragIndex, dragIndex, QModelIndex(), targetIndex)) {
return;
}
if(dropIndex > dragIndex){
if(isDropTopArea){
targetIndex = dropIndex-1;
}else{
targetIndex = dropIndex;
}
}else{
if(isDropTopArea){
targetIndex = dropIndex;
}else{
targetIndex = dropIndex+1;
}
}
_rows.move(dragIndex,targetIndex);
endMoveRows();
Q_EMIT layoutAboutToBeChanged();
if(dragItem->_parent == dropItem->_parent){
QList<FluTreeNode*>* children = &(dragItem->_parent->_children);
int srcIndex = children->indexOf(dragItem);
int destIndex = children->indexOf(dropItem);
if(dropIndex > dragIndex){
if(isDropTopArea){
targetIndex = destIndex-1;
}else{
targetIndex = destIndex;
}
}else{
if(isDropTopArea){
targetIndex = destIndex;
}else{
targetIndex = destIndex+1;
}
}
children->move(srcIndex,targetIndex);
}else{
QList<FluTreeNode*>* srcChildren = &(dragItem->_parent->_children);
QList<FluTreeNode*>* destChildren = &(dropItem->_parent->_children);
int srcIndex = srcChildren->indexOf(dragItem);
int destIndex = destChildren->indexOf(dropItem);
dragItem->_depth = dropItem->_depth;
dragItem->_parent = dropItem->_parent;
if(dragItem->hasChildren()){
QList<FluTreeNode*> stack = dragItem->_children;
foreach (auto node, stack) {
node->_depth = dragItem->_depth+1;
}
std::reverse(stack.begin(), stack.end());
while (stack.count() > 0) {
auto item = stack.at(stack.count()-1);
stack.pop_back();
QList<FluTreeNode*> children = item->_children;
if(!children.isEmpty()){
std::reverse(children.begin(), children.end());
foreach (auto c, children) {
c->_depth = item->_depth+1;
stack.append(c);
}
}
}
}
srcChildren->removeAt(srcIndex);
if(dropIndex > dragIndex){
if(isDropTopArea){
targetIndex = destIndex;
}else{
targetIndex = destIndex + 1;
}
}else{
if(isDropTopArea){
targetIndex = destIndex;
}else{
targetIndex = destIndex + 1;
}
}
destChildren->insert(targetIndex,dragItem);
}
changePersistentIndex(index(qMin(dragIndex,dropIndex),0),index(qMax(dragIndex,dropIndex),0));
Q_EMIT dataChanged(index(0,0),index(rowCount()-1,0));
}
bool FluTreeModel::hitHasChildrenExpanded(int row) { bool FluTreeModel::hitHasChildrenExpanded(int row) {
auto itemData = _rows.at(row); auto itemData = _rows.at(row);
if (itemData->hasChildren() && itemData->_isExpanded) { if (itemData->hasChildren() && itemData->_isExpanded) {
@ -315,7 +202,7 @@ bool FluTreeModel::hitHasChildrenExpanded(int row){
void FluTreeModel::refreshNode(int row) { void FluTreeModel::refreshNode(int row) {
Q_EMIT dataChanged(index(row, 0), index(row, 0)); Q_EMIT dataChanged(index(row, 0), index(row, 0));
}; }
FluTreeNode *FluTreeModel::getNode(int row) { FluTreeNode *FluTreeModel::getNode(int row) {
return _rows.at(row); return _rows.at(row);
@ -344,6 +231,7 @@ void FluTreeModel::allExpand(){
_rows = data; _rows = data;
endResetModel(); endResetModel();
} }
void FluTreeModel::allCollapse() { void FluTreeModel::allCollapse() {
beginResetModel(); beginResetModel();
QList<FluTreeNode *> stack = _root->_children; QList<FluTreeNode *> stack = _root->_children;
@ -365,3 +253,13 @@ void FluTreeModel::allCollapse(){
_rows = _root->_children; _rows = _root->_children;
endResetModel(); endResetModel();
} }
QVariant FluTreeModel::selectionModel() {
QList<FluTreeNode *> data;
foreach (auto item, _dataSource) {
if (item->checked()) {
data.append(item);
}
}
return QVariant::fromValue(data);
}

View File

@ -1,9 +1,9 @@
#ifndef FLUTREEMODEL_H #pragma once
#define FLUTREEMODEL_H
#include <QObject> #include <QObject>
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QJsonArray> #include <QJsonArray>
#include <QVariant>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
#include "stdafx.h" #include "stdafx.h"
@ -12,21 +12,24 @@
*/ */
class FluTreeNode : public QObject { class FluTreeNode : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString key READ key CONSTANT) Q_PROPERTY(QVariantMap data READ data CONSTANT)
Q_PROPERTY(QString title READ title CONSTANT)
Q_PROPERTY(int depth READ depth CONSTANT) Q_PROPERTY(int depth READ depth CONSTANT)
Q_PROPERTY(bool isExpanded READ isExpanded CONSTANT) Q_PROPERTY(bool isExpanded READ isExpanded CONSTANT)
Q_PROPERTY(bool checked READ checked CONSTANT) Q_PROPERTY(bool checked READ checked CONSTANT)
public: public:
explicit FluTreeNode(QObject *parent = nullptr); explicit FluTreeNode(QObject *parent = nullptr);
Q_INVOKABLE QString key(){return _key;};
Q_INVOKABLE QString title(){return _title;}; [[nodiscard]] Q_INVOKABLE int depth() const { return _depth; };
Q_INVOKABLE int depth(){return _depth;};
Q_INVOKABLE bool isExpanded(){return _isExpanded;}; [[nodiscard]] Q_INVOKABLE bool isExpanded() const { return _isExpanded; };
Q_INVOKABLE bool hasChildren(){ return !_children.isEmpty();};
[[nodiscard]] Q_INVOKABLE QVariantMap data() const { return _data; };
[[nodiscard]] Q_INVOKABLE bool hasChildren() const { return !_children.isEmpty(); };
Q_INVOKABLE bool hasNextNodeByIndex(int index) { Q_INVOKABLE bool hasNextNodeByIndex(int index) {
FluTreeNode *p = this; FluTreeNode *p = this;
for(int i=0;i<(_depth - index -1);i++){ for (int i = 0; i <= _depth - index - 1; i++) {
p = p->_parent; p = p->_parent;
} }
if (p->_parent->_children.indexOf(p) == p->_parent->_children.count() - 1) { if (p->_parent->_children.indexOf(p) == p->_parent->_children.count() - 1) {
@ -34,18 +37,20 @@ public:
} }
return true; return true;
} }
Q_INVOKABLE bool checked(){
[[nodiscard]] Q_INVOKABLE bool checked() const {
if (!hasChildren()) { if (!hasChildren()) {
return _checked; return _checked;
} }
foreach (auto item, _children) { for (int i = 0; i <= _children.size() - 1; ++i) {
auto item = _children.at(i);
if (!item->checked()) { if (!item->checked()) {
return false; return false;
} }
} }
return true; return true;
}; };
Q_INVOKABLE bool hideLineFooter() { Q_INVOKABLE bool hideLineFooter() {
if (_parent) { if (_parent) {
auto childIndex = _parent->_children.indexOf(this); auto childIndex = _parent->_children.indexOf(this);
@ -59,7 +64,8 @@ public:
} }
return false; return false;
}; };
bool isShown(){
[[nodiscard]] bool isShown() const {
auto p = _parent; auto p = _parent;
while (p) { while (p) {
if (!p->_isExpanded) { if (!p->_isExpanded) {
@ -69,50 +75,70 @@ public:
} }
return true; return true;
} }
public: public:
QString _key="";
QString _title = ""; QString _title = "";
int _depth = 0; int _depth = 0;
bool _checked = false; bool _checked = false;
bool _isExpanded = true; bool _isExpanded = true;
QVariantMap _data;
QList<FluTreeNode *> _children; QList<FluTreeNode *> _children;
FluTreeNode *_parent = nullptr; FluTreeNode *_parent = nullptr;
}; };
class FluTreeModel : public QAbstractItemModel class FluTreeModel : public QAbstractTableModel {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(int, dataSourceSize) Q_PROPERTY_AUTO(int, dataSourceSize)
Q_PROPERTY_AUTO(QList<FluTreeNode*>,selectionModel) Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource)
QML_NAMED_ELEMENT(FluTreeModel) QML_NAMED_ELEMENT(FluTreeModel)
QML_ADDED_IN_MINOR_VERSION(1)
public: public:
enum TreeModelRoles {
RowModel = 0x0101,
ColumnModel = 0x0102
};
explicit FluTreeModel(QObject *parent = nullptr); explicit FluTreeModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override; [[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override; [[nodiscard]] int columnCount(const QModelIndex &parent = {}) const override;
QModelIndex parent(const QModelIndex &child) const override;
QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const override; [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE void removeRows(int row, int count); Q_INVOKABLE void removeRows(int row, int count);
Q_INVOKABLE void insertRows(int row,QList<FluTreeNode*> data);
Q_INVOKABLE void insertRows(int row, const QList<FluTreeNode *> &data);
Q_INVOKABLE QObject *getRow(int row); Q_INVOKABLE QObject *getRow(int row);
Q_INVOKABLE void setRow(int row, QVariantMap data);
Q_INVOKABLE void setData(QList<FluTreeNode *> data); Q_INVOKABLE void setData(QList<FluTreeNode *> data);
Q_INVOKABLE void setDataSource(QList<QMap<QString, QVariant>> data); Q_INVOKABLE void setDataSource(QList<QMap<QString, QVariant>> data);
Q_INVOKABLE void collapse(int row); Q_INVOKABLE void collapse(int row);
Q_INVOKABLE void expand(int row); Q_INVOKABLE void expand(int row);
Q_INVOKABLE void dragAndDrop(int dragIndex,int dropIndex,bool isDropTopArea);
Q_INVOKABLE FluTreeNode *getNode(int row); Q_INVOKABLE FluTreeNode *getNode(int row);
Q_INVOKABLE void refreshNode(int row); Q_INVOKABLE void refreshNode(int row);
Q_INVOKABLE void checkRow(int row, bool checked); Q_INVOKABLE void checkRow(int row, bool checked);
Q_INVOKABLE bool hitHasChildrenExpanded(int row); Q_INVOKABLE bool hitHasChildrenExpanded(int row);
Q_INVOKABLE void allExpand(); Q_INVOKABLE void allExpand();
Q_INVOKABLE void allCollapse(); Q_INVOKABLE void allCollapse();
Q_INVOKABLE QVariant selectionModel();
private: private:
QList<FluTreeNode *> _rows; QList<FluTreeNode *> _rows;
QList<FluTreeNode *> _dataSource; QList<FluTreeNode *> _dataSource;
FluTreeNode *_root = nullptr; FluTreeNode *_root = nullptr;
}; };
#endif // FLUTREEMODEL_H

View File

@ -1,12 +1,14 @@
#include "FluWatermark.h" #include "FluWatermark.h"
#include "FluTextStyle.h"
FluWatermark::FluWatermark(QQuickItem *parent) : QQuickPaintedItem(parent) { FluWatermark::FluWatermark(QQuickItem *parent) : QQuickPaintedItem(parent) {
gap(QPoint(100,100)); _gap = QPoint(100, 100);
offset(QPoint(_gap.x()/2,_gap.y()/2)); _offset = QPoint(_gap.x() / 2, _gap.y() / 2);
rotate(22); _rotate = 22;
_textColor = QColor(222, 222, 222, 222);
_textSize = 16;
setZ(9999); setZ(9999);
textColor(QColor(222,222,222,222));
textSize(16);
connect(this, &FluWatermark::textColorChanged, this, [=] { update(); }); connect(this, &FluWatermark::textColorChanged, this, [=] { update(); });
connect(this, &FluWatermark::gapChanged, this, [=] { update(); }); connect(this, &FluWatermark::gapChanged, this, [=] { update(); });
connect(this, &FluWatermark::offsetChanged, this, [=] { update(); }); connect(this, &FluWatermark::offsetChanged, this, [=] { update(); });
@ -17,20 +19,19 @@ FluWatermark::FluWatermark(QQuickItem* parent) : QQuickPaintedItem(parent){
void FluWatermark::paint(QPainter *painter) { void FluWatermark::paint(QPainter *painter) {
QFont font; QFont font;
font.setFamily(FluTextStyle::getInstance()->family());
font.setPixelSize(_textSize); font.setPixelSize(_textSize);
painter->setFont(font); painter->setFont(font);
painter->setPen(_textColor); painter->setPen(_textColor);
QFontMetricsF fontMetrics(font); QFontMetricsF fontMetrics(font);
qreal fontWidth = fontMetrics.horizontalAdvance(_text); qreal fontWidth = fontMetrics.horizontalAdvance(_text);
qreal fontHeight = fontMetrics.height(); qreal fontHeight = fontMetrics.height();
int stepX = fontWidth + _gap.x(); int stepX = qRound(fontWidth + _gap.x());
int stepY = fontHeight + _gap.y(); int stepY = qRound(fontHeight + _gap.y());
int rowCount = width() / stepX+1; int rowCount = qRound(width() / stepX + 1);
int colCount = height() / stepY+1; int colCount = qRound(height() / stepY + 1);
for (int r = 0; r < rowCount; r++) for (int r = 0; r < rowCount; r++) {
{ for (int c = 0; c < colCount; c++) {
for (int c = 0; c < colCount; c++)
{
qreal centerX = stepX * r + _offset.x() + fontWidth / 2.0; qreal centerX = stepX * r + _offset.x() + fontWidth / 2.0;
qreal centerY = stepY * c + _offset.y() + fontHeight / 2.0; qreal centerY = stepY * c + _offset.y() + fontHeight / 2.0;
painter->save(); painter->save();

View File

@ -1,5 +1,4 @@
#ifndef FLUWATERMARK_H #pragma once
#define FLUWATERMARK_H
#include <QQuickItem> #include <QQuickItem>
#include <QQuickPaintedItem> #include <QQuickPaintedItem>
@ -9,8 +8,7 @@
/** /**
* @brief The FluWatermark class * @brief The FluWatermark class
*/ */
class FluWatermark : public QQuickPaintedItem class FluWatermark : public QQuickPaintedItem {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QString, text) Q_PROPERTY_AUTO(QString, text)
Q_PROPERTY_AUTO(QPoint, gap) Q_PROPERTY_AUTO(QPoint, gap)
@ -21,7 +19,6 @@ class FluWatermark : public QQuickPaintedItem
QML_NAMED_ELEMENT(FluWatermark) QML_NAMED_ELEMENT(FluWatermark)
public: public:
explicit FluWatermark(QQuickItem *parent = nullptr); explicit FluWatermark(QQuickItem *parent = nullptr);
void paint(QPainter *painter) override; void paint(QPainter *painter) override;
}; };
#endif // FLUWATERMARK_H

1417
src/FluentIconDef.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
#include <QGuiApplication> #include <QGuiApplication>
#include "Def.h" #include "Def.h"
#include "FluentIconDef.h"
#include "FluApp.h" #include "FluApp.h"
#include "FluColors.h" #include "FluColors.h"
#include "FluTheme.h" #include "FluTheme.h"
@ -14,22 +15,25 @@
#include "FluQrCodeItem.h" #include "FluQrCodeItem.h"
#include "FluTableSortProxyModel.h" #include "FluTableSortProxyModel.h"
#include "FluFrameless.h" #include "FluFrameless.h"
#include "FluTableModel.h"
void FluentUI::registerTypes(QQmlEngine *engine) { void FluentUI::registerTypes(QQmlEngine *engine) {
initializeEngine(engine,uri); initializeEngine(engine, _uri);
registerTypes(uri); registerTypes(_uri);
} }
void FluentUI::registerTypes(const char *uri){ void FluentUI::registerTypes(const char *uri) const {
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) #if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
Q_INIT_RESOURCE(fluentui); Q_INIT_RESOURCE(fluentui);
int major = _major;
int minor = _minor;
//@uri FluentUI //@uri FluentUI
qmlRegisterType<FluQrCodeItem>(uri, major, minor, "FluQrCodeItem"); qmlRegisterType<FluQrCodeItem>(uri, major, minor, "FluQrCodeItem");
qmlRegisterType<FluCaptcha>(uri, major, minor, "FluCaptcha"); qmlRegisterType<FluCaptcha>(uri, major, minor, "FluCaptcha");
qmlRegisterType<FluWatermark>(uri, major, minor, "FluWatermark"); qmlRegisterType<FluWatermark>(uri, major, minor, "FluWatermark");
qmlRegisterType<FluAccentColor>(uri, major, minor, "FluAccentColor"); qmlRegisterType<FluAccentColor>(uri, major, minor, "FluAccentColor");
qmlRegisterType<FluTreeModel>(uri, major, minor, "FluTreeModel"); qmlRegisterType<FluTreeModel>(uri, major, minor, "FluTreeModel");
qmlRegisterType<FluTableModel>(uri, major, minor, "FluTableModel");
qmlRegisterType<FluRectangle>(uri, major, minor, "FluRectangle"); qmlRegisterType<FluRectangle>(uri, major, minor, "FluRectangle");
qmlRegisterType<FluFrameless>(uri, major, minor, "FluFrameless"); qmlRegisterType<FluFrameless>(uri, major, minor, "FluFrameless");
qmlRegisterType<FluTableSortProxyModel>(uri, major, minor, "FluTableSortProxyModel"); qmlRegisterType<FluTableSortProxyModel>(uri, major, minor, "FluTableSortProxyModel");
@ -130,7 +134,7 @@ void FluentUI::registerTypes(const char *uri){
qmlRegisterSingletonType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRouter.qml"), uri, major, minor, "FluRouter"); qmlRegisterSingletonType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRouter.qml"), uri, major, minor, "FluRouter");
qmlRegisterSingletonType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluEventBus.qml"), uri, major, minor, "FluEventBus"); qmlRegisterSingletonType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluEventBus.qml"), uri, major, minor, "FluEventBus");
qmlRegisterUncreatableMetaObject(Fluent_Awesome::staticMetaObject, uri,major,minor,"FluentIcons", "Access to enums & flags only"); qmlRegisterUncreatableMetaObject(Fluent_Icons::staticMetaObject, uri, major, minor, "FluentIcons", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluThemeType::staticMetaObject, uri, major, minor, "FluThemeType", "Access to enums & flags only"); qmlRegisterUncreatableMetaObject(FluThemeType::staticMetaObject, uri, major, minor, "FluThemeType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluPageType::staticMetaObject, uri, major, minor, "FluPageType", "Access to enums & flags only"); qmlRegisterUncreatableMetaObject(FluPageType::staticMetaObject, uri, major, minor, "FluPageType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluWindowType::staticMetaObject, uri, major, minor, "FluWindowType", "Access to enums & flags only"); qmlRegisterUncreatableMetaObject(FluWindowType::staticMetaObject, uri, major, minor, "FluWindowType", "Access to enums & flags only");
@ -144,11 +148,17 @@ void FluentUI::registerTypes(const char *uri){
qmlRegisterUncreatableMetaObject(FluTimelineType::staticMetaObject, uri, major, minor, "FluTimelineType", "Access to enums & flags only"); qmlRegisterUncreatableMetaObject(FluTimelineType::staticMetaObject, uri, major, minor, "FluTimelineType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluSheetType::staticMetaObject, uri, major, minor, "FluSheetType", "Access to enums & flags only"); qmlRegisterUncreatableMetaObject(FluSheetType::staticMetaObject, uri, major, minor, "FluSheetType", "Access to enums & flags only");
// qmlRegisterSingletonInstance(uri, major, minor, "FluApp", FluApp::getInstance());
// qmlRegisterSingletonInstance(uri, major, minor, "FluColors", FluColors::getInstance());
// qmlRegisterSingletonInstance(uri, major, minor, "FluTheme", FluTheme::getInstance());
// qmlRegisterSingletonInstance(uri, major, minor, "FluTools", FluTools::getInstance());
// qmlRegisterSingletonInstance(uri, major, minor, "FluTextStyle", FluTextStyle::getInstance());
qmlRegisterModule(uri, major, minor); qmlRegisterModule(uri, major, minor);
#endif #endif
} }
void FluentUI::initializeEngine(QQmlEngine *engine, const char *uri){ void FluentUI::initializeEngine(QQmlEngine *engine, [[maybe_unused]] const char *uri) {
engine->rootContext()->setContextProperty("FluApp", FluApp::getInstance()); engine->rootContext()->setContextProperty("FluApp", FluApp::getInstance());
engine->rootContext()->setContextProperty("FluColors", FluColors::getInstance()); engine->rootContext()->setContextProperty("FluColors", FluColors::getInstance());
engine->rootContext()->setContextProperty("FluTheme", FluTheme::getInstance()); engine->rootContext()->setContextProperty("FluTheme", FluTheme::getInstance());

View File

@ -1,5 +1,4 @@
#ifndef FLUENTUI_H #pragma once
#define FLUENTUI_H
#include <QObject> #include <QObject>
#include <QQmlEngine> #include <QQmlEngine>
@ -8,18 +7,20 @@
/** /**
* @brief The FluentUI class * @brief The FluentUI class
*/ */
class FluentUI : public QObject class FluentUI : public QObject {
{
Q_OBJECT Q_OBJECT
public: public:
SINGLETON(FluentUI) SINGLETON(FluentUI)
Q_DECL_EXPORT void registerTypes(QQmlEngine *engine);
void registerTypes(const char *uri);
void initializeEngine(QQmlEngine *engine, const char *uri);
private:
const int major = 1;
const int minor = 0;
const char *uri = "FluentUI";
};
#endif // FLUENTUI_H Q_DECL_EXPORT void registerTypes(QQmlEngine *engine);
void registerTypes(const char *uri) const;
void initializeEngine(QQmlEngine *engine, [[maybe_unused]] const char *uri);
private:
const int _major = 1;
const int _minor = 0;
const char *_uri = "FluentUI";
};

View File

@ -10,8 +10,7 @@ Item {
property real noiseOpacity: 0.02 property real noiseOpacity: 0.02
property alias target : effect_source.sourceItem property alias target : effect_source.sourceItem
property int blurRadius: 32 property int blurRadius: 32
property rect targetRect: Qt.rect(control.x, control.y, control.width, property rect targetRect: Qt.rect(control.x, control.y, control.width,control.height)
control.height)
ShaderEffectSource { ShaderEffectSource {
id: effect_source id: effect_source
anchors.fill: parent anchors.fill: parent
@ -34,7 +33,7 @@ Item {
} }
Image { Image {
anchors.fill: parent anchors.fill: parent
source: "../Image/noise.png" source: "qrc:/qt/qml/FluentUI/Image/noise.png"
fillMode: Image.Tile fillMode: Image.Tile
opacity: control.noiseOpacity opacity: control.noiseOpacity
} }

View File

@ -14,7 +14,7 @@ Rectangle{
property string closeText : qsTr("Close") property string closeText : qsTr("Close")
property string stayTopText : qsTr("Sticky on Top") property string stayTopText : qsTr("Sticky on Top")
property string stayTopCancelText : qsTr("Sticky on Top cancelled") property string stayTopCancelText : qsTr("Sticky on Top cancelled")
property color textColor: FluTheme.dark ? "#FFFFFF" : "#000000" property color textColor: FluTheme.fontPrimaryColor
property color minimizeNormalColor: FluTheme.itemNormalColor property color minimizeNormalColor: FluTheme.itemNormalColor
property color minimizeHoverColor: FluTheme.itemHoverColor property color minimizeHoverColor: FluTheme.itemHoverColor
property color minimizePressColor: FluTheme.itemPressColor property color minimizePressColor: FluTheme.itemPressColor

View File

@ -7,6 +7,7 @@ FluTextBox{
property var items:[] property var items:[]
property string emptyText: qsTr("No results found") property string emptyText: qsTr("No results found")
property int autoSuggestBoxReplacement: FluentIcons.Search property int autoSuggestBoxReplacement: FluentIcons.Search
property string textRole: "title"
property var filter: function(item){ property var filter: function(item){
if(item.title.indexOf(control.text)!==-1){ if(item.title.indexOf(control.text)!==-1){
return true return true
@ -25,7 +26,7 @@ FluTextBox{
function handleClick(modelData){ function handleClick(modelData){
control_popup.visible = false control_popup.visible = false
control.itemClicked(modelData) control.itemClicked(modelData)
control.updateText(modelData.title) control.updateText(modelData[textRole])
} }
function loadData(){ function loadData(){
var result = [] var result = []
@ -48,7 +49,6 @@ FluTextBox{
} }
Popup{ Popup{
id:control_popup id:control_popup
y:control.height
focus: false focus: false
padding: 0 padding: 0
enter: Transition { enter: Transition {
@ -59,12 +59,8 @@ FluTextBox{
duration: FluTheme.animationEnabled ? 83 : 0 duration: FluTheme.animationEnabled ? 83 : 0
} }
} }
contentItem: FluRectangle{ contentItem: FluClip{
radius: [4,4,4,4] radius: [5,5,5,5]
FluShadow{
radius: 4
}
color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
ListView{ ListView{
id: list_view id: list_view
anchors.fill: parent anchors.fill: parent
@ -97,14 +93,17 @@ FluTextBox{
radius:4 radius:4
} }
color: { color: {
if(hovered){ if(pressed){
return FluTheme.dark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1) return FluTheme.itemPressColor
} }
return FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(0,0,0,0) if(hovered){
return FluTheme.itemHoverColor
}
return FluTheme.itemNormalColor
} }
} }
contentItem: FluText{ contentItem: FluText{
text:modelData.title text: modelData[textRole]
leftPadding: 10 leftPadding: 10
rightPadding: 10 rightPadding: 10
verticalAlignment : Qt.AlignVCenter verticalAlignment : Qt.AlignVCenter
@ -112,22 +111,28 @@ FluTextBox{
} }
} }
} }
background: Item{ background:Rectangle{
id:container id: rect_background
implicitWidth: control.width implicitWidth: control.width
implicitHeight: 38*Math.min(Math.max(list_view.count,1),8) implicitHeight: 38*Math.min(Math.max(list_view.count,1),8)
radius: 5
color: FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(1,1,1,1)
border.color: FluTheme.dark ? Qt.rgba(26/255,26/255,26/255,1) : Qt.rgba(191/255,191/255,191/255,1)
FluShadow{
radius: 5
}
} }
} }
onTextChanged: { onTextChanged: {
d.loadData() d.loadData()
if(d.flagVisible){ if(d.flagVisible){
var pos = control.mapToItem(null, 0, 0) var pos = control.mapToItem(null, 0, 0)
if(d.window.height>pos.y+control.height+container.implicitHeight){ if(d.window.height>pos.y+control.height+rect_background.implicitHeight){
control_popup.y = control.height control_popup.y = Qt.binding(function(){return control.height})
} else if(pos.y>container.implicitHeight){ } else if(pos.y>rect_background.implicitHeight){
control_popup.y = -container.implicitHeight control_popup.y = -rect_background.implicitHeight
} else { } else {
control_popup.y = d.window.height-(pos.y+container.implicitHeight) control_popup.y = d.window.height-(pos.y+rect_background.implicitHeight) - 1
} }
control_popup.visible = true control_popup.visible = true
} }

View File

@ -57,12 +57,12 @@ Item {
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
color: { color: {
if(item_mouse.pressed){ if(item_mouse.pressed){
return FluTheme.dark ? Qt.rgba(150/255,150/255,150/235,1) : Qt.rgba(134/255,134/255,134/235,1) return FluTheme.dark ? Qt.rgba(150/255,150/255,150/255,1) : Qt.rgba(134/255,134/255,134/255,1)
} }
if(item_mouse.containsMouse){ if(item_mouse.containsMouse){
return FluTheme.dark ? Qt.rgba(204/255,204/255,204/235,1) : Qt.rgba(92/255,92/255,92/235,1) return FluTheme.dark ? Qt.rgba(204/255,204/255,204/255,1) : Qt.rgba(92/255,92/255,92/255,1)
} }
return FluTheme.dark ? Qt.rgba(255/255,255/255,255/235,1) : Qt.rgba(26/255,26/255,26/235,1) return FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(26/255,26/255,26/255,1)
} }
MouseArea{ MouseArea{
id:item_mouse id:item_mouse

View File

@ -53,8 +53,6 @@ FluButton {
} }
Menu{ Menu{
id:popup id:popup
height: container.height
width: container.width
modal: true modal: true
Overlay.modal: Item {} Overlay.modal: Item {}
enter: Transition { enter: Transition {
@ -75,11 +73,9 @@ FluButton {
} }
} }
contentItem: Item{ contentItem: Item{
clip: true
FluFrame{
id:container id:container
width: 300 implicitWidth: 300
height: 360 implicitHeight: 360
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: 0 spacing: 0
@ -609,8 +605,10 @@ FluButton {
} }
} }
} }
} background:Rectangle{
background: Item{ radius: 5
color: FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(1,1,1,1)
border.color: FluTheme.dark ? Qt.rgba(26/255,26/255,26/255,1) : Qt.rgba(191/255,191/255,191/255,1)
FluShadow{ FluShadow{
radius: 5 radius: 5
} }
@ -618,13 +616,12 @@ FluButton {
function showPopup() { function showPopup() {
var pos = control.mapToItem(null, 0, 0) var pos = control.mapToItem(null, 0, 0)
if(d.window.height>pos.y+control.height+container.height){ if(d.window.height>pos.y+control.height+container.height){
popup.y = control.height popup.y = control.height - 1
} else if(pos.y>container.height){ } else if(pos.y>container.height){
popup.y = -container.height popup.y = -container.height
} else { } else {
popup.y = d.window.height-(pos.y+container.height) popup.y = d.window.height-(pos.y+container.height)
} }
popup.x = -(popup.width-control.width)/2
popup.open() popup.open()
} }
} }

View File

@ -13,16 +13,15 @@ Button{
property color current : Qt.rgba(1,1,1,1) property color current : Qt.rgba(1,1,1,1)
signal accepted() signal accepted()
property int colorHandleRadius: 8 property int colorHandleRadius: 8
property string cancelText: "取消" property string cancelText: qsTr("Cancel")
property string okText: "确定" property string okText: qsTr("OK")
property string titleText: "颜色选择器" property string titleText: qsTr("Color Picker")
property string editText: "编辑颜色" property string editText: qsTr("Edit Color")
property string redText: "红色" property string redText: qsTr("Red")
property string greenText: "绿色" property string greenText: qsTr("Green")
property string blueText: "蓝色" property string blueText: qsTr("Blue")
property string opacityText: "透明度" property string opacityText: qsTr("Opacity")
background: background: Rectangle{
Rectangle{
id:layout_color id:layout_color
radius: 5 radius: 5
color:"#00000000" color:"#00000000"

View File

@ -11,6 +11,7 @@ T.ComboBox {
property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1) property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1)
property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1) property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1) property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
property alias textBox: text_field
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding) implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
@ -39,6 +40,7 @@ T.ComboBox {
opacity: enabled ? 1 : 0.3 opacity: enabled ? 1 : 0.3
} }
contentItem: T.TextField { contentItem: T.TextField {
id: text_field
property bool disabled: !control.editable property bool disabled: !control.editable
leftPadding: !control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1 leftPadding: !control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1
rightPadding: control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1 rightPadding: control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1
@ -134,10 +136,9 @@ T.ComboBox {
} }
} }
background:Rectangle{ background:Rectangle{
color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(249/255,249/255,249/255,1)
border.color: FluTheme.dark ? Window.active ? Qt.rgba(55/255,55/255,55/255,1):Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1)
border.width: 1
radius: 5 radius: 5
color: FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(1,1,1,1)
border.color: FluTheme.dark ? Qt.rgba(26/255,26/255,26/255,1) : Qt.rgba(191/255,191/255,191/255,1)
FluShadow{ FluShadow{
radius: 5 radius: 5
} }

View File

@ -4,7 +4,6 @@ import QtQuick.Layouts 1.15
import QtQuick.Window 2.15 import QtQuick.Window 2.15
import FluentUI 1.0 import FluentUI 1.0
FluButton { FluButton {
property bool showYear: true property bool showYear: true
property var current property var current
@ -96,8 +95,6 @@ FluButton {
Menu{ Menu{
id:popup id:popup
modal: true modal: true
width: container.width
height: container.height
Overlay.modal: Item {} Overlay.modal: Item {}
enter: Transition { enter: Transition {
reversible: true reversible: true
@ -116,30 +113,26 @@ FluButton {
duration: FluTheme.animationEnabled ? 83 : 0 duration: FluTheme.animationEnabled ? 83 : 0
} }
} }
background:Item{ background:Rectangle{
radius: 5
color: FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(1,1,1,1)
border.color: FluTheme.dark ? Qt.rgba(26/255,26/255,26/255,1) : Qt.rgba(191/255,191/255,191/255,1)
FluShadow{ FluShadow{
radius: 4 radius: 5
} }
} }
contentItem: Item{ contentItem: Item{
clip: true
Rectangle{
id:container id:container
radius: 4 implicitHeight: 340
width: 300 implicitWidth: 300
height: 340
color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
MouseArea{ MouseArea{
anchors.fill: parent anchors.fill: parent
} }
FluShadow{
radius: 4
}
RowLayout{ RowLayout{
id:layout_content id:layout_content
spacing: 0 spacing: 0
width: parent.width width: parent.width
height: 300 height: 280
Component{ Component{
id:list_delegate id:list_delegate
Item{ Item{
@ -166,7 +159,7 @@ FluButton {
if(item_mouse.containsMouse){ if(item_mouse.containsMouse){
return FluTheme.dark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1) return FluTheme.dark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1)
} }
return FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(0,0,0,0) return Qt.rgba(0,0,0,0)
} }
radius: 3 radius: 3
MouseArea{ MouseArea{
@ -214,8 +207,9 @@ FluButton {
} }
ListView{ ListView{
id:list_view_1 id:list_view_1
width: 100 Layout.preferredWidth: 100
height: parent.height Layout.preferredHeight: parent.height - 2
Layout.alignment: Qt.AlignVCenter
boundsBehavior:Flickable.StopAtBounds boundsBehavior:Flickable.StopAtBounds
ScrollBar.vertical: FluScrollBar {} ScrollBar.vertical: FluScrollBar {}
model: generateYearArray(1924,2048) model: generateYearArray(1924,2048)
@ -232,14 +226,16 @@ FluButton {
} }
} }
Rectangle{ Rectangle{
width: 1 Layout.preferredWidth: 1
height: parent.height Layout.preferredHeight: parent.height
color: control.dividerColor color: control.dividerColor
visible: showYear
} }
ListView{ ListView{
id:list_view_2 id:list_view_2
width: showYear ? 100 : 150 Layout.preferredWidth: showYear ? 99 : 150
height: parent.height Layout.preferredHeight: parent.height - 2
Layout.alignment: Qt.AlignVCenter
clip: true clip: true
ScrollBar.vertical: FluScrollBar {} ScrollBar.vertical: FluScrollBar {}
preferredHighlightBegin: 0 preferredHighlightBegin: 0
@ -254,20 +250,20 @@ FluButton {
} }
} }
Rectangle{ Rectangle{
width: 1 Layout.preferredWidth: 1
height: parent.height Layout.preferredHeight: parent.height
color: control.dividerColor color: control.dividerColor
} }
ListView{ ListView{
id:list_view_3 id:list_view_3
width: showYear ? 100 : 150 Layout.preferredWidth: showYear ? 99 : 150
height: parent.height Layout.preferredHeight: parent.height - 2
Layout.alignment: Qt.AlignVCenter
clip: true clip: true
preferredHighlightBegin: 0 preferredHighlightBegin: 0
preferredHighlightEnd: 0 preferredHighlightEnd: 0
highlightMoveDuration: 0 highlightMoveDuration: 0
ScrollBar.vertical: FluScrollBar {} ScrollBar.vertical: FluScrollBar {}
Layout.alignment: Qt.AlignVCenter
boundsBehavior:Flickable.StopAtBounds boundsBehavior:Flickable.StopAtBounds
delegate: FluLoader{ delegate: FluLoader{
property var model: modelData property var model: modelData
@ -277,17 +273,12 @@ FluButton {
} }
} }
} }
Rectangle{
width: parent.width
height: 1
anchors.top: layout_content.bottom
color: control.dividerColor
}
Rectangle{ Rectangle{
id:layout_actions id:layout_actions
height: 40 height: 60
radius: 5
color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1) color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
border.color: FluTheme.dark ? Qt.rgba(26/255,26/255,26/255,1) : Qt.rgba(191/255,191/255,191/255,1)
radius: 5
anchors{ anchors{
bottom:parent.bottom bottom:parent.bottom
left: parent.left left: parent.left
@ -340,7 +331,6 @@ FluButton {
} }
} }
} }
}
y:35 y:35
function showPopup() { function showPopup() {
d.changeFlag = true d.changeFlag = true
@ -361,7 +351,7 @@ FluButton {
text_day.text = day text_day.text = day
var pos = control.mapToItem(null, 0, 0) var pos = control.mapToItem(null, 0, 0)
if(d.window.height>pos.y+control.height+container.height){ if(d.window.height>pos.y+control.height+container.height){
popup.y = control.height popup.y = control.height-1
} else if(pos.y>container.height){ } else if(pos.y>container.height){
popup.y = -container.height popup.y = -container.height
} else { } else {

View File

@ -19,16 +19,20 @@ FluButton {
} }
iconColor:control.textColor iconColor:control.textColor
} }
Item{
id: d
property var window: Window.window
}
onClicked: { onClicked: {
if(menu.count !==0){ if(menu.count !==0){
var pos = control.mapToItem(null, 0, 0) var pos = control.mapToItem(null, 0, 0)
var containerHeight = menu.count*36 var containerHeight = menu.count*36
if(window.height>pos.y+control.height+containerHeight){ if(d.window.height>pos.y+control.height+containerHeight){
menu.y = control.height menu.y = control.height
}else if(pos.y>containerHeight){ }else if(pos.y>containerHeight){
menu.y = -containerHeight menu.y = -containerHeight
}else{ }else{
menu.y = window.height-(pos.y+containerHeight) menu.y = d.window.height-(pos.y+containerHeight)
} }
menu.open() menu.open()
} }

View File

@ -27,7 +27,12 @@ Item {
height: 45 height: 45
radius: 4 radius: 4
border.color: FluTheme.dividerColor border.color: FluTheme.dividerColor
color: FluTheme.dark ? Window.active ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1) color: {
if(Window.active){
return FluTheme.frameActiveColor
}
return FluTheme.frameColor
}
MouseArea{ MouseArea{
id:control_mouse id:control_mouse
anchors.fill: parent anchors.fill: parent
@ -84,12 +89,18 @@ Item {
height: contentHeight+container.anchors.topMargin height: contentHeight+container.anchors.topMargin
width: parent.width width: parent.width
z:-999 z:-999
clip: true
Rectangle{ Rectangle{
id:container id:container
anchors.fill: parent anchors.fill: parent
radius: 4 radius: 4
clip: true clip: true
color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1) color: {
if(Window.active){
return FluTheme.frameActiveColor
}
return FluTheme.frameColor
}
border.color: FluTheme.dividerColor border.color: FluTheme.dividerColor
anchors.topMargin: -contentHeight anchors.topMargin: -contentHeight
states: [ states: [

View File

@ -19,6 +19,11 @@ T.Frame {
id:d id:d
radius: 4 radius: 4
border.color: FluTheme.dividerColor border.color: FluTheme.dividerColor
color: FluTheme.dark ? Window.active ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(251/255,251/255,253/255,1) color: {
if(Window.active){
return FluTheme.frameActiveColor
}
return FluTheme.frameColor
}
} }
} }

View File

@ -8,8 +8,13 @@ import FluentUI 1.0
T.GroupBox { T.GroupBox {
id: control id: control
property int borderWidth : 1 property int borderWidth : 1
property color borderColor : FluTheme.dark ? Window.active ? Qt.rgba(55/255,55/255,55/255,1):Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1) property color borderColor : FluTheme.dividerColor
property color color: FluTheme.dark ? Window.active ? Qt.rgba(38/255,44/255,54/255,1) : Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1) property color color: {
if(Window.active){
return FluTheme.frameActiveColor
}
return FluTheme.frameColor
}
property int radius: 4 property int radius: 4
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
contentWidth + leftPadding + rightPadding, contentWidth + leftPadding + rightPadding,

View File

@ -7,13 +7,15 @@ Text {
property int iconSize: 20 property int iconSize: 20
property color iconColor: FluTheme.dark ? "#FFFFFF" : "#000000" property color iconColor: FluTheme.dark ? "#FFFFFF" : "#000000"
id:control id:control
font.family: "Segoe Fluent Icons" font.family: font_loader.name
font.pixelSize: iconSize font.pixelSize: iconSize
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: iconColor color: iconColor
text: (String.fromCharCode(iconSource).toString(16)) text: (String.fromCharCode(iconSource).toString(16))
opacity: iconSource>0
FontLoader{ FontLoader{
source: "../Font/Segoe_Fluent_Icons.ttf" id: font_loader
source: "qrc:/qt/qml/FluentUI/Font/FluentIcons.ttf"
} }
} }

View File

@ -18,12 +18,13 @@ FluObject {
if(screenLayout){ if(screenLayout){
var last = screenLayout.getLastloader(); var last = screenLayout.getLastloader();
if(last.type === type && last.text === text && moremsg === last.moremsg){ if(last.type === type && last.text === text && moremsg === last.moremsg){
last.restart(); last.duration = duration
return; if (duration > 0) last.restart();
return last;
} }
} }
initScreenLayout(); initScreenLayout();
contentComponent.createObject(screenLayout,{ return contentComponent.createObject(screenLayout,{
type:type, type:type,
text:text, text:text,
duration:duration, duration:duration,
@ -33,7 +34,7 @@ FluObject {
function createCustom(itemcomponent,duration){ function createCustom(itemcomponent,duration){
initScreenLayout(); initScreenLayout();
if(itemcomponent){ if(itemcomponent){
contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration}); return contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
} }
} }
function initScreenLayout(){ function initScreenLayout(){
@ -85,7 +86,9 @@ FluObject {
} }
Timer { Timer {
id:delayTimer id:delayTimer
interval: duration; running: duration > 0; repeat: duration > 0 interval: duration;
running: duration > 0;
repeat: duration > 0
onTriggered: content.close(); onTriggered: content.close();
} }
FluLoader{ FluLoader{
@ -235,18 +238,26 @@ FluObject {
} }
} }
function showSuccess(text,duration=1000,moremsg){ function showSuccess(text,duration=1000,moremsg){
mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : ""); return mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "");
} }
function showInfo(text,duration=1000,moremsg){ function showInfo(text,duration=1000,moremsg){
mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : ""); return mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "");
} }
function showWarning(text,duration=1000,moremsg){ function showWarning(text,duration=1000,moremsg){
mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : ""); return mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "");
} }
function showError(text,duration=1000,moremsg){ function showError(text,duration=1000,moremsg){
mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : ""); return mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
} }
function showCustom(itemcomponent,duration=1000){ function showCustom(itemcomponent,duration=1000){
mcontrol.createCustom(itemcomponent,duration); return mcontrol.createCustom(itemcomponent,duration);
}
function clearAllInfo(){
if(mcontrol.screenLayout != null) {
mcontrol.screenLayout.destroy()
mcontrol.screenLayout = null
}
return true
} }
} }

View File

@ -44,8 +44,8 @@ T.Menu {
background: Rectangle { background: Rectangle {
implicitWidth: 150 implicitWidth: 150
implicitHeight: 36 implicitHeight: 36
color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(240/255,240/255,240/255,1) color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(252/255,252/255,252/255,1)
border.color: FluTheme.dark ? Window.active ? Qt.rgba(55/255,55/255,55/255,1):Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1) border.color: FluTheme.dark ? Qt.rgba(26/255,26/255,26/255,1) : Qt.rgba(191/255,191/255,191/255,1)
border.width: 1 border.width: 1
radius: 5 radius: 5
FluShadow{} FluShadow{}

View File

@ -48,9 +48,6 @@ T.MenuBarItem {
radius: 3 radius: 3
color: { color: {
if(control.highlighted){ if(control.highlighted){
return FluTheme.itemCheckColor
}
if(control.hovered){
return FluTheme.itemHoverColor return FluTheme.itemHoverColor
} }
return FluTheme.itemNormalColor return FluTheme.itemNormalColor

View File

@ -101,7 +101,7 @@ T.MenuItem {
radius: 4 radius: 4
color: { color: {
if(control.highlighted){ if(control.highlighted){
return FluTheme.itemCheckColor return FluTheme.itemHoverColor
} }
return FluTheme.itemNormalColor return FluTheme.itemNormalColor
} }

View File

@ -3,8 +3,10 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import FluentUI 1.0 import FluentUI 1.0
Item { Item {
signal requestPage(int page, int count) signal requestPage(int page, int count)
property string previousText: qsTr("<Previous") property string previousText: qsTr("<Previous")
property string nextText: qsTr("Next>") property string nextText: qsTr("Next>")
property int pageCurrent: 0 property int pageCurrent: 0
@ -13,6 +15,8 @@ Item {
property int pageCount: itemCount > 0 ? Math.ceil(itemCount / __itemPerPage) : 0 property int pageCount: itemCount > 0 ? Math.ceil(itemCount / __itemPerPage) : 0
property int __itemPerPage: 10 property int __itemPerPage: 10
property int __pageButtonHalf: Math.floor(pageButtonCount / 2) + 1 property int __pageButtonHalf: Math.floor(pageButtonCount / 2) + 1
property Component header: null
property Component footer: null
id: control id: control
implicitHeight: 40 implicitHeight: 40
implicitWidth: content.width implicitWidth: content.width
@ -21,6 +25,9 @@ Item {
height: control.height height: control.height
spacing: 10 spacing: 10
padding: 10 padding: 10
Loader {
sourceComponent: header
}
FluToggleButton { FluToggleButton {
visible: control.pageCount > 1 visible: control.pageCount > 1
disabled: control.pageCurrent <= 1 disabled: control.pageCurrent <= 1
@ -86,9 +93,11 @@ Item {
control.calcNewPage(control.pageCurrent + 1); control.calcNewPage(control.pageCurrent + 1);
} }
} }
Loader {
sourceComponent: footer
} }
function calcNewPage(page) }
{ function calcNewPage(page) {
if (!page) if (!page)
return return
let page_num = Number(page) let page_num = Number(page)

Some files were not shown because too many files have changed in this diff Show More