Compare commits

..

No commits in common. "6ebd659e13a4cacadb27412936fad3b260787136" and "485bcc8acc8c19ffa0a665b05db18e90c24709bf" have entirely different histories.

229 changed files with 4430 additions and 4554 deletions

View File

@ -49,9 +49,13 @@ 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,9 +177,12 @@
<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>
@ -194,6 +197,7 @@
<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>
@ -204,10 +208,5 @@
<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,37 +4,41 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import FluentUI 1.0 import FluentUI 1.0
FluLauncher { Item {
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: {
Network.openLog = false FluNetwork.openLog = false
Network.setInterceptor(function(param){ FluNetwork.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.animationEnabled = true FluTheme.enableAnimation = true
FluRouter.routes = { FluApp.routes = {
"/":"qrc:/example/qml/window/MainWindow.qml", "/":"qrc:/example/qml/window/MainWindow.qml",
"/about":"qrc:/example/qml/window/AboutWindow.qml", "/about":"qrc:/example/qml/window/AboutWindow.qml",
"/login":"qrc:/example/qml/window/LoginWindow.qml", "/login":"qrc:/example/qml/window/LoginWindow.qml",
@ -47,9 +51,9 @@ FluLauncher {
} }
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=")){
FluRouter.navigate("/crash",{crashFilePath:args[1].replace("-crashed=","")}) FluApp.navigate("/crash",{crashFilePath:args[1].replace("-crashed=","")})
}else{ }else{
FluRouter.navigate("/") FluApp.navigate("/")
} }
} }
} }

View File

@ -9,10 +9,10 @@ FluScrollablePage{
title: qsTr("Bar Chart") title: qsTr("Bar Chart")
FluFrame{ FluArea{
Layout.preferredWidth: 500 width: 500
Layout.preferredHeight: 370 height: 370
padding: 10 paddings: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent
@ -69,10 +69,10 @@ FluScrollablePage{
} }
} }
FluFrame{ FluArea{
Layout.preferredWidth: 500 width: 500
Layout.preferredHeight: 370 height: 370
padding: 10 paddings: 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);
} }
FluFrame{ FluArea{
Layout.preferredWidth: 500 height: 370
Layout.preferredHeight: 370 width: 500
padding: 10 paddings: 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")
FluFrame{ FluArea{
Layout.preferredWidth: 500 width: 500
Layout.preferredHeight: 370 height: 370
padding: 10 paddings: 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")
FluFrame{ FluArea{
Layout.preferredWidth: 500 width: 500
Layout.preferredHeight: 370 height: 370
padding: 10 paddings: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent
@ -50,10 +50,10 @@ FluScrollablePage{
} }
} }
FluFrame{ FluArea{
Layout.preferredWidth: 500 width: 500
Layout.preferredHeight: 370 height: 370
padding: 10 paddings: 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")
FluFrame{ FluArea{
Layout.preferredWidth: 500 width: 500
Layout.preferredHeight: 370 height: 370
padding: 10 paddings: 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")
FluFrame{ FluArea{
Layout.preferredWidth: 500 width: 500
Layout.preferredHeight: 370 height: 370
padding: 10 paddings: 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);
} }
FluFrame{ FluArea{
Layout.preferredWidth: 500 height: 370
Layout.preferredHeight: 370 width: 500
padding: 10 paddings: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluChart{ FluChart{
anchors.fill: parent anchors.fill: parent
@ -119,4 +119,5 @@ FluScrollablePage{
} }
} }
} }
} }

View File

@ -135,11 +135,7 @@ 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

@ -1,10 +0,0 @@
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(){
FluRouter.navigate("/about") FluApp.navigate("/about")
} }
} }

View File

@ -104,12 +104,6 @@ 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
@ -277,12 +271,6 @@ 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{
@ -474,7 +462,7 @@ FluObject{
FluPaneItem{ FluPaneItem{
title: qsTr("Hot Loader") title: qsTr("Hot Loader")
onTapListener: function(){ onTapListener: function(){
FluRouter.navigate("/hotload") FluApp.navigate("/hotload")
} }
} }
FluPaneItem{ FluPaneItem{
@ -485,12 +473,10 @@ 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,3 +1,2 @@
singleton ItemsOriginal 1.0 ItemsOriginal.qml singleton ItemsOriginal 1.0 ItemsOriginal.qml
singleton ItemsFooter 1.0 ItemsFooter.qml singleton ItemsFooter 1.0 ItemsFooter.qml
singleton GlobalModel 1.0 GlobalModel.qml

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,10 +9,11 @@ FluScrollablePage{
title: qsTr("Expander") title: qsTr("Expander")
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
height: layout_column.height+20 height: layout_column.height+20
padding: 10 paddings: 10
Layout.topMargin: 20
Column{ Column{
id:layout_column id:layout_column
spacing: 15 spacing: 15
@ -82,7 +83,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: -6 Layout.topMargin: -1
code:'FluExpander{ code:'FluExpander{
headerText: qsTr("Open a radio box") headerText: qsTr("Open a radio box")
Item{ Item{

View File

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

View File

@ -1,48 +0,0 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import FluentUI 1.0
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,11 +9,10 @@ import "../global"
FluScrollablePage{ FluScrollablePage{
launchMode: FluPageType.SingleTask launchMode: FluPageType.SingleTask
animationEnabled: false animDisabled: true
header: Item{}
FluentInitializrWindow{ FluentInitalizrWindow{
id:fluent_Initializr id:fluent_initalizr
} }
ListModel{ ListModel{
@ -29,11 +28,11 @@ FluScrollablePage{
} }
ListElement{ ListElement{
icon: "qrc:/example/res/image/favicon.ico" icon: "qrc:/example/res/image/favicon.ico"
title: qsTr("FluentUI Initializr") title: qsTr("FluentUI Initalizr")
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_Initializr.showDialog() fluent_initalizr.showDialog()
} }
} }
} }
@ -122,7 +121,6 @@ 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
} }
} }
@ -179,7 +177,7 @@ FluScrollablePage{
property string desc: modelData.extra.desc property string desc: modelData.extra.desc
width: 320 width: 320
height: 120 height: 120
FluFrame{ FluArea{
radius: 8 radius: 8
width: 300 width: 300
height: 100 height: 100

View File

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

View File

@ -9,10 +9,11 @@ FluScrollablePage{
title: qsTr("InfoBar") title: qsTr("InfoBar")
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 270 Layout.topMargin: 20
padding: 10 height: 270
paddings: 10
ColumnLayout{ ColumnLayout{
spacing: 14 spacing: 14
anchors{ anchors{
@ -59,7 +60,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
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,10 +47,11 @@ FluScrollablePage{
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 100 height: 100
padding: 10 paddings: 10
Layout.topMargin: 20
Column{ Column{
id: layout_column id: layout_column
spacing: 15 spacing: 15
@ -77,7 +78,7 @@ FluScrollablePage{
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluMenu{ code:'FluMenu{
id:menu id:menu
FluMenuItem:{ FluMenuItem:{
@ -98,10 +99,10 @@ menu.popup()
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 100 height: 100
padding: 10 paddings: 10
Layout.topMargin: 20 Layout.topMargin: 20
Column{ Column{
spacing: 15 spacing: 15
@ -150,7 +151,7 @@ menu.popup()
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
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")
FluWindowResultLauncher{ Connections{
id:loginResultLauncher target: loginPageRegister
path: "/login" function onResult(data)
onResult: {
(data)=>{
password = data.password password = data.password
} }
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 86 height: 86
padding: 10 paddings: 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: {
FluRouter.navigate("/standardWindow") FluApp.navigate("/standardWindow")
} }
} }
} }
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 86 height: 86
padding: 10 paddings: 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: {
FluRouter.navigate("/singleTaskWindow") FluApp.navigate("/singleTaskWindow")
} }
} }
} }
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 86 height: 86
padding: 10 paddings: 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: {
FluRouter.navigate("/singleInstanceWindow") FluApp.navigate("/singleInstanceWindow")
} }
} }
} }
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluWindow{ code:'FluWindow{
//launchMode: FluWindowType.Standard //launchMode: FluWindowType.Standard
//launchMode: FluWindowType.SingleTask //launchMode: FluWindowType.SingleTask
@ -101,10 +101,10 @@ FluScrollablePage{
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 100 height: 100
padding: 10 paddings: 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: {
FluRouter.navigate("/about") FluApp.navigate("/about")
} }
} }
} }
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluButton{ code:'FluButton{
text: qsTr("Create Window") text: qsTr("Create Window")
onClicked: { onClicked: {
FluRouter.navigate("/about") FluApp.navigate("/about")
} }
} }
' '
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 130 height: 130
padding: 10 paddings: 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: {
loginResultLauncher.launch({username:"zhuzichu"}) loginPageRegister.launch({username:"zhuzichu"})
} }
} }
FluText{ FluText{
@ -163,12 +163,13 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluWindowResultLauncher{ code:'property var loginPageRegister: registerForWindowResult("/login")
id:loginResultLauncher
path: "/login" Connections{
onResult: target: loginPageRegister
(data)=>{ function onResult(data)
{
password = data.password password = data.password
} }
} }
@ -176,7 +177,7 @@ FluScrollablePage{
FluButton{ FluButton{
text: qsTr("Create Window") text: qsTr("Create Window")
onClicked: { onClicked: {
loginResultLauncher.launch({username:"zhuzichu"}) loginPageRegister.launch({username:"zhuzichu"})
} }
} }
' '

View File

@ -4,7 +4,6 @@ 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{
@ -12,7 +11,7 @@ FluContentPage{
id:root id:root
title: qsTr("Network") title: qsTr("Network")
NetworkCallable{ FluNetworkCallable{
id:callable id:callable
onStart: { onStart: {
showLoading() showLoading()
@ -40,6 +39,7 @@ 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 = ""
Network.get("https://httpbingo.org/get") FluNetwork.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 = ""
Network.head("https://httpbingo.org/head") FluNetwork.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 = ""
Network.postBody("https://httpbingo.org/post") FluNetwork.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 = ""
Network.postForm("https://httpbingo.org/post") FluNetwork.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 = ""
Network.postJson("https://httpbingo.org/post") FluNetwork.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 = ""
Network.postJsonArray("https://httpbingo.org/post") FluNetwork.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 = ""
Network.putBody("https://httpbingo.org/put") FluNetwork.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 = ""
Network.putForm("https://httpbingo.org/put") FluNetwork.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 = ""
Network.putJson("https://httpbingo.org/put") FluNetwork.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 = ""
Network.putJsonArray("https://httpbingo.org/put") FluNetwork.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 = ""
Network.patchBody("https://httpbingo.org/patch") FluNetwork.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 = ""
Network.patchForm("https://httpbingo.org/patch") FluNetwork.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 = ""
Network.patchJson("https://httpbingo.org/patch") FluNetwork.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 = ""
Network.patchJsonArray("https://httpbingo.org/patch") FluNetwork.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 = ""
Network.deleteBody("https://httpbingo.org/delete") FluNetwork.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 = ""
Network.deleteForm("https://httpbingo.org/delete") FluNetwork.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 = ""
Network.deleteJson("https://httpbingo.org/delete") FluNetwork.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 = ""
Network.deleteJsonArray("https://httpbingo.org/delete") FluNetwork.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 = ""
Network.postJson("https://httpbingo.org/post") FluNetwork.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 = ""
Network.postJson("https://httpbingo.org/post") FluNetwork.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 = ""
Network.postJson("https://httpbingo.org/post") FluNetwork.postJson("https://httpbingo.org/post")
.setCacheMode(NetworkType.RequestFailedReadCache) .setCacheMode(FluNetworkType.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 = ""
Network.postJson("https://httpbingo.org/post") FluNetwork.postJson("https://httpbingo.org/post")
.setCacheMode(NetworkType.IfNoneCacheRequest) .setCacheMode(FluNetworkType.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 = ""
Network.postJson("https://httpbingo.org/post") FluNetwork.postJson("https://httpbingo.org/post")
.setCacheMode(NetworkType.FirstCacheThenRequest) .setCacheMode(FluNetworkType.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 = ""
Network.postJson("https://httpbingo.org/post") FluNetwork.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){
Network.get("http://vjs.zencdn.net/v/oceans.mp4") FluNetwork.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){
Network.get("http://vjs.zencdn.net/v/oceans.mp4") FluNetwork.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{
} }
} }
NetworkCallable{ FluNetworkCallable{
id:callable_upload_file id:callable_upload_file
onStart: { onStart: {
btn_upload.disabled = true btn_upload.disabled = true
@ -455,7 +455,7 @@ FluContentPage{
} }
} }
NetworkCallable{ FluNetworkCallable{
id:callable_download_file id:callable_download_file
onStart: { onStart: {
btn_download.progress = 0 btn_download.progress = 0
@ -480,7 +480,7 @@ FluContentPage{
} }
} }
NetworkCallable{ FluNetworkCallable{
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: {
Network.postForm("https://httpbingo.org/post") FluNetwork.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{
} }
} }
FluFrame{ FluArea{
anchors{ anchors{
top: layout_flick.top top: layout_flick.top
bottom: layout_flick.bottom bottom: layout_flick.bottom

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,10 +9,11 @@ FluScrollablePage{
title: qsTr("Rectangle") title: qsTr("Rectangle")
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 80 Layout.topMargin: 20
padding: 10 height: 80
paddings: 10
Column{ Column{
spacing: 15 spacing: 15
@ -63,7 +64,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
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/Qt_174_RemoteLoader.qml" source: "https://zhu-zichu.gitee.io/Qt5_T_RemoteLoader.qml"
} }
} }

View File

@ -4,24 +4,38 @@ 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
} }
} }
FluFrame{ Component.onCompleted: {
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
Layout.preferredHeight: 60 height: 60
padding: 10 paddings: 10
Row{ Row{
spacing: 20 spacing: 20
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -42,11 +56,11 @@ FluScrollablePage{
} }
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 50 height: 50
padding: 10 paddings: 10
FluCheckBox{ FluCheckBox{
text: qsTr("Use System AppBar") text: qsTr("Use System AppBar")
checked: FluApp.useSystemAppBar checked: FluApp.useSystemAppBar
@ -58,11 +72,11 @@ FluScrollablePage{
} }
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 50 height: 50
padding: 10 paddings: 10
FluCheckBox{ FluCheckBox{
text:qsTr("Fits AppBar Windows") text:qsTr("Fits AppBar Windows")
checked: window.fitsAppBarWindows checked: window.fitsAppBarWindows
@ -81,15 +95,15 @@ FluScrollablePage{
negativeText: qsTr("Cancel") negativeText: qsTr("Cancel")
positiveText: qsTr("OK") positiveText: qsTr("OK")
onPositiveClicked: { onPositiveClicked: {
FluRouter.exit(931) FluApp.exit(931)
} }
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 128 height: 128
padding: 10 paddings: 10
ColumnLayout{ ColumnLayout{
spacing: 5 spacing: 5
@ -115,11 +129,11 @@ FluScrollablePage{
} }
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 160 height: 160
padding: 10 paddings: 10
ColumnLayout{ ColumnLayout{
spacing: 5 spacing: 5
@ -135,10 +149,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(){
GlobalModel.displayMode = modelData.mode viewmodel_settings.displayMode = modelData.mode
} }
} }
} }
@ -155,11 +169,11 @@ FluScrollablePage{
} }
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 80 height: 80
padding: 10 paddings: 10
ColumnLayout{ ColumnLayout{
spacing: 10 spacing: 10

View File

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

View File

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

View File

@ -13,6 +13,7 @@ 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,6 +27,7 @@ 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
@ -42,7 +43,8 @@ FluContentPage{
FluText{ FluText{
color:"#FFFFFF" color:"#FFFFFF"
text:model.index text:model.index
font: FluTextStyle.Title font.bold: true
font.pixelSize: 18
anchors.centerIn: parent anchors.centerIn: parent
} }
} }

View File

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

View File

@ -29,10 +29,11 @@ FluScrollablePage{
newTab() newTab()
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 50 Layout.topMargin: 20
padding: 10 height: 50
paddings: 10
RowLayout{ RowLayout{
spacing: 14 spacing: 14
FluDropDownButton{ FluDropDownButton{
@ -90,11 +91,11 @@ FluScrollablePage{
} }
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 15 Layout.topMargin: 15
Layout.preferredHeight: 400 height: 400
padding: 10 paddings: 10
FluTabView{ FluTabView{
id:tab_view id:tab_view
onNewPressed:{ onNewPressed:{
@ -104,7 +105,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
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
animationEnabled: false enableAnimation: 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
animationEnabled: false enableAnimation: 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{
} }
} }
FluFrame{ FluArea{
id:layout_controls id:layout_controls
anchors{ anchors{
left: parent.left left: parent.left

View File

@ -9,10 +9,11 @@ FluScrollablePage{
title: qsTr("Text") title: qsTr("Text")
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 60 Layout.topMargin: 20
padding: 10 height: 60
paddings: 10
FluCopyableText{ FluCopyableText{
text: qsTr("This is a text that can be copied") text: qsTr("This is a text that can be copied")
@ -22,7 +23,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
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,20 +4,30 @@ 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")
FluFrame{ TextBoxViewModel{
id:viewModel
}
FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 68 height: 68
padding: 10 paddings: 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
@ -35,16 +45,16 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluTextBox{ code:'FluTextBox{
placeholderText: qsTr("Single-line Input Box") placeholderText: qsTr("Single-line Input Box")
}' }'
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 68 height: 68
padding: 10 paddings: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluPasswordBox{ FluPasswordBox{
@ -66,21 +76,26 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluPasswordBox{ code:'FluPasswordBox{
placeholderText: qsTr("Please enter your password") placeholderText: qsTr("Please enter your password")
}' }'
} }
FluFrame{
FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 36+multiine_textbox.height height: 36+multiine_textbox.height
padding: 10 paddings: 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
@ -99,16 +114,16 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluMultilineTextBox{ code:'FluMultilineTextBox{
placeholderText: qsTr("Multi-line Input Box") placeholderText: qsTr("Multi-line Input Box")
}' }'
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 68 height: 68
padding: 10 paddings: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluAutoSuggestBox{ FluAutoSuggestBox{
placeholderText: qsTr("AutoSuggestBox") placeholderText: qsTr("AutoSuggestBox")
@ -130,16 +145,16 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluAutoSuggestBox{ code:'FluAutoSuggestBox{
placeholderText: qsTr("AutoSuggestBox") placeholderText: qsTr("AutoSuggestBox")
}' }'
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 68 height: 68
padding: 10 paddings: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluSpinBox{ FluSpinBox{
disabled: spin_box_switch.checked disabled: spin_box_switch.checked
@ -159,7 +174,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluSpinBox{ code:'FluSpinBox{
}' }'

View File

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

View File

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

View File

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

View File

@ -10,14 +10,15 @@ 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")
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
Layout.preferredHeight: 68 height: 68
padding: 10 paddings: 10
Column{ Column{
spacing: 5 spacing: 5
@ -40,7 +41,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluIconButton{ code:'FluIconButton{
iconSource:FluentIcons.ChromeCloseContrast iconSource:FluentIcons.ChromeCloseContrast
iconSize: 15 iconSize: 15
@ -52,11 +53,11 @@ FluScrollablePage{
' '
} }
FluFrame{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
Layout.preferredHeight: 68 height: 68
padding: 10 paddings: 10
Column{ Column{
spacing: 5 spacing: 5
@ -83,7 +84,7 @@ FluScrollablePage{
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: -6 Layout.topMargin: -1
code:'FluButton{ code:'FluButton{
id: button_1 id: button_1
text: qsTr("Delete") text: qsTr("Delete")

View File

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

View File

@ -33,6 +33,7 @@ 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
@ -102,7 +103,7 @@ FluContentPage {
} }
} }
} }
FluFrame{ FluArea{
anchors{ anchors{
left: layout_column.right left: layout_column.right
top: parent.top top: parent.top

View File

@ -10,14 +10,15 @@ FluContentPage {
title: qsTr("Typography") title: qsTr("Typography")
rightPadding: 10 rightPadding: 10
FluFrame{ FluArea{
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
} }
padding: 10 paddings: 10
ColumnLayout{ ColumnLayout{
spacing: 0 spacing: 0
scale: textScale scale: textScale

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,14 +8,14 @@ import "../component"
FluWindowDialog { FluWindowDialog {
id:window id:window
title:qsTr("FluentUI Initializr") title:qsTr("FluentUI Initalizr")
width: 600 width: 600
height: 400 height: 400
contentDelegate:Component{ contentDelegate:Component{
Item{ Item{
Connections{ Connections{
target: InitializrHelper target: InitalizrHelper
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 Initializr") text:qsTr("FluentUI Initalizr")
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: {
InitializrHelper.generate(text_box_name.text,text_box_path.text) InitalizrHelper.generate(text_box_name.text,text_box_path.text)
} }
} }
} }

View File

@ -20,7 +20,7 @@ FluWindow {
loader.reload() loader.reload()
} }
} }
FluFrame{ FluArea{
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: FluTextStyle.Title font.pixelSize: 26
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
} }
setResult({password:textbox_password.text}) onResult({password:textbox_password.text})
window.close() window.close()
} }
} }

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 854 KiB

Binary file not shown.

After

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
FluLauncher { Item {
id: app id: app
Component.onCompleted: { Component.onCompleted: {
FluApp.init(app) FluApp.init(app)
FluApp.windowIcon = "qrc:/logo.ico" FluApp.windowIcon = "qrc:/logo.ico"
FluRouter.routes = { FluApp.routes = {
"/":"qrc:/main.qml", "/":"qrc:/main.qml",
} }
FluRouter.navigate("/") FluApp.navigate("/")
} }
} }

View File

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

View File

@ -1,169 +0,0 @@
#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,9 +15,8 @@
#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/InitializrHelper.h" #include "src/helper/InitalizrHelper.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))
@ -32,9 +31,6 @@ 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");
@ -57,8 +53,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,uri); Log::setup(argv,"example");
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 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))
@ -69,22 +65,18 @@ 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("InitializrHelper",InitializrHelper::getInstance()); engine.rootContext()->setContextProperty("InitalizrHelper",InitalizrHelper::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) {
@ -94,7 +86,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(), qApp->arguments()); QProcess::startDetached(qApp->applicationFilePath(), QStringList());
} }
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,4,0) add_definitions(-DFLUENTUI_VERSION=1,7,3,0)
if (FLUENTUI_BUILD_STATIC_LIB) if (FLUENTUI_BUILD_STATIC_LIB)
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB) add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
@ -73,16 +73,12 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
endif() endif()
#qml #qml
file(GLOB_RECURSE QML_PATHS *.qml qmldir) file(GLOB_RECURSE QML_PATHS *.qml)
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,16 +4,26 @@
#include <QObject> #include <QObject>
#include <QtQml/qqml.h> #include <QtQml/qqml.h>
namespace FluSheetType { namespace FluViewModelType {
Q_NAMESPACE Q_NAMESPACE
enum Position { enum Scope {
Left = 0x0000, Window = 0x0000,
Top = 0x0001, Application = 0x0001
Right = 0x0002,
Bottom = 0x0004,
}; };
Q_ENUM_NS(Position) Q_ENUM_NS(Scope)
QML_NAMED_ELEMENT(FluSheetType) QML_NAMED_ELEMENT(FluViewModelType)
}
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,6 +10,20 @@
#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);
} }
@ -31,3 +45,76 @@ 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,6 +4,7 @@
#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>
@ -12,12 +13,31 @@
#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);
@ -29,8 +49,15 @@ 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,5 +1,4 @@
#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));
@ -112,12 +111,17 @@ 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(FluTools::getInstance()->withOpacity(primaryColor,0.7)); accentColor->darkest(withOpacity(primaryColor,0.7));
accentColor->darker(FluTools::getInstance()->withOpacity(primaryColor,0.8)); accentColor->darker(withOpacity(primaryColor,0.8));
accentColor->dark(FluTools::getInstance()->withOpacity(primaryColor,0.9)); accentColor->dark(withOpacity(primaryColor,0.9));
accentColor->normal(primaryColor); accentColor->normal(primaryColor);
accentColor->light(FluTools::getInstance()->withOpacity(primaryColor,0.9)); accentColor->light(withOpacity(primaryColor,0.9));
accentColor->lighter(FluTools::getInstance()->withOpacity(primaryColor,0.8)); accentColor->lighter(withOpacity(primaryColor,0.8));
accentColor->lightest(FluTools::getInstance()->withOpacity(primaryColor,0.7)); accentColor->lightest(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,7 +3,6 @@
#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"
@ -51,6 +50,7 @@ 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);

23
src/FluEventBus.cpp Normal file
View File

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

41
src/FluEventBus.h Normal file
View File

@ -0,0 +1,41 @@
#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

View File

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

View File

@ -1,61 +0,0 @@
#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

500
src/FluFramelessHelper.cpp Normal file
View File

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

79
src/FluFramelessHelper.h Normal file
View File

@ -0,0 +1,79 @@
#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,4 +1,4 @@
#include "Network.h" #include "FluNetwork.h"
#include <QUrlQuery> #include <QUrlQuery>
#include <QBuffer> #include <QBuffer>
@ -18,11 +18,11 @@
#include <QEventLoop> #include <QEventLoop>
#include <QGuiApplication> #include <QGuiApplication>
NetworkCallable::NetworkCallable(QObject *parent):QObject{parent}{ FluNetworkCallable::FluNetworkCallable(QObject *parent):QObject{parent}{
} }
QString NetworkParams::method2String(){ QString FluNetworkParams::method2String(){
switch (_method) { switch (_method) {
case METHOD_GET: case METHOD_GET:
return "GET"; return "GET";
@ -41,25 +41,25 @@ QString NetworkParams::method2String(){
} }
} }
int NetworkParams::getTimeout(){ int FluNetworkParams::getTimeout(){
if(_timeout != -1){ if(_timeout != -1){
return _timeout; return _timeout;
} }
return Network::getInstance()->timeout(); return FluNetwork::getInstance()->timeout();
} }
int NetworkParams::getRetry(){ int FluNetworkParams::getRetry(){
if(_retry != -1){ if(_retry != -1){
return _retry; return _retry;
} }
return Network::getInstance()->retry(); return FluNetwork::getInstance()->retry();
} }
bool NetworkParams::getOpenLog(){ bool FluNetworkParams::getOpenLog(){
if(!_openLog.isNull()){ if(!_openLog.isNull()){
return _openLog.toBool(); return _openLog.toBool();
} }
return Network::getInstance()->openLog(); return FluNetwork::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;
} }
NetworkParams::NetworkParams(QObject *parent) FluNetworkParams::FluNetworkParams(QObject *parent)
: QObject{parent} : QObject{parent}
{ {
} }
NetworkParams::NetworkParams(QString url,Type type,Method method,QObject *parent) FluNetworkParams::FluNetworkParams(QString url,Type type,Method method,QObject *parent)
: QObject{parent} : QObject{parent}
{ {
this->_method = method; this->_method = method;
@ -87,62 +87,62 @@ NetworkParams::NetworkParams(QString url,Type type,Method method,QObject *parent
this->_type = type; this->_type = type;
} }
NetworkParams* NetworkParams::add(QString key,QVariant val){ FluNetworkParams* FluNetworkParams::add(QString key,QVariant val){
_paramMap.insert(key,val); _paramMap.insert(key,val);
return this; return this;
} }
NetworkParams* NetworkParams::addFile(QString key,QVariant val){ FluNetworkParams* FluNetworkParams::addFile(QString key,QVariant val){
_fileMap.insert(key,val); _fileMap.insert(key,val);
return this; return this;
} }
NetworkParams* NetworkParams::addHeader(QString key,QVariant val){ FluNetworkParams* FluNetworkParams::addHeader(QString key,QVariant val){
_headerMap.insert(key,val); _headerMap.insert(key,val);
return this; return this;
} }
NetworkParams* NetworkParams::addQuery(QString key,QVariant val){ FluNetworkParams* FluNetworkParams::addQuery(QString key,QVariant val){
_queryMap.insert(key,val); _queryMap.insert(key,val);
return this; return this;
} }
NetworkParams* NetworkParams::setBody(QString val){ FluNetworkParams* FluNetworkParams::setBody(QString val){
_body = val; _body = val;
return this; return this;
} }
NetworkParams* NetworkParams::setTimeout(int val){ FluNetworkParams* FluNetworkParams::setTimeout(int val){
_timeout = val; _timeout = val;
return this; return this;
} }
NetworkParams* NetworkParams::setRetry(int val){ FluNetworkParams* FluNetworkParams::setRetry(int val){
_retry = val; _retry = val;
return this; return this;
} }
NetworkParams* NetworkParams::setCacheMode(int val){ FluNetworkParams* FluNetworkParams::setCacheMode(int val){
_cacheMode = val; _cacheMode = val;
return this; return this;
} }
NetworkParams* NetworkParams::toDownload(QString destPath,bool append){ FluNetworkParams* FluNetworkParams::toDownload(QString destPath,bool append){
_downloadParam = new FluDownloadParam(destPath,append,this); _downloadParam = new FluDownloadParam(destPath,append,this);
return this; return this;
} }
NetworkParams* NetworkParams::bind(QObject* target){ FluNetworkParams* FluNetworkParams::bind(QObject* target){
_target = target; _target = target;
return this; return this;
} }
NetworkParams* NetworkParams::openLog(QVariant val){ FluNetworkParams* FluNetworkParams::openLog(QVariant val){
_openLog = val; _openLog = val;
return this; return this;
} }
QString NetworkParams::buildCacheKey(){ QString FluNetworkParams::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 NetworkParams::buildCacheKey(){
return QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex(); return QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex();
} }
void NetworkParams::go(NetworkCallable* callable){ void FluNetworkParams::go(FluNetworkCallable* callable){
QJSValueList data; QJSValueList data;
data<<qjsEngine(callable)->newQObject(this); data<<qjsEngine(callable)->newQObject(this);
Network::getInstance()->_interceptor.call(data); FluNetwork::getInstance()->_interceptor.call(data);
if(_downloadParam){ if(_downloadParam){
Network::getInstance()->handleDownload(this,callable); FluNetwork::getInstance()->handleDownload(this,callable);
}else{ }else{
Network::getInstance()->handle(this,callable); FluNetwork::getInstance()->handle(this,callable);
} }
} }
void Network::handle(NetworkParams* params,NetworkCallable* c){ void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
QPointer<NetworkCallable> callable(c); QPointer<FluNetworkCallable> 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 == NetworkType::CacheMode::FirstCacheThenRequest && cacheExists(cacheKey)){ if(params->_cacheMode == FluNetworkType::CacheMode::FirstCacheThenRequest && cacheExists(cacheKey)){
if(!callable.isNull()){ if(!callable.isNull()){
callable->cache(readCache(cacheKey)); callable->cache(readCache(cacheKey));
} }
} }
if(params->_cacheMode == NetworkType::CacheMode::IfNoneCacheRequest && cacheExists(cacheKey)){ if(params->_cacheMode == FluNetworkType::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 Network::handle(NetworkParams* params,NetworkCallable* c){
disconnect(conn_quit); disconnect(conn_quit);
} }
QString response; QString response;
if(params->_method == NetworkParams::METHOD_HEAD){ if(params->_method == FluNetworkParams::METHOD_HEAD){
response = headerList2String(reply->rawHeaderPairs()); response = headerList2String(reply->rawHeaderPairs());
}else{ }else{
if(reply->isOpen()){ if(reply->isOpen()){
@ -238,7 +238,7 @@ void Network::handle(NetworkParams* params,NetworkCallable* 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 != NetworkType::CacheMode::NoCache){ if(params->_cacheMode != FluNetworkType::CacheMode::NoCache){
saveResponse(cacheKey,response); saveResponse(cacheKey,response);
} }
callable->success(response); callable->success(response);
@ -248,7 +248,7 @@ void Network::handle(NetworkParams* params,NetworkCallable* c){
}else{ }else{
if(i == params->getRetry()-1){ if(i == params->getRetry()-1){
if(!callable.isNull()){ if(!callable.isNull()){
if(params->_cacheMode == NetworkType::CacheMode::RequestFailedReadCache && cacheExists(cacheKey)){ if(params->_cacheMode == FluNetworkType::CacheMode::RequestFailedReadCache && cacheExists(cacheKey)){
if(!callable.isNull()){ if(!callable.isNull()){
callable->cache(readCache(cacheKey)); callable->cache(readCache(cacheKey));
} }
@ -267,8 +267,8 @@ void Network::handle(NetworkParams* params,NetworkCallable* c){
}); });
} }
void Network::handleDownload(NetworkParams* params,NetworkCallable* c){ void FluNetwork::handleDownload(FluNetworkParams* params,FluNetworkCallable* c){
QPointer<NetworkCallable> callable(c); QPointer<FluNetworkCallable> callable(c);
QThreadPool::globalInstance()->start([=](){ QThreadPool::globalInstance()->start([=](){
if(!callable.isNull()){ if(!callable.isNull()){
callable->start(); callable->start();
@ -391,7 +391,7 @@ void Network::handleDownload(NetworkParams* params,NetworkCallable* c){
}); });
} }
QString Network::readCache(const QString& key){ QString FluNetwork::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 Network::readCache(const QString& key){
return result; return result;
} }
bool Network::cacheExists(const QString& key){ bool FluNetwork::cacheExists(const QString& key){
return QFile(getCacheFilePath(key)).exists(); return QFile(getCacheFilePath(key)).exists();
} }
QString Network::getCacheFilePath(const QString& key){ QString FluNetwork::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 Network::getCacheFilePath(const QString& key){
return cacheDir.absoluteFilePath(key); return cacheDir.absoluteFilePath(key);
} }
QString Network::headerList2String(const QList<QNetworkReply::RawHeaderPair>& data){ QString FluNetwork::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 Network::headerList2String(const QList<QNetworkReply::RawHeaderPair>& da
return QJsonDocument(object).toJson(QJsonDocument::Compact); return QJsonDocument(object).toJson(QJsonDocument::Compact);
} }
QString Network::map2String(const QMap<QString, QVariant>& map){ QString FluNetwork::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 Network::map2String(const QMap<QString, QVariant>& map){
return parameters.join(" "); return parameters.join(" ");
} }
void Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable){ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<FluNetworkCallable> callable){
QByteArray verb = params->method2String().toUtf8(); QByteArray verb = params->method2String().toUtf8();
switch (params->_type) { switch (params->_type) {
case NetworkParams::TYPE_FORM:{ case FluNetworkParams::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 Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request
} }
break; break;
} }
case NetworkParams::TYPE_JSON:{ case FluNetworkParams::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 Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request
reply = manager->sendCustomRequest(request,verb,data); reply = manager->sendCustomRequest(request,verb,data);
break; break;
} }
case NetworkParams::TYPE_JSONARRAY:{ case FluNetworkParams::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 Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request
reply = manager->sendCustomRequest(request,params->method2String().toUtf8(),data); reply = manager->sendCustomRequest(request,params->method2String().toUtf8(),data);
break; break;
} }
case NetworkParams::TYPE_BODY:{ case FluNetworkParams::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 Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request
} }
} }
void Network::printRequestStartLog(QNetworkRequest request,NetworkParams* params){ void FluNetwork::printRequestStartLog(QNetworkRequest request,FluNetworkParams* params){
if(!params->getOpenLog()){ if(!params->getOpenLog()){
return; return;
} }
@ -551,7 +551,7 @@ void Network::printRequestStartLog(QNetworkRequest request,NetworkParams* params
} }
} }
void Network::printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response){ void FluNetwork::printRequestEndLog(QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,const QString& response){
if(!params->getOpenLog()){ if(!params->getOpenLog()){
return; return;
} }
@ -560,7 +560,7 @@ void Network::printRequestEndLog(QNetworkRequest request,NetworkParams* params,Q
qDebug()<<"<Result>"<<qUtf8Printable(response); qDebug()<<"<Result>"<<qUtf8Printable(response);
} }
void Network::saveResponse(QString key,QString response){ void FluNetwork::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 Network::saveResponse(QString key,QString response){
file->write(response.toUtf8().toBase64()); file->write(response.toUtf8().toBase64());
} }
void Network::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers){ void FluNetwork::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 Network::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>&
} }
} }
void Network::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){ void FluNetwork::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 Network::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){
url->setQuery(urlQuery); url->setQuery(urlQuery);
} }
Network::Network(QObject *parent): QObject{parent} FluNetwork::FluNetwork(QObject *parent): QObject{parent}
{ {
timeout(5000); timeout(5000);
retry(3); retry(3);
@ -599,78 +599,78 @@ Network::Network(QObject *parent): QObject{parent}
cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network")); cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network"));
} }
NetworkParams* Network::get(const QString& url){ FluNetworkParams* FluNetwork::get(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_NONE,NetworkParams::METHOD_GET,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_NONE,FluNetworkParams::METHOD_GET,this);
} }
NetworkParams* Network::head(const QString& url){ FluNetworkParams* FluNetwork::head(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_NONE,NetworkParams::METHOD_HEAD,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_NONE,FluNetworkParams::METHOD_HEAD,this);
} }
NetworkParams* Network::postBody(const QString& url){ FluNetworkParams* FluNetwork::postBody(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_POST,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_POST,this);
} }
NetworkParams* Network::putBody(const QString& url){ FluNetworkParams* FluNetwork::putBody(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_PUT,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_PUT,this);
} }
NetworkParams* Network::patchBody(const QString& url){ FluNetworkParams* FluNetwork::patchBody(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_PATCH,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_PATCH,this);
} }
NetworkParams* Network::deleteBody(const QString& url){ FluNetworkParams* FluNetwork::deleteBody(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_DELETE,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_DELETE,this);
} }
NetworkParams* Network::postForm(const QString& url){ FluNetworkParams* FluNetwork::postForm(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_POST,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_POST,this);
} }
NetworkParams* Network::putForm(const QString& url){ FluNetworkParams* FluNetwork::putForm(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_PUT,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_PUT,this);
} }
NetworkParams* Network::patchForm(const QString& url){ FluNetworkParams* FluNetwork::patchForm(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_PATCH,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_PATCH,this);
} }
NetworkParams* Network::deleteForm(const QString& url){ FluNetworkParams* FluNetwork::deleteForm(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_DELETE,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_DELETE,this);
} }
NetworkParams* Network::postJson(const QString& url){ FluNetworkParams* FluNetwork::postJson(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_POST,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_POST,this);
} }
NetworkParams* Network::putJson(const QString& url){ FluNetworkParams* FluNetwork::putJson(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_PUT,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_PUT,this);
} }
NetworkParams* Network::patchJson(const QString& url){ FluNetworkParams* FluNetwork::patchJson(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_PATCH,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_PATCH,this);
} }
NetworkParams* Network::deleteJson(const QString& url){ FluNetworkParams* FluNetwork::deleteJson(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_DELETE,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_DELETE,this);
} }
NetworkParams* Network::postJsonArray(const QString& url){ FluNetworkParams* FluNetwork::postJsonArray(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_POST,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_POST,this);
} }
NetworkParams* Network::putJsonArray(const QString& url){ FluNetworkParams* FluNetwork::putJsonArray(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_PUT,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_PUT,this);
} }
NetworkParams* Network::patchJsonArray(const QString& url){ FluNetworkParams* FluNetwork::patchJsonArray(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_PATCH,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_PATCH,this);
} }
NetworkParams* Network::deleteJsonArray(const QString& url){ FluNetworkParams* FluNetwork::deleteJsonArray(const QString& url){
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_DELETE,this); return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_DELETE,this);
} }
void Network::setInterceptor(QJSValue interceptor){ void FluNetwork::setInterceptor(QJSValue interceptor){
this->_interceptor = interceptor; this->_interceptor = interceptor;
} }

158
src/FluNetwork.h Normal file
View File

@ -0,0 +1,158 @@
#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,47 +1,35 @@
#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,7 +14,6 @@ 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