Compare commits

..

20 Commits
1.5.6 ... 1.5.8

Author SHA1 Message Date
af74f35e43 update 2023-09-13 21:24:02 +08:00
3b61985cfe update 2023-09-13 18:12:58 +08:00
eb96cf5b47 update 2023-09-13 17:27:09 +08:00
d48ad16ae3 update 2023-09-13 16:08:54 +08:00
39fb4d1b1a update 2023-09-13 15:43:31 +08:00
674de3f881 update 2023-09-13 15:26:21 +08:00
0c2b3173eb update 2023-09-13 15:21:07 +08:00
b2471bcf0d update 2023-09-13 15:11:22 +08:00
79a7c97fe8 update 2023-09-12 22:55:42 +08:00
fd30819393 update 2023-09-12 18:45:15 +08:00
05040ec4a9 update 2023-09-11 18:10:50 +08:00
0297445218 update 2023-09-10 17:05:36 +08:00
3990c95489 update 2023-09-10 16:58:23 +08:00
618b21854f Compatible with static build 2023-09-09 20:09:20 +08:00
ef40e3b109 update 2023-09-09 10:19:47 +08:00
f2b67af58a update 2023-09-08 23:01:31 +08:00
c0f15060af update 2023-09-08 22:43:52 +08:00
24f3cb1027 update 2023-09-08 22:33:23 +08:00
4b01fcf2b4 update 2023-09-08 19:14:45 +08:00
752fe8cfba update 2023-09-08 17:39:10 +08:00
134 changed files with 3668 additions and 1259 deletions

View File

@ -1,5 +1,6 @@
include(CMakeParseArguments) include(CMakeParseArguments)
find_package(Qt5 REQUIRED COMPONENTS Core) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
function(FindQmlPluginDump) function(FindQmlPluginDump)
get_target_property (QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION) get_target_property (QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
@ -35,7 +36,6 @@ function(add_qmlplugin TARGET)
${QMLPLUGIN_SOURCES} ${QMLPLUGIN_SOURCES}
) )
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib) set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib)
add_custom_target("${TARGET}-qmlfiles" SOURCES ${QMLPLUGIN_QMLFILES})
if(QMLPLUGIN_NO_AUTORCC) if(QMLPLUGIN_NO_AUTORCC)
set_target_properties(${TARGET} PROPERTIES AUTOMOC OFF) set_target_properties(${TARGET} PROPERTIES AUTOMOC OFF)

View File

@ -1,5 +1,3 @@
// 应用程序版本信息
// 请勿修改此头文件,因为这个文件是自动生成的
#ifndef VERSION_H #ifndef VERSION_H
#define VERSION_H #define VERSION_H

85
.github/workflows/windows-qt5.yml vendored Normal file
View File

@ -0,0 +1,85 @@
name: Windows Qt5.15.2
on:
push:
paths:
- '*.txt'
- 'src/**'
- 'example/**'
- 'scripts/**'
- '.github/workflows/windows_qt5.yml'
pull_request:
paths:
- '*.txt'
- 'example/**'
- 'src/**'
- 'scripts/**'
- '.github/workflows/windows_qt5.yml'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2019]
include:
- qt_ver: 5.15.2
qt_arch: win32_msvc2019
msvc_arch: x86
qt_arch_install: msvc2019
env:
targetName: example.exe
fileName: example
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt_ver }}
arch: ${{ matrix.qt_arch }}
cache: ${{steps.cache-qt.outputs.cache-hit}}
- name: msvc-build
id: build
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }}
mkdir build
cd build
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_PREFIX_PATH=D:\a\FluentUI\Qt\5.15.2\msvc2019 -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -GNinja ..
cmake --build . --target all --config Release --parallel
echo winSdkDir=%WindowsSdkDir% >> %GITHUB_ENV%
echo winSdkVer=%WindowsSdkVersion% >> %GITHUB_ENV%
echo vcToolsInstallDir=%VCToolsInstallDir% >> %GITHUB_ENV%
echo vcToolsRedistDir=%VCToolsRedistDir% >> %GITHUB_ENV%
- name: package
id: package
env:
archiveName: ${{ env.fileName }}-${{ matrix.qt_arch }}-${{ matrix.qt_ver }}
msvcArch: ${{ matrix.msvc_arch }}
shell: pwsh
run: |
& scripts\windows-publish.ps1 ${env:archiveName} ${env:targetName}
# 记录packageName给后续step
$name = ${env:archiveName}
echo "::set-output name=packageName::$name"
- uses: actions/upload-artifact@v2
with:
name: ${{ steps.package.outputs.packageName }}
path: ${{ steps.package.outputs.packageName }}
- name: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.package.outputs.packageName }}.zip
asset_name: ${{ env.fileName }}_${{ github.ref_name }}_${{ matrix.qt_arch }}_Qt${{ matrix.qt_ver }}.zip
tag: ${{ github.ref }}
overwrite: true

BIN
3rdparty/Win_x86/mingw/libcrypto-1_1.dll vendored Normal file

Binary file not shown.

BIN
3rdparty/Win_x86/mingw/libssl-1_1.dll vendored Normal file

Binary file not shown.

BIN
3rdparty/Win_x86/msvc/libcrypto-1_1.dll vendored Normal file

Binary file not shown.

BIN
3rdparty/Win_x86/msvc/libssl-1_1.dll vendored Normal file

Binary file not shown.

View File

@ -288,3 +288,28 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
************************************************************************************
qml-colorpicker
MIT License
Copyright (c) 2022 Ruslan Shestopalyuk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -53,7 +53,7 @@ endforeach(filepath)
if(QT_VERSION VERSION_GREATER_EQUAL "6.2") if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
#遍历所有qml文件 #遍历所有qml文件
file(GLOB_RECURSE QML_PATHS *.qml qmldir) file(GLOB_RECURSE QML_PATHS *.qml)
foreach(filepath ${QML_PATHS}) foreach(filepath ${QML_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
if(${filepath} MATCHES "Qt${QT_VERSION_MAJOR}/") if(${filepath} MATCHES "Qt${QT_VERSION_MAJOR}/")
@ -64,7 +64,7 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
endforeach(filepath) endforeach(filepath)
#遍历所有资源文件 #遍历所有资源文件
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp) file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp qmldir)
foreach(filepath ${RES_PATHS}) foreach(filepath ${RES_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND resource_files ${filename}) list(APPEND resource_files ${filename})
@ -93,12 +93,17 @@ else ()
) )
endif () endif ()
#复制动态库到可执行文件同级目录下
if(WIN32) if(WIN32)
#复制动态库到可执行文件同级目录下
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(3RDPARTY_ARCH_DIR ${CMAKE_SOURCE_DIR}/3rdparty/Win_x86)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(3RDPARTY_ARCH_DIR ${CMAKE_SOURCE_DIR}/3rdparty/Win_x64)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(DLLPATH ${CMAKE_SOURCE_DIR}/3rdparty/msvc/*.dll) set(DLLPATH ${3RDPARTY_ARCH_DIR}/msvc/*.dll)
else() else()
set(DLLPATH ${CMAKE_SOURCE_DIR}/3rdparty/mingw/*.dll) set(DLLPATH ${3RDPARTY_ARCH_DIR}/mingw/*.dll)
endif() endif()
string(REPLACE "/" ${PATH_SEPARATOR} DLLPATH "${DLLPATH}") string(REPLACE "/" ${PATH_SEPARATOR} DLLPATH "${DLLPATH}")
file(GLOB DLL_FILES ${DLLPATH}) file(GLOB DLL_FILES ${DLLPATH})
@ -122,7 +127,7 @@ else()
target_include_directories(example PRIVATE target_include_directories(example PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
) )
target_sources(example PRIVATE resource.qrc) target_sources(example PRIVATE example.qrc)
endif() endif()
#导入component头文件,不然通过QML_NAMED_ELEMENT生成的c++类会找不到头文件报错 #导入component头文件,不然通过QML_NAMED_ELEMENT生成的c++类会找不到头文件报错
@ -130,6 +135,13 @@ target_include_directories(example PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/component ${CMAKE_CURRENT_SOURCE_DIR}/src/component
) )
#如何是静态库则需要手动注册插件导入FluentUI.h头文件
if(FLUENTUI_BUILD_STATIC_LIB)
target_include_directories(example PRIVATE
${CMAKE_SOURCE_DIR}/src
)
endif()
#设置属性 #设置属性
set_target_properties(example PROPERTIES set_target_properties(example PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
@ -139,18 +151,6 @@ set_target_properties(example PROPERTIES
WIN32_EXECUTABLE TRUE WIN32_EXECUTABLE TRUE
) )
#链接库
if (FLUENTUI_BUILD_STATIC_LIB)
target_link_libraries(example PRIVATE
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Svg
Qt${QT_VERSION_MAJOR}::Network
fluentui
fluentuiplugin
FramelessHelper::Core
FramelessHelper::Quick
)
else()
target_link_libraries(example PRIVATE target_link_libraries(example PRIVATE
Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Svg
@ -159,7 +159,6 @@ else()
FramelessHelper::Core FramelessHelper::Core
FramelessHelper::Quick FramelessHelper::Quick
) )
endif()
#安装 #安装
install(TARGETS example install(TARGETS example

View File

@ -126,7 +126,6 @@
<file>qml/component/CustomWindow.qml</file> <file>qml/component/CustomWindow.qml</file>
<file>qml/global/ItemsFooter.qml</file> <file>qml/global/ItemsFooter.qml</file>
<file>qml/global/ItemsOriginal.qml</file> <file>qml/global/ItemsOriginal.qml</file>
<file>qml/global/MainEvent.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_Awesome.qml</file>
@ -186,5 +185,7 @@
<file>res/image/image_1.jpg</file> <file>res/image/image_1.jpg</file>
<file>qml/window/PageWindow.qml</file> <file>qml/window/PageWindow.qml</file>
<file>qml/page/T_StaggeredView.qml</file> <file>qml/page/T_StaggeredView.qml</file>
<file>qml/viewmodel/SettingsViewModel.qml</file>
<file>qml/viewmodel/TextBoxViewModel.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -28,6 +28,7 @@ Window {
FluApp.init(app) FluApp.init(app)
FluTheme.darkMode = FluThemeType.System FluTheme.darkMode = FluThemeType.System
FluTheme.enableAnimation = true FluTheme.enableAnimation = true
FluTheme.nativeText = true
FluApp.routes = { FluApp.routes = {
"/":"qrc:/example/qml/window/MainWindow.qml", "/":"qrc:/example/qml/window/MainWindow.qml",
"/about":"qrc:/example/qml/window/AboutWindow.qml", "/about":"qrc:/example/qml/window/AboutWindow.qml",

View File

@ -139,7 +139,8 @@ FluExpander{
"FluChart", "FluChart",
"FluRangeSlider", "FluRangeSlider",
"FluStaggeredView", "FluStaggeredView",
"FluProgressButton" "FluProgressButton",
"FluLoadingButton"
]; ];
code = code.replace(/\n/g, "<br>"); code = code.replace(/\n/g, "<br>");
code = code.replace(/ /g, "&nbsp;"); code = code.replace(/ /g, "&nbsp;");

View File

@ -1,9 +0,0 @@
pragma Singleton
import QtQuick
import QtQuick.Controls
import FluentUI
QtObject {
property int displayMode : FluNavigationViewType.Auto
}

View File

@ -1,3 +1,2 @@
singleton ItemsOriginal 1.0 ItemsOriginal.qml singleton ItemsOriginal 1.0 ItemsOriginal.qml
singleton ItemsFooter 1.0 ItemsFooter.qml singleton ItemsFooter 1.0 ItemsFooter.qml
singleton MainEvent 1.0 MainEvent.qml

View File

@ -50,7 +50,7 @@ FluScrollablePage{
FluRectangle{ FluRectangle{
width: 1920/4 width: 1920/4
height: 1200/4 height: 1200/4
radius:[15,15,15,15] radius:[8,8,8,8]
Image { Image {
id:image id:image
asynchronous: true asynchronous: true

View File

@ -213,6 +213,45 @@ FluScrollablePage{
}' }'
} }
FluArea{
Layout.fillWidth: true
height: 68
Layout.topMargin: 20
paddings: 10
FluLoadingButton{
id:btn_loading
loading:loading_button_switch.checked
text:"Loading Button"
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
onClicked: {
}
}
FluToggleSwitch{
id:loading_button_switch
checked: true
anchors{
right: parent.right
verticalCenter: parent.verticalCenter
}
text:"Loading"
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluLoadingButton{
text:"Loading Button"
onClicked: {
}
}'
}
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true

View File

@ -9,10 +9,10 @@ FluScrollablePage{
title:"Captcha" title:"Captcha"
FluCaptcha{ FluCaptcha{
id:captcha id:captcha
Layout.topMargin: 20 Layout.topMargin: 20
ignoreCase:switch_case.checked
MouseArea{ MouseArea{
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
@ -30,6 +30,13 @@ FluScrollablePage{
} }
} }
FluToggleSwitch{
id:switch_case
text:"Ignore Case"
checked: true
Layout.topMargin: 10
}
RowLayout{ RowLayout{
spacing: 10 spacing: 10
Layout.topMargin: 10 Layout.topMargin: 10
@ -49,6 +56,4 @@ FluScrollablePage{
} }
} }
} }
} }

View File

@ -36,8 +36,15 @@ FluScrollablePage{
FluText{ FluText{
text:"轮播图支持无限轮播无限滑动用ListView实现的组件" text:"轮播图支持无限轮播无限滑动用ListView实现的组件"
} }
Item{
width: 400
height: 300
FluShadow{
radius: 8
}
FluCarousel{ FluCarousel{
radius:[5,5,5,5] anchors.fill: parent
radius:[8,8,8,8]
delegate: Component{ delegate: Component{
Image { Image {
anchors.fill: parent anchors.fill: parent
@ -54,6 +61,7 @@ FluScrollablePage{
} }
} }
} }
}
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
@ -66,8 +74,15 @@ FluScrollablePage{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
left:parent.left left:parent.left
} }
Item{
width: 400
height: 300
FluShadow{
radius: 8
}
FluCarousel{ FluCarousel{
radius:[15,15,15,15] anchors.fill: parent
radius:[8,8,8,8]
loopTime:1500 loopTime:1500
indicatorGravity: Qt.AlignHCenter | Qt.AlignTop indicatorGravity: Qt.AlignHCenter | Qt.AlignTop
indicatorMarginTop:15 indicatorMarginTop:15
@ -107,6 +122,8 @@ FluScrollablePage{
} }
} }
} }
}
} }
CodeExpander{ CodeExpander{

View File

@ -70,12 +70,12 @@ FluScrollablePage{
width: 220 width: 220
height: 240 height: 240
FluShadow{ FluShadow{
radius:8 radius:5
anchors.fill: item_content anchors.fill: item_content
} }
FluItem{ FluItem{
id:item_content id:item_content
radius: [8,8,8,8] radius: [5,5,5,5]
width: 200 width: 200
height: 220 height: 220
anchors.centerIn: parent anchors.centerIn: parent
@ -89,7 +89,7 @@ FluScrollablePage{
} }
Rectangle{ Rectangle{
anchors.fill: parent anchors.fill: parent
radius: 8 radius: 5
color:{ color:{
if(FluTheme.dark){ if(FluTheme.dark){
if(item_mouse.containsMouse){ if(item_mouse.containsMouse){

View File

@ -11,6 +11,7 @@ FluContentPage{
title:"Http" title:"Http"
property string cacheDirPath: FluTools.getApplicationDirPath() + "/cache/http" property string cacheDirPath: FluTools.getApplicationDirPath() + "/cache/http"
property bool isDownCompleted: false
FluHttp{ FluHttp{
id:http id:http
@ -171,6 +172,10 @@ FluContentPage{
} }
onSuccess: onSuccess:
(result)=>{ (result)=>{
if(!isDownCompleted){
tour.open()
isDownCompleted = true
}
showSuccess(result) showSuccess(result)
} }
onDownloadProgress: onDownloadProgress:
@ -281,6 +286,13 @@ FluContentPage{
} }
} }
FluTour{
id:tour
steps:[
{title:"友情提示",description: "下载已完成,左击这里可以打开文件所在路径,右击可以弹出菜单删除文件!",target:()=>btn_breakpoint_download}
]
}
HttpCallable{ HttpCallable{
id:callable_upload id:callable_upload
onStart: { onStart: {

View File

@ -116,7 +116,7 @@ FluScrollablePage{
FluRectangle{ FluRectangle{
width: 1920/5 width: 1920/5
height: 1200/5 height: 1200/5
radius:[15,15,15,15] radius:[8,8,8,8]
Image { Image {
asynchronous: true asynchronous: true
source: "qrc:/example/res/image/banner_1.jpg" source: "qrc:/example/res/image/banner_1.jpg"

View File

@ -30,9 +30,10 @@ FluScrollablePage{
Layout.topMargin: 10 Layout.topMargin: 10
Layout.leftMargin: 4 Layout.leftMargin: 4
Layout.bottomMargin: 4 Layout.bottomMargin: 4
radius: 4
color: FluTheme.dark ? FluColors.Black : FluColors.White color: FluTheme.dark ? FluColors.Black : FluColors.White
FluShadow{ FluShadow{
radius: 0 radius: 4
color: FluTheme.primaryColor.dark color: FluTheme.primaryColor.dark
} }
Image{ Image{

View File

@ -5,11 +5,58 @@ import QtQuick.Controls
import FluentUI import FluentUI
import "qrc:///example/qml/global" import "qrc:///example/qml/global"
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
import "qrc:///example/qml/viewmodel"
FluScrollablePage{ FluScrollablePage{
title:"Settings" title:"Settings"
SettingsViewModel{
id:viewmodel_settings
}
FluEvent{
id:event_checkupdate_finish
name: "checkUpdateFinish"
onTriggered: {
btn_checkupdate.loading = false
}
}
Component.onCompleted: {
FluEventBus.registerEvent(event_checkupdate_finish)
}
Component.onDestruction: {
FluEventBus.unRegisterEvent(event_checkupdate_finish)
}
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 60
paddings: 10
Row{
spacing: 20
anchors.verticalCenter: parent.verticalCenter
FluText{
text:"当前版本 v%1".arg(appInfo.version)
font: FluTextStyle.Body
anchors.verticalCenter: parent.verticalCenter
}
FluLoadingButton{
id:btn_checkupdate
text:"检查更新"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
loading = true
FluEventBus.post("checkUpdate")
}
}
}
}
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
@ -60,10 +107,10 @@ FluScrollablePage{
Repeater{ Repeater{
model: [{title:"Open",mode:FluNavigationViewType.Open},{title:"Compact",mode:FluNavigationViewType.Compact},{title:"Minimal",mode:FluNavigationViewType.Minimal},{title:"Auto",mode:FluNavigationViewType.Auto}] model: [{title:"Open",mode:FluNavigationViewType.Open},{title:"Compact",mode:FluNavigationViewType.Compact},{title:"Minimal",mode:FluNavigationViewType.Minimal},{title:"Auto",mode:FluNavigationViewType.Auto}]
delegate: FluRadioButton{ delegate: FluRadioButton{
checked : MainEvent.displayMode===modelData.mode checked : viewmodel_settings.displayMode===modelData.mode
text:modelData.title text:modelData.title
clickListener:function(){ clickListener:function(){
MainEvent.displayMode = modelData.mode viewmodel_settings.displayMode = modelData.mode
} }
} }
} }

View File

@ -4,12 +4,19 @@ import QtQuick.Layouts
import QtQuick.Window import QtQuick.Window
import FluentUI import FluentUI
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
import "qrc:///example/qml/viewmodel"
FluScrollablePage{ FluScrollablePage{
launchMode: FluPageType.SingleInstance
title:"TextBox" title:"TextBox"
TextBoxViewModel{
id:viewModel
}
Component.onDestruction: {
console.debug("T_TextBox页面销毁了")
}
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 height: 68
@ -20,6 +27,10 @@ FluScrollablePage{
placeholderText: "单行输入框" placeholderText: "单行输入框"
disabled:text_box_switch.checked disabled:text_box_switch.checked
cleanEnabled: true cleanEnabled: true
text:viewModel.text1
onTextChanged: {
viewModel.text1 = text
}
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
left: parent.left left: parent.left
@ -84,6 +95,10 @@ FluScrollablePage{
FluMultilineTextBox{ FluMultilineTextBox{
id:multiine_textbox id:multiine_textbox
placeholderText: "多行输入框" placeholderText: "多行输入框"
text:viewModel.text2
onTextChanged: {
viewModel.text2 = text
}
disabled:text_box_multi_switch.checked disabled:text_box_multi_switch.checked
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter

View File

@ -0,0 +1,13 @@
import QtQuick
import FluentUI
FluViewModel{
objectName: "SettingsViewModel"
property int displayMode
onInitData: {
displayMode = FluNavigationViewType.Auto
}
}

View File

@ -0,0 +1,8 @@
import QtQuick
import FluentUI
FluViewModel {
objectName: "TextBoxView"
property string text1
property string text2
}

View File

@ -7,6 +7,7 @@ import FluentUI
import example import example
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
import "qrc:///example/qml/global" import "qrc:///example/qml/global"
import "qrc:///example/qml/viewmodel"
CustomWindow { CustomWindow {
@ -20,15 +21,32 @@ CustomWindow {
appBarVisible: false appBarVisible: false
launchMode: FluWindowType.SingleTask launchMode: FluWindowType.SingleTask
SettingsViewModel{
id:viewmodel_settings
}
closeFunc:function(event){ closeFunc:function(event){
dialog_close.open() dialog_close.open()
event.accepted = false event.accepted = false
} }
FluEvent{
id:event_checkupdate
name: "checkUpdate"
onTriggered: {
checkUpdate(false)
}
}
Component.onCompleted: { Component.onCompleted: {
FluTools.setQuitOnLastWindowClosed(false) FluTools.setQuitOnLastWindowClosed(false)
tour.open() tour.open()
checkUpdate() checkUpdate(true)
FluEventBus.registerEvent(event_checkupdate)
}
Component.onDestruction: {
FluEventBus.unRegisterEvent(event_checkupdate)
} }
SystemTrayIcon { SystemTrayIcon {
@ -164,13 +182,13 @@ CustomWindow {
height: parent.height height: parent.height
z:999 z:999
//Stack模式每次切换都会将页面压入栈中随着栈的页面增多消耗的内存也越多内存消耗多就会卡顿这时候就需要按返回将页面pop掉释放内存。该模式可以配合FluPage中的launchMode属性设置页面的启动模式 //Stack模式每次切换都会将页面压入栈中随着栈的页面增多消耗的内存也越多内存消耗多就会卡顿这时候就需要按返回将页面pop掉释放内存。该模式可以配合FluPage中的launchMode属性设置页面的启动模式
pageMode: FluNavigationViewType.Stack // pageMode: FluNavigationViewType.Stack
//NoStack模式每次切换都会销毁之前的页面然后创建一个新的页面只需消耗少量内存推荐 //NoStack模式每次切换都会销毁之前的页面然后创建一个新的页面只需消耗少量内存推荐
// pageMode: FluNavigationViewType.NoStack pageMode: FluNavigationViewType.NoStack
items: ItemsOriginal items: ItemsOriginal
footerItems:ItemsFooter footerItems:ItemsFooter
topPadding:FluTools.isMacos() ? 20 : 0 topPadding:FluTools.isMacos() ? 20 : 0
displayMode:MainEvent.displayMode displayMode:viewmodel_settings.displayMode
logo: "qrc:/example/res/image/favicon.ico" logo: "qrc:/example/res/image/favicon.ico"
title:"FluentUI" title:"FluentUI"
onLogoClicked:{ onLogoClicked:{
@ -311,11 +329,13 @@ CustomWindow {
HttpCallable{ HttpCallable{
id:callable id:callable
property bool silent: true
onStart: { onStart: {
console.debug("satrt check update...") console.debug("satrt check update...")
} }
onFinish: { onFinish: {
console.debug("check update finish") console.debug("check update finish")
FluEventBus.post("checkUpdateFinish");
} }
onSuccess: onSuccess:
(result)=>{ (result)=>{
@ -326,15 +346,23 @@ CustomWindow {
dialog_update.newVerson = data.tag_name dialog_update.newVerson = data.tag_name
dialog_update.body = data.body dialog_update.body = data.body
dialog_update.open() dialog_update.open()
}else{
if(!silent){
showInfo("当前版本已经是最新版")
}
} }
} }
onError: onError:
(status,errorString)=>{ (status,errorString)=>{
if(!silent){
showError("网络异常!")
}
console.debug(status+";"+errorString) console.debug(status+";"+errorString)
} }
} }
function checkUpdate(){ function checkUpdate(silent){
callable.silent = silent
var request = http.newRequest("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest") var request = http.newRequest("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest")
http.get(request,callable); http.get(request,callable);
} }

View File

@ -28,6 +28,7 @@ Window {
FluApp.init(app) FluApp.init(app)
FluTheme.darkMode = FluThemeType.System FluTheme.darkMode = FluThemeType.System
FluTheme.enableAnimation = true FluTheme.enableAnimation = true
FluTheme.nativeText = true
FluApp.routes = { FluApp.routes = {
"/":"qrc:/example/qml/window/MainWindow.qml", "/":"qrc:/example/qml/window/MainWindow.qml",
"/about":"qrc:/example/qml/window/AboutWindow.qml", "/about":"qrc:/example/qml/window/AboutWindow.qml",

View File

@ -139,7 +139,8 @@ FluExpander{
"FluChart", "FluChart",
"FluRangeSlider", "FluRangeSlider",
"FluStaggeredView", "FluStaggeredView",
"FluProgressButton" "FluProgressButton",
"FluLoadingButton"
]; ];
code = code.replace(/\n/g, "<br>"); code = code.replace(/\n/g, "<br>");
code = code.replace(/ /g, "&nbsp;"); code = code.replace(/ /g, "&nbsp;");

View File

@ -1,9 +0,0 @@
pragma Singleton
import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
QtObject {
property int displayMode : FluNavigationViewType.Auto
}

View File

@ -1,3 +1,2 @@
singleton ItemsOriginal 1.0 ItemsOriginal.qml singleton ItemsOriginal 1.0 ItemsOriginal.qml
singleton ItemsFooter 1.0 ItemsFooter.qml singleton ItemsFooter 1.0 ItemsFooter.qml
singleton MainEvent 1.0 MainEvent.qml

View File

@ -51,7 +51,7 @@ FluScrollablePage{
FluRectangle{ FluRectangle{
width: 1920/4 width: 1920/4
height: 1200/4 height: 1200/4
radius:[15,15,15,15] radius:[8,8,8,8]
Image { Image {
id:image id:image
asynchronous: true asynchronous: true

View File

@ -213,6 +213,45 @@ FluScrollablePage{
}' }'
} }
FluArea{
Layout.fillWidth: true
height: 68
Layout.topMargin: 20
paddings: 10
FluLoadingButton{
id:btn_loading
loading:loading_button_switch.checked
text:"Loading Button"
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
onClicked: {
}
}
FluToggleSwitch{
id:loading_button_switch
checked: true
anchors{
right: parent.right
verticalCenter: parent.verticalCenter
}
text:"Loading"
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluLoadingButton{
text:"Loading Button"
onClicked: {
}
}'
}
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true

View File

@ -10,10 +10,10 @@ FluScrollablePage{
title:"Captcha" title:"Captcha"
FluCaptcha{ FluCaptcha{
id:captcha id:captcha
Layout.topMargin: 20 Layout.topMargin: 20
ignoreCase:switch_case.checked
MouseArea{ MouseArea{
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
@ -31,6 +31,13 @@ FluScrollablePage{
} }
} }
FluToggleSwitch{
id:switch_case
text:"Ignore Case"
checked: true
Layout.topMargin: 10
}
RowLayout{ RowLayout{
spacing: 10 spacing: 10
Layout.topMargin: 10 Layout.topMargin: 10
@ -50,6 +57,4 @@ FluScrollablePage{
} }
} }
} }
} }

View File

@ -37,8 +37,15 @@ FluScrollablePage{
FluText{ FluText{
text:"轮播图支持无限轮播无限滑动用ListView实现的组件" text:"轮播图支持无限轮播无限滑动用ListView实现的组件"
} }
Item{
width: 400
height: 300
FluShadow{
radius: 8
}
FluCarousel{ FluCarousel{
radius:[5,5,5,5] anchors.fill: parent
radius:[8,8,8,8]
delegate: Component{ delegate: Component{
Image { Image {
anchors.fill: parent anchors.fill: parent
@ -55,6 +62,7 @@ FluScrollablePage{
} }
} }
} }
}
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
@ -67,8 +75,15 @@ FluScrollablePage{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
left:parent.left left:parent.left
} }
Item{
width: 400
height: 300
FluShadow{
radius: 8
}
FluCarousel{ FluCarousel{
radius:[15,15,15,15] anchors.fill: parent
radius:[8,8,8,8]
loopTime:1500 loopTime:1500
indicatorGravity: Qt.AlignHCenter | Qt.AlignTop indicatorGravity: Qt.AlignHCenter | Qt.AlignTop
indicatorMarginTop:15 indicatorMarginTop:15
@ -108,6 +123,8 @@ FluScrollablePage{
} }
} }
} }
}
} }
CodeExpander{ CodeExpander{

View File

@ -71,12 +71,12 @@ FluScrollablePage{
width: 220 width: 220
height: 240 height: 240
FluShadow{ FluShadow{
radius:8 radius:5
anchors.fill: item_content anchors.fill: item_content
} }
FluItem{ FluItem{
id:item_content id:item_content
radius: [8,8,8,8] radius: [5,5,5,5]
width: 200 width: 200
height: 220 height: 220
anchors.centerIn: parent anchors.centerIn: parent
@ -90,7 +90,7 @@ FluScrollablePage{
} }
Rectangle{ Rectangle{
anchors.fill: parent anchors.fill: parent
radius: 8 radius: 5
color:{ color:{
if(FluTheme.dark){ if(FluTheme.dark){
if(item_mouse.containsMouse){ if(item_mouse.containsMouse){

View File

@ -12,6 +12,7 @@ FluContentPage{
title:"Http" title:"Http"
property string cacheDirPath: FluTools.getApplicationDirPath() + "/cache/http" property string cacheDirPath: FluTools.getApplicationDirPath() + "/cache/http"
property bool isDownCompleted: false
FluHttp{ FluHttp{
id:http id:http
@ -172,6 +173,10 @@ FluContentPage{
} }
onSuccess: onSuccess:
(result)=>{ (result)=>{
if(!isDownCompleted){
tour.open()
isDownCompleted = true
}
showSuccess(result) showSuccess(result)
} }
onDownloadProgress: onDownloadProgress:
@ -282,6 +287,13 @@ FluContentPage{
} }
} }
FluTour{
id:tour
steps:[
{title:"友情提示",description: "下载已完成,左击这里可以打开文件所在路径,右击可以弹出菜单删除文件!",target:()=>btn_breakpoint_download}
]
}
HttpCallable{ HttpCallable{
id:callable_upload id:callable_upload
onStart: { onStart: {

View File

@ -16,9 +16,12 @@ FluScrollablePage{
height: 400 height: 400
paddings: 10 paddings: 10
FluPivot{ FluPivot{
anchors.fill: parent anchors.fill: parent
currentIndex: 2 currentIndex: 2
FluPivotItem{ FluPivotItem{
title:"All" title:"All"
contentItem:FluText{ contentItem:FluText{

View File

@ -117,7 +117,7 @@ FluScrollablePage{
FluRectangle{ FluRectangle{
width: 1920/5 width: 1920/5
height: 1200/5 height: 1200/5
radius:[15,15,15,15] radius:[8,8,8,8]
Image { Image {
asynchronous: true asynchronous: true
source: "qrc:/example/res/image/banner_1.jpg" source: "qrc:/example/res/image/banner_1.jpg"

View File

@ -31,9 +31,10 @@ FluScrollablePage{
Layout.topMargin: 10 Layout.topMargin: 10
Layout.leftMargin: 4 Layout.leftMargin: 4
Layout.bottomMargin: 4 Layout.bottomMargin: 4
radius: 4
color: FluTheme.dark ? FluColors.Black : FluColors.White color: FluTheme.dark ? FluColors.Black : FluColors.White
FluShadow{ FluShadow{
radius: 0 radius: 4
color: FluTheme.primaryColor.dark color: FluTheme.primaryColor.dark
} }
Image{ Image{

View File

@ -5,12 +5,61 @@ import QtQuick.Controls 2.15
import FluentUI 1.0 import FluentUI 1.0
import "qrc:///example/qml/global" import "qrc:///example/qml/global"
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
import "qrc:///example/qml/viewmodel"
import "../component" import "../component"
import "../viewmodel"
import "../global"
FluScrollablePage{ FluScrollablePage{
title:"Settings" title:"Settings"
SettingsViewModel{
id:viewmodel_settings
}
FluEvent{
id:event_checkupdate_finish
name: "checkUpdateFinish"
onTriggered: {
btn_checkupdate.loading = false
}
}
Component.onCompleted: {
FluEventBus.registerEvent(event_checkupdate_finish)
}
Component.onDestruction: {
FluEventBus.unRegisterEvent(event_checkupdate_finish)
}
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 60
paddings: 10
Row{
spacing: 20
anchors.verticalCenter: parent.verticalCenter
FluText{
text:"当前版本 v%1".arg(appInfo.version)
font: FluTextStyle.Body
anchors.verticalCenter: parent.verticalCenter
}
FluLoadingButton{
id:btn_checkupdate
text:"检查更新"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
loading = true
FluEventBus.post("checkUpdate")
}
}
}
}
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
@ -61,10 +110,10 @@ FluScrollablePage{
Repeater{ Repeater{
model: [{title:"Open",mode:FluNavigationViewType.Open},{title:"Compact",mode:FluNavigationViewType.Compact},{title:"Minimal",mode:FluNavigationViewType.Minimal},{title:"Auto",mode:FluNavigationViewType.Auto}] model: [{title:"Open",mode:FluNavigationViewType.Open},{title:"Compact",mode:FluNavigationViewType.Compact},{title:"Minimal",mode:FluNavigationViewType.Minimal},{title:"Auto",mode:FluNavigationViewType.Auto}]
delegate: FluRadioButton{ delegate: FluRadioButton{
checked : MainEvent.displayMode===modelData.mode checked : viewmodel_settings.displayMode===modelData.mode
text:modelData.title text:modelData.title
clickListener:function(){ clickListener:function(){
MainEvent.displayMode = modelData.mode viewmodel_settings.displayMode = modelData.mode
} }
} }
} }

View File

@ -4,13 +4,21 @@ import QtQuick.Layouts 1.15
import QtQuick.Window 2.15 import QtQuick.Window 2.15
import FluentUI 1.0 import FluentUI 1.0
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
import "qrc:///example/qml/viewmodel"
import "../component" import "../component"
import "../viewmodel"
FluScrollablePage{ FluScrollablePage{
launchMode: FluPageType.SingleInstance
title:"TextBox" title:"TextBox"
TextBoxViewModel{
id:viewModel
}
Component.onDestruction: {
console.debug("T_TextBox页面销毁了")
}
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 height: 68
@ -21,6 +29,10 @@ FluScrollablePage{
placeholderText: "单行输入框" placeholderText: "单行输入框"
disabled:text_box_switch.checked disabled:text_box_switch.checked
cleanEnabled: true cleanEnabled: true
text:viewModel.text1
onTextChanged: {
viewModel.text1 = text
}
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
left: parent.left left: parent.left
@ -85,6 +97,10 @@ FluScrollablePage{
FluMultilineTextBox{ FluMultilineTextBox{
id:multiine_textbox id:multiine_textbox
placeholderText: "多行输入框" placeholderText: "多行输入框"
text:viewModel.text2
onTextChanged: {
viewModel.text2 = text
}
disabled:text_box_multi_switch.checked disabled:text_box_multi_switch.checked
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter

View File

@ -0,0 +1,13 @@
import QtQuick 2.15
import FluentUI 1.0
FluViewModel{
objectName: "SettingsViewModel"
property int displayMode
onInitData: {
displayMode = FluNavigationViewType.Auto
}
}

View File

@ -0,0 +1,8 @@
import QtQuick 2.15
import FluentUI 1.0
FluViewModel {
objectName: "TextBoxView"
property string text1
property string text2
}

View File

@ -6,8 +6,11 @@ import Qt.labs.platform 1.1
import FluentUI 1.0 import FluentUI 1.0
import example 1.0 import example 1.0
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
import "../component"
import "qrc:///example/qml/global" import "qrc:///example/qml/global"
import "qrc:///example/qml/viewmodel"
import "../component"
import "../viewmodel"
import "../global"
CustomWindow { CustomWindow {
@ -21,15 +24,32 @@ CustomWindow {
appBarVisible: false appBarVisible: false
launchMode: FluWindowType.SingleTask launchMode: FluWindowType.SingleTask
SettingsViewModel{
id:viewmodel_settings
}
closeFunc:function(event){ closeFunc:function(event){
dialog_close.open() dialog_close.open()
event.accepted = false event.accepted = false
} }
FluEvent{
id:event_checkupdate
name: "checkUpdate"
onTriggered: {
checkUpdate(false)
}
}
Component.onCompleted: { Component.onCompleted: {
FluTools.setQuitOnLastWindowClosed(false) FluTools.setQuitOnLastWindowClosed(false)
tour.open() tour.open()
checkUpdate() checkUpdate(true)
FluEventBus.registerEvent(event_checkupdate)
}
Component.onDestruction: {
FluEventBus.unRegisterEvent(event_checkupdate)
} }
SystemTrayIcon { SystemTrayIcon {
@ -139,7 +159,7 @@ CustomWindow {
id:loader id:loader
lazy: true lazy: true
anchors.fill: parent anchors.fill: parent
source: "https://zhu-zichu.gitee.io/Qt6_156_LieflatPage.qml" source: "https://zhu-zichu.gitee.io/Qt5_156_LieflatPage.qml"
} }
} }
front: Item{ front: Item{
@ -165,13 +185,13 @@ CustomWindow {
height: parent.height height: parent.height
z:999 z:999
//Stack模式每次切换都会将页面压入栈中随着栈的页面增多消耗的内存也越多内存消耗多就会卡顿这时候就需要按返回将页面pop掉释放内存。该模式可以配合FluPage中的launchMode属性设置页面的启动模式 //Stack模式每次切换都会将页面压入栈中随着栈的页面增多消耗的内存也越多内存消耗多就会卡顿这时候就需要按返回将页面pop掉释放内存。该模式可以配合FluPage中的launchMode属性设置页面的启动模式
pageMode: FluNavigationViewType.Stack // pageMode: FluNavigationViewType.Stack
//NoStack模式每次切换都会销毁之前的页面然后创建一个新的页面只需消耗少量内存推荐 //NoStack模式每次切换都会销毁之前的页面然后创建一个新的页面只需消耗少量内存推荐
// pageMode: FluNavigationViewType.NoStack pageMode: FluNavigationViewType.NoStack
items: ItemsOriginal items: ItemsOriginal
footerItems:ItemsFooter footerItems:ItemsFooter
topPadding:FluTools.isMacos() ? 20 : 0 topPadding:FluTools.isMacos() ? 20 : 0
displayMode:MainEvent.displayMode displayMode:viewmodel_settings.displayMode
logo: "qrc:/example/res/image/favicon.ico" logo: "qrc:/example/res/image/favicon.ico"
title:"FluentUI" title:"FluentUI"
onLogoClicked:{ onLogoClicked:{
@ -312,11 +332,13 @@ CustomWindow {
HttpCallable{ HttpCallable{
id:callable id:callable
property bool silent: true
onStart: { onStart: {
console.debug("satrt check update...") console.debug("satrt check update...")
} }
onFinish: { onFinish: {
console.debug("check update finish") console.debug("check update finish")
FluEventBus.post("checkUpdateFinish");
} }
onSuccess: onSuccess:
(result)=>{ (result)=>{
@ -327,15 +349,23 @@ CustomWindow {
dialog_update.newVerson = data.tag_name dialog_update.newVerson = data.tag_name
dialog_update.body = data.body dialog_update.body = data.body
dialog_update.open() dialog_update.open()
}else{
if(!silent){
showInfo("当前版本已经是最新版")
}
} }
} }
onError: onError:
(status,errorString)=>{ (status,errorString)=>{
if(!silent){
showError("网络异常!")
}
console.debug(status+";"+errorString) console.debug(status+";"+errorString)
} }
} }
function checkUpdate(){ function checkUpdate(silent){
callable.silent = silent
var request = http.newRequest("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest") var request = http.newRequest("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest")
http.get(request,callable); http.get(request,callable);
} }

View File

@ -8,10 +8,17 @@
#include <QProcess> #include <QProcess>
#include <FramelessHelper/Quick/framelessquickmodule.h> #include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h> #include <FramelessHelper/Core/private/framelessconfig_p.h>
#include <QtQml/qqmlextensionplugin.h>
#include "AppInfo.h" #include "AppInfo.h"
#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"
#ifdef FLUENTUI_BUILD_STATIC_LIB
#if (QT_VERSION > QT_VERSION_CHECK(6, 2, 0))
Q_IMPORT_QML_PLUGIN(FluentUIPlugin)
#endif
#include <FluentUI.h>
#endif
FRAMELESSHELPER_USE_NAMESPACE FRAMELESSHELPER_USE_NAMESPACE
@ -24,7 +31,6 @@ int main(int argc, char *argv[])
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif #endif
#endif #endif
//将样式设置为Basic不然会导致组件显示异常
qputenv("QT_QUICK_CONTROLS_STYLE","Basic"); qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
FramelessHelper::Quick::initialize(); FramelessHelper::Quick::initialize();
QGuiApplication::setOrganizationName("ZhuZiChu"); QGuiApplication::setOrganizationName("ZhuZiChu");
@ -35,7 +41,7 @@ int main(int argc, char *argv[])
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur); FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
#ifdef Q_OS_WIN // 此设置仅在Windows下生效 #ifdef Q_OS_WIN
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder); FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,false); FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,false);
#endif #endif
@ -46,8 +52,9 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
FramelessHelper::Quick::registerTypes(&engine); FramelessHelper::Quick::registerTypes(&engine);
#ifdef FLUENTUI_BUILD_STATIC_LIB #ifdef FLUENTUI_BUILD_STATIC_LIB
engine.addImportPath("qrc:/"); // 让静态资源可以被QML引擎搜索到 FluentUI::getInstance()->registerTypes(&engine);
#endif #endif
qDebug()<<engine.importPathList();
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal"); qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
qmlRegisterType<FileWatcher>("example", 1, 0, "FileWatcher"); qmlRegisterType<FileWatcher>("example", 1, 0, "FileWatcher");
qmlRegisterType<FpsItem>("example", 1, 0, "FpsItem"); qmlRegisterType<FpsItem>("example", 1, 0, "FpsItem");

View File

@ -1,16 +1,21 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
if (FLUENTUI_BUILD_STATIC_LIB) if (FLUENTUI_BUILD_STATIC_LIB AND (QT_VERSION VERSION_GREATER_EQUAL "6.2"))
project(fluentui LANGUAGES CXX) project(fluentui LANGUAGES CXX)
else() else()
project(fluentuiplugin LANGUAGES CXX) project(fluentuiplugin LANGUAGES CXX)
endif() endif()
#配置通用编译 #配置通用编译
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(APPLE) if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
endif() endif()
if (FLUENTUI_BUILD_STATIC_LIB)
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
endif()
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 Qml)
@ -32,6 +37,9 @@ endforeach(filepath)
if(QT_VERSION VERSION_GREATER_EQUAL "6.2") if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
#删除fluentuiplugin.cpp与fluentuiplugin.h这些只要Qt5使用Qt6不需要 #删除fluentuiplugin.cpp与fluentuiplugin.h这些只要Qt5使用Qt6不需要
list(REMOVE_ITEM sources_files fluentuiplugin.h fluentuiplugin.cpp) list(REMOVE_ITEM sources_files fluentuiplugin.h fluentuiplugin.cpp)
if (NOT FLUENTUI_BUILD_STATIC_LIB)
list(REMOVE_ITEM sources_files FluentUI.h FluentUI.cpp)
endif()
#遍历所有qml文件 #遍历所有qml文件
file(GLOB_RECURSE QML_PATHS *.qml) file(GLOB_RECURSE QML_PATHS *.qml)
@ -83,6 +91,9 @@ if(WIN32)
endif() endif()
if(QT_VERSION VERSION_GREATER_EQUAL "6.2") if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
if(FLUENTUI_BUILD_STATIC_LIB)
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${CMAKE_BINARY_DIR}/FluentUI)
endif()
qt_add_library(${PROJECT_NAME} ${LIB_TYPE}) qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
qt_add_qml_module(${PROJECT_NAME} qt_add_qml_module(${PROJECT_NAME}
PLUGIN_TARGET ${PLUGIN_TARGET_NAME} PLUGIN_TARGET ${PLUGIN_TARGET_NAME}
@ -94,14 +105,14 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
SOURCES ${sources_files} ${FLUENTUI_VERSION_RC_PATH} SOURCES ${sources_files} ${FLUENTUI_VERSION_RC_PATH}
QML_FILES ${qml_files} QML_FILES ${qml_files}
RESOURCES ${resource_files} RESOURCES ${resource_files}
RESOURCE_PREFIX "/" RESOURCE_PREFIX "/qt/qml"
) )
else() else()
include(QmlPlugin) include(QmlPlugin)
add_qmlplugin(${PROJECT_NAME} add_qmlplugin(${PROJECT_NAME}
URI "FluentUI" URI "FluentUI"
VERSION 1.0 VERSION 1.0
SOURCES ${sources_files} ${FLUENTUI_VERSION_RC_PATH} resource.qrc SOURCES ${sources_files} ${FLUENTUI_VERSION_RC_PATH} Qt5/imports/fluentui.qrc
QMLFILES ${qml_files} QMLFILES ${qml_files}
QMLDIR imports/FluentUI QMLDIR imports/FluentUI
BINARY_DIR ${FLUENTUI_QML_PLUGIN_DIRECTORY} BINARY_DIR ${FLUENTUI_QML_PLUGIN_DIRECTORY}
@ -109,6 +120,9 @@ else()
) )
endif() endif()
#去掉mingw生成的动态库libxxx前缀lib不去掉前缀会导致 module "FluentUI" plugin "fluentuiplugin" not found
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
#链接库 #链接库
target_link_libraries(${PROJECT_NAME} PUBLIC target_link_libraries(${PROJECT_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::CorePrivate Qt${QT_VERSION_MAJOR}::CorePrivate

View File

@ -4,19 +4,22 @@
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
namespace FluViewModelType {
Q_NAMESPACE
enum Scope {
Window = 0x0000,
Application = 0x0001
};
Q_ENUM_NS(Scope)
QML_NAMED_ELEMENT(FluViewModelType)
}
namespace FluHttpType { namespace FluHttpType {
Q_NAMESPACE Q_NAMESPACE
enum CacheMode { enum CacheMode {
/** 不使用缓存 */
NoCache = 0x0000, NoCache = 0x0000,
/** 请求网络失败后,读取缓存 */
RequestFailedReadCache = 0x0001, RequestFailedReadCache = 0x0001,
/** 如果缓存不存在才请求网络,否则使用缓存 */
IfNoneCacheRequest = 0x0002, IfNoneCacheRequest = 0x0002,
/** 先使用缓存,不管是否存在,仍然请求网络 */
FirstCacheThenRequest = 0x0004, FirstCacheThenRequest = 0x0004,
}; };
Q_ENUM_NS(CacheMode) Q_ENUM_NS(CacheMode)

View File

@ -10,19 +10,7 @@
#include <QClipboard> #include <QClipboard>
#include "Def.h" #include "Def.h"
FluApp* FluApp::m_instance = nullptr; FluApp::FluApp(QObject *parent):QObject{parent}{
FluApp *FluApp::getInstance()
{
if(FluApp::m_instance == nullptr){
FluApp::m_instance = new FluApp;
}
return FluApp::m_instance;
}
FluApp::FluApp(QObject *parent)
: QObject{parent}
{
httpInterceptor(nullptr); httpInterceptor(nullptr);
} }
@ -83,8 +71,7 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
view->setColor(QColor(Qt::transparent)); view->setColor(QColor(Qt::transparent));
} }
QJsonArray FluApp::awesomelist(const QString& keyword) QJsonArray FluApp::awesomelist(const QString& keyword){
{
QJsonArray arr; QJsonArray arr;
QMetaEnum enumType = Fluent_Awesome::staticMetaObject.enumerator(Fluent_Awesome::staticMetaObject.indexOfEnumerator("Fluent_AwesomeType")); QMetaEnum enumType = Fluent_Awesome::staticMetaObject.enumerator(Fluent_Awesome::staticMetaObject.indexOfEnumerator("Fluent_AwesomeType"));
for(int i=0; i < enumType.keyCount(); ++i){ for(int i=0; i < enumType.keyCount(); ++i){

View File

@ -11,6 +11,7 @@
#include "FluRegister.h" #include "FluRegister.h"
#include "FluHttpInterceptor.h" #include "FluHttpInterceptor.h"
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h"
/** /**
* @brief The FluApp class * @brief The FluApp class
@ -18,80 +19,26 @@
class FluApp : public QObject class FluApp : public QObject
{ {
Q_OBJECT Q_OBJECT
/**
* @brief initialRoute 初始路由
*/
Q_PROPERTY_AUTO(QString,initialRoute); Q_PROPERTY_AUTO(QString,initialRoute);
/**
* @brief routes 路由表
*/
Q_PROPERTY_AUTO(QJsonObject,routes); Q_PROPERTY_AUTO(QJsonObject,routes);
/**
* @brief http拦截器
*/
Q_PROPERTY_AUTO(FluHttpInterceptor*,httpInterceptor); Q_PROPERTY_AUTO(FluHttpInterceptor*,httpInterceptor);
QML_NAMED_ELEMENT(FluApp) QML_NAMED_ELEMENT(FluApp)
QML_SINGLETON QML_SINGLETON
private: private:
/**
* @brief FluApp 将默认构造函数设置为私有则qml创建单例就会走create工厂方法创建单例
* @param parent
*/
explicit FluApp(QObject *parent = nullptr); explicit FluApp(QObject *parent = nullptr);
public:
~FluApp(); ~FluApp();
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
return getInstance();
}
static FluApp *getInstance();
/**
* @brief run
*/
Q_INVOKABLE void run();
/**
* @brief navigate
* @param route
* @param argument
* @param fluRegister
*/
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
/**
* @brief init
* @param window
*/
Q_INVOKABLE void init(QQuickWindow *window);
/**
* @brief awesomelist
* @param keyword
* @return
*/
Q_INVOKABLE QJsonArray awesomelist(const QString& keyword = "");
/**
* @brief closeApp
*/
Q_INVOKABLE void closeApp();
Q_INVOKABLE void deleteWindow(QQuickWindow* window);
public: public:
/** SINGLETONG(FluApp)
* @brief wnds static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
*/ Q_INVOKABLE void run();
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
Q_INVOKABLE void init(QQuickWindow *window);
Q_INVOKABLE QJsonArray awesomelist(const QString& keyword = "");
Q_INVOKABLE void closeApp();
Q_INVOKABLE void deleteWindow(QQuickWindow* window);
public:
QMap<quint64, QQuickWindow*> wnds; QMap<quint64, QQuickWindow*> wnds;
private: private:
static FluApp* m_instance;
/**
* @brief appWindow
*/
QWindow *appWindow; QWindow *appWindow;
}; };

View File

@ -5,17 +5,18 @@
#include <QRandomGenerator> #include <QRandomGenerator>
#include <qmath.h> #include <qmath.h>
FluCaptcha::FluCaptcha(QQuickItem *parent) FluCaptcha::FluCaptcha(QQuickItem *parent):QQuickPaintedItem(parent){
: QQuickPaintedItem(parent) ignoreCase(true);
{ QFont fontStype;
font(QFont("楷体",25,QFont::Bold,true)); fontStype.setPixelSize(28);
fontStype.setBold(true);
font(fontStype);
setWidth(180); setWidth(180);
setHeight(80); setHeight(80);
refresh(); refresh();
} }
void FluCaptcha::paint(QPainter* painter) void FluCaptcha::paint(QPainter* painter){
{
painter->save(); painter->save();
painter->fillRect(boundingRect().toRect(),QColor(255,255,255,255)); painter->fillRect(boundingRect().toRect(),QColor(255,255,255,255));
QPen pen; QPen pen;
@ -69,5 +70,8 @@ void FluCaptcha::refresh(){
} }
bool FluCaptcha::verify(const QString& code){ bool FluCaptcha::verify(const QString& code){
if(_ignoreCase){
return this->_code.toUpper() == code.toUpper();
}
return this->_code == code; return this->_code == code;
} }

View File

@ -10,15 +10,17 @@ class FluCaptcha : public QQuickPaintedItem
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QFont,font); Q_PROPERTY_AUTO(QFont,font);
Q_PROPERTY_AUTO(bool,ignoreCase);
QML_NAMED_ELEMENT(FluCaptcha) QML_NAMED_ELEMENT(FluCaptcha)
private: private:
int _generaNumber(int number); int _generaNumber(int number);
QString _code;
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); Q_INVOKABLE bool verify(const QString& code);
private:
QString _code;
}; };
#endif // FLUCAPTCHA_H #endif // FLUCAPTCHA_H

View File

@ -1,7 +1,4 @@
#include "FluColorSet.h" #include "FluColorSet.h"
FluColorSet::FluColorSet(QObject *parent) FluColorSet::FluColorSet(QObject *parent):QObject{parent}{
: QObject{parent}
{
} }

View File

@ -1,18 +1,6 @@
#include "FluColors.h" #include "FluColors.h"
FluColors* FluColors::m_instance = nullptr; FluColors::FluColors(QObject *parent):QObject{parent}{
FluColors *FluColors::getInstance()
{
if(FluColors::m_instance == nullptr){
FluColors::m_instance = new FluColors;
}
return FluColors::m_instance;
}
FluColors::FluColors(QObject *parent)
: QObject{parent}
{
Transparent("#00000000"); Transparent("#00000000");
Black("#000000"); Black("#000000");
White("#ffffff"); White("#ffffff");

View File

@ -5,6 +5,7 @@
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
#include "FluColorSet.h" #include "FluColorSet.h"
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h"
/** /**
* @brief The FluColors class * @brief The FluColors class
@ -49,13 +50,9 @@ class FluColors : public QObject
QML_SINGLETON QML_SINGLETON
private: private:
explicit FluColors(QObject *parent = nullptr); explicit FluColors(QObject *parent = nullptr);
static FluColors* m_instance;
public: public:
static FluColors *getInstance(); SINGLETONG(FluColors)
static FluColors *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) static FluColors *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
{
return getInstance();
}
}; };
#endif // FLUCOLORS_H #endif // FLUCOLORS_H

23
src/FluEventBus.cpp Normal file
View File

@ -0,0 +1,23 @@
#include "FluEventBus.h"
FluEvent::FluEvent(QObject *parent):QObject{parent}{
}
FluEventBus::FluEventBus(QObject *parent):QObject{parent}{
}
void FluEventBus::registerEvent(FluEvent* event){
_eventData.append(event);
}
void FluEventBus::unRegisterEvent(FluEvent* event){
_eventData.removeOne(event);
}
void FluEventBus::post(const QString& name,const QMap<QString, QVariant>& data){
foreach (auto event, _eventData) {
if(event->name()==name){
Q_EMIT event->triggered(data);
}
}
}

35
src/FluEventBus.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef FLUEVENTBUS_H
#define FLUEVENTBUS_H
#include <QObject>
#include <QtQml/qqml.h>
#include "stdafx.h"
#include "singleton.h"
class FluEvent : public QObject{
Q_OBJECT
Q_PROPERTY_AUTO(QString,name);
QML_NAMED_ELEMENT(FluEvent)
public:
explicit FluEvent(QObject *parent = nullptr);
Q_SIGNAL void triggered(QMap<QString, QVariant> data);
};
class FluEventBus : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(FluEventBus)
QML_SINGLETON
private:
explicit FluEventBus(QObject *parent = nullptr);
public:
SINGLETONG(FluEventBus)
static FluEventBus *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE void registerEvent(FluEvent* event);
Q_INVOKABLE void unRegisterEvent(FluEvent* event);
Q_INVOKABLE void post(const QString& name,const QMap<QString, QVariant>& params = {});
private:
QList<FluEvent*> _eventData;
};
#endif // FLUEVENTBUS_H

View File

@ -14,9 +14,7 @@
#include "FluApp.h" #include "FluApp.h"
#include "FluTools.h" #include "FluTools.h"
HttpRequest::HttpRequest(QObject *parent) HttpRequest::HttpRequest(QObject *parent):QObject{parent}{
: QObject{parent}
{
} }
QMap<QString, QVariant> HttpRequest::toMap(){ QMap<QString, QVariant> HttpRequest::toMap(){
@ -55,14 +53,10 @@ QString HttpRequest::httpId(){
return FluTools::getInstance()->sha256(QJsonDocument::fromVariant(QVariant(toMap())).toJson(QJsonDocument::Compact)); return FluTools::getInstance()->sha256(QJsonDocument::fromVariant(QVariant(toMap())).toJson(QJsonDocument::Compact));
} }
HttpCallable::HttpCallable(QObject *parent) HttpCallable::HttpCallable(QObject *parent):QObject{parent}{
: QObject{parent}
{
} }
FluHttp::FluHttp(QObject *parent) FluHttp::FluHttp(QObject *parent):QObject{parent}{
: QObject{parent}
{
retry(3); retry(3);
timeout(15000); timeout(15000);
cacheMode(FluHttpType::CacheMode::NoCache); cacheMode(FluHttpType::CacheMode::NoCache);
@ -82,7 +76,9 @@ void FluHttp::cancel(){
} }
} }
void FluHttp::post(HttpRequest* request,HttpCallable* callable){ void FluHttp::post(HttpRequest* r,HttpCallable* c){
auto request = QPointer(r);
auto callable = QPointer(c);
request->method("post"); request->method("post");
auto requestMap = request->toMap(); auto requestMap = request->toMap();
auto httpId = request->httpId(); auto httpId = request->httpId();
@ -143,7 +139,9 @@ void FluHttp::post(HttpRequest* request,HttpCallable* callable){
}); });
} }
void FluHttp::postString(HttpRequest* request,HttpCallable* callable){ void FluHttp::postString(HttpRequest* r,HttpCallable* c){
auto request = QPointer(r);
auto callable = QPointer(c);
request->method("postString"); request->method("postString");
auto requestMap = request->toMap(); auto requestMap = request->toMap();
auto httpId = request->httpId(); auto httpId = request->httpId();
@ -196,7 +194,9 @@ void FluHttp::postString(HttpRequest* request,HttpCallable* callable){
}); });
} }
void FluHttp::postJson(HttpRequest* request,HttpCallable* callable){ void FluHttp::postJson(HttpRequest* r,HttpCallable* c){
auto request = QPointer(r);
auto callable = QPointer(c);
request->method("postJson"); request->method("postJson");
auto requestMap = request->toMap(); auto requestMap = request->toMap();
auto httpId = request->httpId(); auto httpId = request->httpId();
@ -248,7 +248,9 @@ void FluHttp::postJson(HttpRequest* request,HttpCallable* callable){
}); });
} }
void FluHttp::get(HttpRequest* request,HttpCallable* callable){ void FluHttp::get(HttpRequest* r,HttpCallable* c){
auto request = QPointer(r);
auto callable = QPointer(c);
request->method("get"); request->method("get");
auto requestMap = request->toMap(); auto requestMap = request->toMap();
auto httpId = request->httpId(); auto httpId = request->httpId();
@ -299,7 +301,9 @@ void FluHttp::get(HttpRequest* request,HttpCallable* callable){
}); });
} }
void FluHttp::download(HttpRequest* request,HttpCallable* callable){ void FluHttp::download(HttpRequest* r,HttpCallable* c){
auto request = QPointer(r);
auto callable = QPointer(c);
request->method("download"); request->method("download");
auto requestMap = request->toMap(); auto requestMap = request->toMap();
auto httpId = request->httpId(); auto httpId = request->httpId();
@ -535,11 +539,11 @@ void FluHttp::onStart(QPointer<HttpCallable> callable){
} }
} }
void FluHttp::onFinish(QPointer<HttpCallable> callable,HttpRequest* request){ void FluHttp::onFinish(QPointer<HttpCallable> callable,QPointer<HttpRequest> request){
if(callable){ if(callable){
Q_EMIT callable->finish(); Q_EMIT callable->finish();
} }
if(request->parent()->inherits("FluHttp")){ if(request&&request->parent()->inherits("FluHttp")){
request->deleteLater(); request->deleteLater();
} }
} }

View File

@ -53,7 +53,7 @@ private:
bool cacheExists(const QString& httpId); bool cacheExists(const QString& httpId);
QString getCacheFilePath(const QString& httpId); QString getCacheFilePath(const QString& httpId);
void onStart(QPointer<HttpCallable> callable); void onStart(QPointer<HttpCallable> callable);
void onFinish(QPointer<HttpCallable> callable,HttpRequest* request); void onFinish(QPointer<HttpCallable> callable,QPointer<HttpRequest> request);
void onError(QPointer<HttpCallable> callable,int status,QString errorString,QString result); void onError(QPointer<HttpCallable> callable,int status,QString errorString,QString result);
void onSuccess(QPointer<HttpCallable> callable,QString result); void onSuccess(QPointer<HttpCallable> callable,QString result);
void onCache(QPointer<HttpCallable> callable,QString result); void onCache(QPointer<HttpCallable> callable,QString result);

View File

@ -1,7 +1,4 @@
#include "FluHttpInterceptor.h" #include "FluHttpInterceptor.h"
FluHttpInterceptor::FluHttpInterceptor(QObject *parent) FluHttpInterceptor::FluHttpInterceptor(QObject *parent):QObject{parent}{
: QObject{parent}
{
} }

View File

@ -10,9 +10,6 @@ class FluHttpInterceptor : public QObject
QML_NAMED_ELEMENT(FluHttpInterceptor) QML_NAMED_ELEMENT(FluHttpInterceptor)
public: public:
explicit FluHttpInterceptor(QObject *parent = nullptr); explicit FluHttpInterceptor(QObject *parent = nullptr);
signals:
}; };
#endif // FLUHTTPINTERCEPTOR_H #endif // FLUHTTPINTERCEPTOR_H

View File

@ -3,9 +3,7 @@
#include "FluApp.h" #include "FluApp.h"
#include <QCoreApplication> #include <QCoreApplication>
FluRegister::FluRegister(QObject *parent) FluRegister::FluRegister(QObject *parent):QObject{parent}{
: QObject{parent}
{
from(nullptr); from(nullptr);
to(nullptr); to(nullptr);
path(""); path("");

View File

@ -17,25 +17,9 @@ class FluRegister : public QObject
Q_PROPERTY_AUTO(QString,path); Q_PROPERTY_AUTO(QString,path);
public: public:
explicit FluRegister(QObject *parent = nullptr); explicit FluRegister(QObject *parent = nullptr);
/**
* @brief launch 窗口跳转
* @param argument 跳转携带参数
*/
Q_INVOKABLE void launch(const QJsonObject& argument = {}); Q_INVOKABLE void launch(const QJsonObject& argument = {});
/**
* @brief onResult 将结果数据回传到上一个窗口
* @param data 结果数据
*/
Q_INVOKABLE void onResult(const QJsonObject& data = {}); Q_INVOKABLE void onResult(const QJsonObject& data = {});
/**
* @brief result 收到结果数据的信号
* @param data 结果数据
*/
Q_SIGNAL void result(const QJsonObject& data); Q_SIGNAL void result(const QJsonObject& data);
}; };
#endif // FLUREGISTER_H #endif // FLUREGISTER_H

View File

@ -1,19 +1,6 @@
#include "FluTextStyle.h" #include "FluTextStyle.h"
FluTextStyle* FluTextStyle::m_instance = nullptr; FluTextStyle::FluTextStyle(QObject *parent):QObject{parent}{
FluTextStyle *FluTextStyle::getInstance()
{
if(FluTextStyle::m_instance == nullptr){
FluTextStyle::m_instance = new FluTextStyle;
}
return FluTextStyle::m_instance;
}
FluTextStyle::FluTextStyle(QObject *parent)
: QObject{parent}
{
QFont caption; QFont caption;
caption.setPixelSize(12); caption.setPixelSize(12);
Caption(caption); Caption(caption);

View File

@ -5,6 +5,7 @@
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
#include <QFont> #include <QFont>
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h"
class FluTextStyle : public QObject class FluTextStyle : public QObject
{ {
@ -21,13 +22,9 @@ public:
QML_SINGLETON QML_SINGLETON
private: private:
explicit FluTextStyle(QObject *parent = nullptr); explicit FluTextStyle(QObject *parent = nullptr);
static FluTextStyle* m_instance;
public: public:
static FluTextStyle *getInstance(); SINGLETONG(FluTextStyle)
static FluTextStyle *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) static FluTextStyle *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
{
return getInstance();
}
}; };
#endif // FLUTEXTSTYLE_H #endif // FLUTEXTSTYLE_H

View File

@ -1,7 +1,6 @@
#include "FluTheme.h" #include "FluTheme.h"
#include "Def.h" #include <QGuiApplication>
#include "FluColors.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
#include <QStyleHints> #include <QStyleHints>
#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1))) #elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))
@ -10,22 +9,10 @@
#else #else
#include <QPalette> #include <QPalette>
#endif #endif
#include "Def.h"
#include "FluColors.h"
#include <QGuiApplication> FluTheme::FluTheme(QObject *parent):QObject{parent}{
FluTheme* FluTheme::m_instance = nullptr;
FluTheme *FluTheme::getInstance()
{
if(FluTheme::m_instance == nullptr){
FluTheme::m_instance = new FluTheme;
}
return FluTheme::m_instance;
}
FluTheme::FluTheme(QObject *parent)
: QObject{parent}
{
connect(this,&FluTheme::darkModeChanged,this,[=]{ connect(this,&FluTheme::darkModeChanged,this,[=]{
Q_EMIT darkChanged(); Q_EMIT darkChanged();
}); });
@ -37,8 +24,7 @@ FluTheme::FluTheme(QObject *parent)
qApp->installEventFilter(this); qApp->installEventFilter(this);
} }
bool FluTheme::eventFilter(QObject *obj, QEvent *event) bool FluTheme::eventFilter(QObject *obj, QEvent *event){
{
Q_UNUSED(obj); Q_UNUSED(obj);
if (event->type() == QEvent::ApplicationPaletteChange || event->type() == QEvent::ThemeChange) if (event->type() == QEvent::ApplicationPaletteChange || event->type() == QEvent::ThemeChange)
{ {
@ -50,8 +36,7 @@ bool FluTheme::eventFilter(QObject *obj, QEvent *event)
return false; return false;
} }
bool FluTheme::systemDark() bool FluTheme::systemDark(){
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
return (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark); return (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark);
#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1))) #elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))

View File

@ -5,6 +5,7 @@
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
#include "FluColorSet.h" #include "FluColorSet.h"
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h"
/** /**
* @brief The FluTheme class * @brief The FluTheme class
@ -12,49 +13,25 @@
class FluTheme : public QObject class FluTheme : public QObject
{ {
Q_OBJECT Q_OBJECT
/**
* @brief dark 改变窗口夜间样式只读属性可以通过darkMode切换
*/
Q_PROPERTY(bool dark READ dark NOTIFY darkChanged) Q_PROPERTY(bool dark READ dark NOTIFY darkChanged)
/**
* @brief primaryColor 主题颜色
*/
Q_PROPERTY_AUTO(FluColorSet*,primaryColor) Q_PROPERTY_AUTO(FluColorSet*,primaryColor)
/**
* @brief darkMode 夜间模式支持System=0、Light=1、Dark=2
*/
Q_PROPERTY_AUTO(int,darkMode); Q_PROPERTY_AUTO(int,darkMode);
/**
* @brief nativeText 本地渲染文本
*/
Q_PROPERTY_AUTO(bool,nativeText); Q_PROPERTY_AUTO(bool,nativeText);
/**
* @brief 是否开启动画效果
*/
Q_PROPERTY_AUTO(bool,enableAnimation); Q_PROPERTY_AUTO(bool,enableAnimation);
QML_NAMED_ELEMENT(FluTheme) QML_NAMED_ELEMENT(FluTheme)
QML_SINGLETON QML_SINGLETON
private: private:
static FluTheme* m_instance;
explicit FluTheme(QObject *parent = nullptr); explicit FluTheme(QObject *parent = nullptr);
bool eventFilter(QObject *obj, QEvent *event);
bool systemDark();
public: public:
static FluTheme *getInstance(); SINGLETONG(FluTheme)
static FluTheme *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) static FluTheme *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
{
return getInstance();
}
bool dark(); bool dark();
Q_SIGNAL void darkChanged(); Q_SIGNAL void darkChanged();
private: private:
bool _dark; bool _dark;
bool _systemDark; bool _systemDark;
bool eventFilter(QObject *obj, QEvent *event);
bool systemDark();
}; };
#endif // FLUTHEME_H #endif // FLUTHEME_H

View File

@ -1,4 +1,5 @@
#include "FluTools.h" #include "FluTools.h"
#include <QGuiApplication> #include <QGuiApplication>
#include <QClipboard> #include <QClipboard>
#include <QUuid> #include <QUuid>
@ -11,21 +12,7 @@
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QTextDocument> #include <QTextDocument>
FluTools* FluTools::m_instance = nullptr; FluTools::FluTools(QObject *parent):QObject{parent}{
FluTools *FluTools::getInstance()
{
if(FluTools::m_instance == nullptr){
FluTools::m_instance = new FluTools;
}
return FluTools::m_instance;
}
FluTools::FluTools(QObject *parent)
: QObject{parent}
{
} }
void FluTools::clipText(const QString& text){ void FluTools::clipText(const QString& text){
@ -36,8 +23,7 @@ QString FluTools::uuid(){
return QUuid::createUuid().toString(); return QUuid::createUuid().toString();
} }
QString FluTools::readFile(const QString &fileName) QString FluTools::readFile(const QString &fileName){
{
QString content; QString content;
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) { if (file.open(QIODevice::ReadOnly)) {
@ -132,18 +118,15 @@ QColor FluTools::colorAlpha(const QColor& color,qreal alpha){
return QColor(color.red(),color.green(),color.blue(),255*alpha); return QColor(color.red(),color.green(),color.blue(),255*alpha);
} }
QString FluTools::md5(QString text) QString FluTools::md5(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(QString text){
{
return text.toUtf8().toBase64(); return text.toUtf8().toBase64();
} }
QString FluTools::fromBase64(QString text) QString FluTools::fromBase64(QString text){
{
return QByteArray::fromBase64(text.toUtf8()); return QByteArray::fromBase64(text.toUtf8());
} }

View File

@ -5,6 +5,7 @@
#include <QFile> #include <QFile>
#include <QColor> #include <QColor>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
#include "singleton.h"
/** /**
* @brief The FluTools class * @brief The FluTools class
@ -12,187 +13,39 @@
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);
static FluTools* m_instance;
public: public:
static FluTools *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) SINGLETONG(FluTools)
{ static FluTools *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
return getInstance();
}
static FluTools *getInstance();
/**
* @brief qtMajor Qt Major版本
* @return
*/
Q_INVOKABLE int qtMajor(); Q_INVOKABLE int qtMajor();
/**
* @brief qtMajor Qt Minor版本
* @return
*/
Q_INVOKABLE int qtMinor(); Q_INVOKABLE int qtMinor();
/**
* @brief isMacos 是否是Macos系统
* @return
*/
Q_INVOKABLE bool isMacos(); Q_INVOKABLE bool isMacos();
/**
* @brief isLinux 是否是Linux系统
* @return
*/
Q_INVOKABLE bool isLinux(); Q_INVOKABLE bool isLinux();
/**
* @brief isWin 是否是Windows系统
* @return
*/
Q_INVOKABLE bool isWin(); Q_INVOKABLE bool isWin();
/**
* @brief clipText 将字符串添加到剪切板
* @param text
*/
Q_INVOKABLE void clipText(const QString& text); Q_INVOKABLE void clipText(const QString& text);
/**
* @brief uuid 获取uuid
* @return
*/
Q_INVOKABLE QString uuid(); Q_INVOKABLE QString uuid();
/**
* @brief readFile 读取文件内容
* @param fileName
* @return
*/
Q_INVOKABLE QString readFile(const QString& fileName); Q_INVOKABLE QString readFile(const QString& fileName);
/**
* @brief setQuitOnLastWindowClosed 设置关闭最后一个窗口是否退出程序
* @param val
*/
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val); Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
/**
* @brief setOverrideCursor 设置全局鼠标样式
* @param shape
*/
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape); Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
/**
* @brief restoreOverrideCursor 还原全局鼠标样式
*/
Q_INVOKABLE void restoreOverrideCursor(); Q_INVOKABLE void restoreOverrideCursor();
/**
* @brief html2PlantText 将html转换成纯文本
* @param html
*/
Q_INVOKABLE QString html2PlantText(const QString& html); Q_INVOKABLE QString html2PlantText(const QString& html);
/**
* @brief toLocalPath 获取文件路径可以去掉windows系统下的file:///macos下的file://
* @param url
* @return 返回文件路径
*/
Q_INVOKABLE QString toLocalPath(const QUrl& url); Q_INVOKABLE QString toLocalPath(const QUrl& url);
/**
* @brief deleteItem 销毁Item对象
* @param p
*/
Q_INVOKABLE void deleteItem(QObject *p); Q_INVOKABLE void deleteItem(QObject *p);
/**
* @brief getFileNameByUrl
* @param url
* @return
*/
Q_INVOKABLE QString getFileNameByUrl(const QUrl& url); Q_INVOKABLE QString getFileNameByUrl(const QUrl& url);
/**
* @brief getVirtualGeometry
* @return
*/
Q_INVOKABLE QRect getVirtualGeometry(); Q_INVOKABLE QRect getVirtualGeometry();
/**
* @brief getApplicationDirPath
* @return
*/
Q_INVOKABLE QString getApplicationDirPath(); Q_INVOKABLE QString getApplicationDirPath();
/**
* @brief getUrlByFilePath
* @param path
* @return
*/
Q_INVOKABLE QUrl getUrlByFilePath(const QString& path); Q_INVOKABLE QUrl getUrlByFilePath(const QString& path);
/**
* @brief colorAlpha
* @param color
* @param alpha
* @return
*/
Q_INVOKABLE QColor colorAlpha(const QColor&,qreal alpha); Q_INVOKABLE QColor colorAlpha(const QColor&,qreal alpha);
/**
* @brief md5
* @param text
* @return
*/
Q_INVOKABLE QString md5(QString text); Q_INVOKABLE QString md5(QString text);
/**
* @brief sha256
* @param text
* @return
*/
Q_INVOKABLE QString sha256(QString text); Q_INVOKABLE QString sha256(QString text);
/**
* @brief toBase64
* @param text
* @return
*/
Q_INVOKABLE QString toBase64(QString text); Q_INVOKABLE QString toBase64(QString text);
/**
* @brief fromBase64
* @param text
* @return
*/
Q_INVOKABLE QString fromBase64(QString text); Q_INVOKABLE QString fromBase64(QString text);
/**
* @brief removeDir
* @param dirPath
* @return
*/
Q_INVOKABLE bool removeDir(QString dirPath); Q_INVOKABLE bool removeDir(QString dirPath);
/**
* @brief removeFile
* @param filePath
* @return
*/
Q_INVOKABLE bool removeFile(QString filePath); Q_INVOKABLE bool removeFile(QString filePath);
/**
* @brief showFileInFolder
* @param path
*/
Q_INVOKABLE void showFileInFolder(QString path); Q_INVOKABLE void showFileInFolder(QString path);
}; };
#endif // FLUTOOLS_H #endif // FLUTOOLS_H

114
src/FluViewModel.cpp Normal file
View File

@ -0,0 +1,114 @@
#include "FluViewModel.h"
#include <QQuickItem>
#include "Def.h"
Model::Model(QObject *parent):QObject{parent}{
}
Model::~Model(){
}
ViewModelManager::ViewModelManager(QObject *parent): QObject{parent}{
}
void ViewModelManager::insertViewModel(FluViewModel* value){
_viewmodel.append(value);
}
void ViewModelManager::deleteViewModel(FluViewModel* value){
_viewmodel.removeOne(value);
}
QObject* ViewModelManager::getModel(const QString& key){
return _data.value(key);
}
void ViewModelManager::insert(const QString& key,QObject* value){
_data.insert(key,value);
}
bool ViewModelManager::exist(const QString& key){
return _data.contains(key);
}
void ViewModelManager::refreshViewModel(FluViewModel* viewModel,QString key,QVariant value){
foreach (auto item, _viewmodel) {
if(item->getKey() == viewModel->getKey()){
item->setProperty(key.toStdString().c_str(),value);
}
}
}
PropertyObserver::PropertyObserver(QString name,QObject* model,QObject *parent):QObject{parent}{
_name = name;
_model = model;
_property = QQmlProperty(parent,_name);
_property.connectNotifySignal(this,SLOT(_propertyChange()));
}
PropertyObserver::~PropertyObserver(){
}
void PropertyObserver::_propertyChange(){
auto value = _property.read();
_model->setProperty(_name.toStdString().c_str(),value);
ViewModelManager::getInstance()->refreshViewModel((FluViewModel*)parent(),_name,value);
}
FluViewModel::FluViewModel(QObject *parent):QObject{parent}{
ViewModelManager::getInstance()->insertViewModel(this);
scope(FluViewModelType::Scope::Window);
}
FluViewModel::~FluViewModel(){
ViewModelManager::getInstance()->deleteViewModel(this);
}
void FluViewModel::classBegin(){
}
void FluViewModel::componentComplete(){
auto o = parent();
while (nullptr != o) {
_window = o;
o = o->parent();
}
const QMetaObject* obj = metaObject();
if(_scope == FluViewModelType::Scope::Window){
_key = property("objectName_").toString()+QString::number(reinterpret_cast<qulonglong>(_window), 16);
}else{
_key = property("objectName").toString();
}
QObject * model;
if(!ViewModelManager::getInstance()->exist(_key)){
if(_scope == FluViewModelType::Scope::Window){
model = new Model(_window);
}else{
model = new Model();
}
Q_EMIT initData();
for (int i = 0; i < obj->propertyCount(); ++i) {
const QMetaProperty property = obj->property(i);
QString propertyName = property.name();
auto value = property.read(this);
model->setProperty(propertyName.toStdString().c_str(),value);
new PropertyObserver(propertyName,model,this);
}
ViewModelManager::getInstance()->insert(_key,model);
}else{
model = ViewModelManager::getInstance()->getModel(_key);
for (int i = 0; i < obj->propertyCount(); ++i) {
const QMetaProperty property = obj->property(i);
QString propertyName = property.name();
new PropertyObserver(propertyName,model,this);
}
}
foreach (auto key, model->dynamicPropertyNames()) {
setProperty(key,model->property(key));
}
}
QString FluViewModel::getKey(){
return _key;
}

68
src/FluViewModel.h Normal file
View File

@ -0,0 +1,68 @@
#ifndef FLUVIEWMODEL_H
#define FLUVIEWMODEL_H
#include <QQuickItem>
#include <QtQml/qqml.h>
#include <QQuickWindow>
#include <QQmlProperty>
#include "stdafx.h"
#include "singleton.h"
class Model : public QObject{
Q_OBJECT
public:
explicit Model(QObject *parent = nullptr);
~Model();
};
class FluViewModel : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY_AUTO(int,scope);
Q_PROPERTY_AUTO(QObject*,target);
QML_NAMED_ELEMENT(FluViewModel)
public:
explicit FluViewModel(QObject *parent = nullptr);
~FluViewModel();
void classBegin() override;
void componentComplete() override;
Q_SIGNAL void initData();
QString getKey();
private:
QObject* _window = nullptr;
QString _key;
};
class PropertyObserver: public QObject{
Q_OBJECT
public:
explicit PropertyObserver(QString name,QObject* model,QObject *parent = nullptr);
~PropertyObserver();
private:
Q_SLOT void _propertyChange();
private:
QString _name;
QQmlProperty _property;
QObject* _model;
};
class ViewModelManager:public QObject{
Q_OBJECT
private:
explicit ViewModelManager(QObject *parent = nullptr);
public:
SINGLETONG(ViewModelManager)
bool exist(const QString& key);
void insert(const QString& key,QObject* value);
QObject* getModel(const QString& key);
void insertViewModel(FluViewModel* value);
void deleteViewModel(FluViewModel* value);
void refreshViewModel(FluViewModel* viewModel,QString key,QVariant value);
private:
QMap<QString,QObject*> _data;
QList<FluViewModel*> _viewmodel;
};
#endif // FLUVIEWMODEL_H

View File

@ -1,7 +1,6 @@
#include "FluWatermark.h" #include "FluWatermark.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);
@ -16,8 +15,7 @@ FluWatermark::FluWatermark(QQuickItem* parent) : QQuickPaintedItem(parent)
connect(this,&FluWatermark::textSizeChanged,this,[=]{update();}); connect(this,&FluWatermark::textSizeChanged,this,[=]{update();});
} }
void FluWatermark::paint(QPainter* painter) void FluWatermark::paint(QPainter* painter){
{
QFont font; QFont font;
font.setPixelSize(_textSize); font.setPixelSize(_textSize);
painter->setFont(font); painter->setFont(font);

190
src/FluentUI.cpp Normal file
View File

@ -0,0 +1,190 @@
#include "FluentUI.h"
#include <QGuiApplication>
#include "WindowHelper.h"
#include "Def.h"
#include "FluApp.h"
#include "FluColors.h"
#include "FluTheme.h"
#include "FluTools.h"
#include "FluTextStyle.h"
#include "FluHttp.h"
#include "FluHttpInterceptor.h"
#include "FluWatermark.h"
#include "FluCaptcha.h"
#include "FluEventBus.h"
#include "FluViewModel.h"
#include "Screenshot.h"
#include "QRCode.h"
int major = 1;
int minor = 0;
auto uri = "FluentUI";
FluentUI* FluentUI::m_instance = nullptr;
FluentUI *FluentUI::getInstance()
{
if(FluentUI::m_instance == nullptr){
FluentUI::m_instance = new FluentUI;
}
return FluentUI::m_instance;
}
void FluentUI::registerTypes(QQmlEngine *engine){
initializeEngine(engine,uri);
registerTypes(uri);
}
void FluentUI::registerTypes(const char *uri){
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
Q_INIT_RESOURCE(fluentui);
#endif
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
qmlRegisterType<QRCode>(uri,major,minor,"QRCode");
qmlRegisterType<FluCaptcha>(uri,major,minor,"FluCaptcha");
qmlRegisterType<FluWatermark>(uri,major,minor,"FluWatermark");
qmlRegisterType<ScreenshotBackground>(uri,major,minor,"ScreenshotBackground");
qmlRegisterType<Screenshot>(uri,major,minor,"Screenshot");
qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet");
qmlRegisterType<FluHttpInterceptor>(uri,major,minor,"FluHttpInterceptor");
qmlRegisterType<FluHttp>(uri,major,minor,"FluHttp");
qmlRegisterType<HttpCallable>(uri,major,minor,"HttpCallable");
qmlRegisterType<HttpRequest>(uri,major,minor,"HttpRequest");
qmlRegisterType<FluEvent>(uri,major,minor,"FluEvent");
qmlRegisterType<FluViewModel>(uri,major,minor,"FluViewModel");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/ColorPicker.qml"),uri,major,minor,"ColorPicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/Checkerboard.qml"),uri,major,minor,"Checkerboard");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/ColorSlider.qml"),uri,major,minor,"ColorSlider");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/NumberBox.qml"),uri,major,minor,"NumberBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/PanelBorder.qml"),uri,major,minor,"PanelBorder");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/SBPicker.qml"),uri,major,minor,"SBPicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluAcrylic.qml"),uri,major,minor,"FluAcrylic");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluAppBar.qml"),uri,major,minor,"FluAppBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluArea.qml"),uri,major,minor,"FluArea");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluAutoSuggestBox.qml"),uri,major,minor,"FluAutoSuggestBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluBadge.qml"),uri,major,minor,"FluBadge");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluBreadcrumbBar.qml"),uri,major,minor,"FluBreadcrumbBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluButton.qml"),uri,major,minor,"FluButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluCalendarPicker.qml"),uri,major,minor,"FluCalendarPicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluCalendarView.qml"),uri,major,minor,"FluCalendarView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluCarousel.qml"),uri,major,minor,"FluCarousel");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluChart.qml"),uri,major,minor,"FluChart");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluCheckBox.qml"),uri,major,minor,"FluCheckBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluColorPicker.qml"),uri,major,minor,"FluColorPicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluColorView.qml"),uri,major,minor,"FluColorView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluComboBox.qml"),uri,major,minor,"FluComboBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluContentDialog.qml"),uri,major,minor,"FluContentDialog");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluContentPage.qml"),uri,major,minor,"FluContentPage");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluControl.qml"),uri,major,minor,"FluControl");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluCopyableText.qml"),uri,major,minor,"FluCopyableText");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluDatePicker.qml"),uri,major,minor,"FluDatePicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluDivider.qml"),uri,major,minor,"FluDivider");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluDropDownButton.qml"),uri,major,minor,"FluDropDownButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluExpander.qml"),uri,major,minor,"FluExpander");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluFilledButton.qml"),uri,major,minor,"FluFilledButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluFlipView.qml"),uri,major,minor,"FluFlipView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluFocusRectangle.qml"),uri,major,minor,"FluFocusRectangle");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluIcon.qml"),uri,major,minor,"FluIcon");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluIconButton.qml"),uri,major,minor,"FluIconButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluImage.qml"),uri,major,minor,"FluImage");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluInfoBar.qml"),uri,major,minor,"FluInfoBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluItem.qml"),uri,major,minor,"FluItem");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluItemDelegate.qml"),uri,major,minor,"FluItemDelegate");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMenu.qml"),uri,major,minor,"FluMenu");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMenuBar.qml"),uri,major,minor,"FluMenuBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMenuBarItem.qml"),uri,major,minor,"FluMenuBarItem");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMenuItem.qml"),uri,major,minor,"FluMenuItem");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMenuSeparator.qml"),uri,major,minor,"FluMenuSeparator");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMultilineTextBox.qml"),uri,major,minor,"FluMultilineTextBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluNavigationView.qml"),uri,major,minor,"FluNavigationView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluObject.qml"),uri,major,minor,"FluObject");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPage.qml"),uri,major,minor,"FluPage");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPagination.qml"),uri,major,minor,"FluPagination");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPaneItem.qml"),uri,major,minor,"FluPaneItem");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPaneItemEmpty.qml"),uri,major,minor,"FluPaneItemEmpty");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPaneItemExpander.qml"),uri,major,minor,"FluPaneItemExpander");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPaneItemHeader.qml"),uri,major,minor,"FluPaneItemHeader");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPaneItemSeparator.qml"),uri,major,minor,"FluPaneItemSeparator");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPasswordBox.qml"),uri,major,minor,"FluPasswordBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPivot.qml"),uri,major,minor,"FluPivot");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPivotItem.qml"),uri,major,minor,"FluPivotItem");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPopup.qml"),uri,major,minor,"FluPopup");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluProgressBar.qml"),uri,major,minor,"FluProgressBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluProgressRing.qml"),uri,major,minor,"FluProgressRing");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluQRCode.qml"),uri,major,minor,"FluQRCode");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRadioButton.qml"),uri,major,minor,"FluRadioButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRadioButtons.qml"),uri,major,minor,"FluRadioButtons");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRatingControl.qml"),uri,major,minor,"FluRatingControl");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRectangle.qml"),uri,major,minor,"FluRectangle");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRemoteLoader.qml"),uri,major,minor,"FluRemoteLoader");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluScreenshot.qml"),uri,major,minor,"FluScreenshot");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluScrollBar.qml"),uri,major,minor,"FluScrollBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluScrollIndicator.qml"),uri,major,minor,"FluScrollIndicator");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluScrollablePage.qml"),uri,major,minor,"FluScrollablePage");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluShadow.qml"),uri,major,minor,"FluShadow");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluSlider.qml"),uri,major,minor,"FluSlider");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluSpinBox.qml"),uri,major,minor,"FluSpinBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluStatusView.qml"),uri,major,minor,"FluStatusView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTabView.qml"),uri,major,minor,"FluTabView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTableModelColumn.qml"),uri,major,minor,"FluTableModelColumn");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTableView.qml"),uri,major,minor,"FluTableView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluText.qml"),uri,major,minor,"FluText");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTextBox.qml"),uri,major,minor,"FluTextBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTextBoxBackground.qml"),uri,major,minor,"FluTextBoxBackground");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTextBoxMenu.qml"),uri,major,minor,"FluTextBoxMenu");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTextButton.qml"),uri,major,minor,"FluTextButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTimePicker.qml"),uri,major,minor,"FluTimePicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTimeline.qml"),uri,major,minor,"FluTimeline");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluToggleButton.qml"),uri,major,minor,"FluToggleButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluToggleSwitch.qml"),uri,major,minor,"FluToggleSwitch");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTooltip.qml"),uri,major,minor,"FluTooltip");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTour.qml"),uri,major,minor,"FluTour");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTreeView.qml"),uri,major,minor,"FluTreeView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluWindow.qml"),uri,major,minor,"FluWindow");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRangeSlider.qml"),uri,major,minor,"FluRangeSlider");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluStaggeredView.qml"),uri,major,minor,"FluStaggeredView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluProgressButton.qml"),uri,major,minor,"FluProgressButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluLoadingButton.qml"),uri,major,minor,"FluLoadingButton");
qmlRegisterUncreatableMetaObject(Fluent_Awesome::staticMetaObject, uri,major,minor,"FluentIcons", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluHttpType::staticMetaObject, uri,major,minor,"FluHttpType", "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(FluWindowType::staticMetaObject, uri,major,minor,"FluWindowType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTreeViewType::staticMetaObject, uri,major,minor,"FluTreeViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluStatusViewType::staticMetaObject, uri,major,minor,"FluStatusViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluContentDialogType::staticMetaObject, uri,major,minor,"FluContentDialogType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTimePickerType::staticMetaObject, uri,major,minor,"FluTimePickerType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluCalendarViewType::staticMetaObject, uri,major,minor,"FluCalendarViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTabViewType::staticMetaObject, uri,major,minor,"FluTabViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluNavigationViewType::staticMetaObject, uri,major,minor,"FluNavigationViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTimelineType::staticMetaObject, uri,major,minor,"FluTimelineType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluScreenshotType::staticMetaObject, uri,major,minor,"FluScreenshotType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluViewModelType::staticMetaObject, uri,major,minor,"FluViewModelType", "Access to enums & flags only");
qmlRegisterModule(uri,major,minor);
}
void FluentUI::initializeEngine(QQmlEngine *engine, const char *uri){
#ifdef Q_OS_WIN
QFont font;
font.setFamily("Microsoft YaHei");
QGuiApplication::setFont(font);
#endif
FluApp* app = FluApp::getInstance();
engine->rootContext()->setContextProperty("FluApp",app);
FluColors* colors = FluColors::getInstance();
engine->rootContext()->setContextProperty("FluColors",colors);
FluTheme* theme = FluTheme::getInstance();
engine->rootContext()->setContextProperty("FluTheme",theme);
FluTools* tools = FluTools::getInstance();
engine->rootContext()->setContextProperty("FluTools",tools);
FluTextStyle* textStyle = FluTextStyle::getInstance();
engine->rootContext()->setContextProperty("FluTextStyle",textStyle);
FluEventBus* eventBus = FluEventBus::getInstance();
engine->rootContext()->setContextProperty("FluEventBus",eventBus);
engine->addImportPath("qrc:/qt/qml");
}

19
src/FluentUI.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef FLUENTUI_H
#define FLUENTUI_H
#include <QObject>
#include <QQmlEngine>
class FluentUI : public QObject
{
Q_OBJECT
public:
static FluentUI *getInstance();
Q_DECL_EXPORT void registerTypes(QQmlEngine *engine);
void registerTypes(const char *uri);
void initializeEngine(QQmlEngine *engine, const char *uri);
private:
static FluentUI* m_instance;
};
#endif // FLUENTUI_H

View File

@ -2,17 +2,13 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QMetaMethod> #include <QMetaMethod>
std::shared_ptr<MainThread> MainThread::createShared(QObject* bindObject) std::shared_ptr<MainThread> MainThread::createShared(QObject* bindObject){
{
return std::shared_ptr<MainThread>(new MainThread(bindObject), [=](QObject* mainThread) { return std::shared_ptr<MainThread>(new MainThread(bindObject), [=](QObject* mainThread) {
mainThread->deleteLater(); mainThread->deleteLater();
}); });
} }
MainThread::MainThread(QObject* bindObject) MainThread::MainThread(QObject* bindObject): _bindObject(bindObject), _ignoreNullObject(bindObject == nullptr){
: mBindObject(bindObject)
, mIgnoreNullObject(bindObject == nullptr)
{
qRegisterMetaType<std::function<void()>>("std::function<void()>"); qRegisterMetaType<std::function<void()>>("std::function<void()>");
auto mainUIThread = qApp->thread(); auto mainUIThread = qApp->thread();
if (this->thread() != mainUIThread) if (this->thread() != mainUIThread)
@ -21,18 +17,15 @@ MainThread::MainThread(QObject* bindObject)
} }
} }
MainThread::~MainThread() MainThread::~MainThread(){
{
} }
void MainThread::post(std::function<void()> func) void MainThread::post(std::function<void()> func){
{
QMetaObject::invokeMethod(createShared().get(), "mainThreadSlot", Q_ARG(std::function<void()>, func)); QMetaObject::invokeMethod(createShared().get(), "mainThreadSlot", Q_ARG(std::function<void()>, func));
} }
void MainThread::mainThreadSlot(std::function<void()> func) void MainThread::mainThreadSlot(std::function<void()> func){
{ if ((_ignoreNullObject || _bindObject) && func)
if ((mIgnoreNullObject || mBindObject) && func)
{ {
func(); func();
} }

View File

@ -9,7 +9,6 @@ class MainThread : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static void post(std::function<void()> func); static void post(std::function<void()> func);
~MainThread(); ~MainThread();
private: private:
@ -18,7 +17,7 @@ private slots:
void mainThreadSlot(std::function<void()> func); void mainThreadSlot(std::function<void()> func);
private: private:
MainThread(QObject* bindObject = nullptr); MainThread(QObject* bindObject = nullptr);
QPointer<QObject> mBindObject; QPointer<QObject> _bindObject;
bool mIgnoreNullObject{ false }; bool _ignoreNullObject{ false };
}; };
#endif // MAINTHREAD_H #endif // MAINTHREAD_H

View File

@ -6,8 +6,7 @@
using namespace ZXing; using namespace ZXing;
QRCode::QRCode(QQuickItem* parent) : QQuickPaintedItem(parent) QRCode::QRCode(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);
@ -24,8 +23,7 @@ QRCode::QRCode(QQuickItem* parent) : QQuickPaintedItem(parent)
} }
void QRCode::paint(QPainter* painter) void QRCode::paint(QPainter* painter){
{
if(_text.isEmpty()){ if(_text.isEmpty()){
return; return;
} }

View File

@ -17,7 +17,6 @@ class QRCode : public QQuickPaintedItem
public: public:
explicit QRCode(QQuickItem *parent = nullptr); explicit QRCode(QQuickItem *parent = nullptr);
void paint(QPainter* painter) override; void paint(QPainter* painter) override;
}; };
#endif // QRCODE_H #endif // QRCODE_H

View File

@ -23,7 +23,6 @@ Rectangle {
radius: 4 radius: 4
border.width: 1 border.width: 1
border.color: dividerColor border.color: dividerColor
Component.onCompleted: { Component.onCompleted: {
if(current){ if(current){
const date = current const date = current
@ -33,7 +32,6 @@ Rectangle {
text_date.text = year+"-"+(month+1)+"-"+day text_date.text = year+"-"+(month+1)+"-"+day
} }
} }
MouseArea{ MouseArea{
id:mouse_area id:mouse_area
hoverEnabled: true hoverEnabled: true

View File

@ -7,6 +7,7 @@ Item {
property var date: new Date() property var date: new Date()
property var currentDate : new Date() property var currentDate : new Date()
property var toDay: new Date() property var toDay: new Date()
property int radius: 5
signal dateClicked(var date) signal dateClicked(var date)
id:control id:control
width: 280 width: 280
@ -214,10 +215,7 @@ Item {
} }
FluArea{ FluArea{
anchors.fill: parent anchors.fill: parent
radius: 5 radius: control.radius
FluShadow{
radius: 5
}
Rectangle{ Rectangle{
id:layout_divider id:layout_divider
height: 1 height: 1

View File

@ -10,7 +10,7 @@ Canvas {
property var chartOptions property var chartOptions
property double chartAnimationProgress: 0.1 property double chartAnimationProgress: 0.1
property int animationEasingType: Easing.InOutExpo property int animationEasingType: Easing.InOutExpo
property double animationDuration: 500 property double animationDuration: 0
property var memorizedContext property var memorizedContext
property var memorizedData property var memorizedData
property var memorizedOptions property var memorizedOptions
@ -89,7 +89,7 @@ Canvas {
control.requestPaint(); control.requestPaint();
} }
onPaint: { onPaint: {
if(control.getContext('2d') !== null && memorizedContext !== control.getContext('2d') || memorizedData !== control.chartData || memorizedOptions !== control.chartOptions) { if(control.getContext('2d') !== null && memorizedContext !== control.getContext('2d') || memorizedData !== control.chartData || memorizedOptions !== control.chartOptions) {
var ctx = control.getContext('2d'); var ctx = control.getContext('2d');
jsChart = Chart.build(ctx, { jsChart = Chart.build(ctx, {

View File

@ -4,15 +4,14 @@ import FluentUI 1.0
import "ColorPicker" import "ColorPicker"
Item { Item {
id:control
property alias colorValue: color_picker.colorValue property alias colorValue: color_picker.colorValue
property int radius: 5
width: color_picker.width+10 width: color_picker.width+10
height: color_picker.height height: color_picker.height
FluArea{ FluArea{
anchors.fill: parent anchors.fill: parent
radius: 5 radius: control.radius
FluShadow{
radius: 5
}
ColorPicker{ ColorPicker{
id:color_picker id:color_picker
} }

View File

@ -38,7 +38,6 @@ FluPopup {
right: parent.right right: parent.right
} }
} }
Flickable{ Flickable{
id:sroll_message id:sroll_message
contentWidth: width contentWidth: width
@ -47,11 +46,10 @@ FluPopup {
left: parent.left left: parent.left
right: parent.right right: parent.right
} }
boundsBehavior:Flickable.StopAtBounds
contentHeight: text_message.height contentHeight: text_message.height
clip: true
height: Math.min(text_message.height,300) height: Math.min(text_message.height,300)
ScrollBar.vertical: FluScrollBar {} ScrollBar.vertical: FluScrollBar {}
FluText{ FluText{
id:text_message id:text_message
font: FluTextStyle.Body font: FluTextStyle.Body
@ -63,9 +61,7 @@ FluPopup {
rightPadding: 20 rightPadding: 20
bottomPadding: 14 bottomPadding: 14
} }
} }
Rectangle{ Rectangle{
id:layout_actions id:layout_actions
height: 68 height: 68
@ -140,4 +136,3 @@ FluPopup {
} }
} }
} }

View File

@ -0,0 +1,40 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
FluButton {
property bool loading: false
id: control
disabled: loading
contentItem: Row{
spacing: 6
FluText {
text: control.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font: control.font
color: control.textColor
anchors.verticalCenter: parent.verticalCenter
}
Item{
width: control.loading ? 16 : 0
height: 16
anchors.verticalCenter: parent.verticalCenter
visible: width!==0
clip: true
Behavior on width {
enabled: FluTheme.enableAnimation
NumberAnimation{
duration: 167
easing.type: Easing.OutCubic
}
}
FluProgressRing{
width: 16
height: 16
strokeWidth:3
anchors.centerIn: parent
}
}
}
}

View File

@ -20,8 +20,8 @@ TextArea{
} }
font:FluTextStyle.Body font:FluTextStyle.Body
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
padding: 8 padding: 7
leftPadding: padding+2 leftPadding: padding+4
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
selectedTextColor: color selectedTextColor: color
selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6) selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6)

View File

@ -124,7 +124,6 @@ Item {
Component{ Component{
id:com_panel_item_header id:com_panel_item_header
Item{ Item{
clip: true
height: { height: {
if(model.parent){ if(model.parent){
return model.parent.isExpand ? 30 : 0 return model.parent.isExpand ? 30 : 0
@ -154,7 +153,6 @@ Item {
Item{ Item{
height: 38 height: 38
width: layout_list.width width: layout_list.width
clip: true
FluControl{ FluControl{
id:item_control id:item_control
anchors{ anchors{
@ -378,7 +376,6 @@ Item {
duration: 83 duration: 83
} }
} }
clip: true
height: { height: {
if(model.parent){ if(model.parent){
return model.parent.isExpand ? 38 : 0 return model.parent.isExpand ? 38 : 0
@ -409,6 +406,31 @@ Item {
Drag.hotSpot.x: item_control.width / 2 Drag.hotSpot.x: item_control.width / 2
Drag.hotSpot.y: item_control.height / 2 Drag.hotSpot.y: item_control.height / 2
Drag.dragType: Drag.Automatic Drag.dragType: Drag.Automatic
onClicked:{
if(type === 0){
if(model.onTapListener){
model.onTapListener()
}else{
nav_list.currentIndex = _idx
layout_footer.currentIndex = -1
model.tap()
if(d.isMinimal || d.isCompact){
d.enableNavigationPanel = false
}
}
}else{
if(model.onTapListener){
model.onTapListener()
}else{
nav_list.currentIndex = nav_list.count-layout_footer.count+_idx
layout_footer.currentIndex = _idx
model.tap()
if(d.isMinimal || d.isCompact){
d.enableNavigationPanel = false
}
}
}
}
MouseArea{ MouseArea{
id:item_mouse id:item_mouse
anchors.fill: parent anchors.fill: parent
@ -433,29 +455,7 @@ Item {
loader_item_menu.item.popup(); loader_item_menu.item.popup();
} }
}else{ }else{
if(type === 0){ item_control.clicked()
if(model.onTapListener){
model.onTapListener()
}else{
nav_list.currentIndex = _idx
layout_footer.currentIndex = -1
model.tap()
if(d.isMinimal || d.isCompact){
d.enableNavigationPanel = false
}
}
}else{
if(model.onTapListener){
model.onTapListener()
}else{
nav_list.currentIndex = nav_list.count-layout_footer.count+_idx
layout_footer.currentIndex = _idx
model.tap()
if(d.isMinimal || d.isCompact){
d.enableNavigationPanel = false
}
}
}
} }
} }
} }

View File

@ -20,8 +20,8 @@ TextField{
return normalColor return normalColor
} }
font:FluTextStyle.Body font:FluTextStyle.Body
padding: 8 padding: 7
leftPadding: padding+2 leftPadding: padding+4
echoMode:btn_reveal.pressed ? TextField.Normal : TextField.Password echoMode:btn_reveal.pressed ? TextField.Normal : TextField.Password
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6) selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6)
@ -36,22 +36,9 @@ TextField{
return placeholderNormalColor return placeholderNormalColor
} }
selectByMouse: true selectByMouse: true
rightPadding: icon_end.visible ? 50 : 30
background: FluTextBoxBackground{ background: FluTextBoxBackground{
inputItem: control inputItem: control
implicitWidth: 240 implicitWidth: 240
FluIcon{
id:icon_end
iconSource: control.iconSource
iconSize: 15
opacity: 0.5
visible: control.iconSource != 0
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 5
}
}
} }
Keys.onEnterPressed: (event)=> d.handleCommit(event) Keys.onEnterPressed: (event)=> d.handleCommit(event)
Keys.onReturnPressed:(event)=> d.handleCommit(event) Keys.onReturnPressed:(event)=> d.handleCommit(event)
@ -65,16 +52,16 @@ TextField{
id:btn_reveal id:btn_reveal
iconSource:FluentIcons.RevealPasswordMedium iconSource:FluentIcons.RevealPasswordMedium
iconSize: 10 iconSize: 10
width: 20 width: 30
height: 20 height: 20
verticalPadding: 0 verticalPadding: 0
horizontalPadding: 0 horizontalPadding: 0
opacity: 0.5 iconColor: FluTheme.dark ? Qt.rgba(222/255,222/255,222/255,1) : Qt.rgba(97/255,97/255,97/255,1)
visible: control.text !== "" visible: control.text !== ""
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
right: parent.right right: parent.right
rightMargin: icon_end.visible ? 25 : 5 rightMargin: 5
} }
} }
FluTextBoxMenu{ FluTextBoxMenu{

View File

@ -2,30 +2,32 @@ import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import FluentUI 1.0 import FluentUI 1.0
Item { Page {
default property alias content: d.children default property alias content: d.children
property alias currentIndex: nav_list.currentIndex property alias currentIndex: nav_list.currentIndex
property color normalColor: FluTheme.dark ? FluColors.Grey120 : FluColors.Grey120 property color textNormalColor: FluTheme.dark ? FluColors.Grey120 : FluColors.Grey120
property color hoverColor: FluTheme.dark ? FluColors.Grey10 : FluColors.Black property color textHoverColor: FluTheme.dark ? FluColors.Grey10 : FluColors.Black
property int textSize: 28
property bool textBold: true
property int textSpacing: 10
property int headerSpacing: 20
property int headerHeight: 40
id:control id:control
width: 400 width: 400
height: 300 height: 300
implicitHeight: height implicitHeight: height
implicitWidth: width implicitWidth: width
MouseArea{
anchors.fill: parent
preventStealing: true
}
FluObject{ FluObject{
id:d id:d
property int tabY: control.headerHeight/2+control.textSize/2 + 3
} }
ListView{ background:Item{}
header:ListView{
id:nav_list id:nav_list
height: 40 implicitHeight: control.headerHeight
width: control.width implicitWidth: control.width
model:d.children model:d.children
clip: true spacing: control.headerSpacing
spacing: 20
interactive: false interactive: false
orientation: ListView.Horizontal orientation: ListView.Horizontal
highlightMoveDuration: FluTheme.enableAnimation ? 167 : 0 highlightMoveDuration: FluTheme.enableAnimation ? 167 : 0
@ -36,7 +38,7 @@ Item {
radius: 1.5 radius: 1.5
color: FluTheme.primaryColor.dark color: FluTheme.primaryColor.dark
width: nav_list.currentItem ? nav_list.currentItem.width : 0 width: nav_list.currentItem ? nav_list.currentItem.width : 0
y:37 y:d.tabY
Behavior on width { Behavior on width {
enabled: FluTheme.enableAnimation enabled: FluTheme.enableAnimation
NumberAnimation{ NumberAnimation{
@ -50,18 +52,25 @@ Item {
id:item_button id:item_button
width: item_title.width width: item_title.width
height: nav_list.height height: nav_list.height
focusPolicy:Qt.TabFocus
background:Item{ background:Item{
FluFocusRectangle{
anchors.margins: -4
visible: item_button.activeFocus
radius:4
}
} }
contentItem: Item{ contentItem: Item{
FluText { FluText {
id:item_title id:item_title
font: FluTextStyle.Title
text: modelData.title text: modelData.title
anchors.centerIn: parent anchors.centerIn: parent
font.pixelSize: control.textSize
font.bold: control.textBold
color: { color: {
if(item_button.hovered) if(item_button.hovered)
return hoverColor return textHoverColor
return normalColor return textNormalColor
} }
} }
} }
@ -72,13 +81,7 @@ Item {
} }
Item{ Item{
id:container id:container
anchors{ anchors.fill: parent
top: nav_list.bottom
topMargin: 10
left: parent.left
right: parent.right
bottom: parent.bottom
}
Repeater{ Repeater{
model:d.children model:d.children
Loader{ Loader{

View File

@ -13,18 +13,115 @@ T.ScrollBar {
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding) implicitContentHeight + topPadding + bottomPadding)
padding: 2
visible: control.policy !== T.ScrollBar.AlwaysOff visible: control.policy !== T.ScrollBar.AlwaysOff
minimumSize: Math.max(orientation === Qt.Horizontal ? height / width : width / height,0.3) minimumSize: Math.max(orientation === Qt.Horizontal ? height / width : width / height,0.3)
QtObject{
id:d
property int minLine : 2
property int maxLine : 6
}
verticalPadding : vertical ? 15 : 3
horizontalPadding : horizontal ? 15 : 3
background: Rectangle{
id:back_rect
radius: 5
color:FluTheme.dark ? Qt.rgba(44/255,44/255,44/255,1) : Qt.rgba(255/255,255/255,255/255,1)
opacity:{
if(vertical){
return d.maxLine === Number(rect_bar.width)
}
return d.maxLine === Number(rect_bar.height)
}
Behavior on opacity {
NumberAnimation{
duration: 50
}
}
}
FluIconButton{
width: 12
height: 12
iconSize: 8
verticalPadding: 0
horizontalPadding: 0
visible: control.horizontal
opacity: back_rect.opacity
anchors{
left: parent.left
leftMargin: 2
verticalCenter: parent.verticalCenter
}
iconColor: control.color
iconSource: FluentIcons.CaretLeftSolid8
onClicked: {
control.decrease()
}
}
FluIconButton{
width: 12
height: 12
iconSize: 8
verticalPadding: 0
horizontalPadding: 0
iconColor: control.color
opacity: back_rect.opacity
anchors{
right: parent.right
rightMargin: 2
verticalCenter: parent.verticalCenter
}
visible: control.horizontal
iconSource: FluentIcons.CaretRightSolid8
onClicked: {
control.increase()
}
}
FluIconButton{
width: 12
height: 12
iconSize: 8
verticalPadding: 0
horizontalPadding: 0
iconColor: control.color
opacity: back_rect.opacity
anchors{
top: parent.top
topMargin: 2
horizontalCenter: parent.horizontalCenter
}
visible: control.vertical
iconSource: FluentIcons.CaretUpSolid8
onClicked: {
control.decrease()
}
}
FluIconButton{
width: 12
height: 12
iconSize: 8
verticalPadding: 0
horizontalPadding: 0
iconColor: control.color
opacity: back_rect.opacity
anchors{
bottom: parent.bottom
bottomMargin: 2
horizontalCenter: parent.horizontalCenter
}
visible: control.vertical
iconSource: FluentIcons.CaretDownSolid8
onClicked: {
control.increase()
}
}
contentItem: Item { contentItem: Item {
property bool collapsed: (control.policy === T.ScrollBar.AlwaysOn || (control.active && control.size < 1.0)) property bool collapsed: (control.policy === T.ScrollBar.AlwaysOn || (control.active && control.size < 1.0))
implicitWidth: control.interactive ? 6 : 2 implicitWidth: control.interactive ? d.maxLine : d.minLine
implicitHeight: control.interactive ? 6 : 2 implicitHeight: control.interactive ? d.maxLine : d.minLine
Rectangle{ Rectangle{
id:rect_bar id:rect_bar
width: vertical ? 2 : parent.width width: vertical ? d.minLine : parent.width
height: horizontal ? 2 : parent.height height: horizontal ? d.minLine : parent.height
color:{ color:{
if(control.pressed){ if(control.pressed){
return control.pressedColor return control.pressedColor
@ -44,8 +141,8 @@ T.ScrollBar {
when: contentItem.collapsed when: contentItem.collapsed
PropertyChanges { PropertyChanges {
target: rect_bar target: rect_bar
width: vertical ? 6 : parent.width width: vertical ? d.maxLine : parent.width
height: horizontal ? 6 : parent.height height: horizontal ? d.maxLine : parent.height
} }
} }
,State{ ,State{
@ -53,8 +150,8 @@ T.ScrollBar {
when: !contentItem.collapsed when: !contentItem.collapsed
PropertyChanges { PropertyChanges {
target: rect_bar target: rect_bar
width: vertical ? 2 : parent.width width: vertical ? d.minLine : parent.width
height: horizontal ? 2 : parent.height height: horizontal ? d.minLine : parent.height
} }
} }
] ]
@ -73,6 +170,8 @@ T.ScrollBar {
} }
,Transition { ,Transition {
to: "show" to: "show"
SequentialAnimation {
PauseAnimation { duration: 450 }
NumberAnimation { NumberAnimation {
target: rect_bar target: rect_bar
properties: vertical ? "width" : "height" properties: vertical ? "width" : "height"
@ -80,6 +179,7 @@ T.ScrollBar {
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
} }
} }
}
] ]
} }
} }

View File

@ -3,64 +3,22 @@ import QtQuick.Controls 2.15
import FluentUI 1.0 import FluentUI 1.0
Item { Item {
//高性能阴影比DropShadow阴影性能高出数倍
property color color: FluTheme.dark ? "#FFFFFF" : "#999999" property color color: FluTheme.dark ? "#FFFFFF" : "#999999"
property int elevation: 6
property int radius: 4 property int radius: 4
id:control id:control
anchors.fill: parent anchors.fill: parent
anchors.margins: -4 Repeater{
model: elevation
Rectangle{ Rectangle{
width: control.width anchors.fill: parent
height: control.height
anchors.centerIn: parent
color: "#00000000" color: "#00000000"
opacity: 0.02 opacity: 0.01 * (elevation-index+1)
border.width: 1 anchors.margins: -index
radius: control.radius radius: control.radius+index
border.width: index
border.color: control.color border.color: control.color
} }
Rectangle{
width: control.width - 2
height: control.height - 2
anchors.centerIn: parent
color: "#00000000"
opacity: 0.04
border.width: 1
radius: control.radius
border.color: control.color
} }
Rectangle{
width: control.width - 4
height: control.height - 4
anchors.centerIn: parent
color: "#00000000"
opacity: 0.06
border.width: 1
radius: control.radius
border.color: control.color
}
Rectangle{
width: control.width - 6
height: control.height - 6
anchors.centerIn: parent
color: "#00000000"
opacity: 0.08
border.width: 1
radius: control.radius
border.color: control.color
}
Rectangle{
width: control.width - 8
height: control.height - 8
anchors.centerIn: parent
opacity: 0.1
radius: control.radius
color: "#00000000"
border.width: 1
border.color: control.color
}
} }

View File

@ -48,7 +48,7 @@ T.SpinBox {
inputMethodHints: control.inputMethodHints inputMethodHints: control.inputMethodHints
Rectangle{ Rectangle{
width: parent.width width: parent.width
height: contentItem.activeFocus ? 3 : 1 height: contentItem.activeFocus ? 2 : 1
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
visible: contentItem.enabled visible: contentItem.enabled
color: { color: {

View File

@ -67,6 +67,7 @@ Rectangle {
Component{ Component{
id:com_edit id:com_edit
FluTextBox{ FluTextBox{
id:text_box
text: display text: display
readOnly: true === columnSource[column].readOnly readOnly: true === columnSource[column].readOnly
Component.onCompleted: { Component.onCompleted: {
@ -75,7 +76,7 @@ Rectangle {
} }
onCommit: { onCommit: {
if(!readOnly){ if(!readOnly){
display = text display = text_box.text
} }
tableView.closeEditor() tableView.closeEditor()
} }
@ -141,7 +142,10 @@ Rectangle {
id:item_text id:item_text
text: itemData text: itemData
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 leftPadding: 11
rightPadding: 11
topPadding: 6
bottomPadding: 6
elide: Text.ElideRight elide: Text.ElideRight
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter

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