Compare commits

..

30 Commits

Author SHA1 Message Date
朱子楚\zhuzi
6ebd659e13 update 2024-04-04 22:47:07 +08:00
朱子楚\zhuzi
bd8c80feb8 update 2024-04-04 17:43:58 +08:00
朱子楚\zhuzi
6b617d10d5 update 2024-04-04 17:08:45 +08:00
朱子楚\zhuzi
cf163f5e3b update 2024-04-04 16:53:31 +08:00
朱子楚\zhuzi
b4329fdd0a update 2024-04-04 12:11:08 +08:00
朱子楚\zhuzi
84b2045b5f update 2024-04-04 02:48:26 +08:00
朱子楚\zhuzi
18193a18be update 2024-04-04 02:01:52 +08:00
朱子楚\zhuzi
fe08b08c1f update 2024-04-04 01:10:14 +08:00
朱子楚\zhuzi
ef96618151 update 2024-04-03 21:52:26 +08:00
朱子楚\zhuzi
be34220652 update 2024-04-03 19:31:01 +08:00
朱子楚\zhuzi
5cf0812562 update 2024-04-03 19:30:15 +08:00
朱子楚\zhuzi
c2b845658d update 2024-04-03 13:24:30 +08:00
朱子楚\zhuzi
eb4ec242b1 update 2024-04-03 11:28:18 +08:00
朱子楚\zhuzi
a95916ab03 update 2024-04-03 11:19:35 +08:00
朱子楚\zhuzi
bf5bedc9ed update 2024-04-03 11:09:35 +08:00
朱子楚\zhuzi
7d1666597f update 2024-04-02 00:32:06 +08:00
朱子楚\zhuzi
da9f63eb24 update 2024-03-31 21:56:11 +08:00
朱子楚\zhuzi
68015776ab update 2024-03-31 21:52:06 +08:00
朱子楚\zhuzi
d222cb640c update 2024-03-31 11:17:05 +08:00
朱子楚\zhuzi
0ab7f811e3 update 2024-03-31 10:59:15 +08:00
朱子楚\zhuzi
6a5f9d04a9 update 2024-03-29 16:56:09 +08:00
朱子楚\zhuzi
cb33af8836 update 2024-03-29 16:23:16 +08:00
朱子楚\zhuzi
5fd934b5f5 update 2024-03-29 00:51:55 +08:00
朱子楚\zhuzi
b7fde5f79c update 2024-03-29 00:48:58 +08:00
朱子楚\zhuzi
41cbeef3fd update 2024-03-28 19:18:56 +08:00
朱子楚\zhuzi
f616a2da6a update 2024-03-27 14:13:36 +08:00
朱子楚\zhuzi
b6c3f0eda9 update 2024-03-27 10:52:47 +08:00
朱子楚\zhuzi
06aa16c0eb update 2024-03-27 10:25:58 +08:00
朱子楚\zhuzi
c52439ac39 update 2024-03-27 09:45:56 +08:00
朱子楚\zhuzi
e81a2cc849 update 2024-03-27 00:36:56 +08:00
229 changed files with 4546 additions and 4422 deletions

View File

@ -49,13 +49,9 @@ configure_file(
) )
#Cpp #Cpp
message("---------->${filename}")
file(GLOB_RECURSE CPP_FILES *.cpp *.h) file(GLOB_RECURSE CPP_FILES *.cpp *.h)
foreach(filepath ${CPP_FILES}) foreach(filepath ${CPP_FILES})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
message(${filename})
list(APPEND sources_files ${filename}) list(APPEND sources_files ${filename})
endforeach(filepath) endforeach(filepath)

View File

@ -177,12 +177,9 @@
<file>qml/window/SingleInstanceWindow.qml</file> <file>qml/window/SingleInstanceWindow.qml</file>
<file>qml/window/SingleTaskWindow.qml</file> <file>qml/window/SingleTaskWindow.qml</file>
<file>qml/window/StandardWindow.qml</file> <file>qml/window/StandardWindow.qml</file>
<file>res/image/bg_scenic.png</file>
<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_StaggeredLayout.qml</file> <file>qml/page/T_StaggeredLayout.qml</file>
<file>qml/viewmodel/SettingsViewModel.qml</file>
<file>qml/viewmodel/TextBoxViewModel.qml</file>
<file>qml/page/T_Clip.qml</file> <file>qml/page/T_Clip.qml</file>
<file>qml/page/T_3D.qml</file> <file>qml/page/T_3D.qml</file>
<file>qml/page/T_Network.qml</file> <file>qml/page/T_Network.qml</file>
@ -197,7 +194,6 @@
<file>res/image/ic_crash.png</file> <file>res/image/ic_crash.png</file>
<file>qml/window/CrashWindow.qml</file> <file>qml/window/CrashWindow.qml</file>
<file>qml/page/T_SplitLayout.qml</file> <file>qml/page/T_SplitLayout.qml</file>
<file>qml/window/FluentInitalizrWindow.qml</file>
<file>res/template/CMakeLists.txt.in</file> <file>res/template/CMakeLists.txt.in</file>
<file>res/template/src/App.qml.in</file> <file>res/template/src/App.qml.in</file>
<file>res/template/src/CMakeLists.txt.in</file> <file>res/template/src/CMakeLists.txt.in</file>
@ -208,5 +204,10 @@
<file>res/template/src/qml.qrc.in</file> <file>res/template/src/qml.qrc.in</file>
<file>res/template/src/zh_CN.ts.in</file> <file>res/template/src/zh_CN.ts.in</file>
<file>res/template/src/README.md.in</file> <file>res/template/src/README.md.in</file>
<file>qml/global/GlobalModel.qml</file>
<file>qml/page/T_Sheet.qml</file>
<file>qml/page/T_GroupBox.qml</file>
<file>res/image/bg_scenic.jpg</file>
<file>qml/window/FluentInitializrWindow.qml</file>
</qresource> </qresource>
</RCC> </RCC>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,41 +4,37 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import FluentUI 1.0 import FluentUI 1.0
Item { FluLauncher {
id: app id: app
Connections{ Connections{
target: FluTheme target: FluTheme
function onDarkModeChanged(){ function onDarkModeChanged(){
SettingsHelper.saveDarkMode(FluTheme.darkMode) SettingsHelper.saveDarkMode(FluTheme.darkMode)
} }
} }
Connections{ Connections{
target: FluApp target: FluApp
function onUseSystemAppBarChanged(){ function onUseSystemAppBarChanged(){
SettingsHelper.saveUseSystemAppBar(FluApp.useSystemAppBar) SettingsHelper.saveUseSystemAppBar(FluApp.useSystemAppBar)
} }
} }
Connections{ Connections{
target: TranslateHelper target: TranslateHelper
function onCurrentChanged(){ function onCurrentChanged(){
SettingsHelper.saveLanguage(TranslateHelper.current) SettingsHelper.saveLanguage(TranslateHelper.current)
} }
} }
Component.onCompleted: { Component.onCompleted: {
FluNetwork.openLog = false Network.openLog = false
FluNetwork.setInterceptor(function(param){ Network.setInterceptor(function(param){
param.addHeader("Token","000000000000000000000") param.addHeader("Token","000000000000000000000")
}) })
FluApp.init(app,Qt.locale(TranslateHelper.current)) FluApp.init(app,Qt.locale(TranslateHelper.current))
FluApp.windowIcon = "qrc:/example/res/image/favicon.ico" FluApp.windowIcon = "qrc:/example/res/image/favicon.ico"
FluApp.useSystemAppBar = SettingsHelper.getUseSystemAppBar() FluApp.useSystemAppBar = SettingsHelper.getUseSystemAppBar()
FluTheme.darkMode = SettingsHelper.getDarkMode() FluTheme.darkMode = SettingsHelper.getDarkMode()
FluTheme.enableAnimation = true FluTheme.animationEnabled = true
FluApp.routes = { FluRouter.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",
"/login":"qrc:/example/qml/window/LoginWindow.qml", "/login":"qrc:/example/qml/window/LoginWindow.qml",
@ -51,9 +47,9 @@ Item {
} }
var args = Qt.application.arguments var args = Qt.application.arguments
if(args.length>=2 && args[1].startsWith("-crashed=")){ if(args.length>=2 && args[1].startsWith("-crashed=")){
FluApp.navigate("/crash",{crashFilePath:args[1].replace("-crashed=","")}) FluRouter.navigate("/crash",{crashFilePath:args[1].replace("-crashed=","")})
}else{ }else{
FluApp.navigate("/") FluRouter.navigate("/")
} }
} }
} }

View File

@ -9,10 +9,10 @@ FluScrollablePage{
title: qsTr("Bar Chart") title: qsTr("Bar Chart")
FluArea{ FluFrame{
width: 500 Layout.preferredWidth: 500
height: 370 Layout.preferredHeight: 370
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent
@ -69,10 +69,10 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
width: 500 Layout.preferredWidth: 500
height: 370 Layout.preferredHeight: 370
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent

View File

@ -13,10 +13,10 @@ FluScrollablePage{
return Math.random().toFixed(1); return Math.random().toFixed(1);
} }
FluArea{ FluFrame{
height: 370 Layout.preferredWidth: 500
width: 500 Layout.preferredHeight: 370
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent

View File

@ -9,10 +9,10 @@ FluScrollablePage{
title: qsTr("Line Chart") title: qsTr("Line Chart")
FluArea{ FluFrame{
width: 500 Layout.preferredWidth: 500
height: 370 Layout.preferredHeight: 370
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent

View File

@ -9,10 +9,10 @@ FluScrollablePage{
title: qsTr("Pie Chart") title: qsTr("Pie Chart")
FluArea{ FluFrame{
width: 500 Layout.preferredWidth: 500
height: 370 Layout.preferredHeight: 370
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent
@ -50,10 +50,10 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
width: 500 Layout.preferredWidth: 500
height: 370 Layout.preferredHeight: 370
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent

View File

@ -9,10 +9,10 @@ FluScrollablePage{
title: qsTr("Polar Area Chart") title: qsTr("Polar Area Chart")
FluArea{ FluFrame{
width: 500 Layout.preferredWidth: 500
height: 370 Layout.preferredHeight: 370
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent

View File

@ -9,10 +9,10 @@ FluScrollablePage{
title: qsTr("Radar Chart") title: qsTr("Radar Chart")
FluArea{ FluFrame{
width: 500 Layout.preferredWidth: 500
height: 370 Layout.preferredHeight: 370
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent

View File

@ -13,10 +13,10 @@ FluScrollablePage{
return Math.random().toFixed(1); return Math.random().toFixed(1);
} }
FluArea{ FluFrame{
height: 370 Layout.preferredWidth: 500
width: 500 Layout.preferredHeight: 370
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent
@ -119,5 +119,4 @@ FluScrollablePage{
} }
} }
} }
} }

View File

@ -135,7 +135,11 @@ FluExpander{
"FluLoadingButton", "FluLoadingButton",
"FluClip", "FluClip",
"FluNetwork", "FluNetwork",
"FluShortcutPicker" "FluShortcutPicker",
"FluWindowResultLauncher",
"FluRouter",
"FluGroupBox",
"FluSheet",
]; ];
code = code.replace(/\n/g, "<br>"); code = code.replace(/\n/g, "<br>");
code = code.replace(/ /g, "&nbsp;"); code = code.replace(/ /g, "&nbsp;");

View File

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

View File

@ -16,7 +16,7 @@ FluObject{
title:qsTr("About") title:qsTr("About")
icon:FluentIcons.Contact icon:FluentIcons.Contact
onTapListener:function(){ onTapListener:function(){
FluApp.navigate("/about") FluRouter.navigate("/about")
} }
} }

View File

@ -104,6 +104,12 @@ FluObject{
url: "qrc:/example/qml/page/T_ToggleSwitch.qml" url: "qrc:/example/qml/page/T_ToggleSwitch.qml"
onTap: { navigationView.push(url) } onTap: { navigationView.push(url) }
} }
FluPaneItem{
title: qsTr("GroupBox")
menuDelegate: paneItemMenu
url: "qrc:/example/qml/page/T_GroupBox.qml"
onTap: { navigationView.push(url) }
}
FluPaneItem{ FluPaneItem{
title: qsTr("PaneItem Disabled") title: qsTr("PaneItem Disabled")
disabled: true disabled: true
@ -271,6 +277,12 @@ FluObject{
url: "qrc:/example/qml/page/T_Menu.qml" url: "qrc:/example/qml/page/T_Menu.qml"
onTap: { navigationView.push(url) } onTap: { navigationView.push(url) }
} }
FluPaneItem{
title: qsTr("Sheet")
menuDelegate: paneItemMenu
url: "qrc:/example/qml/page/T_Sheet.qml"
onTap: { navigationView.push(url) }
}
} }
FluPaneItemExpander{ FluPaneItemExpander{
@ -462,7 +474,7 @@ FluObject{
FluPaneItem{ FluPaneItem{
title: qsTr("Hot Loader") title: qsTr("Hot Loader")
onTapListener: function(){ onTapListener: function(){
FluApp.navigate("/hotload") FluRouter.navigate("/hotload")
} }
} }
FluPaneItem{ FluPaneItem{
@ -473,10 +485,12 @@ FluObject{
} }
FluPaneItem{ FluPaneItem{
title: qsTr("Test Crash") title: qsTr("Test Crash")
visible: FluTools.isWin()
onTapListener: function(){ onTapListener: function(){
AppInfo.testCrash() AppInfo.testCrash()
} }
Component.onCompleted: {
visible = FluTools.isWin()
}
} }
} }

View File

@ -1,2 +1,3 @@
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 GlobalModel 1.0 GlobalModel.qml

View File

@ -11,7 +11,6 @@ FluScrollablePage{
RowLayout{ RowLayout{
spacing: 10 spacing: 10
Layout.topMargin: 20
FluText{ FluText{
text:"tintColor:" text:"tintColor:"
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
@ -42,10 +41,10 @@ FluScrollablePage{
value: 32 value: 32
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 1200/4+20 Layout.preferredHeight: 1200/4+20
paddings: 10 padding: 10
Layout.topMargin: 10 Layout.topMargin: 10
FluClip{ FluClip{
width: 1920/4 width: 1920/4
@ -54,7 +53,7 @@ FluScrollablePage{
Image { Image {
id:image id:image
asynchronous: true asynchronous: true
source: "qrc:/example/res/image/bg_scenic.png" source: "qrc:/example/res/image/bg_scenic.jpg"
anchors.fill: parent anchors.fill: parent
sourceSize: Qt.size(2*width,2*height) sourceSize: Qt.size(2*width,2*height)
} }
@ -72,7 +71,7 @@ FluScrollablePage{
anchors.centerIn: parent anchors.centerIn: parent
text: "Acrylic" text: "Acrylic"
color: "#FFFFFF" color: "#FFFFFF"
font.bold: true font: FluTextStyle.Subtitle
} }
MouseArea { MouseArea {
property point clickPos: Qt.point(0,0) property point clickPos: Qt.point(0,0)
@ -95,7 +94,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'Image{ code:'Image{
id:image id:image
width: 800 width: 800

View File

@ -12,7 +12,6 @@ FluContentPage {
id:text_box id:text_box
placeholderText: qsTr("Please enter a keyword") placeholderText: qsTr("Please enter a keyword")
anchors{ anchors{
topMargin: 20
top:parent.top top:parent.top
} }
} }
@ -59,6 +58,7 @@ FluContentPage {
FluText { FluText {
id:item_name id:item_name
font.pixelSize: 10 font.pixelSize: 10
font.family: FluTextStyle.family
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: item_icon.bottom anchors.top: item_icon.bottom
width:parent.width width:parent.width

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("Badge") title: qsTr("Badge")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20
height: 120 height: 120
paddings: 10 padding: 10
Column{ Column{
spacing: 15 spacing: 15
@ -114,7 +113,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'Rectangle{ code:'Rectangle{
width: 40 width: 40
height: 40 height: 40

View File

@ -18,11 +18,10 @@ FluScrollablePage{
breadcrumb_2.items = items breadcrumb_2.items = items
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20
FluBreadcrumbBar{ FluBreadcrumbBar{
id:breadcrumb_1 id:breadcrumb_1
@ -36,10 +35,10 @@ FluScrollablePage{
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 100 Layout.preferredHeight: 100
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
ColumnLayout{ ColumnLayout{
@ -77,7 +76,7 @@ FluScrollablePage{
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluBreadcrumbBar{ code:'FluBreadcrumbBar{
width:parent.width width:parent.width
separator:">" separator:">"

View File

@ -10,15 +10,14 @@ FluScrollablePage{
title: qsTr("Buttons") title: qsTr("Buttons")
FluText{ FluText{
Layout.topMargin: 20
text: qsTr("Support the Tab key to switch focus, and the Space key to perform click events") text: qsTr("Support the Tab key to switch focus, and the Space key to perform click events")
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 Layout.topMargin: 10
Layout.topMargin: 20 padding: 10
FluTextButton{ FluTextButton{
disabled: text_button_switch.checked disabled: text_button_switch.checked
@ -42,7 +41,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluTextButton{ code:'FluTextButton{
text:"Text Button" text:"Text Button"
onClicked: { onClicked: {
@ -51,10 +50,10 @@ FluScrollablePage{
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluButton{ FluButton{
@ -79,7 +78,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluButton{ code:'FluButton{
text:"Standard Button" text:"Standard Button"
onClicked: { onClicked: {
@ -88,11 +87,11 @@ FluScrollablePage{
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
Layout.topMargin: 20 Layout.topMargin: 20
paddings: 10 padding: 10
FluFilledButton{ FluFilledButton{
disabled: filled_button_switch.checked disabled: filled_button_switch.checked
@ -116,7 +115,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluFilledButton{ code:'FluFilledButton{
text:"Filled Button" text:"Filled Button"
onClicked: { onClicked: {
@ -125,11 +124,11 @@ FluScrollablePage{
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
Layout.topMargin: 20 Layout.topMargin: 20
paddings: 10 padding: 10
FluToggleButton{ FluToggleButton{
disabled:toggle_button_switch.checked disabled:toggle_button_switch.checked
@ -150,7 +149,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluToggleButton{ code:'FluToggleButton{
text:"Toggle Button" text:"Toggle Button"
onClicked: { onClicked: {
@ -172,11 +171,11 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
Layout.topMargin: 20 Layout.topMargin: 20
paddings: 10 padding: 10
FluProgressButton{ FluProgressButton{
id: btn_progress id: btn_progress
@ -202,7 +201,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluProgressButton{ code:'FluProgressButton{
text:"Progress Button" text:"Progress Button"
onClicked: { onClicked: {
@ -211,11 +210,11 @@ FluScrollablePage{
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
Layout.topMargin: 20 Layout.topMargin: 20
paddings: 10 padding: 10
FluLoadingButton{ FluLoadingButton{
id: btn_loading id: btn_loading
@ -241,7 +240,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluLoadingButton{ code:'FluLoadingButton{
text:"Loading Button" text:"Loading Button"
onClicked: { onClicked: {
@ -251,10 +250,10 @@ FluScrollablePage{
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: layout_icon_button.height + 30 Layout.preferredHeight: layout_icon_button.height + 30
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
Flow{ Flow{
id: layout_icon_button id: layout_icon_button
@ -323,7 +322,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluIconButton{ code:'FluIconButton{
iconSource:FluentIcons.ChromeCloseContrast iconSource:FluentIcons.ChromeCloseContrast
onClicked: { onClicked: {
@ -332,10 +331,10 @@ FluScrollablePage{
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluDropDownButton{ FluDropDownButton{
disabled: drop_down_button_switch.checked disabled: drop_down_button_switch.checked
@ -371,7 +370,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluDropDownButton{ code:'FluDropDownButton{
text:"DropDownButton" text:"DropDownButton"
FluMenuItem{ FluMenuItem{
@ -389,10 +388,10 @@ FluScrollablePage{
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 100 Layout.preferredHeight: 100
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluRadioButtons{ FluRadioButtons{
spacing: 8 spacing: 8
@ -424,7 +423,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluRadioButton{ code:'FluRadioButton{
checked:true checked:true
text:"Text Button" text:"Text Button"

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("CalendarPicker") title: qsTr("CalendarPicker")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 80
height: 80 padding: 10
paddings: 10
ColumnLayout{ ColumnLayout{
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@ -28,7 +27,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluCalendarPicker{ code:'FluCalendarPicker{
}' }'

View File

@ -11,7 +11,6 @@ FluScrollablePage{
FluCaptcha{ FluCaptcha{
id: captcha id: captcha
Layout.topMargin: 20
ignoreCase:switch_case.checked ignoreCase:switch_case.checked
MouseArea{ MouseArea{
anchors.fill: parent anchors.fill: parent

View File

@ -22,11 +22,10 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 370 height: 370
paddings: 10 padding: 10
Layout.topMargin: 20
Column{ Column{
spacing: 15 spacing: 15
anchors{ anchors{
@ -62,10 +61,10 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 340 height: 340
paddings: 10 padding: 10
Layout.topMargin: 10 Layout.topMargin: 10
Column{ Column{
spacing: 15 spacing: 15
@ -104,7 +103,6 @@ FluScrollablePage{
horizontalAlignment: Qt.AlignHCenter horizontalAlignment: Qt.AlignHCenter
text:model.title text:model.title
color: FluColors.Grey10 color: FluColors.Grey10
font.pixelSize: 15
} }
} }
} }
@ -126,7 +124,7 @@ FluScrollablePage{
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluCarousel{ code:'FluCarousel{
id:carousel id:carousel
width: 400 width: 400

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("CheckBox") title: qsTr("CheckBox")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 72 Layout.preferredHeight: 72
paddings: 10 padding: 10
Layout.topMargin: 20
FluText{ FluText{
text: qsTr("A 2-state CheckBox") text: qsTr("A 2-state CheckBox")
@ -49,16 +48,16 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluCheckBox{ code:'FluCheckBox{
text:"Text" text:"Text"
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 72 Layout.preferredHeight: 72
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluText{ FluText{
@ -104,7 +103,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluCheckBox{ code:'FluCheckBox{
text:"Text" text:"Text"
indeterminate:true indeterminate:true

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("Clip") title: qsTr("Clip")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 380
height: 380 padding: 10
paddings: 10
Column{ Column{
spacing: 15 spacing: 15
@ -88,7 +87,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluClip{ code:'FluClip{
radius: [25,25,25,25] radius: [25,25,25,25]
width: 50 width: 50

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("ColorPicker") title: qsTr("ColorPicker")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 60
height: 60 padding: 10
paddings: 10
RowLayout{ RowLayout{
FluText{ FluText{
text: qsTr("Click to Select a Color - >") text: qsTr("Click to Select a Color - >")
@ -33,7 +32,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluColorPicker{ code:'FluColorPicker{
}' }'

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("ComboBox") title: qsTr("ComboBox")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 80 Layout.preferredHeight: 80
paddings: 5 padding: 5
Layout.topMargin: 20
Column{ Column{
spacing: 5 spacing: 5
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -32,10 +31,10 @@ FluScrollablePage{
} }
} }
FluArea { FluFrame {
Layout.fillWidth: true Layout.fillWidth: true
height: 80 Layout.preferredHeight: 80
paddings: 5 padding: 5
Layout.topMargin: 20 Layout.topMargin: 20
Column{ Column{
spacing: 5 spacing: 5
@ -56,10 +55,10 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 80 height: 80
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
Column{ Column{
spacing: 5 spacing: 5
@ -85,7 +84,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluComboBox{ code:'FluComboBox{
editable: true editable: true
model: ListModel { model: ListModel {

View File

@ -7,13 +7,12 @@ import "../component"
FluScrollablePage{ FluScrollablePage{
title: qsTr("TimePicker") title: qsTr("DatePicker")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 80
height: 80 padding: 10
paddings: 10
ColumnLayout{ ColumnLayout{
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@ -32,17 +31,17 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluDatePicker{ code:'FluDatePicker{
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 80 Layout.preferredHeight: 80
paddings: 10 padding: 10
ColumnLayout{ ColumnLayout{
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@ -61,7 +60,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluDatePicker{ code:'FluDatePicker{
showYear:false showYear:false
}' }'

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("Dialog") title: qsTr("Dialog")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20
FluButton{ FluButton{
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: qsTr("Show Double Button Dialog") text: qsTr("Show Double Button Dialog")
@ -24,7 +23,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluContentDialog{ code:'FluContentDialog{
id:dialog id:dialog
title: qsTr("Friendly Reminder") title: qsTr("Friendly Reminder")
@ -57,10 +56,10 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluButton{ FluButton{
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -72,7 +71,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluContentDialog{ code:'FluContentDialog{
id: dialog id: dialog
title: qsTr("Friendly Reminder") title: qsTr("Friendly Reminder")
@ -114,10 +113,10 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 100 Layout.preferredHeight: 100
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluButton{ FluButton{
anchors.top: parent.top anchors.top: parent.top
@ -138,7 +137,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluContentDialog{ code:'FluContentDialog{
id: dialog id: dialog
title: qsTr("Friendly Reminder") title: qsTr("Friendly Reminder")

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("Expander") title: qsTr("Expander")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: layout_column.height+20 height: layout_column.height+20
paddings: 10 padding: 10
Layout.topMargin: 20
Column{ Column{
id:layout_column id:layout_column
spacing: 15 spacing: 15
@ -83,7 +82,7 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluExpander{ code:'FluExpander{
headerText: qsTr("Open a radio box") headerText: qsTr("Open a radio box")
Item{ Item{

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("FlipView") title: qsTr("FlipView")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 340 Layout.preferredHeight: 340
paddings: 10 padding: 10
Layout.topMargin: 20
ColumnLayout{ ColumnLayout{
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
FluText{ FluText{
@ -40,7 +39,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluFlipView{ code:'FluFlipView{
Image{ Image{
source: "qrc:/example/res/image/banner_1.jpg" source: "qrc:/example/res/image/banner_1.jpg"
@ -61,10 +60,10 @@ FluScrollablePage{
' '
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 340 height: 340
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
ColumnLayout{ ColumnLayout{
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -93,7 +92,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluFlipView{ code:'FluFlipView{
vertical:true vertical:true
Image{ Image{

View File

@ -0,0 +1,48 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import FluentUI 1.0
import "../component"
FluScrollablePage{
title: qsTr("GroupBox")
FluGroupBox {
title: qsTr("CheckBox Group")
ColumnLayout {
spacing: 10
anchors.fill: parent
FluCheckBox { text: qsTr("E-mail") }
FluCheckBox { text: qsTr("Calendar") }
FluCheckBox { text: qsTr("Contacts") }
}
}
FluGroupBox {
title: qsTr("RadioButton Group")
FluRadioButtons {
spacing: 10
FluRadioButton { text: qsTr("E-mail") }
FluRadioButton { text: qsTr("Calendar") }
FluRadioButton { text: qsTr("Contacts") }
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: 4
code:'FluGroupBox {
title: qsTr("CheckBox Group")
ColumnLayout {
spacing: 10
anchors.fill: parent
FluCheckBox { text: qsTr("E-mail") }
FluCheckBox { text: qsTr("Calendar") }
FluCheckBox { text: qsTr("Contacts") }
}
}'
}
}

View File

@ -9,10 +9,11 @@ import "../global"
FluScrollablePage{ FluScrollablePage{
launchMode: FluPageType.SingleTask launchMode: FluPageType.SingleTask
animDisabled: true animationEnabled: false
header: Item{}
FluentInitalizrWindow{ FluentInitializrWindow{
id:fluent_initalizr id:fluent_Initializr
} }
ListModel{ ListModel{
@ -28,11 +29,11 @@ FluScrollablePage{
} }
ListElement{ ListElement{
icon: "qrc:/example/res/image/favicon.ico" icon: "qrc:/example/res/image/favicon.ico"
title: qsTr("FluentUI Initalizr") title: qsTr("FluentUI Initializr")
desc: qsTr("FluentUI Initializr is a Tool that helps you create and customize Fluent UI projects with various options.") desc: qsTr("FluentUI Initializr is a Tool that helps you create and customize Fluent UI projects with various options.")
url: "https://github.com/zhuzichu520/FluentUI" url: "https://github.com/zhuzichu520/FluentUI"
clicked: function(model){ clicked: function(model){
fluent_initalizr.showDialog() fluent_Initializr.showDialog()
} }
} }
} }
@ -121,6 +122,7 @@ FluScrollablePage{
Layout.leftMargin: 20 Layout.leftMargin: 20
color: FluColors.Grey120 color: FluColors.Grey120
font.pixelSize: 12 font.pixelSize: 12
font.family: FluTextStyle.family
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
} }
} }
@ -177,7 +179,7 @@ FluScrollablePage{
property string desc: modelData.extra.desc property string desc: modelData.extra.desc
width: 320 width: 320
height: 120 height: 120
FluArea{ FluFrame{
radius: 8 radius: 8
width: 300 width: 300
height: 100 height: 100

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("Image") title: qsTr("Image")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 260 Layout.preferredHeight: 260
paddings: 10 padding: 10
Layout.topMargin: 20
Column{ Column{
spacing: 15 spacing: 15
anchors{ anchors{
@ -37,7 +36,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluImage{ code:'FluImage{
width: 400 width: 400
height: 300 height: 300

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("InfoBar") title: qsTr("InfoBar")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 270
height: 270 padding: 10
paddings: 10
ColumnLayout{ ColumnLayout{
spacing: 14 spacing: 14
anchors{ anchors{
@ -60,7 +59,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'showInfo(qsTr("This is an InfoBar in the Info Style")) code:'showInfo(qsTr("This is an InfoBar in the Info Style"))
showWarning(qsTr("This is an InfoBar in the Warning Style")) showWarning(qsTr("This is an InfoBar in the Warning Style"))

View File

@ -47,11 +47,10 @@ FluScrollablePage{
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 100 Layout.preferredHeight: 100
paddings: 10 padding: 10
Layout.topMargin: 20
Column{ Column{
id: layout_column id: layout_column
spacing: 15 spacing: 15
@ -78,7 +77,7 @@ FluScrollablePage{
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluMenu{ code:'FluMenu{
id:menu id:menu
FluMenuItem:{ FluMenuItem:{
@ -99,10 +98,10 @@ menu.popup()
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 100 Layout.preferredHeight: 100
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
Column{ Column{
spacing: 15 spacing: 15
@ -151,7 +150,7 @@ menu.popup()
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluMenuBar{ code:'FluMenuBar{
id:menu id:menu
FluMenu:{ FluMenu:{

View File

@ -8,23 +8,23 @@ import "../component"
FluScrollablePage{ FluScrollablePage{
property string password: "" property string password: ""
property var loginPageRegister: registerForWindowResult("/login")
title: qsTr("MultiWindow") title: qsTr("MultiWindow")
Connections{ FluWindowResultLauncher{
target: loginPageRegister id:loginResultLauncher
function onResult(data) path: "/login"
{ onResult:
(data)=>{
password = data.password password = data.password
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 86 Layout.preferredHeight: 86
paddings: 10 padding: 10
Layout.topMargin: 20
Column{ Column{
spacing: 15 spacing: 15
anchors{ anchors{
@ -37,16 +37,16 @@ FluScrollablePage{
FluButton{ FluButton{
text: qsTr("Create Window") text: qsTr("Create Window")
onClicked: { onClicked: {
FluApp.navigate("/standardWindow") FluRouter.navigate("/standardWindow")
} }
} }
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 86 Layout.preferredHeight: 86
paddings: 10 padding: 10
Layout.topMargin: 10 Layout.topMargin: 10
Column{ Column{
spacing: 15 spacing: 15
@ -61,16 +61,16 @@ FluScrollablePage{
FluButton{ FluButton{
text: qsTr("Create Window") text: qsTr("Create Window")
onClicked: { onClicked: {
FluApp.navigate("/singleTaskWindow") FluRouter.navigate("/singleTaskWindow")
} }
} }
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 86 Layout.preferredHeight: 86
paddings: 10 padding: 10
Layout.topMargin: 10 Layout.topMargin: 10
Column{ Column{
spacing: 15 spacing: 15
@ -84,14 +84,14 @@ FluScrollablePage{
FluButton{ FluButton{
text: qsTr("Create Window") text: qsTr("Create Window")
onClicked: { onClicked: {
FluApp.navigate("/singleInstanceWindow") FluRouter.navigate("/singleInstanceWindow")
} }
} }
} }
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluWindow{ code:'FluWindow{
//launchMode: FluWindowType.Standard //launchMode: FluWindowType.Standard
//launchMode: FluWindowType.SingleTask //launchMode: FluWindowType.SingleTask
@ -101,10 +101,10 @@ FluScrollablePage{
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 100 Layout.preferredHeight: 100
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
Column{ Column{
spacing: 15 spacing: 15
@ -118,27 +118,27 @@ FluScrollablePage{
FluButton{ FluButton{
text: qsTr("Create Window") text: qsTr("Create Window")
onClicked: { onClicked: {
FluApp.navigate("/about") FluRouter.navigate("/about")
} }
} }
} }
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluButton{ code:'FluButton{
text: qsTr("Create Window") text: qsTr("Create Window")
onClicked: { onClicked: {
FluApp.navigate("/about") FluRouter.navigate("/about")
} }
} }
' '
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 130 Layout.preferredHeight: 130
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
Column{ Column{
@ -153,7 +153,7 @@ FluScrollablePage{
FluButton{ FluButton{
text: qsTr("Create Window") text: qsTr("Create Window")
onClicked: { onClicked: {
loginPageRegister.launch({username:"zhuzichu"}) loginResultLauncher.launch({username:"zhuzichu"})
} }
} }
FluText{ FluText{
@ -163,13 +163,12 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'property var loginPageRegister: registerForWindowResult("/login") code:'FluWindowResultLauncher{
id:loginResultLauncher
Connections{ path: "/login"
target: loginPageRegister onResult:
function onResult(data) (data)=>{
{
password = data.password password = data.password
} }
} }
@ -177,7 +176,7 @@ Connections{
FluButton{ FluButton{
text: qsTr("Create Window") text: qsTr("Create Window")
onClicked: { onClicked: {
loginPageRegister.launch({username:"zhuzichu"}) loginResultLauncher.launch({username:"zhuzichu"})
} }
} }
' '

View File

@ -4,6 +4,7 @@ import QtQuick.Window 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import FluentUI 1.0 import FluentUI 1.0
import Qt.labs.platform 1.0 import Qt.labs.platform 1.0
import example 1.0
import "../component" import "../component"
FluContentPage{ FluContentPage{
@ -11,7 +12,7 @@ FluContentPage{
id:root id:root
title: qsTr("Network") title: qsTr("Network")
FluNetworkCallable{ NetworkCallable{
id:callable id:callable
onStart: { onStart: {
showLoading() showLoading()
@ -39,7 +40,6 @@ FluContentPage{
clip: true clip: true
anchors{ anchors{
top: parent.top top: parent.top
topMargin: 20
bottom: parent.bottom bottom: parent.bottom
left: parent.left left: parent.left
} }
@ -56,7 +56,7 @@ FluContentPage{
text: "Get" text: "Get"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.get("https://httpbingo.org/get") Network.get("https://httpbingo.org/get")
.addQuery("name","孙悟空") .addQuery("name","孙悟空")
.addQuery("age",500) .addQuery("age",500)
.addQuery("address","花果山水帘洞") .addQuery("address","花果山水帘洞")
@ -70,7 +70,7 @@ FluContentPage{
text: "Head" text: "Head"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.head("https://httpbingo.org/head") Network.head("https://httpbingo.org/head")
.addQuery("name","孙悟空") .addQuery("name","孙悟空")
.addQuery("age",500) .addQuery("age",500)
.addQuery("address","花果山水帘洞") .addQuery("address","花果山水帘洞")
@ -84,7 +84,7 @@ FluContentPage{
text: "Post Body" text: "Post Body"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.postBody("https://httpbingo.org/post") Network.postBody("https://httpbingo.org/post")
.setBody("花果山水帘洞美猴王齐天大圣孙悟空") .setBody("花果山水帘洞美猴王齐天大圣孙悟空")
.bind(root) .bind(root)
.go(callable) .go(callable)
@ -96,7 +96,7 @@ FluContentPage{
text: "Post Form" text: "Post Form"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.postForm("https://httpbingo.org/post") Network.postForm("https://httpbingo.org/post")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -110,7 +110,7 @@ FluContentPage{
text: "Post JSON" text: "Post JSON"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.postJson("https://httpbingo.org/post") Network.postJson("https://httpbingo.org/post")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -124,7 +124,7 @@ FluContentPage{
text: "Post JSON Array" text: "Post JSON Array"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.postJsonArray("https://httpbingo.org/post") Network.postJsonArray("https://httpbingo.org/post")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -138,7 +138,7 @@ FluContentPage{
text: "Put Body" text: "Put Body"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.putBody("https://httpbingo.org/put") Network.putBody("https://httpbingo.org/put")
.setBody("花果山水帘洞美猴王齐天大圣孙悟空") .setBody("花果山水帘洞美猴王齐天大圣孙悟空")
.bind(root) .bind(root)
.go(callable) .go(callable)
@ -150,7 +150,7 @@ FluContentPage{
text: "Put Form" text: "Put Form"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.putForm("https://httpbingo.org/put") Network.putForm("https://httpbingo.org/put")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -164,7 +164,7 @@ FluContentPage{
text: "Put JSON" text: "Put JSON"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.putJson("https://httpbingo.org/put") Network.putJson("https://httpbingo.org/put")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -178,7 +178,7 @@ FluContentPage{
text: "Put JSON Array" text: "Put JSON Array"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.putJsonArray("https://httpbingo.org/put") Network.putJsonArray("https://httpbingo.org/put")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -192,7 +192,7 @@ FluContentPage{
text: "Patch Body" text: "Patch Body"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.patchBody("https://httpbingo.org/patch") Network.patchBody("https://httpbingo.org/patch")
.setBody("花果山水帘洞美猴王齐天大圣孙悟空") .setBody("花果山水帘洞美猴王齐天大圣孙悟空")
.bind(root) .bind(root)
.go(callable) .go(callable)
@ -204,7 +204,7 @@ FluContentPage{
text: "Patch Form" text: "Patch Form"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.patchForm("https://httpbingo.org/patch") Network.patchForm("https://httpbingo.org/patch")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -218,7 +218,7 @@ FluContentPage{
text: "Patch JSON" text: "Patch JSON"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.patchJson("https://httpbingo.org/patch") Network.patchJson("https://httpbingo.org/patch")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -232,7 +232,7 @@ FluContentPage{
text: "Patch JSON Array" text: "Patch JSON Array"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.patchJsonArray("https://httpbingo.org/patch") Network.patchJsonArray("https://httpbingo.org/patch")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -246,7 +246,7 @@ FluContentPage{
text: "Delete Body" text: "Delete Body"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.deleteBody("https://httpbingo.org/delete") Network.deleteBody("https://httpbingo.org/delete")
.setBody("花果山水帘洞美猴王齐天大圣孙悟空") .setBody("花果山水帘洞美猴王齐天大圣孙悟空")
.bind(root) .bind(root)
.go(callable) .go(callable)
@ -258,7 +258,7 @@ FluContentPage{
text: "Delete Form" text: "Delete Form"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.deleteForm("https://httpbingo.org/delete") Network.deleteForm("https://httpbingo.org/delete")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -272,7 +272,7 @@ FluContentPage{
text: "Delete JSON" text: "Delete JSON"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.deleteJson("https://httpbingo.org/delete") Network.deleteJson("https://httpbingo.org/delete")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -286,7 +286,7 @@ FluContentPage{
text: "Delete JSON Array" text: "Delete JSON Array"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.deleteJsonArray("https://httpbingo.org/delete") Network.deleteJsonArray("https://httpbingo.org/delete")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -300,7 +300,7 @@ FluContentPage{
text: "Open Log" text: "Open Log"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.postJson("https://httpbingo.org/post") Network.postJson("https://httpbingo.org/post")
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -315,7 +315,7 @@ FluContentPage{
text: "Custom Header" text: "Custom Header"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.postJson("https://httpbingo.org/post") Network.postJson("https://httpbingo.org/post")
.addHeader("os","PC") .addHeader("os","PC")
.addHeader("version","1.0.0") .addHeader("version","1.0.0")
.add("name","孙悟空") .add("name","孙悟空")
@ -331,8 +331,8 @@ FluContentPage{
text: "RequestFailedReadCache" text: "RequestFailedReadCache"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.postJson("https://httpbingo.org/post") Network.postJson("https://httpbingo.org/post")
.setCacheMode(FluNetworkType.RequestFailedReadCache) .setCacheMode(NetworkType.RequestFailedReadCache)
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -347,8 +347,8 @@ FluContentPage{
text: "IfNoneCacheRequest" text: "IfNoneCacheRequest"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.postJson("https://httpbingo.org/post") Network.postJson("https://httpbingo.org/post")
.setCacheMode(FluNetworkType.IfNoneCacheRequest) .setCacheMode(NetworkType.IfNoneCacheRequest)
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -363,8 +363,8 @@ FluContentPage{
text: "FirstCacheThenRequest" text: "FirstCacheThenRequest"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.postJson("https://httpbingo.org/post") Network.postJson("https://httpbingo.org/post")
.setCacheMode(FluNetworkType.FirstCacheThenRequest) .setCacheMode(NetworkType.FirstCacheThenRequest)
.add("name","孙悟空") .add("name","孙悟空")
.add("age",500) .add("age",500)
.add("address","花果山水帘洞") .add("address","花果山水帘洞")
@ -379,7 +379,7 @@ FluContentPage{
text: "Timeout And Retry" text: "Timeout And Retry"
onClicked: { onClicked: {
text_info.text = "" text_info.text = ""
FluNetwork.postJson("https://httpbingo.org/post") Network.postJson("https://httpbingo.org/post")
.setTimeout(5000) .setTimeout(5000)
.setRetry(3) .setRetry(3)
.add("name","孙悟空") .add("name","孙悟空")
@ -407,7 +407,7 @@ FluContentPage{
text: "Download File" text: "Download File"
onClicked: { onClicked: {
folder_dialog.showDialog(function(path){ folder_dialog.showDialog(function(path){
FluNetwork.get("http://vjs.zencdn.net/v/oceans.mp4") Network.get("http://vjs.zencdn.net/v/oceans.mp4")
.toDownload(path) .toDownload(path)
.bind(root) .bind(root)
.go(callable_download_file) .go(callable_download_file)
@ -421,7 +421,7 @@ FluContentPage{
text: "Breakpoint Download File" text: "Breakpoint Download File"
onClicked: { onClicked: {
folder_dialog.showDialog(function(path){ folder_dialog.showDialog(function(path){
FluNetwork.get("http://vjs.zencdn.net/v/oceans.mp4") Network.get("http://vjs.zencdn.net/v/oceans.mp4")
.toDownload(path,true) .toDownload(path,true)
.bind(root) .bind(root)
.go(callable_breakpoint_download_file) .go(callable_breakpoint_download_file)
@ -431,7 +431,7 @@ FluContentPage{
} }
} }
FluNetworkCallable{ NetworkCallable{
id:callable_upload_file id:callable_upload_file
onStart: { onStart: {
btn_upload.disabled = true btn_upload.disabled = true
@ -455,7 +455,7 @@ FluContentPage{
} }
} }
FluNetworkCallable{ NetworkCallable{
id:callable_download_file id:callable_download_file
onStart: { onStart: {
btn_download.progress = 0 btn_download.progress = 0
@ -480,7 +480,7 @@ FluContentPage{
} }
} }
FluNetworkCallable{ NetworkCallable{
id:callable_breakpoint_download_file id:callable_breakpoint_download_file
onStart: { onStart: {
btn_download_breakpoint.progress = 0 btn_download_breakpoint.progress = 0
@ -508,7 +508,7 @@ FluContentPage{
FileDialog { FileDialog {
id: file_dialog id: file_dialog
onAccepted: { onAccepted: {
FluNetwork.postForm("https://httpbingo.org/post") Network.postForm("https://httpbingo.org/post")
.setRetry(1)// .setRetry(1)//
.add("accessToken","12345678") .add("accessToken","12345678")
.addFile("file",FluTools.toLocalPath(file_dialog.currentFile)) .addFile("file",FluTools.toLocalPath(file_dialog.currentFile))
@ -532,7 +532,7 @@ FluContentPage{
} }
} }
FluArea{ FluFrame{
anchors{ anchors{
top: layout_flick.top top: layout_flick.top
bottom: layout_flick.bottom bottom: layout_flick.bottom

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("Pagination") title: qsTr("Pagination")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 200 Layout.preferredHeight: 200
paddings: 10 padding: 10
Layout.topMargin: 20
ColumnLayout{ ColumnLayout{
spacing: 20 spacing: 20
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -37,7 +36,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluPagination{ code:'FluPagination{
pageCurrent: 1 pageCurrent: 1
itemCount: 1000 itemCount: 1000

View File

@ -9,13 +9,10 @@ FluScrollablePage{
title: qsTr("Pivot") title: qsTr("Pivot")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 400
height: 400 padding: 10
paddings: 10
FluPivot{ FluPivot{
anchors.fill: parent anchors.fill: parent
@ -49,7 +46,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluPivot{ code:'FluPivot{
anchors.fill: parent anchors.fill: parent
FluPivotItem:{ FluPivotItem:{

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("Progress") title: qsTr("Progress")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 130
height: 130 padding: 10
paddings: 10
ColumnLayout{ ColumnLayout{
spacing: 10 spacing: 10
@ -32,7 +31,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluProgressBar{ code:'FluProgressBar{
} }
@ -42,11 +41,11 @@ FluProgressRing{
' '
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 286 Layout.preferredHeight: 286
paddings: 10 padding: 10
ColumnLayout{ ColumnLayout{
spacing: 10 spacing: 10
@ -88,7 +87,7 @@ FluProgressRing{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluProgressBar{ code:'FluProgressBar{
indeterminate: false indeterminate: false
} }

View File

@ -11,7 +11,6 @@ FluScrollablePage{
FluQRCode{ FluQRCode{
id:qrcode id:qrcode
Layout.topMargin: 20
size:slider_size.value size:slider_size.value
text:text_box.text text:text_box.text
color:color_picker.current color:color_picker.current

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("RadioButton") title: qsTr("RadioButton")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20
Row{ Row{
spacing: 30 spacing: 30
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -41,16 +40,16 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluRadioButton{ code:'FluRadioButton{
text:"Text" text:"Text"
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 100 Layout.preferredHeight: 100
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluRadioButtons{ FluRadioButtons{
spacing: 8 spacing: 8
@ -83,7 +82,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluRadioButtons{ code:'FluRadioButtons{
spacing: 8 spacing: 8
FluRadioButton{ FluRadioButton{

View File

@ -9,11 +9,10 @@ FluScrollablePage {
title: qsTr("RatingControl") title: qsTr("RatingControl")
FluArea { FluFrame {
Layout.fillWidth: true Layout.fillWidth: true
height: 100 Layout.preferredHeight: 100
paddings: 10 padding: 10
Layout.topMargin: 20
Column { Column {
spacing: 10 spacing: 10
@ -27,7 +26,7 @@ FluScrollablePage {
CodeExpander { CodeExpander {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code: 'FluRatingControl{ code: 'FluRatingControl{
}' }'

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("Rectangle") title: qsTr("Rectangle")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 80
height: 80 padding: 10
paddings: 10
Column{ Column{
spacing: 15 spacing: 15
@ -64,7 +63,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluRectangle{ code:'FluRectangle{
radius: [25,25,25,25] radius: [25,25,25,25]
width: 50 width: 50

View File

@ -9,6 +9,6 @@ FluPage{
launchMode: FluPageType.SingleTop launchMode: FluPageType.SingleTop
FluRemoteLoader{ FluRemoteLoader{
anchors.fill: parent anchors.fill: parent
source: "https://zhu-zichu.gitee.io/Qt5_T_RemoteLoader.qml" source: "https://zhu-zichu.gitee.io/Qt_174_RemoteLoader.qml"
} }
} }

View File

@ -4,38 +4,24 @@ import QtQuick.Window 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import FluentUI 1.0 import FluentUI 1.0
import "../component" import "../component"
import "../viewmodel"
import "../global" import "../global"
FluScrollablePage{ FluScrollablePage{
title: qsTr("Settings") title: qsTr("Settings")
SettingsViewModel{
id:viewmodel_settings
}
FluEvent{ FluEvent{
id:event_checkupdate_finish
name: "checkUpdateFinish" name: "checkUpdateFinish"
onTriggered: { onTriggered: {
btn_checkupdate.loading = false btn_checkupdate.loading = false
} }
} }
Component.onCompleted: { FluFrame{
FluEventBus.registerEvent(event_checkupdate_finish)
}
Component.onDestruction: {
FluEventBus.unRegisterEvent(event_checkupdate_finish)
}
FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 60 Layout.preferredHeight: 60
paddings: 10 padding: 10
Row{ Row{
spacing: 20 spacing: 20
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -56,11 +42,11 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 50 height: 50
paddings: 10 padding: 10
FluCheckBox{ FluCheckBox{
text: qsTr("Use System AppBar") text: qsTr("Use System AppBar")
checked: FluApp.useSystemAppBar checked: FluApp.useSystemAppBar
@ -72,11 +58,11 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 50 height: 50
paddings: 10 padding: 10
FluCheckBox{ FluCheckBox{
text:qsTr("Fits AppBar Windows") text:qsTr("Fits AppBar Windows")
checked: window.fitsAppBarWindows checked: window.fitsAppBarWindows
@ -95,15 +81,15 @@ FluScrollablePage{
negativeText: qsTr("Cancel") negativeText: qsTr("Cancel")
positiveText: qsTr("OK") positiveText: qsTr("OK")
onPositiveClicked: { onPositiveClicked: {
FluApp.exit(931) FluRouter.exit(931)
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 128 height: 128
paddings: 10 padding: 10
ColumnLayout{ ColumnLayout{
spacing: 5 spacing: 5
@ -129,11 +115,11 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 160 height: 160
paddings: 10 padding: 10
ColumnLayout{ ColumnLayout{
spacing: 5 spacing: 5
@ -149,10 +135,10 @@ FluScrollablePage{
Repeater{ Repeater{
model: [{title:qsTr("Open"),mode:FluNavigationViewType.Open},{title:qsTr("Compact"),mode:FluNavigationViewType.Compact},{title:qsTr("Minimal"),mode:FluNavigationViewType.Minimal},{title:qsTr("Auto"),mode:FluNavigationViewType.Auto}] model: [{title:qsTr("Open"),mode:FluNavigationViewType.Open},{title:qsTr("Compact"),mode:FluNavigationViewType.Compact},{title:qsTr("Minimal"),mode:FluNavigationViewType.Minimal},{title:qsTr("Auto"),mode:FluNavigationViewType.Auto}]
delegate: FluRadioButton{ delegate: FluRadioButton{
checked : viewmodel_settings.displayMode===modelData.mode text: modelData.title
text:modelData.title checked: GlobalModel.displayMode === modelData.mode
clickListener:function(){ clickListener:function(){
viewmodel_settings.displayMode = modelData.mode GlobalModel.displayMode = modelData.mode
} }
} }
} }
@ -169,11 +155,11 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 80 height: 80
paddings: 10 padding: 10
ColumnLayout{ ColumnLayout{
spacing: 10 spacing: 10

View File

@ -0,0 +1,90 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import FluentUI 1.0
import "../component"
FluScrollablePage{
title: qsTr("Sheet")
FluSheet{
id:sheet
title: qsTr("Title")
FluText{
text: qsTr("Some contents...\nSome contents...\nSome contents...")
anchors{
left: parent.left
leftMargin: 10
}
}
}
FluFrame{
Layout.fillWidth: true
Layout.preferredHeight: 280
padding: 10
Column{
anchors.centerIn: parent
spacing: 10
Row{
spacing: 10
FluButton{
width: 80
height: 30
text: qsTr("top")
onClicked: {
sheet.open(FluSheetType.Top)
}
}
FluButton{
width: 80
height: 30
text: qsTr("right")
onClicked: {
sheet.open(FluSheetType.Right)
}
}
}
Row{
spacing: 10
FluButton{
width: 80
height: 30
text: qsTr("bottom")
onClicked: {
sheet.open(FluSheetType.Bottom)
}
}
FluButton{
width: 80
height: 30
text: qsTr("left")
onClicked: {
sheet.open(FluSheetType.Left)
}
}
}
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -6
code:'FluSheet{
id:sheet
title: qsTr("Title")
FluText{
text: qsTr("Some contents...")
anchors{
left: parent.left
leftMargin: 10
}
}
}
sheet.open(FluSheetType.Bottom)
'
}
}

View File

@ -9,18 +9,17 @@ FluScrollablePage{
title: qsTr("ShortcutPicker") title: qsTr("ShortcutPicker")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 100
height: 100 padding: 10
paddings: 10
FluShortcutPicker{ FluShortcutPicker{
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluShortcutPicker{ code:'FluShortcutPicker{
}' }'

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("Slider") title: qsTr("Slider")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 200 Layout.preferredHeight: 200
Layout.topMargin: 20 padding: 10
paddings: 10
Row{ Row{
spacing: 30 spacing: 30
@ -27,18 +26,18 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluSlider{ code:'FluSlider{
value:50 value:50
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 200 Layout.preferredHeight: 200
Layout.topMargin: 20 Layout.topMargin: 20
paddings: 10 padding: 10
Row{ Row{
spacing: 30 spacing: 30
FluRangeSlider{ FluRangeSlider{
@ -51,7 +50,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluRangeSlider{ code:'FluRangeSlider{
orientation: Qt.Vertical orientation: Qt.Vertical
}' }'

View File

@ -13,7 +13,6 @@ FluContentPage{
id:layout_dropdown id:layout_dropdown
anchors{ anchors{
top: parent.top top: parent.top
topMargin: 20
} }
FluText{ FluText{
text:"orientation:" text:"orientation:"

View File

@ -27,7 +27,6 @@ FluContentPage{
Flickable{ Flickable{
id: scroll id: scroll
anchors.fill: parent anchors.fill: parent
anchors.topMargin: 20
boundsBehavior:Flickable.StopAtBounds boundsBehavior:Flickable.StopAtBounds
contentHeight: staggered_view.implicitHeight contentHeight: staggered_view.implicitHeight
clip: true clip: true
@ -43,8 +42,7 @@ FluContentPage{
FluText{ FluText{
color:"#FFFFFF" color:"#FFFFFF"
text:model.index text:model.index
font.bold: true font: FluTextStyle.Title
font.pixelSize: 18
anchors.centerIn: parent anchors.centerIn: parent
} }
} }

View File

@ -9,12 +9,11 @@ FluScrollablePage{
title: qsTr("StatusLayout") title: qsTr("StatusLayout")
FluArea{ FluFrame{
id:layout_actions id:layout_actions
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 50
height: 50 padding: 10
paddings: 10
RowLayout{ RowLayout{
spacing: 14 spacing: 14
FluDropDownButton{ FluDropDownButton{
@ -53,11 +52,11 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 10 Layout.topMargin: 10
height: 380 Layout.preferredHeight: 380
paddings: 10 padding: 10
FluStatusLayout{ FluStatusLayout{
id:status_view id:status_view
anchors.fill: parent anchors.fill: parent
@ -76,7 +75,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluStatusLayout{ code:'FluStatusLayout{
anchors.fill: parent anchors.fill: parent
statusMode: FluStatusLayoutType.Loading statusMode: FluStatusLayoutType.Loading

View File

@ -29,11 +29,10 @@ FluScrollablePage{
newTab() newTab()
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 50
height: 50 padding: 10
paddings: 10
RowLayout{ RowLayout{
spacing: 14 spacing: 14
FluDropDownButton{ FluDropDownButton{
@ -91,11 +90,11 @@ FluScrollablePage{
} }
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 15 Layout.topMargin: 15
height: 400 Layout.preferredHeight: 400
paddings: 10 padding: 10
FluTabView{ FluTabView{
id:tab_view id:tab_view
onNewPressed:{ onNewPressed:{
@ -105,7 +104,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluTabView{ code:'FluTabView{
anchors.fill: parent anchors.fill: parent
Component.onCompleted: { Component.onCompleted: {

View File

@ -159,7 +159,7 @@ FluContentPage{
FluCheckBox{ FluCheckBox{
anchors.centerIn: parent anchors.centerIn: parent
checked: true === options.checked checked: true === options.checked
enableAnimation: false animationEnabled: false
clickListener: function(){ clickListener: function(){
var obj = table_view.getRow(row) var obj = table_view.getRow(row)
obj.checkbox = table_view.customItem(com_checbox,{checked:!options.checked}) obj.checkbox = table_view.customItem(com_checbox,{checked:!options.checked})
@ -239,7 +239,7 @@ FluContentPage{
} }
FluCheckBox{ FluCheckBox{
checked: true === root.seletedAll checked: true === root.seletedAll
enableAnimation: false animationEnabled: false
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
clickListener: function(){ clickListener: function(){
root.seletedAll = !root.seletedAll root.seletedAll = !root.seletedAll
@ -390,7 +390,7 @@ FluContentPage{
} }
} }
FluArea{ FluFrame{
id:layout_controls id:layout_controls
anchors{ anchors{
left: parent.left left: parent.left

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("Text") title: qsTr("Text")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 60
height: 60 padding: 10
paddings: 10
FluCopyableText{ FluCopyableText{
text: qsTr("This is a text that can be copied") text: qsTr("This is a text that can be copied")
@ -23,7 +22,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluCopyableText{ code:'FluCopyableText{
text: qsTr("This is a text that can be copied") text: qsTr("This is a text that can be copied")
}' }'

View File

@ -4,30 +4,20 @@ import QtQuick.Layouts 1.15
import QtQuick.Window 2.15 import QtQuick.Window 2.15
import FluentUI 1.0 import FluentUI 1.0
import "../component" import "../component"
import "../viewmodel"
FluScrollablePage{ FluScrollablePage{
title: qsTr("TextBox") title: qsTr("TextBox")
TextBoxViewModel{ FluFrame{
id:viewModel
}
FluArea{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20
FluTextBox{ FluTextBox{
placeholderText: qsTr("Single-line Input Box") placeholderText: qsTr("Single-line Input Box")
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
@ -45,16 +35,16 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluTextBox{ code:'FluTextBox{
placeholderText: qsTr("Single-line Input Box") placeholderText: qsTr("Single-line Input Box")
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluPasswordBox{ FluPasswordBox{
@ -76,26 +66,21 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluPasswordBox{ code:'FluPasswordBox{
placeholderText: qsTr("Please enter your password") placeholderText: qsTr("Please enter your password")
}' }'
} }
FluFrame{
FluArea{
Layout.fillWidth: true Layout.fillWidth: true
height: 36+multiine_textbox.height Layout.preferredHeight: 36+multiine_textbox.height
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluMultilineTextBox{ FluMultilineTextBox{
id: multiine_textbox id: multiine_textbox
placeholderText: qsTr("Multi-line Input Box") placeholderText: qsTr("Multi-line Input Box")
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
@ -114,16 +99,16 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluMultilineTextBox{ code:'FluMultilineTextBox{
placeholderText: qsTr("Multi-line Input Box") placeholderText: qsTr("Multi-line Input Box")
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluAutoSuggestBox{ FluAutoSuggestBox{
placeholderText: qsTr("AutoSuggestBox") placeholderText: qsTr("AutoSuggestBox")
@ -145,16 +130,16 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluAutoSuggestBox{ code:'FluAutoSuggestBox{
placeholderText: qsTr("AutoSuggestBox") placeholderText: qsTr("AutoSuggestBox")
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluSpinBox{ FluSpinBox{
disabled: spin_box_switch.checked disabled: spin_box_switch.checked
@ -174,7 +159,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluSpinBox{ code:'FluSpinBox{
}' }'

View File

@ -11,11 +11,10 @@ FluScrollablePage{
id: root id: root
title: qsTr("Theme") title: qsTr("Theme")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20
Layout.preferredHeight: 340 Layout.preferredHeight: 340
paddings: 10 padding: 10
ColumnLayout{ ColumnLayout{
spacing:0 spacing:0
@ -115,16 +114,16 @@ FluScrollablePage{
} }
FluToggleSwitch{ FluToggleSwitch{
Layout.topMargin: 5 Layout.topMargin: 5
checked: FluTheme.enableAnimation checked: FluTheme.animationEnabled
onClicked: { onClicked: {
FluTheme.enableAnimation = !FluTheme.enableAnimation FluTheme.animationEnabled = !FluTheme.animationEnabled
} }
} }
} }
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluTheme.accentColor = FluColors.Orange code:'FluTheme.accentColor = FluColors.Orange
FluTheme.dark = true FluTheme.dark = true

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("TimePicker") title: qsTr("TimePicker")
launchMode: FluPageType.SingleInstance launchMode: FluPageType.SingleInstance
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.preferredHeight: 80
height: 80 padding: 10
paddings: 10
ColumnLayout{ ColumnLayout{
@ -43,17 +42,17 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluTimePicker{ code:'FluTimePicker{
}' }'
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 80 Layout.preferredHeight: 80
paddings: 10 padding: 10
ColumnLayout{ ColumnLayout{
@ -83,7 +82,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluTimePicker{ code:'FluTimePicker{
hourFormat:FluTimePickerType.HH hourFormat:FluTimePickerType.HH
}' }'

View File

@ -106,7 +106,6 @@ FluScrollablePage{
RowLayout{ RowLayout{
spacing: 20 spacing: 20
Layout.topMargin: 20
FluTextBox{ FluTextBox{
id: text_box id: text_box
text: "Technical testing 2015-09-01" text: "Technical testing 2015-09-01"

View File

@ -9,11 +9,10 @@ FluScrollablePage{
title: qsTr("ToggleSwitch") title: qsTr("ToggleSwitch")
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Layout.topMargin: 20
Row{ Row{
spacing: 30 spacing: 30
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -41,7 +40,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluToggleSwitch{ code:'FluToggleSwitch{
text:"Text" text:"Text"
}' }'

View File

@ -10,15 +10,14 @@ FluScrollablePage{
title: qsTr("Tooltip") title: qsTr("Tooltip")
FluText{ FluText{
Layout.topMargin: 20
text: qsTr("Hover over Tultip and it pops up") text: qsTr("Hover over Tultip and it pops up")
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Column{ Column{
spacing: 5 spacing: 5
@ -41,7 +40,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluIconButton{ code:'FluIconButton{
iconSource:FluentIcons.ChromeCloseContrast iconSource:FluentIcons.ChromeCloseContrast
iconSize: 15 iconSize: 15
@ -53,11 +52,11 @@ FluScrollablePage{
' '
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 68 Layout.preferredHeight: 68
paddings: 10 padding: 10
Column{ Column{
spacing: 5 spacing: 5
@ -84,7 +83,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluButton{ code:'FluButton{
id: button_1 id: button_1
text: qsTr("Delete") text: qsTr("Delete")

View File

@ -18,11 +18,10 @@ FluScrollablePage{
] ]
} }
FluArea{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
height: 130 Layout.preferredHeight: 130
paddings: 10 padding: 10
Layout.topMargin: 20
FluFilledButton{ FluFilledButton{
anchors{ anchors{
@ -66,7 +65,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -1 Layout.topMargin: -6
code:'FluTour{ code:'FluTour{
id:tour id:tour
steps:[ steps:[

View File

@ -33,7 +33,6 @@ FluContentPage {
spacing: 12 spacing: 12
width: 300 width: 300
anchors{ anchors{
topMargin: 20
top:parent.top top:parent.top
left: parent.left left: parent.left
leftMargin: 10 leftMargin: 10
@ -103,7 +102,7 @@ FluContentPage {
} }
} }
} }
FluArea{ FluFrame{
anchors{ anchors{
left: layout_column.right left: layout_column.right
top: parent.top top: parent.top

View File

@ -10,15 +10,14 @@ FluContentPage {
title: qsTr("Typography") title: qsTr("Typography")
rightPadding: 10 rightPadding: 10
FluArea{ FluFrame{
anchors{ anchors{
top:parent.top top:parent.top
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: parent.bottom bottom: parent.bottom
topMargin: 20
} }
paddings: 10 padding: 10
ColumnLayout{ ColumnLayout{
spacing: 0 spacing: 0
scale: textScale scale: textScale

View File

@ -9,9 +9,8 @@ FluContentPage{
title: qsTr("Watermark") title: qsTr("Watermark")
FluArea{ FluFrame{
anchors.fill: parent anchors.fill: parent
anchors.topMargin: 20
ColumnLayout{ ColumnLayout{
anchors{ anchors{

View File

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

View File

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

View File

@ -31,7 +31,7 @@ FluWindow {
MouseArea{ MouseArea{
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
FluApp.navigate("/") FluRouter.navigate("/")
} }
} }
} }

View File

@ -71,7 +71,7 @@ FluWindow {
FluFilledButton{ FluFilledButton{
text: qsTr("Restart Program") text: qsTr("Restart Program")
onClicked: { onClicked: {
FluApp.exit(931) FluRouter.exit(931)
} }
} }
} }

View File

@ -8,14 +8,14 @@ import "../component"
FluWindowDialog { FluWindowDialog {
id:window id:window
title:qsTr("FluentUI Initalizr") title:qsTr("FluentUI Initializr")
width: 600 width: 600
height: 400 height: 400
contentDelegate:Component{ contentDelegate:Component{
Item{ Item{
Connections{ Connections{
target: InitalizrHelper target: InitializrHelper
function onError(message){ function onError(message){
showError(message) showError(message)
} }
@ -27,7 +27,7 @@ FluWindowDialog {
FluText{ FluText{
id:text_title id:text_title
text:qsTr("FluentUI Initalizr") text:qsTr("FluentUI Initializr")
font: FluTextStyle.Title font: FluTextStyle.Title
anchors{ anchors{
left: parent.left left: parent.left
@ -102,7 +102,7 @@ FluWindowDialog {
width: 120 width: 120
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
onClicked: { onClicked: {
InitalizrHelper.generate(text_box_name.text,text_box_path.text) InitializrHelper.generate(text_box_name.text,text_box_path.text)
} }
} }
} }

View File

@ -20,7 +20,7 @@ FluWindow {
loader.reload() loader.reload()
} }
} }
FluArea{ FluFrame{
anchors.fill: parent anchors.fill: parent
FluRemoteLoader{ FluRemoteLoader{
id:loader id:loader
@ -41,7 +41,7 @@ FluWindow {
} }
FluText{ FluText{
text: qsTr("Drag in a qml file") text: qsTr("Drag in a qml file")
font.pixelSize: 26 font: FluTextStyle.Title
anchors.centerIn: parent anchors.centerIn: parent
visible: !loader.itemLodaer().item && loader.statusMode === FluStatusLayoutType.Success visible: !loader.itemLodaer().item && loader.statusMode === FluStatusLayoutType.Success
} }

View File

@ -51,7 +51,7 @@ FluWindow {
showError(qsTr("Please feel free to enter a password")) showError(qsTr("Please feel free to enter a password"))
return return
} }
onResult({password:textbox_password.text}) setResult({password:textbox_password.text})
window.close() window.close()
} }
} }

View File

@ -7,7 +7,6 @@ import Qt.labs.platform 1.1
import FluentUI 1.0 import FluentUI 1.0
import example 1.0 import example 1.0
import "../component" import "../component"
import "../viewmodel"
import "../global" import "../global"
FluWindow { FluWindow {
@ -29,37 +28,23 @@ FluWindow {
z:7 z:7
} }
SettingsViewModel{
id:viewmodel_settings
}
FluEvent{ FluEvent{
id:event_checkupdate
name: "checkUpdate" name: "checkUpdate"
onTriggered: { onTriggered: {
checkUpdate(false) checkUpdate(false)
} }
} }
onFirstVisible: { onLazyLoad: {
timer_tour_delay.restart()
}
Timer{
id:timer_tour_delay
interval: 200
onTriggered: {
tour.open() tour.open()
} }
}
Component.onCompleted: { Component.onCompleted: {
checkUpdate(true) checkUpdate(true)
FluEventBus.registerEvent(event_checkupdate)
} }
Component.onDestruction: { Component.onDestruction: {
FluEventBus.unRegisterEvent(event_checkupdate) FluRouter.exit()
} }
SystemTrayIcon { SystemTrayIcon {
@ -71,7 +56,7 @@ FluWindow {
MenuItem { MenuItem {
text: "退出" text: "退出"
onTriggered: { onTriggered: {
FluApp.exit() FluRouter.exit()
} }
} }
} }
@ -106,7 +91,7 @@ FluWindow {
positiveText: qsTr("Quit") positiveText: qsTr("Quit")
neutralText: qsTr("Cancel") neutralText: qsTr("Cancel")
onPositiveClicked:{ onPositiveClicked:{
FluApp.exit(0) FluRouter.exit(0)
} }
} }
@ -116,9 +101,9 @@ FluWindow {
width: 186 width: 186
FluMenuItem{ FluMenuItem{
text: qsTr("Open in Separate Window") text: qsTr("Open in Separate Window")
font.pixelSize: 12 font: FluTextStyle.Caption
onClicked: { onClicked: {
FluApp.navigate("/pageWindow",{title:modelData.title,url:modelData.url}) FluRouter.navigate("/pageWindow",{title:modelData.title,url:modelData.url})
} }
} }
} }
@ -175,14 +160,14 @@ FluWindow {
} }
} }
Component.onCompleted: { Component.onCompleted: {
appBar.setHitTestVisible(layout_back_buttons) window.setHitTestVisible(layout_back_buttons)
} }
} }
FluRemoteLoader{ FluRemoteLoader{
id:loader id:loader
lazy: true lazy: true
anchors.fill: parent anchors.fill: parent
source: "https://zhu-zichu.gitee.io/Qt_168_LieflatPage.qml" source: "https://zhu-zichu.gitee.io/Qt_174_LieflatPage.qml"
} }
} }
front: Item{ front: Item{
@ -197,7 +182,7 @@ FluWindow {
z:999 z:999
//StackpopFluPagelaunchMode //StackpopFluPagelaunchMode
// pageMode: FluNavigationViewType.Stack // pageMode: FluNavigationViewType.Stack
//NoStackFluViewModel //NoStack
pageMode: FluNavigationViewType.NoStack pageMode: FluNavigationViewType.NoStack
items: ItemsOriginal items: ItemsOriginal
footerItems:ItemsFooter footerItems:ItemsFooter
@ -207,7 +192,7 @@ FluWindow {
} }
return FluTools.isMacos() ? 20 : 0 return FluTools.isMacos() ? 20 : 0
} }
displayMode:viewmodel_settings.displayMode displayMode: GlobalModel.displayMode
logo: "qrc:/example/res/image/favicon.ico" logo: "qrc:/example/res/image/favicon.ico"
title:"FluentUI" title:"FluentUI"
onLogoClicked:{ onLogoClicked:{
@ -233,9 +218,9 @@ FluWindow {
ItemsOriginal.paneItemMenu = nav_item_right_menu ItemsOriginal.paneItemMenu = nav_item_right_menu
ItemsFooter.navigationView = nav_view ItemsFooter.navigationView = nav_view
ItemsFooter.paneItemMenu = nav_item_right_menu ItemsFooter.paneItemMenu = nav_item_right_menu
appBar.setHitTestVisible(nav_view.buttonMenu) window.setHitTestVisible(nav_view.buttonMenu)
appBar.setHitTestVisible(nav_view.buttonBack) window.setHitTestVisible(nav_view.buttonBack)
appBar.setHitTestVisible(nav_view.imageLogo) window.setHitTestVisible(nav_view.imageLogo)
setCurrentIndex(0) setCurrentIndex(0)
} }
} }
@ -268,7 +253,7 @@ FluWindow {
} }
function handleDarkChanged(button){ function handleDarkChanged(button){
if(!FluTheme.enableAnimation || window.fitsAppBarWindows === false){ if(!FluTheme.animationEnabled || window.fitsAppBarWindows === false){
changeDark() changeDark()
}else{ }else{
if(loader_reveal.sourceComponent){ if(loader_reveal.sourceComponent){
@ -355,11 +340,11 @@ FluWindow {
} }
} }
FluNetworkCallable{ NetworkCallable{
id:callable id:callable
property bool silent: true property bool silent: true
onStart: { onStart: {
console.debug("satrt check update...") console.debug("start check update...")
} }
onFinish: { onFinish: {
console.debug("check update finish") console.debug("check update finish")
@ -391,7 +376,7 @@ FluWindow {
function checkUpdate(silent){ function checkUpdate(silent){
callable.silent = silent callable.silent = silent
FluNetwork.get("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest") Network.get("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest")
.go(callable) .go(callable)
} }
} }

View File

@ -16,7 +16,7 @@ FluWindow {
onInitArgument: onInitArgument:
(arg)=>{ (arg)=>{
window.title = arg.title window.title = arg.title
loader.setSource( arg.url,{animDisabled:true}) loader.setSource(arg.url,{animationEnabled:false})
} }
FluLoader{ FluLoader{
id: loader id: loader

Binary file not shown.

After

Width:  |  Height:  |  Size: 854 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 MiB

View File

@ -4,14 +4,14 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import FluentUI 1.0 import FluentUI 1.0
Item { FluLauncher {
id: app id: app
Component.onCompleted: { Component.onCompleted: {
FluApp.init(app) FluApp.init(app)
FluApp.windowIcon = "qrc:/logo.ico" FluApp.windowIcon = "qrc:/logo.ico"
FluApp.routes = { FluRouter.routes = {
"/":"qrc:/main.qml", "/":"qrc:/main.qml",
} }
FluApp.navigate("/") FluRouter.navigate("/")
} }
} }

View File

@ -1,16 +1,16 @@
#include "InitalizrHelper.h" #include "InitializrHelper.h"
#include <QDir> #include <QDir>
#include <QGuiApplication> #include <QGuiApplication>
InitalizrHelper::InitalizrHelper(QObject *parent) : QObject(parent) InitializrHelper::InitializrHelper(QObject *parent) : QObject(parent)
{ {
} }
InitalizrHelper::~InitalizrHelper() = default; InitializrHelper::~InitializrHelper() = default;
bool InitalizrHelper::copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists){ bool InitializrHelper::copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists){
QDir _formDir = fromDir; QDir _formDir = fromDir;
QDir _toDir = toDir; QDir _toDir = toDir;
if(!_toDir.exists()) if(!_toDir.exists())
@ -44,7 +44,7 @@ bool InitalizrHelper::copyDir(const QDir& fromDir, const QDir& toDir, bool cover
} }
template <typename...Args> template <typename...Args>
void InitalizrHelper::templateToFile(const QString& source,const QString& dest,Args &&...args){ void InitializrHelper::templateToFile(const QString& source,const QString& dest,Args &&...args){
QFile file(source); QFile file(source);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&file); QTextStream in(&file);
@ -67,12 +67,12 @@ void InitalizrHelper::templateToFile(const QString& source,const QString& dest,A
} }
} }
void InitalizrHelper::copyFile(const QString& source,const QString& dest){ void InitializrHelper::copyFile(const QString& source,const QString& dest){
QFile::copy(source,dest); QFile::copy(source,dest);
QFile::setPermissions(dest, QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther); QFile::setPermissions(dest, QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther);
} }
void InitalizrHelper::generate(const QString& name,const QString& path){ void InitializrHelper::generate(const QString& name,const QString& path){
if(name.isEmpty()){ if(name.isEmpty()){
error(tr("The name cannot be empty")); error(tr("The name cannot be empty"));
return; return;

View File

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

View File

@ -1,4 +1,4 @@
#include "FluNetwork.h" #include "Network.h"
#include <QUrlQuery> #include <QUrlQuery>
#include <QBuffer> #include <QBuffer>
@ -18,11 +18,11 @@
#include <QEventLoop> #include <QEventLoop>
#include <QGuiApplication> #include <QGuiApplication>
FluNetworkCallable::FluNetworkCallable(QObject *parent):QObject{parent}{ NetworkCallable::NetworkCallable(QObject *parent):QObject{parent}{
} }
QString FluNetworkParams::method2String(){ QString NetworkParams::method2String(){
switch (_method) { switch (_method) {
case METHOD_GET: case METHOD_GET:
return "GET"; return "GET";
@ -41,25 +41,25 @@ QString FluNetworkParams::method2String(){
} }
} }
int FluNetworkParams::getTimeout(){ int NetworkParams::getTimeout(){
if(_timeout != -1){ if(_timeout != -1){
return _timeout; return _timeout;
} }
return FluNetwork::getInstance()->timeout(); return Network::getInstance()->timeout();
} }
int FluNetworkParams::getRetry(){ int NetworkParams::getRetry(){
if(_retry != -1){ if(_retry != -1){
return _retry; return _retry;
} }
return FluNetwork::getInstance()->retry(); return Network::getInstance()->retry();
} }
bool FluNetworkParams::getOpenLog(){ bool NetworkParams::getOpenLog(){
if(!_openLog.isNull()){ if(!_openLog.isNull()){
return _openLog.toBool(); return _openLog.toBool();
} }
return FluNetwork::getInstance()->openLog(); return Network::getInstance()->openLog();
} }
FluDownloadParam::FluDownloadParam(QObject *parent) FluDownloadParam::FluDownloadParam(QObject *parent)
@ -74,12 +74,12 @@ FluDownloadParam::FluDownloadParam(QString destPath,bool append,QObject *parent)
this->_append = append; this->_append = append;
} }
FluNetworkParams::FluNetworkParams(QObject *parent) NetworkParams::NetworkParams(QObject *parent)
: QObject{parent} : QObject{parent}
{ {
} }
FluNetworkParams::FluNetworkParams(QString url,Type type,Method method,QObject *parent) NetworkParams::NetworkParams(QString url,Type type,Method method,QObject *parent)
: QObject{parent} : QObject{parent}
{ {
this->_method = method; this->_method = method;
@ -87,62 +87,62 @@ FluNetworkParams::FluNetworkParams(QString url,Type type,Method method,QObject *
this->_type = type; this->_type = type;
} }
FluNetworkParams* FluNetworkParams::add(QString key,QVariant val){ NetworkParams* NetworkParams::add(QString key,QVariant val){
_paramMap.insert(key,val); _paramMap.insert(key,val);
return this; return this;
} }
FluNetworkParams* FluNetworkParams::addFile(QString key,QVariant val){ NetworkParams* NetworkParams::addFile(QString key,QVariant val){
_fileMap.insert(key,val); _fileMap.insert(key,val);
return this; return this;
} }
FluNetworkParams* FluNetworkParams::addHeader(QString key,QVariant val){ NetworkParams* NetworkParams::addHeader(QString key,QVariant val){
_headerMap.insert(key,val); _headerMap.insert(key,val);
return this; return this;
} }
FluNetworkParams* FluNetworkParams::addQuery(QString key,QVariant val){ NetworkParams* NetworkParams::addQuery(QString key,QVariant val){
_queryMap.insert(key,val); _queryMap.insert(key,val);
return this; return this;
} }
FluNetworkParams* FluNetworkParams::setBody(QString val){ NetworkParams* NetworkParams::setBody(QString val){
_body = val; _body = val;
return this; return this;
} }
FluNetworkParams* FluNetworkParams::setTimeout(int val){ NetworkParams* NetworkParams::setTimeout(int val){
_timeout = val; _timeout = val;
return this; return this;
} }
FluNetworkParams* FluNetworkParams::setRetry(int val){ NetworkParams* NetworkParams::setRetry(int val){
_retry = val; _retry = val;
return this; return this;
} }
FluNetworkParams* FluNetworkParams::setCacheMode(int val){ NetworkParams* NetworkParams::setCacheMode(int val){
_cacheMode = val; _cacheMode = val;
return this; return this;
} }
FluNetworkParams* FluNetworkParams::toDownload(QString destPath,bool append){ NetworkParams* NetworkParams::toDownload(QString destPath,bool append){
_downloadParam = new FluDownloadParam(destPath,append,this); _downloadParam = new FluDownloadParam(destPath,append,this);
return this; return this;
} }
FluNetworkParams* FluNetworkParams::bind(QObject* target){ NetworkParams* NetworkParams::bind(QObject* target){
_target = target; _target = target;
return this; return this;
} }
FluNetworkParams* FluNetworkParams::openLog(QVariant val){ NetworkParams* NetworkParams::openLog(QVariant val){
_openLog = val; _openLog = val;
return this; return this;
} }
QString FluNetworkParams::buildCacheKey(){ QString NetworkParams::buildCacheKey(){
QJsonObject obj; QJsonObject obj;
obj.insert("url",_url); obj.insert("url",_url);
obj.insert("method",method2String()); obj.insert("method",method2String());
@ -161,30 +161,30 @@ QString FluNetworkParams::buildCacheKey(){
return QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex(); return QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex();
} }
void FluNetworkParams::go(FluNetworkCallable* callable){ void NetworkParams::go(NetworkCallable* callable){
QJSValueList data; QJSValueList data;
data<<qjsEngine(callable)->newQObject(this); data<<qjsEngine(callable)->newQObject(this);
FluNetwork::getInstance()->_interceptor.call(data); Network::getInstance()->_interceptor.call(data);
if(_downloadParam){ if(_downloadParam){
FluNetwork::getInstance()->handleDownload(this,callable); Network::getInstance()->handleDownload(this,callable);
}else{ }else{
FluNetwork::getInstance()->handle(this,callable); Network::getInstance()->handle(this,callable);
} }
} }
void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){ void Network::handle(NetworkParams* params,NetworkCallable* c){
QPointer<FluNetworkCallable> callable(c); QPointer<NetworkCallable> callable(c);
QThreadPool::globalInstance()->start([=](){ QThreadPool::globalInstance()->start([=](){
if(!callable.isNull()){ if(!callable.isNull()){
callable->start(); callable->start();
} }
QString cacheKey = params->buildCacheKey(); QString cacheKey = params->buildCacheKey();
if(params->_cacheMode == FluNetworkType::CacheMode::FirstCacheThenRequest && cacheExists(cacheKey)){ if(params->_cacheMode == NetworkType::CacheMode::FirstCacheThenRequest && cacheExists(cacheKey)){
if(!callable.isNull()){ if(!callable.isNull()){
callable->cache(readCache(cacheKey)); callable->cache(readCache(cacheKey));
} }
} }
if(params->_cacheMode == FluNetworkType::CacheMode::IfNoneCacheRequest && cacheExists(cacheKey)){ if(params->_cacheMode == NetworkType::CacheMode::IfNoneCacheRequest && cacheExists(cacheKey)){
if(!callable.isNull()){ if(!callable.isNull()){
callable->cache(readCache(cacheKey)); callable->cache(readCache(cacheKey));
callable->finish(); callable->finish();
@ -228,7 +228,7 @@ void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
disconnect(conn_quit); disconnect(conn_quit);
} }
QString response; QString response;
if(params->_method == FluNetworkParams::METHOD_HEAD){ if(params->_method == NetworkParams::METHOD_HEAD){
response = headerList2String(reply->rawHeaderPairs()); response = headerList2String(reply->rawHeaderPairs());
}else{ }else{
if(reply->isOpen()){ if(reply->isOpen()){
@ -238,7 +238,7 @@ void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if(httpStatus == 200){ if(httpStatus == 200){
if(!callable.isNull()){ if(!callable.isNull()){
if(params->_cacheMode != FluNetworkType::CacheMode::NoCache){ if(params->_cacheMode != NetworkType::CacheMode::NoCache){
saveResponse(cacheKey,response); saveResponse(cacheKey,response);
} }
callable->success(response); callable->success(response);
@ -248,7 +248,7 @@ void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
}else{ }else{
if(i == params->getRetry()-1){ if(i == params->getRetry()-1){
if(!callable.isNull()){ if(!callable.isNull()){
if(params->_cacheMode == FluNetworkType::CacheMode::RequestFailedReadCache && cacheExists(cacheKey)){ if(params->_cacheMode == NetworkType::CacheMode::RequestFailedReadCache && cacheExists(cacheKey)){
if(!callable.isNull()){ if(!callable.isNull()){
callable->cache(readCache(cacheKey)); callable->cache(readCache(cacheKey));
} }
@ -267,8 +267,8 @@ void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
}); });
} }
void FluNetwork::handleDownload(FluNetworkParams* params,FluNetworkCallable* c){ void Network::handleDownload(NetworkParams* params,NetworkCallable* c){
QPointer<FluNetworkCallable> callable(c); QPointer<NetworkCallable> callable(c);
QThreadPool::globalInstance()->start([=](){ QThreadPool::globalInstance()->start([=](){
if(!callable.isNull()){ if(!callable.isNull()){
callable->start(); callable->start();
@ -391,7 +391,7 @@ void FluNetwork::handleDownload(FluNetworkParams* params,FluNetworkCallable* c){
}); });
} }
QString FluNetwork::readCache(const QString& key){ QString Network::readCache(const QString& key){
auto filePath = getCacheFilePath(key); auto filePath = getCacheFilePath(key);
QString result; QString result;
QFile file(filePath); QFile file(filePath);
@ -405,11 +405,11 @@ QString FluNetwork::readCache(const QString& key){
return result; return result;
} }
bool FluNetwork::cacheExists(const QString& key){ bool Network::cacheExists(const QString& key){
return QFile(getCacheFilePath(key)).exists(); return QFile(getCacheFilePath(key)).exists();
} }
QString FluNetwork::getCacheFilePath(const QString& key){ QString Network::getCacheFilePath(const QString& key){
QDir cacheDir(_cacheDir); QDir cacheDir(_cacheDir);
if(!cacheDir.exists()){ if(!cacheDir.exists()){
cacheDir.mkpath(_cacheDir); cacheDir.mkpath(_cacheDir);
@ -417,7 +417,7 @@ QString FluNetwork::getCacheFilePath(const QString& key){
return cacheDir.absoluteFilePath(key); return cacheDir.absoluteFilePath(key);
} }
QString FluNetwork::headerList2String(const QList<QNetworkReply::RawHeaderPair>& data){ QString Network::headerList2String(const QList<QNetworkReply::RawHeaderPair>& data){
QJsonObject object; QJsonObject object;
for (auto it = data.constBegin(); it != data.constEnd(); ++it) { for (auto it = data.constBegin(); it != data.constEnd(); ++it) {
object.insert(QString(it->first),QString(it->second)); object.insert(QString(it->first),QString(it->second));
@ -425,7 +425,7 @@ QString FluNetwork::headerList2String(const QList<QNetworkReply::RawHeaderPair>&
return QJsonDocument(object).toJson(QJsonDocument::Compact); return QJsonDocument(object).toJson(QJsonDocument::Compact);
} }
QString FluNetwork::map2String(const QMap<QString, QVariant>& map){ QString Network::map2String(const QMap<QString, QVariant>& map){
QStringList parameters; QStringList parameters;
for (auto it = map.constBegin(); it != map.constEnd(); ++it) { for (auto it = map.constBegin(); it != map.constEnd(); ++it) {
parameters << QString("%1=%2").arg(it.key(), it.value().toString()); parameters << QString("%1=%2").arg(it.key(), it.value().toString());
@ -433,10 +433,10 @@ QString FluNetwork::map2String(const QMap<QString, QVariant>& map){
return parameters.join(" "); return parameters.join(" ");
} }
void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<FluNetworkCallable> callable){ void Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable){
QByteArray verb = params->method2String().toUtf8(); QByteArray verb = params->method2String().toUtf8();
switch (params->_type) { switch (params->_type) {
case FluNetworkParams::TYPE_FORM:{ case NetworkParams::TYPE_FORM:{
bool isFormData = !params->_fileMap.isEmpty(); bool isFormData = !params->_fileMap.isEmpty();
if(isFormData){ if(isFormData){
QHttpMultiPart *multiPart = new QHttpMultiPart(); QHttpMultiPart *multiPart = new QHttpMultiPart();
@ -484,7 +484,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ
} }
break; break;
} }
case FluNetworkParams::TYPE_JSON:{ case NetworkParams::TYPE_JSON:{
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8")); request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
QJsonObject json; QJsonObject json;
for (const auto& each : params->_paramMap.toStdMap()) for (const auto& each : params->_paramMap.toStdMap())
@ -495,7 +495,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ
reply = manager->sendCustomRequest(request,verb,data); reply = manager->sendCustomRequest(request,verb,data);
break; break;
} }
case FluNetworkParams::TYPE_JSONARRAY:{ case NetworkParams::TYPE_JSONARRAY:{
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8")); request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
QJsonArray jsonArray; QJsonArray jsonArray;
for (const auto& each : params->_paramMap.toStdMap()) for (const auto& each : params->_paramMap.toStdMap())
@ -508,7 +508,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ
reply = manager->sendCustomRequest(request,params->method2String().toUtf8(),data); reply = manager->sendCustomRequest(request,params->method2String().toUtf8(),data);
break; break;
} }
case FluNetworkParams::TYPE_BODY:{ case NetworkParams::TYPE_BODY:{
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("text/plain;charset=utf-8")); request.setHeader(QNetworkRequest::ContentTypeHeader, QString("text/plain;charset=utf-8"));
QByteArray data = params->_body.toUtf8(); QByteArray data = params->_body.toUtf8();
reply = manager->sendCustomRequest(request,verb,data); reply = manager->sendCustomRequest(request,verb,data);
@ -523,7 +523,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ
} }
} }
void FluNetwork::printRequestStartLog(QNetworkRequest request,FluNetworkParams* params){ void Network::printRequestStartLog(QNetworkRequest request,NetworkParams* params){
if(!params->getOpenLog()){ if(!params->getOpenLog()){
return; return;
} }
@ -551,7 +551,7 @@ void FluNetwork::printRequestStartLog(QNetworkRequest request,FluNetworkParams*
} }
} }
void FluNetwork::printRequestEndLog(QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,const QString& response){ void Network::printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response){
if(!params->getOpenLog()){ if(!params->getOpenLog()){
return; return;
} }
@ -560,7 +560,7 @@ void FluNetwork::printRequestEndLog(QNetworkRequest request,FluNetworkParams* pa
qDebug()<<"<Result>"<<qUtf8Printable(response); qDebug()<<"<Result>"<<qUtf8Printable(response);
} }
void FluNetwork::saveResponse(QString key,QString response){ void Network::saveResponse(QString key,QString response){
QSharedPointer<QFile> file(new QFile(getCacheFilePath(key))); QSharedPointer<QFile> file(new QFile(getCacheFilePath(key)));
QIODevice::OpenMode mode = QIODevice::WriteOnly|QIODevice::Truncate; QIODevice::OpenMode mode = QIODevice::WriteOnly|QIODevice::Truncate;
if (!file->open(mode)) if (!file->open(mode))
@ -570,7 +570,7 @@ void FluNetwork::saveResponse(QString key,QString response){
file->write(response.toUtf8().toBase64()); file->write(response.toUtf8().toBase64());
} }
void FluNetwork::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers){ void Network::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers){
request->setHeader(QNetworkRequest::UserAgentHeader,QString::fromStdString("Mozilla/5.0 %1/%2").arg(QGuiApplication::applicationName(),QGuiApplication::applicationVersion())); request->setHeader(QNetworkRequest::UserAgentHeader,QString::fromStdString("Mozilla/5.0 %1/%2").arg(QGuiApplication::applicationName(),QGuiApplication::applicationVersion()));
QMapIterator<QString, QVariant> iter(headers); QMapIterator<QString, QVariant> iter(headers);
while (iter.hasNext()) while (iter.hasNext())
@ -580,7 +580,7 @@ void FluNetwork::addHeaders(QNetworkRequest* request,const QMap<QString, QVarian
} }
} }
void FluNetwork::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){ void Network::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){
QMapIterator<QString, QVariant> iter(params); QMapIterator<QString, QVariant> iter(params);
QUrlQuery urlQuery(*url); QUrlQuery urlQuery(*url);
while (iter.hasNext()) while (iter.hasNext())
@ -591,7 +591,7 @@ void FluNetwork::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){
url->setQuery(urlQuery); url->setQuery(urlQuery);
} }
FluNetwork::FluNetwork(QObject *parent): QObject{parent} Network::Network(QObject *parent): QObject{parent}
{ {
timeout(5000); timeout(5000);
retry(3); retry(3);
@ -599,78 +599,78 @@ FluNetwork::FluNetwork(QObject *parent): QObject{parent}
cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network")); cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network"));
} }
FluNetworkParams* FluNetwork::get(const QString& url){ NetworkParams* Network::get(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_NONE,FluNetworkParams::METHOD_GET,this); return new NetworkParams(url,NetworkParams::TYPE_NONE,NetworkParams::METHOD_GET,this);
} }
FluNetworkParams* FluNetwork::head(const QString& url){ NetworkParams* Network::head(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_NONE,FluNetworkParams::METHOD_HEAD,this); return new NetworkParams(url,NetworkParams::TYPE_NONE,NetworkParams::METHOD_HEAD,this);
} }
FluNetworkParams* FluNetwork::postBody(const QString& url){ NetworkParams* Network::postBody(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_POST,this); return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_POST,this);
} }
FluNetworkParams* FluNetwork::putBody(const QString& url){ NetworkParams* Network::putBody(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_PUT,this); return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_PUT,this);
} }
FluNetworkParams* FluNetwork::patchBody(const QString& url){ NetworkParams* Network::patchBody(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_PATCH,this); return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_PATCH,this);
} }
FluNetworkParams* FluNetwork::deleteBody(const QString& url){ NetworkParams* Network::deleteBody(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_DELETE,this); return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_DELETE,this);
} }
FluNetworkParams* FluNetwork::postForm(const QString& url){ NetworkParams* Network::postForm(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_POST,this); return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_POST,this);
} }
FluNetworkParams* FluNetwork::putForm(const QString& url){ NetworkParams* Network::putForm(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_PUT,this); return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_PUT,this);
} }
FluNetworkParams* FluNetwork::patchForm(const QString& url){ NetworkParams* Network::patchForm(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_PATCH,this); return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_PATCH,this);
} }
FluNetworkParams* FluNetwork::deleteForm(const QString& url){ NetworkParams* Network::deleteForm(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_DELETE,this); return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_DELETE,this);
} }
FluNetworkParams* FluNetwork::postJson(const QString& url){ NetworkParams* Network::postJson(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_POST,this); return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_POST,this);
} }
FluNetworkParams* FluNetwork::putJson(const QString& url){ NetworkParams* Network::putJson(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_PUT,this); return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_PUT,this);
} }
FluNetworkParams* FluNetwork::patchJson(const QString& url){ NetworkParams* Network::patchJson(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_PATCH,this); return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_PATCH,this);
} }
FluNetworkParams* FluNetwork::deleteJson(const QString& url){ NetworkParams* Network::deleteJson(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_DELETE,this); return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_DELETE,this);
} }
FluNetworkParams* FluNetwork::postJsonArray(const QString& url){ NetworkParams* Network::postJsonArray(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_POST,this); return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_POST,this);
} }
FluNetworkParams* FluNetwork::putJsonArray(const QString& url){ NetworkParams* Network::putJsonArray(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_PUT,this); return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_PUT,this);
} }
FluNetworkParams* FluNetwork::patchJsonArray(const QString& url){ NetworkParams* Network::patchJsonArray(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_PATCH,this); return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_PATCH,this);
} }
FluNetworkParams* FluNetwork::deleteJsonArray(const QString& url){ NetworkParams* Network::deleteJsonArray(const QString& url){
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_DELETE,this); return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_DELETE,this);
} }
void FluNetwork::setInterceptor(QJSValue interceptor){ void Network::setInterceptor(QJSValue interceptor){
this->_interceptor = interceptor; this->_interceptor = interceptor;
} }

View File

@ -0,0 +1,169 @@
#ifndef NETWORK_H
#define NETWORK_H
#include <QObject>
#include <QtQml/qqml.h>
#include <QFile>
#include <QJsonValue>
#include <QJSValue>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "src/stdafx.h"
#include "src/singleton.h"
namespace NetworkType {
Q_NAMESPACE
enum CacheMode {
NoCache = 0x0000,
RequestFailedReadCache = 0x0001,
IfNoneCacheRequest = 0x0002,
FirstCacheThenRequest = 0x0004,
};
Q_ENUM_NS(CacheMode)
QML_NAMED_ELEMENT(NetworkType)
}
/**
* @brief The NetworkCallable class
*/
class NetworkCallable : public QObject{
Q_OBJECT
QML_NAMED_ELEMENT(NetworkCallable)
public:
explicit NetworkCallable(QObject *parent = nullptr);
Q_SIGNAL void start();
Q_SIGNAL void finish();
Q_SIGNAL void error(int status,QString errorString,QString result);
Q_SIGNAL void success(QString result);
Q_SIGNAL void cache(QString result);
Q_SIGNAL void uploadProgress(qint64 sent, qint64 total);
Q_SIGNAL void downloadProgress(qint64 recv, qint64 total);
};
/**
* @brief The FluDownloadParam class
*/
class FluDownloadParam : public QObject{
Q_OBJECT
public:
explicit FluDownloadParam(QObject *parent = nullptr);
FluDownloadParam(QString destPath,bool append,QObject *parent = nullptr);
public:
QString _destPath;
bool _append;
};
/**
* @brief The NetworkParams class
*/
class NetworkParams : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(NetworkParams)
public:
enum Method{
METHOD_GET,
METHOD_HEAD,
METHOD_POST,
METHOD_PUT,
METHOD_PATCH,
METHOD_DELETE
};
enum Type{
TYPE_NONE,
TYPE_FORM,
TYPE_JSON,
TYPE_JSONARRAY,
TYPE_BODY
};
explicit NetworkParams(QObject *parent = nullptr);
NetworkParams(QString url,Type type,Method method,QObject *parent = nullptr);
Q_INVOKABLE NetworkParams* addQuery(QString key,QVariant val);
Q_INVOKABLE NetworkParams* addHeader(QString key,QVariant val);
Q_INVOKABLE NetworkParams* add(QString key,QVariant val);
Q_INVOKABLE NetworkParams* addFile(QString key,QVariant val);
Q_INVOKABLE NetworkParams* setBody(QString val);
Q_INVOKABLE NetworkParams* setTimeout(int val);
Q_INVOKABLE NetworkParams* setRetry(int val);
Q_INVOKABLE NetworkParams* setCacheMode(int val);
Q_INVOKABLE NetworkParams* toDownload(QString destPath,bool append = false);
Q_INVOKABLE NetworkParams* bind(QObject* target);
Q_INVOKABLE NetworkParams* openLog(QVariant val);
Q_INVOKABLE void go(NetworkCallable* result);
QString buildCacheKey();
QString method2String();
int getTimeout();
int getRetry();
bool getOpenLog();
public:
FluDownloadParam* _downloadParam = nullptr;
QObject* _target = nullptr;
Method _method;
Type _type;
QString _url;
QString _body;
QMap<QString, QVariant> _queryMap;
QMap<QString, QVariant> _headerMap;
QMap<QString, QVariant> _paramMap;
QMap<QString, QVariant> _fileMap;
int _timeout = -1;
int _retry = -1;
QVariant _openLog;
int _cacheMode = NetworkType::CacheMode::NoCache;
};
/**
* @brief The Network class
*/
class Network : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(int,timeout)
Q_PROPERTY_AUTO(int,retry)
Q_PROPERTY_AUTO(QString,cacheDir)
Q_PROPERTY_AUTO(bool,openLog)
QML_NAMED_ELEMENT(Network)
QML_SINGLETON
private:
explicit Network(QObject *parent = nullptr);
public:
SINGLETON(Network)
static Network *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE NetworkParams* get(const QString& url);
Q_INVOKABLE NetworkParams* head(const QString& url);
Q_INVOKABLE NetworkParams* postBody(const QString& url);
Q_INVOKABLE NetworkParams* putBody(const QString& url);
Q_INVOKABLE NetworkParams* patchBody(const QString& url);
Q_INVOKABLE NetworkParams* deleteBody(const QString& url);
Q_INVOKABLE NetworkParams* postForm(const QString& url);
Q_INVOKABLE NetworkParams* putForm(const QString& url);
Q_INVOKABLE NetworkParams* patchForm(const QString& url);
Q_INVOKABLE NetworkParams* deleteForm(const QString& url);
Q_INVOKABLE NetworkParams* postJson(const QString& url);
Q_INVOKABLE NetworkParams* putJson(const QString& url);
Q_INVOKABLE NetworkParams* patchJson(const QString& url);
Q_INVOKABLE NetworkParams* deleteJson(const QString& url);
Q_INVOKABLE NetworkParams* postJsonArray(const QString& url);
Q_INVOKABLE NetworkParams* putJsonArray(const QString& url);
Q_INVOKABLE NetworkParams* patchJsonArray(const QString& url);
Q_INVOKABLE NetworkParams* deleteJsonArray(const QString& url);
Q_INVOKABLE void setInterceptor(QJSValue interceptor);
void handle(NetworkParams* params,NetworkCallable* result);
void handleDownload(NetworkParams* params,NetworkCallable* result);
private:
void sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable);
void addQueryParam(QUrl* url,const QMap<QString, QVariant>& params);
void addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers);
void saveResponse(QString key,QString response);
QString readCache(const QString& key);
bool cacheExists(const QString& key);
QString getCacheFilePath(const QString& key);
QString map2String(const QMap<QString, QVariant>& map);
QString headerList2String(const QList<QNetworkReply::RawHeaderPair>& data);
void printRequestStartLog(QNetworkRequest request,NetworkParams* params);
void printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response);
public:
QJSValue _interceptor;
};
#endif // Network_H

View File

@ -15,8 +15,9 @@
#include "src/component/FileWatcher.h" #include "src/component/FileWatcher.h"
#include "src/component/FpsItem.h" #include "src/component/FpsItem.h"
#include "src/helper/SettingsHelper.h" #include "src/helper/SettingsHelper.h"
#include "src/helper/InitalizrHelper.h" #include "src/helper/InitializrHelper.h"
#include "src/helper/TranslateHelper.h" #include "src/helper/TranslateHelper.h"
#include "src/helper/Network.h"
#ifdef FLUENTUI_BUILD_STATIC_LIB #ifdef FLUENTUI_BUILD_STATIC_LIB
#if (QT_VERSION > QT_VERSION_CHECK(6, 2, 0)) #if (QT_VERSION > QT_VERSION_CHECK(6, 2, 0))
@ -31,6 +32,9 @@ Q_IMPORT_QML_PLUGIN(FluentUIPlugin)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
const char *uri = "example";
int major = 1;
int minor = 0;
#ifdef WIN32 #ifdef WIN32
::SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); ::SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
qputenv("QT_QPA_PLATFORM","windows:darkmode=2"); qputenv("QT_QPA_PLATFORM","windows:darkmode=2");
@ -53,8 +57,8 @@ int main(int argc, char *argv[])
QGuiApplication::setApplicationVersion(APPLICATION_VERSION); QGuiApplication::setApplicationVersion(APPLICATION_VERSION);
QGuiApplication::setQuitOnLastWindowClosed(false); QGuiApplication::setQuitOnLastWindowClosed(false);
SettingsHelper::getInstance()->init(argv); SettingsHelper::getInstance()->init(argv);
Log::setup(argv,"example"); Log::setup(argv,uri);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL); QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
#endif #endif
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
@ -65,18 +69,22 @@ int main(int argc, char *argv[])
#endif #endif
#endif #endif
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
//@uri example
qmlRegisterType<CircularReveal>(uri, major, minor, "CircularReveal");
qmlRegisterType<FileWatcher>(uri, major, minor, "FileWatcher");
qmlRegisterType<FpsItem>(uri, major, minor, "FpsItem");
qmlRegisterType<NetworkCallable>(uri,major,minor,"NetworkCallable");
qmlRegisterType<NetworkParams>(uri,major,minor,"NetworkParams");
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
TranslateHelper::getInstance()->init(&engine); TranslateHelper::getInstance()->init(&engine);
engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance()); engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance());
engine.rootContext()->setContextProperty("SettingsHelper",SettingsHelper::getInstance()); engine.rootContext()->setContextProperty("SettingsHelper",SettingsHelper::getInstance());
engine.rootContext()->setContextProperty("InitalizrHelper",InitalizrHelper::getInstance()); engine.rootContext()->setContextProperty("InitializrHelper",InitializrHelper::getInstance());
engine.rootContext()->setContextProperty("TranslateHelper",TranslateHelper::getInstance()); engine.rootContext()->setContextProperty("TranslateHelper",TranslateHelper::getInstance());
engine.rootContext()->setContextProperty("Network",Network::getInstance());
#ifdef FLUENTUI_BUILD_STATIC_LIB #ifdef FLUENTUI_BUILD_STATIC_LIB
FluentUI::getInstance()->registerTypes(&engine); FluentUI::getInstance()->registerTypes(&engine);
#endif #endif
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
qmlRegisterType<FileWatcher>("example", 1, 0, "FileWatcher");
qmlRegisterType<FpsItem>("example", 1, 0, "FpsItem");
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml")); const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) { &app, [url](QObject *obj, const QUrl &objUrl) {
@ -86,7 +94,7 @@ int main(int argc, char *argv[])
engine.load(url); engine.load(url);
const int exec = QGuiApplication::exec(); const int exec = QGuiApplication::exec();
if (exec == 931) { if (exec == 931) {
QProcess::startDetached(qApp->applicationFilePath(), QStringList()); QProcess::startDetached(qApp->applicationFilePath(), qApp->arguments());
} }
return exec; return exec;
} }

View File

@ -13,7 +13,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# #
add_definitions(-DFLUENTUI_VERSION=1,7,3,0) add_definitions(-DFLUENTUI_VERSION=1,7,4,0)
if (FLUENTUI_BUILD_STATIC_LIB) if (FLUENTUI_BUILD_STATIC_LIB)
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB) add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
@ -73,12 +73,16 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
endif() endif()
#qml #qml
file(GLOB_RECURSE QML_PATHS *.qml) file(GLOB_RECURSE QML_PATHS *.qml qmldir)
foreach(filepath ${QML_PATHS}) foreach(filepath ${QML_PATHS})
if(${filepath} MATCHES "Qt${QT_VERSION_MAJOR}/") if(${filepath} MATCHES "Qt${QT_VERSION_MAJOR}/")
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
if(${filename} MATCHES "qmldir")
list(APPEND resource_files ${filename})
else()
list(APPEND qml_files ${filename}) list(APPEND qml_files ${filename})
endif() endif()
endif()
endforeach(filepath) endforeach(filepath)
# #

View File

@ -4,26 +4,16 @@
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
namespace FluViewModelType { namespace FluSheetType {
Q_NAMESPACE Q_NAMESPACE
enum Scope { enum Position {
Window = 0x0000, Left = 0x0000,
Application = 0x0001 Top = 0x0001,
Right = 0x0002,
Bottom = 0x0004,
}; };
Q_ENUM_NS(Scope) Q_ENUM_NS(Position)
QML_NAMED_ELEMENT(FluViewModelType) QML_NAMED_ELEMENT(FluSheetType)
}
namespace FluNetworkType {
Q_NAMESPACE
enum CacheMode {
NoCache = 0x0000,
RequestFailedReadCache = 0x0001,
IfNoneCacheRequest = 0x0002,
FirstCacheThenRequest = 0x0004,
};
Q_ENUM_NS(CacheMode)
QML_NAMED_ELEMENT(FluNetworkType)
} }
namespace FluThemeType { namespace FluThemeType {

View File

@ -10,20 +10,6 @@
#include <QClipboard> #include <QClipboard>
#include <QTranslator> #include <QTranslator>
FluWindowRegister::FluWindowRegister(QObject *parent):QObject{parent}{
from(nullptr);
to(nullptr);
path("");
}
void FluWindowRegister::launch(const QJsonObject& argument){
FluApp::getInstance()->navigate(path(),argument,this);
}
void FluWindowRegister::onResult(const QJsonObject& data){
Q_EMIT result(data);
}
FluApp::FluApp(QObject *parent):QObject{parent}{ FluApp::FluApp(QObject *parent):QObject{parent}{
useSystemAppBar(false); useSystemAppBar(false);
} }
@ -45,76 +31,3 @@ void FluApp::init(QObject *target,QLocale locale){
} }
} }
} }
void FluApp::run(){
navigate(initialRoute());
}
void FluApp::navigate(const QString& route,const QJsonObject& argument,FluWindowRegister* windowRegister){
if(!routes().contains(route)){
qCritical()<<"Not Found Route "<<route;
return;
}
QQmlComponent component(_engine, routes().value(route).toString());
if (component.isError()) {
qCritical() << component.errors();
return;
}
QVariantMap properties;
properties.insert("_route",route);
if(windowRegister){
properties.insert("_windowRegister",QVariant::fromValue(windowRegister));
}
properties.insert("argument",argument);
QQuickWindow *win=nullptr;
for (const auto& pair : _windows.toStdMap()) {
QString r = pair.second->property("_route").toString();
if(r == route){
win = pair.second;
break;
}
}
if(win){
int launchMode = win->property("launchMode").toInt();
if(launchMode == 1){
win->setProperty("",argument);
win->show();
win->raise();
win->requestActivate();
return;
}else if(launchMode == 2){
win->close();
}
}
win = qobject_cast<QQuickWindow*>(component.createWithInitialProperties(properties));
if(windowRegister){
windowRegister->to(win);
}
}
void FluApp::exit(int retCode){
for (const auto& pair : _windows.toStdMap()) {
pair.second->close();
removeWindow(pair.second);
}
qApp->exit(retCode);
}
void FluApp::addWindow(QQuickWindow* window){
_windows.insert(window->winId(),window);
}
void FluApp::removeWindow(QQuickWindow* window){
if(window){
_windows.remove(window->winId());
window->deleteLater();
window = nullptr;
}
}
QVariant FluApp::createWindowRegister(QQuickWindow* window,const QString& path){
FluWindowRegister *p = new FluWindowRegister(window);
p->from(window);
p->path(path);
return QVariant::fromValue(p);
}

View File

@ -4,7 +4,6 @@
#include <QObject> #include <QObject>
#include <QWindow> #include <QWindow>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
#include <QJsonArray>
#include <QQmlContext> #include <QQmlContext>
#include <QJsonObject> #include <QJsonObject>
#include <QQmlEngine> #include <QQmlEngine>
@ -13,31 +12,12 @@
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h" #include "singleton.h"
/**
* @brief The FluWindowRegister class
*/
class FluWindowRegister : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(QQuickWindow*,from)
Q_PROPERTY_AUTO(QQuickWindow*,to)
Q_PROPERTY_AUTO(QString,path);
public:
explicit FluWindowRegister(QObject *parent = nullptr);
Q_INVOKABLE void launch(const QJsonObject& argument = {});
Q_INVOKABLE void onResult(const QJsonObject& data = {});
Q_SIGNAL void result(const QJsonObject& data);
};
/** /**
* @brief The FluApp class * @brief The FluApp class
*/ */
class FluApp : public QObject class FluApp : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QString,initialRoute);
Q_PROPERTY_AUTO(QJsonObject,routes);
Q_PROPERTY_AUTO(bool,useSystemAppBar); Q_PROPERTY_AUTO(bool,useSystemAppBar);
Q_PROPERTY_AUTO(QString,windowIcon); Q_PROPERTY_AUTO(QString,windowIcon);
Q_PROPERTY_AUTO(QLocale,locale); Q_PROPERTY_AUTO(QLocale,locale);
@ -49,15 +29,8 @@ private:
public: public:
SINGLETON(FluApp) SINGLETON(FluApp)
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();} static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE void run();
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluWindowRegister* windowRegister = nullptr);
Q_INVOKABLE void init(QObject *target,QLocale locale = QLocale::system()); Q_INVOKABLE void init(QObject *target,QLocale locale = QLocale::system());
Q_INVOKABLE void exit(int retCode = 0);
Q_INVOKABLE QVariant createWindowRegister(QQuickWindow* window,const QString& path);
void addWindow(QQuickWindow* window);
void removeWindow(QQuickWindow* window);
private: private:
QMap<quint64, QQuickWindow*> _windows;
QQmlEngine *_engine; QQmlEngine *_engine;
QTranslator* _translator = nullptr; QTranslator* _translator = nullptr;
}; };

View File

@ -1,4 +1,5 @@
#include "FluColors.h" #include "FluColors.h"
#include "FluTools.h"
FluColors::FluColors(QObject *parent):QObject{parent}{ FluColors::FluColors(QObject *parent):QObject{parent}{
Transparent(QColor(0, 0, 0, 0)); Transparent(QColor(0, 0, 0, 0));
@ -111,17 +112,12 @@ FluColors::FluColors(QObject *parent):QObject{parent}{
FluAccentColor* FluColors::createAccentColor(QColor primaryColor){ FluAccentColor* FluColors::createAccentColor(QColor primaryColor){
FluAccentColor *accentColor = new FluAccentColor(this); FluAccentColor *accentColor = new FluAccentColor(this);
accentColor->darkest(withOpacity(primaryColor,0.7)); accentColor->darkest(FluTools::getInstance()->withOpacity(primaryColor,0.7));
accentColor->darker(withOpacity(primaryColor,0.8)); accentColor->darker(FluTools::getInstance()->withOpacity(primaryColor,0.8));
accentColor->dark(withOpacity(primaryColor,0.9)); accentColor->dark(FluTools::getInstance()->withOpacity(primaryColor,0.9));
accentColor->normal(primaryColor); accentColor->normal(primaryColor);
accentColor->light(withOpacity(primaryColor,0.9)); accentColor->light(FluTools::getInstance()->withOpacity(primaryColor,0.9));
accentColor->lighter(withOpacity(primaryColor,0.8)); accentColor->lighter(FluTools::getInstance()->withOpacity(primaryColor,0.8));
accentColor->lightest(withOpacity(primaryColor,0.7)); accentColor->lightest(FluTools::getInstance()->withOpacity(primaryColor,0.7));
return accentColor; return accentColor;
} }
QColor FluColors::withOpacity(QColor color,qreal opacity){
int alpha = qRound(opacity * 255) & 0xff;
return QColor::fromRgba((alpha << 24) | (color.rgba() & 0xffffff));
}

View File

@ -3,6 +3,7 @@
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
#include "FluAccentColor.h" #include "FluAccentColor.h"
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h" #include "singleton.h"
@ -50,7 +51,6 @@ class FluColors : public QObject
QML_SINGLETON QML_SINGLETON
private: private:
explicit FluColors(QObject *parent = nullptr); explicit FluColors(QObject *parent = nullptr);
QColor withOpacity(QColor color,qreal opacity);
public: public:
SINGLETON(FluColors) SINGLETON(FluColors)
Q_INVOKABLE FluAccentColor* createAccentColor(QColor primaryColor); Q_INVOKABLE FluAccentColor* createAccentColor(QColor primaryColor);

View File

@ -1,23 +0,0 @@
#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);
}
}
}

View File

@ -1,41 +0,0 @@
#ifndef FLUEVENTBUS_H
#define FLUEVENTBUS_H
#include <QObject>
#include <QtQml/qqml.h>
#include "stdafx.h"
#include "singleton.h"
/**
* @brief The FluEvent class
*/
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);
};
/**
* @brief The FluEventBus class
*/
class FluEventBus : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(FluEventBus)
QML_SINGLETON
private:
explicit FluEventBus(QObject *parent = nullptr);
public:
SINGLETON(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

484
src/FluFrameless.cpp Normal file
View File

@ -0,0 +1,484 @@
#include "FluFrameless.h"
#include <QQuickWindow>
#include <QGuiApplication>
#include <QScreen>
#include <QDateTime>
#ifdef Q_OS_WIN
#pragma comment (lib,"user32.lib")
#pragma comment (lib,"dwmapi.lib")
#include <windows.h>
#include <windowsx.h>
#include <dwmapi.h>
static inline QByteArray qtNativeEventType()
{
static const auto result = "windows_generic_MSG";
return result;
}
static inline bool isCompositionEnabled(){
typedef HRESULT (WINAPI* DwmIsCompositionEnabledPtr)(BOOL *pfEnabled);
HMODULE module = ::LoadLibraryW(L"dwmapi.dll");
if (module)
{
BOOL composition_enabled = false;
DwmIsCompositionEnabledPtr dwm_is_composition_enabled;
dwm_is_composition_enabled= reinterpret_cast<DwmIsCompositionEnabledPtr>(::GetProcAddress(module, "DwmIsCompositionEnabled"));
if (dwm_is_composition_enabled)
{
dwm_is_composition_enabled(&composition_enabled);
}
return composition_enabled;
}
return false;
}
#endif
FluFrameless::FluFrameless(QQuickItem *parent)
: QQuickItem{parent}
{
appbar(nullptr);
maximizeButton(nullptr);
minimizedButton(nullptr);
closeButton(nullptr);
topmost(false);
disabled(false);
}
FluFrameless::~FluFrameless(){
}
void FluFrameless::onDestruction(){
qApp->removeNativeEventFilter(this);
}
void FluFrameless::componentComplete(){
if(_disabled){
return;
}
_current = window()->winId();
window()->setFlags(( window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
if(QQuickWindow::sceneGraphBackend() == "software"){
window()->setFlag(Qt::FramelessWindowHint,false);
}
#endif
if(!_fixSize){
window()->setFlag(Qt::WindowMaximizeButtonHint);
}
window()->installEventFilter(this);
qApp->installNativeEventFilter(this);
if(_maximizeButton){
setHitTestVisible(_maximizeButton);
}
if(_minimizedButton){
setHitTestVisible(_minimizedButton);
}
if(_closeButton){
setHitTestVisible(_closeButton);
}
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
if(_fixSize){
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
for (int i = 0; i < qApp->screens().count(); ++i) {
connect( qApp->screens().at(i),&QScreen::logicalDotsPerInchChanged,this,[=]{
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
});
}
}else{
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
}
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
connect(window(),&QQuickWindow::screenChanged,this,[hwnd]{
::SetWindowPos(hwnd,0,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
});
#endif
connect(this,&FluFrameless::topmostChanged,this,[this]{
_setWindowTopmost(topmost());
});
_setWindowTopmost(topmost());
}
bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result){
#ifdef Q_OS_WIN
if ((eventType != qtNativeEventType()) || !message) {
return false;
}
const auto msg = static_cast<const MSG *>(message);
const HWND hwnd = msg->hwnd;
if (!hwnd || !msg) {
return false;
}
const qint64 wid = reinterpret_cast<qint64>(hwnd);
if(wid != _current){
return false;
}
const UINT uMsg = msg->message;
const WPARAM wParam = msg->wParam;
const LPARAM lParam = msg->lParam;
static QPoint offsetXY;
if(uMsg == WM_WINDOWPOSCHANGING){
WINDOWPOS* wp = reinterpret_cast<WINDOWPOS*>(lParam);
if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0)
{
wp->flags |= SWP_NOCOPYBITS;
*result = ::DefWindowProcW(hwnd, uMsg, wParam, lParam);
return true;
}
return false;
}else if(uMsg == WM_NCCALCSIZE){
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
const LONG originalTop = clientRect->top;
const LONG originalLeft = clientRect->left;
const LONG originalRight = clientRect->right;
const LONG originalBottom = clientRect->bottom;
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
*result = hitTestResult;
return true;
}
int offsetSize = 0;
bool isMaximum = ::IsZoomed(hwnd);
offsetXY = QPoint(abs(clientRect->left - originalLeft),abs(clientRect->top - originalTop));
if(isMaximum || _isFullScreen()){
offsetSize = 0;
}else{
offsetSize = 1;
}
if(!isCompositionEnabled()){
offsetSize = 0;
}
if (!isMaximum || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) {
clientRect->top = originalTop + offsetSize;
clientRect->bottom = originalBottom - offsetSize;
clientRect->left = originalLeft + offsetSize;
clientRect->right = originalRight - offsetSize;
}
_setMaximizeHovered(false);
*result = WVR_REDRAW;
return true;
}else if(uMsg == WM_NCHITTEST){
if(_hitMaximizeButton()){
if (*result == HTNOWHERE) {
*result = HTZOOM;
}
_setMaximizeHovered(true);
return true;
}
_setMaximizeHovered(false);
_setMaximizePressed(false);
*result = 0;
POINT nativeGlobalPos{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
POINT nativeLocalPos = nativeGlobalPos;
::ScreenToClient(hwnd, &nativeLocalPos);
RECT clientRect{0, 0, 0, 0};
::GetClientRect(hwnd, &clientRect);
auto clientWidth = clientRect.right-clientRect.left;
auto clientHeight = clientRect.bottom-clientRect.top;
bool left = nativeLocalPos.x < _margins;
bool right = nativeLocalPos.x > clientWidth - _margins;
bool top = nativeLocalPos.y < _margins;
bool bottom = nativeLocalPos.y > clientHeight - _margins;
*result = 0;
if (!_fixSize && !_isFullScreen() && !_isMaximized()) {
if (left && top) {
*result = HTTOPLEFT;
} else if (left && bottom) {
*result = HTBOTTOMLEFT;
} else if (right && top) {
*result = HTTOPRIGHT;
} else if (right && bottom) {
*result = HTBOTTOMRIGHT;
} else if (left) {
*result = HTLEFT;
} else if (right) {
*result = HTRIGHT;
} else if (top) {
*result = HTTOP;
} else if (bottom) {
*result = HTBOTTOM;
}
}
if (0 != *result) {
return true;
}
if(_hitAppBar()){
*result = HTCAPTION;
return true;
}
*result = HTCLIENT;
return true;
}else if(uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN){
if(_hitMaximizeButton()){
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QGuiApplication::sendEvent(_maximizeButton,&event);
_setMaximizePressed(true);
return true;
}
}else if(uMsg == WM_NCLBUTTONUP || uMsg == WM_NCRBUTTONUP){
if(_hitMaximizeButton()){
QMouseEvent event = QMouseEvent(QEvent::MouseButtonRelease, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QGuiApplication::sendEvent(_maximizeButton,&event);
_setMaximizePressed(false);
return true;
}
}else if(uMsg == WM_NCPAINT){
*result = FALSE;
return true;
}else if(uMsg == WM_NCACTIVATE){
*result = ::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
return true;
}else if(uMsg == WM_GETMINMAXINFO){
MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
auto pixelRatio = window()->devicePixelRatio();
auto geometry = window()->screen()->availableGeometry();
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
minmaxInfo->ptMaxPosition.x = rect.left - offsetXY.x();
minmaxInfo->ptMaxPosition.y = rect.top - offsetXY.x();
minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2;
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2;
return false;
}else if(uMsg == WM_NCRBUTTONDOWN){
if (wParam == HTCAPTION) {
_showSystemMenu(QCursor::pos());
}
}else if(uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN){
const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0));
const bool spacePressed = ((wParam == VK_SPACE) || (::GetKeyState(VK_SPACE) < 0));
if (altPressed && spacePressed) {
auto pos = window()->position();
_showSystemMenu(QPoint(pos.x(),pos.y()+_appbar->height()));
}
}else if(uMsg == WM_SYSCOMMAND){
if(wParam == SC_MINIMIZE){
if(window()->transientParent()){
window()->transientParent()->showMinimized();
}else{
window()->showMinimized();
}
return true;
}
return false;
}
return false;
#endif
return false;
}
bool FluFrameless::_isMaximized(){
return window()->visibility() == QWindow::Maximized;
}
bool FluFrameless::_isFullScreen(){
return window()->visibility() == QWindow::FullScreen;
}
void FluFrameless::_showSystemMenu(QPoint point){
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
DWORD style = ::GetWindowLongPtr(hwnd,GWL_STYLE);
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
const HMENU hMenu = ::GetSystemMenu(hwnd, FALSE);
if(_isMaximized() || _isFullScreen()){
::EnableMenuItem(hMenu,SC_MOVE,MFS_DISABLED);
::EnableMenuItem(hMenu,SC_RESTORE,MFS_ENABLED);
}else{
::EnableMenuItem(hMenu,SC_MOVE,MFS_ENABLED);
::EnableMenuItem(hMenu,SC_RESTORE,MFS_DISABLED);
}
if(!_fixSize && !_isMaximized() && !_isFullScreen()){
::EnableMenuItem(hMenu,SC_SIZE,MFS_ENABLED);
::EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_ENABLED);
}else{
::EnableMenuItem(hMenu,SC_SIZE,MFS_DISABLED);
::EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_DISABLED);
}
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), point.x()*window()->devicePixelRatio(), point.y()*window()->devicePixelRatio(), 0, hwnd, nullptr);
if (result != FALSE) {
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
}
::SetWindowLongPtr(hwnd, GWL_STYLE, style &~ WS_SYSMENU);
#endif
}
bool FluFrameless::_containsCursorToItem(QQuickItem* item){
if(!item || !item->isVisible()){
return false;
}
auto point = QCursor::pos();
auto rect = QRectF(item->mapToGlobal(QPoint(0,0)),item->size());
if(point.x()>rect.x() && point.x()<(rect.x()+rect.width()) && point.y()>rect.y() && point.y()<(rect.y()+rect.height())){
return true;
}
return false;
}
bool FluFrameless::_hitAppBar(){
foreach (auto item, _hitTestList) {
if(_containsCursorToItem(item)){
return false;
}
}
if(_containsCursorToItem(_appbar)){
return true;
}
return false;
}
bool FluFrameless::_hitMaximizeButton(){
if(_containsCursorToItem(_maximizeButton)){
return true;
}
return false;
}
void FluFrameless::_setMaximizePressed(bool val){
_maximizeButton->setProperty("down",val);
}
void FluFrameless::_setMaximizeHovered(bool val){
_maximizeButton->setProperty("hover",val);
}
void FluFrameless::_updateCursor(int edges){
switch (edges) {
case 0:
window()->setCursor(Qt::ArrowCursor);
break;
case Qt::LeftEdge:
case Qt::RightEdge:
window()->setCursor(Qt::SizeHorCursor);
break;
case Qt::TopEdge:
case Qt::BottomEdge:
window()->setCursor(Qt::SizeVerCursor);
break;
case Qt::LeftEdge | Qt::TopEdge:
case Qt::RightEdge | Qt::BottomEdge:
window()->setCursor(Qt::SizeFDiagCursor);
break;
case Qt::RightEdge | Qt::TopEdge:
case Qt::LeftEdge | Qt::BottomEdge:
window()->setCursor(Qt::SizeBDiagCursor);
break;
}
}
void FluFrameless::showFullScreen(){
window()->showFullScreen();
}
void FluFrameless::showMaximized(){
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
::ShowWindow(hwnd,3);
#else
window()->showMaximized();
#endif
}
void FluFrameless::showMinimized(){
window()->showMinimized();
}
void FluFrameless::showNormal(){
window()->showNormal();
}
void FluFrameless::setHitTestVisible(QQuickItem* val){
if(!_hitTestList.contains(val)){
_hitTestList.append(val);
}
}
void FluFrameless::_setWindowTopmost(bool topmost){
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
if(topmost){
::SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}else{
::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
#else
window()->setFlag(Qt::WindowStaysOnTopHint,topmost);
#endif
}
bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){
#ifndef Q_OS_WIN
switch (ev->type()) {
case QEvent::MouseButtonPress:
if(_edges!=0){
QMouseEvent *event = static_cast<QMouseEvent*>(ev);
if(event->button() == Qt::LeftButton){
_updateCursor(_edges);
window()->startSystemResize(Qt::Edges(_edges));
}
}else{
if(_hitAppBar()){
qint64 clickTimer = QDateTime::currentMSecsSinceEpoch();
qint64 offset = clickTimer - this->_clickTimer;
this->_clickTimer = clickTimer;
if(offset<300){
if(_isMaximized()){
showNormal();
}else{
showMaximized();
}
}else{
window()->startSystemMove();
}
}
}
break;
case QEvent::MouseButtonRelease:
_edges = 0;
break;
case QEvent::MouseMove: {
if(_isMaximized() || _isFullScreen()){
break;
}
if(_fixSize){
break;
}
QMouseEvent *event = static_cast<QMouseEvent*>(ev);
QPoint p =
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
event->pos();
#else
event->position().toPoint();
#endif
if(p.x() >= _margins && p.x() <= (window()->width() - _margins) && p.y() >= _margins && p.y() <= (window()->height() - _margins)){
if(_edges != 0){
_edges = 0;
_updateCursor(_edges);
}
break;
}
_edges = 0;
if ( p.x() < _margins ) {
_edges |= Qt::LeftEdge;
}
if ( p.x() > (window()->width() - _margins) ) {
_edges |= Qt::RightEdge;
}
if ( p.y() < _margins ) {
_edges |= Qt::TopEdge;
}
if ( p.y() > (window()->height() - _margins) ) {
_edges |= Qt::BottomEdge;
}
_updateCursor(_edges);
break;
}
default:
break;
}
#endif
return QObject::eventFilter(obj, ev);
}

61
src/FluFrameless.h Normal file
View File

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

View File

@ -1,500 +0,0 @@
#include "FluFramelessHelper.h"
#include <QGuiApplication>
#include <QScreen>
#include <QQuickItem>
#include "FluTools.h"
#ifdef Q_OS_WIN
#pragma comment (lib,"user32.lib")
#pragma comment (lib,"dwmapi.lib")
#include <windows.h>
#include <windowsx.h>
#include <dwmapi.h>
static inline QByteArray qtNativeEventType()
{
static const auto result = "windows_generic_MSG";
return result;
}
static inline bool isCompositionEnabled(){
typedef HRESULT (WINAPI* DwmIsCompositionEnabledPtr)(BOOL *pfEnabled);
HMODULE module = ::LoadLibraryW(L"dwmapi.dll");
if (module)
{
BOOL composition_enabled = false;
DwmIsCompositionEnabledPtr dwm_is_composition_enabled;
dwm_is_composition_enabled= reinterpret_cast<DwmIsCompositionEnabledPtr>(::GetProcAddress(module, "DwmIsCompositionEnabled"));
if (dwm_is_composition_enabled)
{
dwm_is_composition_enabled(&composition_enabled);
}
return composition_enabled;
}
return false;
}
#endif
FramelessEventFilter::FramelessEventFilter(FluFramelessHelper* helper){
_helper = helper;
_current = _helper->window->winId();
}
bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result){
#ifdef Q_OS_WIN
if ((eventType != qtNativeEventType()) || !message || _helper.isNull() || _helper->window.isNull()) {
return false;
}
const auto msg = static_cast<const MSG *>(message);
const HWND hwnd = msg->hwnd;
if (!hwnd || !msg) {
return false;
}
const qint64 wid = reinterpret_cast<qint64>(hwnd);
if(wid != _current){
return false;
}
const UINT uMsg = msg->message;
const WPARAM wParam = msg->wParam;
const LPARAM lParam = msg->lParam;
static QPoint offsetXY;
if(uMsg == WM_WINDOWPOSCHANGING){
WINDOWPOS* wp = reinterpret_cast<WINDOWPOS*>(lParam);
if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0)
{
wp->flags |= SWP_NOCOPYBITS;
*result = ::DefWindowProcW(hwnd, uMsg, wParam, lParam);
return true;
}
return false;
}else if(uMsg == WM_NCCALCSIZE){
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
const LONG originalTop = clientRect->top;
const LONG originalLeft = clientRect->left;
const LONG originalRight = clientRect->right;
const LONG originalBottom = clientRect->bottom;
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
*result = hitTestResult;
return true;
}
int offsetSize = 0;
bool isMaximum = ::IsZoomed(hwnd);
offsetXY = QPoint(abs(clientRect->left - originalLeft),abs(clientRect->top - originalTop));
if(isMaximum || _helper->fullScreen()){
offsetSize = 0;
}else{
offsetSize = 1;
}
if(!isCompositionEnabled()){
offsetSize = 0;
}
if (!isMaximum || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) {
clientRect->top = originalTop + offsetSize;
clientRect->bottom = originalBottom - offsetSize;
clientRect->left = originalLeft + offsetSize;
clientRect->right = originalRight - offsetSize;
}
*result = WVR_REDRAW;
return true;
}if(uMsg == WM_NCHITTEST){
if(FluTools::getInstance()->isWindows11OrGreater() && _helper->hoverMaxBtn() && _helper->resizeable()){
if (*result == HTNOWHERE) {
*result = HTZOOM;
}
return true;
}
*result = 0;
POINT nativeGlobalPos{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
POINT nativeLocalPos = nativeGlobalPos;
::ScreenToClient(hwnd, &nativeLocalPos);
RECT clientRect{0, 0, 0, 0};
::GetClientRect(hwnd, &clientRect);
auto clientWidth = clientRect.right-clientRect.left;
auto clientHeight = clientRect.bottom-clientRect.top;
int margins = _helper->getMargins();
bool left = nativeLocalPos.x < margins;
bool right = nativeLocalPos.x > clientWidth - margins;
bool top = nativeLocalPos.y < margins;
bool bottom = nativeLocalPos.y > clientHeight - margins;
*result = 0;
if (_helper->resizeable() && !_helper->fullScreen() && !_helper->maximized()) {
if (left && top) {
*result = HTTOPLEFT;
} else if (left && bottom) {
*result = HTBOTTOMLEFT;
} else if (right && top) {
*result = HTTOPRIGHT;
} else if (right && bottom) {
*result = HTBOTTOMRIGHT;
} else if (left) {
*result = HTLEFT;
} else if (right) {
*result = HTRIGHT;
} else if (top) {
*result = HTTOP;
} else if (bottom) {
*result = HTBOTTOM;
}
}
if (0 != *result) {
return true;
}
QVariant appBar = _helper->getAppBar();
if(!appBar.isNull()&& _helper->hoverAppBar()){
*result = HTCAPTION;
return true;
}
*result = HTCLIENT;
return true;
}else if(uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN){
if(_helper->hoverMaxBtn()){
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
return true;
}
}else if(uMsg == WM_NCLBUTTONUP || uMsg == WM_NCRBUTTONUP){
if(_helper->hoverMaxBtn()){
QMouseEvent event = QMouseEvent(QEvent::MouseButtonRelease, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
}
}else if(uMsg == WM_NCPAINT){
*result = FALSE;
return true;
}else if(uMsg == WM_NCACTIVATE){
*result = ::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
return true;
}else if(uMsg == WM_GETMINMAXINFO){
MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
minmaxInfo->ptMaxPosition.x = 0;
minmaxInfo->ptMaxPosition.y = 0;
minmaxInfo->ptMaxSize.x = 0;
minmaxInfo->ptMaxSize.y = 0;
#else
auto pixelRatio = _helper->window->devicePixelRatio();
auto geometry = _helper->window->screen()->availableGeometry();
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
minmaxInfo->ptMaxPosition.x = rect.left - offsetXY.x();
minmaxInfo->ptMaxPosition.y = rect.top - offsetXY.x();
minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2;
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2;
#endif
return false;
}else if(uMsg == WM_NCRBUTTONDOWN){
if (wParam == HTCAPTION) {
_helper->showSystemMenu(QCursor::pos());
}
}else if(uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN){
const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0));
const bool spacePressed = ((wParam == VK_SPACE) || (::GetKeyState(VK_SPACE) < 0));
if (altPressed && spacePressed) {
auto pos = _helper->window->position();
_helper->showSystemMenu(QPoint(pos.x(),pos.y()+_helper->getAppBarHeight()));
}
}else if(uMsg == WM_SYSCOMMAND){
if(wParam == SC_MINIMIZE){
if(_helper->window->transientParent()){
_helper->window->transientParent()->showMinimized();
}else{
_helper->window->showMinimized();
}
return true;
}
return false;
}
return false;
#endif
return false;
}
FluFramelessHelper::FluFramelessHelper(QObject *parent)
: QObject{parent}
{
}
void FluFramelessHelper::classBegin(){
}
void FluFramelessHelper::_updateCursor(int edges){
switch (edges) {
case 0:
window->setCursor(Qt::ArrowCursor);
break;
case Qt::LeftEdge:
case Qt::RightEdge:
window->setCursor(Qt::SizeHorCursor);
break;
case Qt::TopEdge:
case Qt::BottomEdge:
window->setCursor(Qt::SizeVerCursor);
break;
case Qt::LeftEdge | Qt::TopEdge:
case Qt::RightEdge | Qt::BottomEdge:
window->setCursor(Qt::SizeFDiagCursor);
break;
case Qt::RightEdge | Qt::TopEdge:
case Qt::LeftEdge | Qt::BottomEdge:
window->setCursor(Qt::SizeBDiagCursor);
break;
}
}
bool FluFramelessHelper::eventFilter(QObject *obj, QEvent *ev){
if (!window.isNull() && window->flags()) {
switch (ev->type()) {
case QEvent::MouseButtonPress:
if(_edges!=0){
QMouseEvent *event = static_cast<QMouseEvent*>(ev);
if(event->button() == Qt::LeftButton){
_updateCursor(_edges);
window->startSystemResize(Qt::Edges(_edges));
}
}
break;
case QEvent::MouseButtonRelease:
_edges = 0;
break;
case QEvent::MouseMove: {
if(maximized() || fullScreen()){
break;
}
if(!resizeable()){
break;
}
QMouseEvent *event = static_cast<QMouseEvent*>(ev);
QPoint p =
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
event->pos();
#else
event->position().toPoint();
#endif
if(p.x() >= _margins && p.x() <= (window->width() - _margins) && p.y() >= _margins && p.y() <= (window->height() - _margins)){
if(_edges != 0){
_edges = 0;
_updateCursor(_edges);
}
break;
}
_edges = 0;
if ( p.x() < _margins ) {
_edges |= Qt::LeftEdge;
}
if ( p.x() > (window->width() - _margins) ) {
_edges |= Qt::RightEdge;
}
if ( p.y() < _margins ) {
_edges |= Qt::TopEdge;
}
if ( p.y() > (window->height() - _margins) ) {
_edges |= Qt::BottomEdge;
}
_updateCursor(_edges);
break;
}
default:
break;
}
}
return QObject::eventFilter(obj, ev);
}
void FluFramelessHelper::componentComplete(){
auto o = parent();
do {
window = qobject_cast<QQuickWindow *>(o);
if (window) {
break;
}
o = o->parent();
} while (nullptr != o);
if(!window.isNull()){
_stayTop = QQmlProperty(window,"stayTop");
_screen = QQmlProperty(window,"screen");
_fixSize = QQmlProperty(window,"fixSize");
_realHeight = QQmlProperty(window,"_realHeight");
_realWidth = QQmlProperty(window,"_realWidth");
_appBarHeight = QQmlProperty(window,"_appBarHeight");
_appBar = window->property("appBar");
#ifdef Q_OS_WIN
if(!_appBar.isNull()){
_appBar.value<QObject*>()->setProperty("systemMoveEnable",false);
}
window->setFlags((window->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
if(FluTools::getInstance()->isSoftware()){
window->setFlag(Qt::FramelessWindowHint,false);
}
#endif
if(resizeable()){
window->setFlag(Qt::WindowMaximizeButtonHint);
}
_nativeEvent =new FramelessEventFilter(this);
qApp->installNativeEventFilter(_nativeEvent);
HWND hwnd = reinterpret_cast<HWND>(window->winId());
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
if(resizeable()){
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
}else{
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
for (int i = 0; i < qApp->screens().count(); ++i) {
connect( qApp->screens().at(i),&QScreen::logicalDotsPerInchChanged,this,[=]{
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
});
}
}
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
#else
window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window);
window->installEventFilter(this);
#endif
int w = _realWidth.read().toInt();
int h = _realHeight.read().toInt()+_appBarHeight.read().toInt();
if(!resizeable()){
window->setMaximumSize(QSize(w,h));
window->setMinimumSize(QSize(w,h));
}
window->resize(QSize(w,h));
_onStayTopChange();
_stayTop.connectNotifySignal(this,SLOT(_onStayTopChange()));
_screen.connectNotifySignal(this,SLOT(_onScreenChanged()));
Q_EMIT loadCompleted();
}
}
void FluFramelessHelper::_onScreenChanged(){
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window->winId());
::SetWindowPos(hwnd,0,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
#endif
}
void FluFramelessHelper::showSystemMenu(QPoint point){
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window->winId());
DWORD style = ::GetWindowLongPtr(hwnd,GWL_STYLE);
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
const HMENU hMenu = ::GetSystemMenu(hwnd, FALSE);
if(maximized() || fullScreen()){
::EnableMenuItem(hMenu,SC_MOVE,MFS_DISABLED);
::EnableMenuItem(hMenu,SC_RESTORE,MFS_ENABLED);
}else{
::EnableMenuItem(hMenu,SC_MOVE,MFS_ENABLED);
::EnableMenuItem(hMenu,SC_RESTORE,MFS_DISABLED);
}
if(resizeable() && !maximized() && !fullScreen()){
::EnableMenuItem(hMenu,SC_SIZE,MFS_ENABLED);
::EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_ENABLED);
}else{
::EnableMenuItem(hMenu,SC_SIZE,MFS_DISABLED);
::EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_DISABLED);
}
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), point.x()*window->devicePixelRatio(), point.y()*window->devicePixelRatio(), 0, hwnd, nullptr);
if (result != FALSE) {
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
}
::SetWindowLongPtr(hwnd, GWL_STYLE, style &~ WS_SYSMENU);
#endif
}
void FluFramelessHelper::showMaximized(){
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window->winId());
::ShowWindow(hwnd,3);
#endif
}
void FluFramelessHelper::_onStayTopChange(){
bool isStayTop = _stayTop.read().toBool();
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window->winId());
if(isStayTop){
::SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}else{
::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
#else
window->setFlag(Qt::WindowStaysOnTopHint,isStayTop);
#endif
}
FluFramelessHelper::~FluFramelessHelper(){
if (!window.isNull()) {
window->setFlags(Qt::Window);
#ifdef Q_OS_WIN
qApp->removeNativeEventFilter(_nativeEvent);
delete _nativeEvent;
#endif
window->removeEventFilter(this);
}
}
bool FluFramelessHelper::hoverMaxBtn(){
if(_appBar.isNull()){
return false;
}
QVariant var;
QMetaObject::invokeMethod(_appBar.value<QObject*>(), "_maximizeButtonHover",Q_RETURN_ARG(QVariant, var));
if(var.isNull()){
return false;
}
return var.toBool();
}
bool FluFramelessHelper::hoverAppBar(){
if(_appBar.isNull()){
return false;
}
QVariant var;
QMetaObject::invokeMethod(_appBar.value<QObject*>(), "_appBarHover",Q_RETURN_ARG(QVariant, var));
if(var.isNull()){
return false;
}
return var.toBool();
}
QVariant FluFramelessHelper::getAppBar(){
return _appBar;
}
int FluFramelessHelper::getAppBarHeight(){
if(_appBar.isNull()){
return 0;
}
QVariant var = _appBar.value<QObject*>()->property("height");
if(var.isNull()){
return 0;
}
return var.toInt();
}
QObject* FluFramelessHelper::maximizeButton(){
if(_appBar.isNull()){
return nullptr;
}
QVariant var = _appBar.value<QObject*>()->property("buttonMaximize");
if(var.isNull()){
return nullptr;
}
return var.value<QObject*>();
}
bool FluFramelessHelper::resizeable(){
return !_fixSize.read().toBool();
}
bool FluFramelessHelper::maximized(){
return window->visibility() == QWindow::Maximized;
}
bool FluFramelessHelper::fullScreen(){
return window->visibility() == QWindow::FullScreen;
}
int FluFramelessHelper::getMargins(){
return _margins;
}

View File

@ -1,79 +0,0 @@
#ifndef FLUFRAMELESSHELPER_H
#define FLUFRAMELESSHELPER_H
#include <QObject>
#include <QQuickWindow>
#include <QtQml/qqml.h>
#include <QAbstractNativeEventFilter>
#include <QQmlProperty>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
using QT_NATIVE_EVENT_RESULT_TYPE = qintptr;
using QT_ENTER_EVENT_TYPE = QEnterEvent;
#else
using QT_NATIVE_EVENT_RESULT_TYPE = long;
using QT_ENTER_EVENT_TYPE = QEvent;
#endif
class FluFramelessHelper;
/**
* @brief The FramelessEventFilter class
*/
class FramelessEventFilter : public QAbstractNativeEventFilter
{
public:
FramelessEventFilter(FluFramelessHelper* helper);
bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
public:
QPointer<FluFramelessHelper> _helper = nullptr;
qint64 _current = 0;
};
/**
* @brief The FluFramelessHelper class
*/
class FluFramelessHelper : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
QML_NAMED_ELEMENT(FluFramelessHelper)
public:
explicit FluFramelessHelper(QObject *parent = nullptr);
~FluFramelessHelper();
void classBegin() override;
void componentComplete() override;
bool hoverMaxBtn();
bool hoverAppBar();
bool resizeable();
int getMargins();
bool maximized();
bool fullScreen();
int getAppBarHeight();
QVariant getAppBar();
QObject* maximizeButton();
Q_INVOKABLE void showSystemMenu(QPoint point);
Q_INVOKABLE void showMaximized();
Q_SIGNAL void loadCompleted();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
private:
void _updateCursor(int edges);
Q_SLOT void _onStayTopChange();
Q_SLOT void _onScreenChanged();
public:
QPointer<QQuickWindow> window = nullptr;
private:
FramelessEventFilter* _nativeEvent = nullptr;
QQmlProperty _stayTop;
QQmlProperty _screen;
QQmlProperty _fixSize;
QQmlProperty _realHeight;
QQmlProperty _realWidth;
QQmlProperty _appBarHeight;
QVariant _appBar;
int _edges = 0;
int _margins = 8;
};
#endif // FLUFRAMELESSHELPER_H

View File

@ -1,158 +0,0 @@
#ifndef FLUNETWORK_H
#define FLUNETWORK_H
#include <QObject>
#include <QtQml/qqml.h>
#include <QFile>
#include <QJsonValue>
#include <QJSValue>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "Def.h"
#include "stdafx.h"
#include "singleton.h"
/**
* @brief The NetworkCallable class
*/
class FluNetworkCallable : public QObject{
Q_OBJECT
QML_NAMED_ELEMENT(FluNetworkCallable)
public:
explicit FluNetworkCallable(QObject *parent = nullptr);
Q_SIGNAL void start();
Q_SIGNAL void finish();
Q_SIGNAL void error(int status,QString errorString,QString result);
Q_SIGNAL void success(QString result);
Q_SIGNAL void cache(QString result);
Q_SIGNAL void uploadProgress(qint64 sent, qint64 total);
Q_SIGNAL void downloadProgress(qint64 recv, qint64 total);
};
/**
* @brief The FluDownloadParam class
*/
class FluDownloadParam : public QObject{
Q_OBJECT
public:
explicit FluDownloadParam(QObject *parent = nullptr);
FluDownloadParam(QString destPath,bool append,QObject *parent = nullptr);
public:
QString _destPath;
bool _append;
};
/**
* @brief The FluNetworkParams class
*/
class FluNetworkParams : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(FluNetworkParams)
public:
enum Method{
METHOD_GET,
METHOD_HEAD,
METHOD_POST,
METHOD_PUT,
METHOD_PATCH,
METHOD_DELETE
};
enum Type{
TYPE_NONE,
TYPE_FORM,
TYPE_JSON,
TYPE_JSONARRAY,
TYPE_BODY
};
explicit FluNetworkParams(QObject *parent = nullptr);
FluNetworkParams(QString url,Type type,Method method,QObject *parent = nullptr);
Q_INVOKABLE FluNetworkParams* addQuery(QString key,QVariant val);
Q_INVOKABLE FluNetworkParams* addHeader(QString key,QVariant val);
Q_INVOKABLE FluNetworkParams* add(QString key,QVariant val);
Q_INVOKABLE FluNetworkParams* addFile(QString key,QVariant val);
Q_INVOKABLE FluNetworkParams* setBody(QString val);
Q_INVOKABLE FluNetworkParams* setTimeout(int val);
Q_INVOKABLE FluNetworkParams* setRetry(int val);
Q_INVOKABLE FluNetworkParams* setCacheMode(int val);
Q_INVOKABLE FluNetworkParams* toDownload(QString destPath,bool append = false);
Q_INVOKABLE FluNetworkParams* bind(QObject* target);
Q_INVOKABLE FluNetworkParams* openLog(QVariant val);
Q_INVOKABLE void go(FluNetworkCallable* result);
QString buildCacheKey();
QString method2String();
int getTimeout();
int getRetry();
bool getOpenLog();
public:
FluDownloadParam* _downloadParam = nullptr;
QObject* _target = nullptr;
Method _method;
Type _type;
QString _url;
QString _body;
QMap<QString, QVariant> _queryMap;
QMap<QString, QVariant> _headerMap;
QMap<QString, QVariant> _paramMap;
QMap<QString, QVariant> _fileMap;
int _timeout = -1;
int _retry = -1;
QVariant _openLog;
int _cacheMode = FluNetworkType::CacheMode::NoCache;
};
/**
* @brief The FluNetwork class
*/
class FluNetwork : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(int,timeout)
Q_PROPERTY_AUTO(int,retry)
Q_PROPERTY_AUTO(QString,cacheDir)
Q_PROPERTY_AUTO(bool,openLog)
QML_NAMED_ELEMENT(FluNetwork)
QML_SINGLETON
private:
explicit FluNetwork(QObject *parent = nullptr);
public:
SINGLETON(FluNetwork)
static FluNetwork *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE FluNetworkParams* get(const QString& url);
Q_INVOKABLE FluNetworkParams* head(const QString& url);
Q_INVOKABLE FluNetworkParams* postBody(const QString& url);
Q_INVOKABLE FluNetworkParams* putBody(const QString& url);
Q_INVOKABLE FluNetworkParams* patchBody(const QString& url);
Q_INVOKABLE FluNetworkParams* deleteBody(const QString& url);
Q_INVOKABLE FluNetworkParams* postForm(const QString& url);
Q_INVOKABLE FluNetworkParams* putForm(const QString& url);
Q_INVOKABLE FluNetworkParams* patchForm(const QString& url);
Q_INVOKABLE FluNetworkParams* deleteForm(const QString& url);
Q_INVOKABLE FluNetworkParams* postJson(const QString& url);
Q_INVOKABLE FluNetworkParams* putJson(const QString& url);
Q_INVOKABLE FluNetworkParams* patchJson(const QString& url);
Q_INVOKABLE FluNetworkParams* deleteJson(const QString& url);
Q_INVOKABLE FluNetworkParams* postJsonArray(const QString& url);
Q_INVOKABLE FluNetworkParams* putJsonArray(const QString& url);
Q_INVOKABLE FluNetworkParams* patchJsonArray(const QString& url);
Q_INVOKABLE FluNetworkParams* deleteJsonArray(const QString& url);
Q_INVOKABLE void setInterceptor(QJSValue interceptor);
void handle(FluNetworkParams* params,FluNetworkCallable* result);
void handleDownload(FluNetworkParams* params,FluNetworkCallable* result);
private:
void sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<FluNetworkCallable> callable);
void addQueryParam(QUrl* url,const QMap<QString, QVariant>& params);
void addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers);
void saveResponse(QString key,QString response);
QString readCache(const QString& key);
bool cacheExists(const QString& key);
QString getCacheFilePath(const QString& key);
QString map2String(const QMap<QString, QVariant>& map);
QString headerList2String(const QList<QNetworkReply::RawHeaderPair>& data);
void printRequestStartLog(QNetworkRequest request,FluNetworkParams* params);
void printRequestEndLog(QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,const QString& response);
public:
QJSValue _interceptor;
};
#endif // FLUNETWORK_H

View File

@ -1,35 +1,47 @@
#include "FluTextStyle.h" #include "FluTextStyle.h"
FluTextStyle::FluTextStyle(QObject *parent):QObject{parent}{ FluTextStyle::FluTextStyle(QObject *parent):QObject{parent}{
_family = QFont().defaultFamily();
#ifdef Q_OS_WIN
_family = "微软雅黑";
#endif
QFont caption; QFont caption;
caption.setFamily(_family);
caption.setPixelSize(12); caption.setPixelSize(12);
Caption(caption); Caption(caption);
QFont body; QFont body;
body.setFamily(_family);
body.setPixelSize(13); body.setPixelSize(13);
Body(body); Body(body);
QFont bodyStrong; QFont bodyStrong;
bodyStrong.setFamily(_family);
bodyStrong.setPixelSize(13); bodyStrong.setPixelSize(13);
bodyStrong.setWeight(QFont::DemiBold); bodyStrong.setWeight(QFont::DemiBold);
BodyStrong(bodyStrong); BodyStrong(bodyStrong);
QFont subtitle; QFont subtitle;
subtitle.setFamily(_family);
subtitle.setPixelSize(20); subtitle.setPixelSize(20);
subtitle.setWeight(QFont::DemiBold); subtitle.setWeight(QFont::DemiBold);
Subtitle(subtitle); Subtitle(subtitle);
QFont title; QFont title;
title.setFamily(_family);
title.setPixelSize(28); title.setPixelSize(28);
title.setWeight(QFont::DemiBold); title.setWeight(QFont::DemiBold);
Title(title); Title(title);
QFont titleLarge; QFont titleLarge;
titleLarge.setFamily(_family);
titleLarge.setPixelSize(40); titleLarge.setPixelSize(40);
titleLarge.setWeight(QFont::DemiBold); titleLarge.setWeight(QFont::DemiBold);
TitleLarge(titleLarge); TitleLarge(titleLarge);
QFont display; QFont display;
display.setFamily(_family);
display.setPixelSize(68); display.setPixelSize(68);
display.setWeight(QFont::DemiBold); display.setWeight(QFont::DemiBold);
Display(display); Display(display);

View File

@ -14,6 +14,7 @@ class FluTextStyle : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
Q_PROPERTY_AUTO(QString,family)
Q_PROPERTY_AUTO(QFont,Caption); Q_PROPERTY_AUTO(QFont,Caption);
Q_PROPERTY_AUTO(QFont,Body); Q_PROPERTY_AUTO(QFont,Body);
Q_PROPERTY_AUTO(QFont,BodyStrong); Q_PROPERTY_AUTO(QFont,BodyStrong);

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