mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-24 11:40:43 +08:00
Compare commits
30 Commits
485bcc8acc
...
6ebd659e13
Author | SHA1 | Date | |
---|---|---|---|
|
6ebd659e13 | ||
|
bd8c80feb8 | ||
|
6b617d10d5 | ||
|
cf163f5e3b | ||
|
b4329fdd0a | ||
|
84b2045b5f | ||
|
18193a18be | ||
|
fe08b08c1f | ||
|
ef96618151 | ||
|
be34220652 | ||
|
5cf0812562 | ||
|
c2b845658d | ||
|
eb4ec242b1 | ||
|
a95916ab03 | ||
|
bf5bedc9ed | ||
|
7d1666597f | ||
|
da9f63eb24 | ||
|
68015776ab | ||
|
d222cb640c | ||
|
0ab7f811e3 | ||
|
6a5f9d04a9 | ||
|
cb33af8836 | ||
|
5fd934b5f5 | ||
|
b7fde5f79c | ||
|
41cbeef3fd | ||
|
f616a2da6a | ||
|
b6c3f0eda9 | ||
|
06aa16c0eb | ||
|
c52439ac39 | ||
|
e81a2cc849 |
@ -49,13 +49,9 @@ configure_file(
|
||||
)
|
||||
|
||||
#遍历所有Cpp文件
|
||||
|
||||
message("---------->${filename}")
|
||||
file(GLOB_RECURSE CPP_FILES *.cpp *.h)
|
||||
foreach(filepath ${CPP_FILES})
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
|
||||
|
||||
message(${filename})
|
||||
list(APPEND sources_files ${filename})
|
||||
endforeach(filepath)
|
||||
|
||||
|
@ -177,12 +177,9 @@
|
||||
<file>qml/window/SingleInstanceWindow.qml</file>
|
||||
<file>qml/window/SingleTaskWindow.qml</file>
|
||||
<file>qml/window/StandardWindow.qml</file>
|
||||
<file>res/image/bg_scenic.png</file>
|
||||
<file>res/image/image_1.jpg</file>
|
||||
<file>qml/window/PageWindow.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_3D.qml</file>
|
||||
<file>qml/page/T_Network.qml</file>
|
||||
@ -197,7 +194,6 @@
|
||||
<file>res/image/ic_crash.png</file>
|
||||
<file>qml/window/CrashWindow.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/src/App.qml.in</file>
|
||||
<file>res/template/src/CMakeLists.txt.in</file>
|
||||
@ -208,5 +204,10 @@
|
||||
<file>res/template/src/qml.qrc.in</file>
|
||||
<file>res/template/src/zh_CN.ts.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>
|
||||
</RCC>
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -4,41 +4,37 @@ import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Item {
|
||||
FluLauncher {
|
||||
id: app
|
||||
|
||||
Connections{
|
||||
target: FluTheme
|
||||
function onDarkModeChanged(){
|
||||
SettingsHelper.saveDarkMode(FluTheme.darkMode)
|
||||
}
|
||||
}
|
||||
|
||||
Connections{
|
||||
target: FluApp
|
||||
function onUseSystemAppBarChanged(){
|
||||
SettingsHelper.saveUseSystemAppBar(FluApp.useSystemAppBar)
|
||||
}
|
||||
}
|
||||
|
||||
Connections{
|
||||
target: TranslateHelper
|
||||
function onCurrentChanged(){
|
||||
SettingsHelper.saveLanguage(TranslateHelper.current)
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
FluNetwork.openLog = false
|
||||
FluNetwork.setInterceptor(function(param){
|
||||
Network.openLog = false
|
||||
Network.setInterceptor(function(param){
|
||||
param.addHeader("Token","000000000000000000000")
|
||||
})
|
||||
FluApp.init(app,Qt.locale(TranslateHelper.current))
|
||||
FluApp.windowIcon = "qrc:/example/res/image/favicon.ico"
|
||||
FluApp.useSystemAppBar = SettingsHelper.getUseSystemAppBar()
|
||||
FluTheme.darkMode = SettingsHelper.getDarkMode()
|
||||
FluTheme.enableAnimation = true
|
||||
FluApp.routes = {
|
||||
FluTheme.animationEnabled = true
|
||||
FluRouter.routes = {
|
||||
"/":"qrc:/example/qml/window/MainWindow.qml",
|
||||
"/about":"qrc:/example/qml/window/AboutWindow.qml",
|
||||
"/login":"qrc:/example/qml/window/LoginWindow.qml",
|
||||
@ -51,9 +47,9 @@ Item {
|
||||
}
|
||||
var args = Qt.application.arguments
|
||||
if(args.length>=2 && args[1].startsWith("-crashed=")){
|
||||
FluApp.navigate("/crash",{crashFilePath:args[1].replace("-crashed=","")})
|
||||
FluRouter.navigate("/crash",{crashFilePath:args[1].replace("-crashed=","")})
|
||||
}else{
|
||||
FluApp.navigate("/")
|
||||
FluRouter.navigate("/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Bar Chart")
|
||||
|
||||
FluArea{
|
||||
width: 500
|
||||
height: 370
|
||||
paddings: 10
|
||||
FluFrame{
|
||||
Layout.preferredWidth: 500
|
||||
Layout.preferredHeight: 370
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluChart{
|
||||
anchors.fill: parent
|
||||
@ -69,10 +69,10 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
width: 500
|
||||
height: 370
|
||||
paddings: 10
|
||||
FluFrame{
|
||||
Layout.preferredWidth: 500
|
||||
Layout.preferredHeight: 370
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluChart{
|
||||
anchors.fill: parent
|
||||
|
@ -13,10 +13,10 @@ FluScrollablePage{
|
||||
return Math.random().toFixed(1);
|
||||
}
|
||||
|
||||
FluArea{
|
||||
height: 370
|
||||
width: 500
|
||||
paddings: 10
|
||||
FluFrame{
|
||||
Layout.preferredWidth: 500
|
||||
Layout.preferredHeight: 370
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluChart{
|
||||
anchors.fill: parent
|
||||
|
@ -9,10 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Line Chart")
|
||||
|
||||
FluArea{
|
||||
width: 500
|
||||
height: 370
|
||||
paddings: 10
|
||||
FluFrame{
|
||||
Layout.preferredWidth: 500
|
||||
Layout.preferredHeight: 370
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluChart{
|
||||
anchors.fill: parent
|
||||
|
@ -9,10 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Pie Chart")
|
||||
|
||||
FluArea{
|
||||
width: 500
|
||||
height: 370
|
||||
paddings: 10
|
||||
FluFrame{
|
||||
Layout.preferredWidth: 500
|
||||
Layout.preferredHeight: 370
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluChart{
|
||||
anchors.fill: parent
|
||||
@ -50,10 +50,10 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
width: 500
|
||||
height: 370
|
||||
paddings: 10
|
||||
FluFrame{
|
||||
Layout.preferredWidth: 500
|
||||
Layout.preferredHeight: 370
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluChart{
|
||||
anchors.fill: parent
|
||||
|
@ -9,10 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Polar Area Chart")
|
||||
|
||||
FluArea{
|
||||
width: 500
|
||||
height: 370
|
||||
paddings: 10
|
||||
FluFrame{
|
||||
Layout.preferredWidth: 500
|
||||
Layout.preferredHeight: 370
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluChart{
|
||||
anchors.fill: parent
|
||||
|
@ -9,10 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Radar Chart")
|
||||
|
||||
FluArea{
|
||||
width: 500
|
||||
height: 370
|
||||
paddings: 10
|
||||
FluFrame{
|
||||
Layout.preferredWidth: 500
|
||||
Layout.preferredHeight: 370
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluChart{
|
||||
anchors.fill: parent
|
||||
|
@ -13,10 +13,10 @@ FluScrollablePage{
|
||||
return Math.random().toFixed(1);
|
||||
}
|
||||
|
||||
FluArea{
|
||||
height: 370
|
||||
width: 500
|
||||
paddings: 10
|
||||
FluFrame{
|
||||
Layout.preferredWidth: 500
|
||||
Layout.preferredHeight: 370
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluChart{
|
||||
anchors.fill: parent
|
||||
@ -119,5 +119,4 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -135,7 +135,11 @@ FluExpander{
|
||||
"FluLoadingButton",
|
||||
"FluClip",
|
||||
"FluNetwork",
|
||||
"FluShortcutPicker"
|
||||
"FluShortcutPicker",
|
||||
"FluWindowResultLauncher",
|
||||
"FluRouter",
|
||||
"FluGroupBox",
|
||||
"FluSheet",
|
||||
];
|
||||
code = code.replace(/\n/g, "<br>");
|
||||
code = code.replace(/ /g, " ");
|
||||
|
10
example/qml/global/GlobalModel.qml
Normal file
10
example/qml/global/GlobalModel.qml
Normal file
@ -0,0 +1,10 @@
|
||||
pragma Singleton
|
||||
|
||||
import QtQuick 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
QtObject{
|
||||
|
||||
property int displayMode: FluNavigationViewType.Auto
|
||||
|
||||
}
|
@ -16,7 +16,7 @@ FluObject{
|
||||
title:qsTr("About")
|
||||
icon:FluentIcons.Contact
|
||||
onTapListener:function(){
|
||||
FluApp.navigate("/about")
|
||||
FluRouter.navigate("/about")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,12 @@ FluObject{
|
||||
url: "qrc:/example/qml/page/T_ToggleSwitch.qml"
|
||||
onTap: { navigationView.push(url) }
|
||||
}
|
||||
FluPaneItem{
|
||||
title: qsTr("GroupBox")
|
||||
menuDelegate: paneItemMenu
|
||||
url: "qrc:/example/qml/page/T_GroupBox.qml"
|
||||
onTap: { navigationView.push(url) }
|
||||
}
|
||||
FluPaneItem{
|
||||
title: qsTr("PaneItem Disabled")
|
||||
disabled: true
|
||||
@ -271,6 +277,12 @@ FluObject{
|
||||
url: "qrc:/example/qml/page/T_Menu.qml"
|
||||
onTap: { navigationView.push(url) }
|
||||
}
|
||||
FluPaneItem{
|
||||
title: qsTr("Sheet")
|
||||
menuDelegate: paneItemMenu
|
||||
url: "qrc:/example/qml/page/T_Sheet.qml"
|
||||
onTap: { navigationView.push(url) }
|
||||
}
|
||||
}
|
||||
|
||||
FluPaneItemExpander{
|
||||
@ -462,7 +474,7 @@ FluObject{
|
||||
FluPaneItem{
|
||||
title: qsTr("Hot Loader")
|
||||
onTapListener: function(){
|
||||
FluApp.navigate("/hotload")
|
||||
FluRouter.navigate("/hotload")
|
||||
}
|
||||
}
|
||||
FluPaneItem{
|
||||
@ -473,10 +485,12 @@ FluObject{
|
||||
}
|
||||
FluPaneItem{
|
||||
title: qsTr("Test Crash")
|
||||
visible: FluTools.isWin()
|
||||
onTapListener: function(){
|
||||
AppInfo.testCrash()
|
||||
}
|
||||
Component.onCompleted: {
|
||||
visible = FluTools.isWin()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
singleton ItemsOriginal 1.0 ItemsOriginal.qml
|
||||
singleton ItemsOriginal 1.0 ItemsOriginal.qml
|
||||
singleton ItemsFooter 1.0 ItemsFooter.qml
|
||||
singleton GlobalModel 1.0 GlobalModel.qml
|
||||
|
@ -11,7 +11,6 @@ FluScrollablePage{
|
||||
|
||||
RowLayout{
|
||||
spacing: 10
|
||||
Layout.topMargin: 20
|
||||
FluText{
|
||||
text:"tintColor:"
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
@ -42,10 +41,10 @@ FluScrollablePage{
|
||||
value: 32
|
||||
}
|
||||
}
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 1200/4+20
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 1200/4+20
|
||||
padding: 10
|
||||
Layout.topMargin: 10
|
||||
FluClip{
|
||||
width: 1920/4
|
||||
@ -54,7 +53,7 @@ FluScrollablePage{
|
||||
Image {
|
||||
id:image
|
||||
asynchronous: true
|
||||
source: "qrc:/example/res/image/bg_scenic.png"
|
||||
source: "qrc:/example/res/image/bg_scenic.jpg"
|
||||
anchors.fill: parent
|
||||
sourceSize: Qt.size(2*width,2*height)
|
||||
}
|
||||
@ -72,7 +71,7 @@ FluScrollablePage{
|
||||
anchors.centerIn: parent
|
||||
text: "Acrylic"
|
||||
color: "#FFFFFF"
|
||||
font.bold: true
|
||||
font: FluTextStyle.Subtitle
|
||||
}
|
||||
MouseArea {
|
||||
property point clickPos: Qt.point(0,0)
|
||||
@ -95,7 +94,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'Image{
|
||||
id:image
|
||||
width: 800
|
||||
|
@ -12,7 +12,6 @@ FluContentPage {
|
||||
id:text_box
|
||||
placeholderText: qsTr("Please enter a keyword")
|
||||
anchors{
|
||||
topMargin: 20
|
||||
top:parent.top
|
||||
}
|
||||
}
|
||||
@ -59,6 +58,7 @@ FluContentPage {
|
||||
FluText {
|
||||
id:item_name
|
||||
font.pixelSize: 10
|
||||
font.family: FluTextStyle.family
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: item_icon.bottom
|
||||
width:parent.width
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Badge")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 120
|
||||
paddings: 10
|
||||
padding: 10
|
||||
|
||||
Column{
|
||||
spacing: 15
|
||||
@ -114,7 +113,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'Rectangle{
|
||||
width: 40
|
||||
height: 40
|
||||
|
@ -18,11 +18,10 @@ FluScrollablePage{
|
||||
breadcrumb_2.items = items
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
|
||||
FluBreadcrumbBar{
|
||||
id:breadcrumb_1
|
||||
@ -36,10 +35,10 @@ FluScrollablePage{
|
||||
}
|
||||
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 100
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 100
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
|
||||
ColumnLayout{
|
||||
@ -77,7 +76,7 @@ FluScrollablePage{
|
||||
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluBreadcrumbBar{
|
||||
width:parent.width
|
||||
separator:">"
|
||||
|
@ -10,15 +10,14 @@ FluScrollablePage{
|
||||
title: qsTr("Buttons")
|
||||
|
||||
FluText{
|
||||
Layout.topMargin: 20
|
||||
text: qsTr("Support the Tab key to switch focus, and the Space key to perform click events")
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 68
|
||||
Layout.topMargin: 10
|
||||
padding: 10
|
||||
|
||||
FluTextButton{
|
||||
disabled: text_button_switch.checked
|
||||
@ -42,7 +41,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluTextButton{
|
||||
text:"Text Button"
|
||||
onClicked: {
|
||||
@ -51,10 +50,10 @@ FluScrollablePage{
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
|
||||
FluButton{
|
||||
@ -79,7 +78,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluButton{
|
||||
text:"Standard Button"
|
||||
onClicked: {
|
||||
@ -88,11 +87,11 @@ FluScrollablePage{
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
Layout.preferredHeight: 68
|
||||
Layout.topMargin: 20
|
||||
paddings: 10
|
||||
padding: 10
|
||||
|
||||
FluFilledButton{
|
||||
disabled: filled_button_switch.checked
|
||||
@ -116,7 +115,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluFilledButton{
|
||||
text:"Filled Button"
|
||||
onClicked: {
|
||||
@ -125,11 +124,11 @@ FluScrollablePage{
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
Layout.preferredHeight: 68
|
||||
Layout.topMargin: 20
|
||||
paddings: 10
|
||||
padding: 10
|
||||
|
||||
FluToggleButton{
|
||||
disabled:toggle_button_switch.checked
|
||||
@ -150,7 +149,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluToggleButton{
|
||||
text:"Toggle Button"
|
||||
onClicked: {
|
||||
@ -172,11 +171,11 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
Layout.preferredHeight: 68
|
||||
Layout.topMargin: 20
|
||||
paddings: 10
|
||||
padding: 10
|
||||
|
||||
FluProgressButton{
|
||||
id: btn_progress
|
||||
@ -202,7 +201,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluProgressButton{
|
||||
text:"Progress Button"
|
||||
onClicked: {
|
||||
@ -211,11 +210,11 @@ FluScrollablePage{
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
Layout.preferredHeight: 68
|
||||
Layout.topMargin: 20
|
||||
paddings: 10
|
||||
padding: 10
|
||||
|
||||
FluLoadingButton{
|
||||
id: btn_loading
|
||||
@ -241,7 +240,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluLoadingButton{
|
||||
text:"Loading Button"
|
||||
onClicked: {
|
||||
@ -251,10 +250,10 @@ FluScrollablePage{
|
||||
}
|
||||
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: layout_icon_button.height + 30
|
||||
paddings: 10
|
||||
Layout.preferredHeight: layout_icon_button.height + 30
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
Flow{
|
||||
id: layout_icon_button
|
||||
@ -323,7 +322,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluIconButton{
|
||||
iconSource:FluentIcons.ChromeCloseContrast
|
||||
onClicked: {
|
||||
@ -332,10 +331,10 @@ FluScrollablePage{
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluDropDownButton{
|
||||
disabled: drop_down_button_switch.checked
|
||||
@ -371,7 +370,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluDropDownButton{
|
||||
text:"DropDownButton"
|
||||
FluMenuItem{
|
||||
@ -389,10 +388,10 @@ FluScrollablePage{
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 100
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 100
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluRadioButtons{
|
||||
spacing: 8
|
||||
@ -424,7 +423,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluRadioButton{
|
||||
checked:true
|
||||
text:"Text Button"
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("CalendarPicker")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 80
|
||||
padding: 10
|
||||
ColumnLayout{
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
@ -28,7 +27,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluCalendarPicker{
|
||||
|
||||
}'
|
||||
|
@ -11,7 +11,6 @@ FluScrollablePage{
|
||||
|
||||
FluCaptcha{
|
||||
id: captcha
|
||||
Layout.topMargin: 20
|
||||
ignoreCase:switch_case.checked
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
|
@ -22,11 +22,10 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 370
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
padding: 10
|
||||
Column{
|
||||
spacing: 15
|
||||
anchors{
|
||||
@ -62,10 +61,10 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 340
|
||||
paddings: 10
|
||||
padding: 10
|
||||
Layout.topMargin: 10
|
||||
Column{
|
||||
spacing: 15
|
||||
@ -104,7 +103,6 @@ FluScrollablePage{
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
text:model.title
|
||||
color: FluColors.Grey10
|
||||
font.pixelSize: 15
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,7 +124,7 @@ FluScrollablePage{
|
||||
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluCarousel{
|
||||
id:carousel
|
||||
width: 400
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("CheckBox")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 72
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 72
|
||||
padding: 10
|
||||
|
||||
FluText{
|
||||
text: qsTr("A 2-state CheckBox")
|
||||
@ -49,16 +48,16 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluCheckBox{
|
||||
text:"Text"
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 72
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 72
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
|
||||
FluText{
|
||||
@ -104,7 +103,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluCheckBox{
|
||||
text:"Text"
|
||||
indeterminate:true
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Clip")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 380
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 380
|
||||
padding: 10
|
||||
|
||||
Column{
|
||||
spacing: 15
|
||||
@ -88,7 +87,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluClip{
|
||||
radius: [25,25,25,25]
|
||||
width: 50
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("ColorPicker")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 60
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 60
|
||||
padding: 10
|
||||
RowLayout{
|
||||
FluText{
|
||||
text: qsTr("Click to Select a Color - >")
|
||||
@ -33,7 +32,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluColorPicker{
|
||||
|
||||
}'
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("ComboBox")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 80
|
||||
paddings: 5
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 80
|
||||
padding: 5
|
||||
Column{
|
||||
spacing: 5
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@ -32,10 +31,10 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea {
|
||||
FluFrame {
|
||||
Layout.fillWidth: true
|
||||
height: 80
|
||||
paddings: 5
|
||||
Layout.preferredHeight: 80
|
||||
padding: 5
|
||||
Layout.topMargin: 20
|
||||
Column{
|
||||
spacing: 5
|
||||
@ -56,10 +55,10 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 80
|
||||
paddings: 10
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
Column{
|
||||
spacing: 5
|
||||
@ -85,7 +84,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluComboBox{
|
||||
editable: true
|
||||
model: ListModel {
|
||||
|
@ -7,13 +7,12 @@ import "../component"
|
||||
|
||||
FluScrollablePage{
|
||||
|
||||
title: qsTr("TimePicker")
|
||||
title: qsTr("DatePicker")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 80
|
||||
padding: 10
|
||||
ColumnLayout{
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
@ -32,17 +31,17 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluDatePicker{
|
||||
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 80
|
||||
padding: 10
|
||||
ColumnLayout{
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
@ -61,7 +60,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluDatePicker{
|
||||
showYear:false
|
||||
}'
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Dialog")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
FluButton{
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: qsTr("Show Double Button Dialog")
|
||||
@ -24,7 +23,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluContentDialog{
|
||||
id:dialog
|
||||
title: qsTr("Friendly Reminder")
|
||||
@ -57,10 +56,10 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluButton{
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@ -72,7 +71,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluContentDialog{
|
||||
id: dialog
|
||||
title: qsTr("Friendly Reminder")
|
||||
@ -114,10 +113,10 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 100
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 100
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluButton{
|
||||
anchors.top: parent.top
|
||||
@ -138,7 +137,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluContentDialog{
|
||||
id: dialog
|
||||
title: qsTr("Friendly Reminder")
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Expander")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: layout_column.height+20
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
padding: 10
|
||||
Column{
|
||||
id:layout_column
|
||||
spacing: 15
|
||||
@ -83,7 +82,7 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
|
||||
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluExpander{
|
||||
headerText: qsTr("Open a radio box")
|
||||
Item{
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("FlipView")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 340
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 340
|
||||
padding: 10
|
||||
ColumnLayout{
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
FluText{
|
||||
@ -40,7 +39,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluFlipView{
|
||||
Image{
|
||||
source: "qrc:/example/res/image/banner_1.jpg"
|
||||
@ -61,10 +60,10 @@ FluScrollablePage{
|
||||
'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 340
|
||||
paddings: 10
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
ColumnLayout{
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@ -93,7 +92,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluFlipView{
|
||||
vertical:true
|
||||
Image{
|
||||
|
48
example/qml/page/T_GroupBox.qml
Normal file
48
example/qml/page/T_GroupBox.qml
Normal file
@ -0,0 +1,48 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Window 2.15
|
||||
import FluentUI 1.0
|
||||
import "../component"
|
||||
|
||||
FluScrollablePage{
|
||||
|
||||
title: qsTr("GroupBox")
|
||||
|
||||
FluGroupBox {
|
||||
title: qsTr("CheckBox Group")
|
||||
ColumnLayout {
|
||||
spacing: 10
|
||||
anchors.fill: parent
|
||||
FluCheckBox { text: qsTr("E-mail") }
|
||||
FluCheckBox { text: qsTr("Calendar") }
|
||||
FluCheckBox { text: qsTr("Contacts") }
|
||||
}
|
||||
}
|
||||
|
||||
FluGroupBox {
|
||||
title: qsTr("RadioButton Group")
|
||||
FluRadioButtons {
|
||||
spacing: 10
|
||||
FluRadioButton { text: qsTr("E-mail") }
|
||||
FluRadioButton { text: qsTr("Calendar") }
|
||||
FluRadioButton { text: qsTr("Contacts") }
|
||||
}
|
||||
}
|
||||
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 4
|
||||
code:'FluGroupBox {
|
||||
title: qsTr("CheckBox Group")
|
||||
ColumnLayout {
|
||||
spacing: 10
|
||||
anchors.fill: parent
|
||||
FluCheckBox { text: qsTr("E-mail") }
|
||||
FluCheckBox { text: qsTr("Calendar") }
|
||||
FluCheckBox { text: qsTr("Contacts") }
|
||||
}
|
||||
}'
|
||||
}
|
||||
|
||||
}
|
@ -9,10 +9,11 @@ import "../global"
|
||||
FluScrollablePage{
|
||||
|
||||
launchMode: FluPageType.SingleTask
|
||||
animDisabled: true
|
||||
animationEnabled: false
|
||||
header: Item{}
|
||||
|
||||
FluentInitalizrWindow{
|
||||
id:fluent_initalizr
|
||||
FluentInitializrWindow{
|
||||
id:fluent_Initializr
|
||||
}
|
||||
|
||||
ListModel{
|
||||
@ -28,11 +29,11 @@ FluScrollablePage{
|
||||
}
|
||||
ListElement{
|
||||
icon: "qrc:/example/res/image/favicon.ico"
|
||||
title: qsTr("FluentUI Initalizr")
|
||||
title: qsTr("FluentUI Initializr")
|
||||
desc: qsTr("FluentUI Initializr is a Tool that helps you create and customize Fluent UI projects with various options.")
|
||||
url: "https://github.com/zhuzichu520/FluentUI"
|
||||
clicked: function(model){
|
||||
fluent_initalizr.showDialog()
|
||||
fluent_Initializr.showDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,6 +122,7 @@ FluScrollablePage{
|
||||
Layout.leftMargin: 20
|
||||
color: FluColors.Grey120
|
||||
font.pixelSize: 12
|
||||
font.family: FluTextStyle.family
|
||||
wrapMode: Text.WrapAnywhere
|
||||
}
|
||||
}
|
||||
@ -177,7 +179,7 @@ FluScrollablePage{
|
||||
property string desc: modelData.extra.desc
|
||||
width: 320
|
||||
height: 120
|
||||
FluArea{
|
||||
FluFrame{
|
||||
radius: 8
|
||||
width: 300
|
||||
height: 100
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Image")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 260
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 260
|
||||
padding: 10
|
||||
Column{
|
||||
spacing: 15
|
||||
anchors{
|
||||
@ -37,7 +36,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluImage{
|
||||
width: 400
|
||||
height: 300
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("InfoBar")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 270
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 270
|
||||
padding: 10
|
||||
ColumnLayout{
|
||||
spacing: 14
|
||||
anchors{
|
||||
@ -60,7 +59,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'showInfo(qsTr("This is an InfoBar in the Info Style"))
|
||||
|
||||
showWarning(qsTr("This is an InfoBar in the Warning Style"))
|
||||
|
@ -47,11 +47,10 @@ FluScrollablePage{
|
||||
}
|
||||
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 100
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 100
|
||||
padding: 10
|
||||
Column{
|
||||
id: layout_column
|
||||
spacing: 15
|
||||
@ -78,7 +77,7 @@ FluScrollablePage{
|
||||
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluMenu{
|
||||
id:menu
|
||||
FluMenuItem:{
|
||||
@ -99,10 +98,10 @@ menu.popup()
|
||||
}
|
||||
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 100
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 100
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
Column{
|
||||
spacing: 15
|
||||
@ -151,7 +150,7 @@ menu.popup()
|
||||
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluMenuBar{
|
||||
id:menu
|
||||
FluMenu:{
|
||||
|
@ -8,23 +8,23 @@ import "../component"
|
||||
FluScrollablePage{
|
||||
|
||||
property string password: ""
|
||||
property var loginPageRegister: registerForWindowResult("/login")
|
||||
|
||||
title: qsTr("MultiWindow")
|
||||
|
||||
Connections{
|
||||
target: loginPageRegister
|
||||
function onResult(data)
|
||||
{
|
||||
password = data.password
|
||||
}
|
||||
FluWindowResultLauncher{
|
||||
id:loginResultLauncher
|
||||
path: "/login"
|
||||
onResult:
|
||||
(data)=>{
|
||||
password = data.password
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 86
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 86
|
||||
padding: 10
|
||||
Column{
|
||||
spacing: 15
|
||||
anchors{
|
||||
@ -37,16 +37,16 @@ FluScrollablePage{
|
||||
FluButton{
|
||||
text: qsTr("Create Window")
|
||||
onClicked: {
|
||||
FluApp.navigate("/standardWindow")
|
||||
FluRouter.navigate("/standardWindow")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 86
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 86
|
||||
padding: 10
|
||||
Layout.topMargin: 10
|
||||
Column{
|
||||
spacing: 15
|
||||
@ -61,16 +61,16 @@ FluScrollablePage{
|
||||
FluButton{
|
||||
text: qsTr("Create Window")
|
||||
onClicked: {
|
||||
FluApp.navigate("/singleTaskWindow")
|
||||
FluRouter.navigate("/singleTaskWindow")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 86
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 86
|
||||
padding: 10
|
||||
Layout.topMargin: 10
|
||||
Column{
|
||||
spacing: 15
|
||||
@ -84,14 +84,14 @@ FluScrollablePage{
|
||||
FluButton{
|
||||
text: qsTr("Create Window")
|
||||
onClicked: {
|
||||
FluApp.navigate("/singleInstanceWindow")
|
||||
FluRouter.navigate("/singleInstanceWindow")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluWindow{
|
||||
//launchMode: FluWindowType.Standard
|
||||
//launchMode: FluWindowType.SingleTask
|
||||
@ -101,10 +101,10 @@ FluScrollablePage{
|
||||
}
|
||||
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 100
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 100
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
Column{
|
||||
spacing: 15
|
||||
@ -118,27 +118,27 @@ FluScrollablePage{
|
||||
FluButton{
|
||||
text: qsTr("Create Window")
|
||||
onClicked: {
|
||||
FluApp.navigate("/about")
|
||||
FluRouter.navigate("/about")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluButton{
|
||||
text: qsTr("Create Window")
|
||||
onClicked: {
|
||||
FluApp.navigate("/about")
|
||||
FluRouter.navigate("/about")
|
||||
}
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 130
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 130
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
|
||||
Column{
|
||||
@ -153,7 +153,7 @@ FluScrollablePage{
|
||||
FluButton{
|
||||
text: qsTr("Create Window")
|
||||
onClicked: {
|
||||
loginPageRegister.launch({username:"zhuzichu"})
|
||||
loginResultLauncher.launch({username:"zhuzichu"})
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
@ -163,21 +163,20 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
code:'property var loginPageRegister: registerForWindowResult("/login")
|
||||
|
||||
Connections{
|
||||
target: loginPageRegister
|
||||
function onResult(data)
|
||||
{
|
||||
password = data.password
|
||||
}
|
||||
Layout.topMargin: -6
|
||||
code:'FluWindowResultLauncher{
|
||||
id:loginResultLauncher
|
||||
path: "/login"
|
||||
onResult:
|
||||
(data)=>{
|
||||
password = data.password
|
||||
}
|
||||
}
|
||||
|
||||
FluButton{
|
||||
text: qsTr("Create Window")
|
||||
onClicked: {
|
||||
loginPageRegister.launch({username:"zhuzichu"})
|
||||
loginResultLauncher.launch({username:"zhuzichu"})
|
||||
}
|
||||
}
|
||||
'
|
||||
|
@ -4,6 +4,7 @@ import QtQuick.Window 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
import Qt.labs.platform 1.0
|
||||
import example 1.0
|
||||
import "../component"
|
||||
|
||||
FluContentPage{
|
||||
@ -11,7 +12,7 @@ FluContentPage{
|
||||
id:root
|
||||
title: qsTr("Network")
|
||||
|
||||
FluNetworkCallable{
|
||||
NetworkCallable{
|
||||
id:callable
|
||||
onStart: {
|
||||
showLoading()
|
||||
@ -39,7 +40,6 @@ FluContentPage{
|
||||
clip: true
|
||||
anchors{
|
||||
top: parent.top
|
||||
topMargin: 20
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
}
|
||||
@ -56,7 +56,7 @@ FluContentPage{
|
||||
text: "Get"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.get("https://httpbingo.org/get")
|
||||
Network.get("https://httpbingo.org/get")
|
||||
.addQuery("name","孙悟空")
|
||||
.addQuery("age",500)
|
||||
.addQuery("address","花果山水帘洞")
|
||||
@ -70,7 +70,7 @@ FluContentPage{
|
||||
text: "Head"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.head("https://httpbingo.org/head")
|
||||
Network.head("https://httpbingo.org/head")
|
||||
.addQuery("name","孙悟空")
|
||||
.addQuery("age",500)
|
||||
.addQuery("address","花果山水帘洞")
|
||||
@ -84,7 +84,7 @@ FluContentPage{
|
||||
text: "Post Body"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.postBody("https://httpbingo.org/post")
|
||||
Network.postBody("https://httpbingo.org/post")
|
||||
.setBody("花果山水帘洞美猴王齐天大圣孙悟空")
|
||||
.bind(root)
|
||||
.go(callable)
|
||||
@ -96,7 +96,7 @@ FluContentPage{
|
||||
text: "Post Form"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.postForm("https://httpbingo.org/post")
|
||||
Network.postForm("https://httpbingo.org/post")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -110,7 +110,7 @@ FluContentPage{
|
||||
text: "Post JSON"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.postJson("https://httpbingo.org/post")
|
||||
Network.postJson("https://httpbingo.org/post")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -124,7 +124,7 @@ FluContentPage{
|
||||
text: "Post JSON Array"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.postJsonArray("https://httpbingo.org/post")
|
||||
Network.postJsonArray("https://httpbingo.org/post")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -138,7 +138,7 @@ FluContentPage{
|
||||
text: "Put Body"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.putBody("https://httpbingo.org/put")
|
||||
Network.putBody("https://httpbingo.org/put")
|
||||
.setBody("花果山水帘洞美猴王齐天大圣孙悟空")
|
||||
.bind(root)
|
||||
.go(callable)
|
||||
@ -150,7 +150,7 @@ FluContentPage{
|
||||
text: "Put Form"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.putForm("https://httpbingo.org/put")
|
||||
Network.putForm("https://httpbingo.org/put")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -164,7 +164,7 @@ FluContentPage{
|
||||
text: "Put JSON"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.putJson("https://httpbingo.org/put")
|
||||
Network.putJson("https://httpbingo.org/put")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -178,7 +178,7 @@ FluContentPage{
|
||||
text: "Put JSON Array"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.putJsonArray("https://httpbingo.org/put")
|
||||
Network.putJsonArray("https://httpbingo.org/put")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -192,7 +192,7 @@ FluContentPage{
|
||||
text: "Patch Body"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.patchBody("https://httpbingo.org/patch")
|
||||
Network.patchBody("https://httpbingo.org/patch")
|
||||
.setBody("花果山水帘洞美猴王齐天大圣孙悟空")
|
||||
.bind(root)
|
||||
.go(callable)
|
||||
@ -204,7 +204,7 @@ FluContentPage{
|
||||
text: "Patch Form"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.patchForm("https://httpbingo.org/patch")
|
||||
Network.patchForm("https://httpbingo.org/patch")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -218,7 +218,7 @@ FluContentPage{
|
||||
text: "Patch JSON"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.patchJson("https://httpbingo.org/patch")
|
||||
Network.patchJson("https://httpbingo.org/patch")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -232,7 +232,7 @@ FluContentPage{
|
||||
text: "Patch JSON Array"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.patchJsonArray("https://httpbingo.org/patch")
|
||||
Network.patchJsonArray("https://httpbingo.org/patch")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -246,7 +246,7 @@ FluContentPage{
|
||||
text: "Delete Body"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.deleteBody("https://httpbingo.org/delete")
|
||||
Network.deleteBody("https://httpbingo.org/delete")
|
||||
.setBody("花果山水帘洞美猴王齐天大圣孙悟空")
|
||||
.bind(root)
|
||||
.go(callable)
|
||||
@ -258,7 +258,7 @@ FluContentPage{
|
||||
text: "Delete Form"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.deleteForm("https://httpbingo.org/delete")
|
||||
Network.deleteForm("https://httpbingo.org/delete")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -272,7 +272,7 @@ FluContentPage{
|
||||
text: "Delete JSON"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.deleteJson("https://httpbingo.org/delete")
|
||||
Network.deleteJson("https://httpbingo.org/delete")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -286,7 +286,7 @@ FluContentPage{
|
||||
text: "Delete JSON Array"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.deleteJsonArray("https://httpbingo.org/delete")
|
||||
Network.deleteJsonArray("https://httpbingo.org/delete")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -300,7 +300,7 @@ FluContentPage{
|
||||
text: "Open Log"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.postJson("https://httpbingo.org/post")
|
||||
Network.postJson("https://httpbingo.org/post")
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -315,7 +315,7 @@ FluContentPage{
|
||||
text: "Custom Header"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.postJson("https://httpbingo.org/post")
|
||||
Network.postJson("https://httpbingo.org/post")
|
||||
.addHeader("os","PC")
|
||||
.addHeader("version","1.0.0")
|
||||
.add("name","孙悟空")
|
||||
@ -331,8 +331,8 @@ FluContentPage{
|
||||
text: "RequestFailedReadCache"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.postJson("https://httpbingo.org/post")
|
||||
.setCacheMode(FluNetworkType.RequestFailedReadCache)
|
||||
Network.postJson("https://httpbingo.org/post")
|
||||
.setCacheMode(NetworkType.RequestFailedReadCache)
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -347,8 +347,8 @@ FluContentPage{
|
||||
text: "IfNoneCacheRequest"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.postJson("https://httpbingo.org/post")
|
||||
.setCacheMode(FluNetworkType.IfNoneCacheRequest)
|
||||
Network.postJson("https://httpbingo.org/post")
|
||||
.setCacheMode(NetworkType.IfNoneCacheRequest)
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -363,8 +363,8 @@ FluContentPage{
|
||||
text: "FirstCacheThenRequest"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.postJson("https://httpbingo.org/post")
|
||||
.setCacheMode(FluNetworkType.FirstCacheThenRequest)
|
||||
Network.postJson("https://httpbingo.org/post")
|
||||
.setCacheMode(NetworkType.FirstCacheThenRequest)
|
||||
.add("name","孙悟空")
|
||||
.add("age",500)
|
||||
.add("address","花果山水帘洞")
|
||||
@ -379,7 +379,7 @@ FluContentPage{
|
||||
text: "Timeout And Retry"
|
||||
onClicked: {
|
||||
text_info.text = ""
|
||||
FluNetwork.postJson("https://httpbingo.org/post")
|
||||
Network.postJson("https://httpbingo.org/post")
|
||||
.setTimeout(5000)
|
||||
.setRetry(3)
|
||||
.add("name","孙悟空")
|
||||
@ -407,7 +407,7 @@ FluContentPage{
|
||||
text: "Download File"
|
||||
onClicked: {
|
||||
folder_dialog.showDialog(function(path){
|
||||
FluNetwork.get("http://vjs.zencdn.net/v/oceans.mp4")
|
||||
Network.get("http://vjs.zencdn.net/v/oceans.mp4")
|
||||
.toDownload(path)
|
||||
.bind(root)
|
||||
.go(callable_download_file)
|
||||
@ -421,7 +421,7 @@ FluContentPage{
|
||||
text: "Breakpoint Download File"
|
||||
onClicked: {
|
||||
folder_dialog.showDialog(function(path){
|
||||
FluNetwork.get("http://vjs.zencdn.net/v/oceans.mp4")
|
||||
Network.get("http://vjs.zencdn.net/v/oceans.mp4")
|
||||
.toDownload(path,true)
|
||||
.bind(root)
|
||||
.go(callable_breakpoint_download_file)
|
||||
@ -431,7 +431,7 @@ FluContentPage{
|
||||
}
|
||||
}
|
||||
|
||||
FluNetworkCallable{
|
||||
NetworkCallable{
|
||||
id:callable_upload_file
|
||||
onStart: {
|
||||
btn_upload.disabled = true
|
||||
@ -455,7 +455,7 @@ FluContentPage{
|
||||
}
|
||||
}
|
||||
|
||||
FluNetworkCallable{
|
||||
NetworkCallable{
|
||||
id:callable_download_file
|
||||
onStart: {
|
||||
btn_download.progress = 0
|
||||
@ -480,7 +480,7 @@ FluContentPage{
|
||||
}
|
||||
}
|
||||
|
||||
FluNetworkCallable{
|
||||
NetworkCallable{
|
||||
id:callable_breakpoint_download_file
|
||||
onStart: {
|
||||
btn_download_breakpoint.progress = 0
|
||||
@ -508,7 +508,7 @@ FluContentPage{
|
||||
FileDialog {
|
||||
id: file_dialog
|
||||
onAccepted: {
|
||||
FluNetwork.postForm("https://httpbingo.org/post")
|
||||
Network.postForm("https://httpbingo.org/post")
|
||||
.setRetry(1)//只请求一次
|
||||
.add("accessToken","12345678")
|
||||
.addFile("file",FluTools.toLocalPath(file_dialog.currentFile))
|
||||
@ -532,7 +532,7 @@ FluContentPage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
anchors{
|
||||
top: layout_flick.top
|
||||
bottom: layout_flick.bottom
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Pagination")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 200
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 200
|
||||
padding: 10
|
||||
ColumnLayout{
|
||||
spacing: 20
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@ -37,7 +36,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluPagination{
|
||||
pageCurrent: 1
|
||||
itemCount: 1000
|
||||
|
@ -9,13 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Pivot")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 400
|
||||
paddings: 10
|
||||
|
||||
|
||||
Layout.preferredHeight: 400
|
||||
padding: 10
|
||||
|
||||
FluPivot{
|
||||
anchors.fill: parent
|
||||
@ -49,7 +46,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluPivot{
|
||||
anchors.fill: parent
|
||||
FluPivotItem:{
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Progress")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 130
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 130
|
||||
padding: 10
|
||||
|
||||
ColumnLayout{
|
||||
spacing: 10
|
||||
@ -32,7 +31,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluProgressBar{
|
||||
|
||||
}
|
||||
@ -42,11 +41,11 @@ FluProgressRing{
|
||||
'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 286
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 286
|
||||
padding: 10
|
||||
|
||||
ColumnLayout{
|
||||
spacing: 10
|
||||
@ -88,7 +87,7 @@ FluProgressRing{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluProgressBar{
|
||||
indeterminate: false
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ FluScrollablePage{
|
||||
|
||||
FluQRCode{
|
||||
id:qrcode
|
||||
Layout.topMargin: 20
|
||||
size:slider_size.value
|
||||
text:text_box.text
|
||||
color:color_picker.current
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("RadioButton")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
Row{
|
||||
spacing: 30
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@ -41,16 +40,16 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluRadioButton{
|
||||
text:"Text"
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 100
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 100
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluRadioButtons{
|
||||
spacing: 8
|
||||
@ -83,7 +82,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluRadioButtons{
|
||||
spacing: 8
|
||||
FluRadioButton{
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage {
|
||||
|
||||
title: qsTr("RatingControl")
|
||||
|
||||
FluArea {
|
||||
FluFrame {
|
||||
Layout.fillWidth: true
|
||||
height: 100
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 100
|
||||
padding: 10
|
||||
|
||||
Column {
|
||||
spacing: 10
|
||||
@ -27,7 +26,7 @@ FluScrollablePage {
|
||||
|
||||
CodeExpander {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code: 'FluRatingControl{
|
||||
|
||||
}'
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Rectangle")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 80
|
||||
padding: 10
|
||||
|
||||
Column{
|
||||
spacing: 15
|
||||
@ -64,7 +63,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluRectangle{
|
||||
radius: [25,25,25,25]
|
||||
width: 50
|
||||
|
@ -9,6 +9,6 @@ FluPage{
|
||||
launchMode: FluPageType.SingleTop
|
||||
FluRemoteLoader{
|
||||
anchors.fill: parent
|
||||
source: "https://zhu-zichu.gitee.io/Qt5_T_RemoteLoader.qml"
|
||||
source: "https://zhu-zichu.gitee.io/Qt_174_RemoteLoader.qml"
|
||||
}
|
||||
}
|
||||
|
@ -4,38 +4,24 @@ import QtQuick.Window 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
import "../component"
|
||||
import "../viewmodel"
|
||||
import "../global"
|
||||
|
||||
FluScrollablePage{
|
||||
|
||||
title: qsTr("Settings")
|
||||
|
||||
SettingsViewModel{
|
||||
id:viewmodel_settings
|
||||
}
|
||||
|
||||
FluEvent{
|
||||
id:event_checkupdate_finish
|
||||
name: "checkUpdateFinish"
|
||||
onTriggered: {
|
||||
btn_checkupdate.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
FluEventBus.registerEvent(event_checkupdate_finish)
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
FluEventBus.unRegisterEvent(event_checkupdate_finish)
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 60
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 60
|
||||
padding: 10
|
||||
Row{
|
||||
spacing: 20
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@ -56,11 +42,11 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 50
|
||||
paddings: 10
|
||||
padding: 10
|
||||
FluCheckBox{
|
||||
text: qsTr("Use System AppBar")
|
||||
checked: FluApp.useSystemAppBar
|
||||
@ -72,11 +58,11 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 50
|
||||
paddings: 10
|
||||
padding: 10
|
||||
FluCheckBox{
|
||||
text:qsTr("Fits AppBar Windows")
|
||||
checked: window.fitsAppBarWindows
|
||||
@ -95,15 +81,15 @@ FluScrollablePage{
|
||||
negativeText: qsTr("Cancel")
|
||||
positiveText: qsTr("OK")
|
||||
onPositiveClicked: {
|
||||
FluApp.exit(931)
|
||||
FluRouter.exit(931)
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 128
|
||||
paddings: 10
|
||||
padding: 10
|
||||
|
||||
ColumnLayout{
|
||||
spacing: 5
|
||||
@ -129,11 +115,11 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 160
|
||||
paddings: 10
|
||||
padding: 10
|
||||
|
||||
ColumnLayout{
|
||||
spacing: 5
|
||||
@ -149,10 +135,10 @@ FluScrollablePage{
|
||||
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}]
|
||||
delegate: FluRadioButton{
|
||||
checked : viewmodel_settings.displayMode===modelData.mode
|
||||
text:modelData.title
|
||||
text: modelData.title
|
||||
checked: GlobalModel.displayMode === modelData.mode
|
||||
clickListener:function(){
|
||||
viewmodel_settings.displayMode = modelData.mode
|
||||
GlobalModel.displayMode = modelData.mode
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,11 +155,11 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
padding: 10
|
||||
|
||||
ColumnLayout{
|
||||
spacing: 10
|
||||
|
90
example/qml/page/T_Sheet.qml
Normal file
90
example/qml/page/T_Sheet.qml
Normal file
@ -0,0 +1,90 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Window 2.15
|
||||
import FluentUI 1.0
|
||||
import "../component"
|
||||
|
||||
FluScrollablePage{
|
||||
|
||||
title: qsTr("Sheet")
|
||||
|
||||
FluSheet{
|
||||
id:sheet
|
||||
title: qsTr("Title")
|
||||
FluText{
|
||||
text: qsTr("Some contents...\nSome contents...\nSome contents...")
|
||||
anchors{
|
||||
left: parent.left
|
||||
leftMargin: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 280
|
||||
padding: 10
|
||||
Column{
|
||||
anchors.centerIn: parent
|
||||
spacing: 10
|
||||
Row{
|
||||
spacing: 10
|
||||
FluButton{
|
||||
width: 80
|
||||
height: 30
|
||||
text: qsTr("top")
|
||||
onClicked: {
|
||||
sheet.open(FluSheetType.Top)
|
||||
}
|
||||
}
|
||||
FluButton{
|
||||
width: 80
|
||||
height: 30
|
||||
text: qsTr("right")
|
||||
onClicked: {
|
||||
sheet.open(FluSheetType.Right)
|
||||
}
|
||||
}
|
||||
}
|
||||
Row{
|
||||
spacing: 10
|
||||
FluButton{
|
||||
width: 80
|
||||
height: 30
|
||||
text: qsTr("bottom")
|
||||
onClicked: {
|
||||
sheet.open(FluSheetType.Bottom)
|
||||
}
|
||||
}
|
||||
FluButton{
|
||||
width: 80
|
||||
height: 30
|
||||
text: qsTr("left")
|
||||
onClicked: {
|
||||
sheet.open(FluSheetType.Left)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -6
|
||||
code:'FluSheet{
|
||||
id:sheet
|
||||
title: qsTr("Title")
|
||||
FluText{
|
||||
text: qsTr("Some contents...")
|
||||
anchors{
|
||||
left: parent.left
|
||||
leftMargin: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
sheet.open(FluSheetType.Bottom)
|
||||
'
|
||||
}
|
||||
|
||||
}
|
@ -9,18 +9,17 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("ShortcutPicker")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 100
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 100
|
||||
padding: 10
|
||||
FluShortcutPicker{
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluShortcutPicker{
|
||||
|
||||
}'
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Slider")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 200
|
||||
Layout.topMargin: 20
|
||||
paddings: 10
|
||||
padding: 10
|
||||
|
||||
Row{
|
||||
spacing: 30
|
||||
@ -27,18 +26,18 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluSlider{
|
||||
value:50
|
||||
}'
|
||||
}
|
||||
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 200
|
||||
Layout.topMargin: 20
|
||||
paddings: 10
|
||||
padding: 10
|
||||
Row{
|
||||
spacing: 30
|
||||
FluRangeSlider{
|
||||
@ -51,7 +50,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluRangeSlider{
|
||||
orientation: Qt.Vertical
|
||||
}'
|
||||
|
@ -13,7 +13,6 @@ FluContentPage{
|
||||
id:layout_dropdown
|
||||
anchors{
|
||||
top: parent.top
|
||||
topMargin: 20
|
||||
}
|
||||
FluText{
|
||||
text:"orientation:"
|
||||
|
@ -27,7 +27,6 @@ FluContentPage{
|
||||
Flickable{
|
||||
id: scroll
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 20
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
contentHeight: staggered_view.implicitHeight
|
||||
clip: true
|
||||
@ -43,8 +42,7 @@ FluContentPage{
|
||||
FluText{
|
||||
color:"#FFFFFF"
|
||||
text:model.index
|
||||
font.bold: true
|
||||
font.pixelSize: 18
|
||||
font: FluTextStyle.Title
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,11 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("StatusLayout")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
id:layout_actions
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 50
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 50
|
||||
padding: 10
|
||||
RowLayout{
|
||||
spacing: 14
|
||||
FluDropDownButton{
|
||||
@ -53,11 +52,11 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 10
|
||||
height: 380
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 380
|
||||
padding: 10
|
||||
FluStatusLayout{
|
||||
id:status_view
|
||||
anchors.fill: parent
|
||||
@ -76,7 +75,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluStatusLayout{
|
||||
anchors.fill: parent
|
||||
statusMode: FluStatusLayoutType.Loading
|
||||
|
@ -29,11 +29,10 @@ FluScrollablePage{
|
||||
newTab()
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 50
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 50
|
||||
padding: 10
|
||||
RowLayout{
|
||||
spacing: 14
|
||||
FluDropDownButton{
|
||||
@ -91,11 +90,11 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 15
|
||||
height: 400
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 400
|
||||
padding: 10
|
||||
FluTabView{
|
||||
id:tab_view
|
||||
onNewPressed:{
|
||||
@ -105,7 +104,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluTabView{
|
||||
anchors.fill: parent
|
||||
Component.onCompleted: {
|
||||
|
@ -159,7 +159,7 @@ FluContentPage{
|
||||
FluCheckBox{
|
||||
anchors.centerIn: parent
|
||||
checked: true === options.checked
|
||||
enableAnimation: false
|
||||
animationEnabled: false
|
||||
clickListener: function(){
|
||||
var obj = table_view.getRow(row)
|
||||
obj.checkbox = table_view.customItem(com_checbox,{checked:!options.checked})
|
||||
@ -239,7 +239,7 @@ FluContentPage{
|
||||
}
|
||||
FluCheckBox{
|
||||
checked: true === root.seletedAll
|
||||
enableAnimation: false
|
||||
animationEnabled: false
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
clickListener: function(){
|
||||
root.seletedAll = !root.seletedAll
|
||||
@ -390,7 +390,7 @@ FluContentPage{
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
id:layout_controls
|
||||
anchors{
|
||||
left: parent.left
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("Text")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 60
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 60
|
||||
padding: 10
|
||||
|
||||
FluCopyableText{
|
||||
text: qsTr("This is a text that can be copied")
|
||||
@ -23,7 +22,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluCopyableText{
|
||||
text: qsTr("This is a text that can be copied")
|
||||
}'
|
||||
|
@ -4,30 +4,20 @@ import QtQuick.Layouts 1.15
|
||||
import QtQuick.Window 2.15
|
||||
import FluentUI 1.0
|
||||
import "../component"
|
||||
import "../viewmodel"
|
||||
|
||||
FluScrollablePage{
|
||||
|
||||
title: qsTr("TextBox")
|
||||
|
||||
TextBoxViewModel{
|
||||
id:viewModel
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
|
||||
FluTextBox{
|
||||
placeholderText: qsTr("Single-line Input Box")
|
||||
disabled: text_box_switch.checked
|
||||
cleanEnabled: true
|
||||
text: viewModel.text1
|
||||
onTextChanged: {
|
||||
viewModel.text1 = text
|
||||
}
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
@ -45,16 +35,16 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluTextBox{
|
||||
placeholderText: qsTr("Single-line Input Box")
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
|
||||
FluPasswordBox{
|
||||
@ -76,26 +66,21 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluPasswordBox{
|
||||
placeholderText: qsTr("Please enter your password")
|
||||
}'
|
||||
}
|
||||
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 36+multiine_textbox.height
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 36+multiine_textbox.height
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
|
||||
FluMultilineTextBox{
|
||||
id: multiine_textbox
|
||||
placeholderText: qsTr("Multi-line Input Box")
|
||||
text:viewModel.text2
|
||||
onTextChanged: {
|
||||
viewModel.text2 = text
|
||||
}
|
||||
disabled: text_box_multi_switch.checked
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
@ -114,16 +99,16 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluMultilineTextBox{
|
||||
placeholderText: qsTr("Multi-line Input Box")
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluAutoSuggestBox{
|
||||
placeholderText: qsTr("AutoSuggestBox")
|
||||
@ -145,16 +130,16 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluAutoSuggestBox{
|
||||
placeholderText: qsTr("AutoSuggestBox")
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
Layout.topMargin: 20
|
||||
FluSpinBox{
|
||||
disabled: spin_box_switch.checked
|
||||
@ -174,7 +159,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluSpinBox{
|
||||
|
||||
}'
|
||||
|
@ -11,11 +11,10 @@ FluScrollablePage{
|
||||
id: root
|
||||
title: qsTr("Theme")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 340
|
||||
paddings: 10
|
||||
padding: 10
|
||||
|
||||
ColumnLayout{
|
||||
spacing:0
|
||||
@ -115,16 +114,16 @@ FluScrollablePage{
|
||||
}
|
||||
FluToggleSwitch{
|
||||
Layout.topMargin: 5
|
||||
checked: FluTheme.enableAnimation
|
||||
checked: FluTheme.animationEnabled
|
||||
onClicked: {
|
||||
FluTheme.enableAnimation = !FluTheme.enableAnimation
|
||||
FluTheme.animationEnabled = !FluTheme.animationEnabled
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluTheme.accentColor = FluColors.Orange
|
||||
|
||||
FluTheme.dark = true
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("TimePicker")
|
||||
launchMode: FluPageType.SingleInstance
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 80
|
||||
padding: 10
|
||||
|
||||
ColumnLayout{
|
||||
|
||||
@ -43,17 +42,17 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluTimePicker{
|
||||
|
||||
}'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 80
|
||||
padding: 10
|
||||
|
||||
ColumnLayout{
|
||||
|
||||
@ -83,7 +82,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluTimePicker{
|
||||
hourFormat:FluTimePickerType.HH
|
||||
}'
|
||||
|
@ -106,7 +106,6 @@ FluScrollablePage{
|
||||
|
||||
RowLayout{
|
||||
spacing: 20
|
||||
Layout.topMargin: 20
|
||||
FluTextBox{
|
||||
id: text_box
|
||||
text: "Technical testing 2015-09-01"
|
||||
|
@ -9,11 +9,10 @@ FluScrollablePage{
|
||||
|
||||
title: qsTr("ToggleSwitch")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
Row{
|
||||
spacing: 30
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@ -41,7 +40,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluToggleSwitch{
|
||||
text:"Text"
|
||||
}'
|
||||
|
@ -10,15 +10,14 @@ FluScrollablePage{
|
||||
title: qsTr("Tooltip")
|
||||
|
||||
FluText{
|
||||
Layout.topMargin: 20
|
||||
text: qsTr("Hover over Tultip and it pops up")
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
|
||||
Column{
|
||||
spacing: 5
|
||||
@ -41,7 +40,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluIconButton{
|
||||
iconSource:FluentIcons.ChromeCloseContrast
|
||||
iconSize: 15
|
||||
@ -53,11 +52,11 @@ FluScrollablePage{
|
||||
'
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
height: 68
|
||||
paddings: 10
|
||||
Layout.preferredHeight: 68
|
||||
padding: 10
|
||||
|
||||
Column{
|
||||
spacing: 5
|
||||
@ -84,7 +83,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluButton{
|
||||
id: button_1
|
||||
text: qsTr("Delete")
|
||||
|
@ -18,11 +18,10 @@ FluScrollablePage{
|
||||
]
|
||||
}
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
height: 130
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredHeight: 130
|
||||
padding: 10
|
||||
|
||||
FluFilledButton{
|
||||
anchors{
|
||||
@ -66,7 +65,7 @@ FluScrollablePage{
|
||||
}
|
||||
CodeExpander{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -1
|
||||
Layout.topMargin: -6
|
||||
code:'FluTour{
|
||||
id:tour
|
||||
steps:[
|
||||
|
@ -33,7 +33,6 @@ FluContentPage {
|
||||
spacing: 12
|
||||
width: 300
|
||||
anchors{
|
||||
topMargin: 20
|
||||
top:parent.top
|
||||
left: parent.left
|
||||
leftMargin: 10
|
||||
@ -103,7 +102,7 @@ FluContentPage {
|
||||
}
|
||||
}
|
||||
}
|
||||
FluArea{
|
||||
FluFrame{
|
||||
anchors{
|
||||
left: layout_column.right
|
||||
top: parent.top
|
||||
|
@ -10,15 +10,14 @@ FluContentPage {
|
||||
title: qsTr("Typography")
|
||||
rightPadding: 10
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
anchors{
|
||||
top:parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
topMargin: 20
|
||||
}
|
||||
paddings: 10
|
||||
padding: 10
|
||||
ColumnLayout{
|
||||
spacing: 0
|
||||
scale: textScale
|
||||
|
@ -9,9 +9,8 @@ FluContentPage{
|
||||
|
||||
title: qsTr("Watermark")
|
||||
|
||||
FluArea{
|
||||
FluFrame{
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 20
|
||||
|
||||
ColumnLayout{
|
||||
anchors{
|
||||
|
@ -1,14 +0,0 @@
|
||||
import QtQuick 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
FluViewModel{
|
||||
|
||||
objectName: "SettingsViewModel"
|
||||
scope: FluViewModelType.Application
|
||||
property int displayMode
|
||||
|
||||
onInitData: {
|
||||
displayMode = FluNavigationViewType.Auto
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
import QtQuick 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
FluViewModel {
|
||||
objectName: "TextBoxView"
|
||||
property string text1
|
||||
property string text2
|
||||
}
|
@ -31,7 +31,7 @@ FluWindow {
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
FluApp.navigate("/")
|
||||
FluRouter.navigate("/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ FluWindow {
|
||||
FluFilledButton{
|
||||
text: qsTr("Restart Program")
|
||||
onClicked: {
|
||||
FluApp.exit(931)
|
||||
FluRouter.exit(931)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,14 @@ import "../component"
|
||||
FluWindowDialog {
|
||||
|
||||
id:window
|
||||
title:qsTr("FluentUI Initalizr")
|
||||
title:qsTr("FluentUI Initializr")
|
||||
width: 600
|
||||
height: 400
|
||||
|
||||
contentDelegate:Component{
|
||||
Item{
|
||||
Connections{
|
||||
target: InitalizrHelper
|
||||
target: InitializrHelper
|
||||
function onError(message){
|
||||
showError(message)
|
||||
}
|
||||
@ -27,7 +27,7 @@ FluWindowDialog {
|
||||
|
||||
FluText{
|
||||
id:text_title
|
||||
text:qsTr("FluentUI Initalizr")
|
||||
text:qsTr("FluentUI Initializr")
|
||||
font: FluTextStyle.Title
|
||||
anchors{
|
||||
left: parent.left
|
||||
@ -102,7 +102,7 @@ FluWindowDialog {
|
||||
width: 120
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: {
|
||||
InitalizrHelper.generate(text_box_name.text,text_box_path.text)
|
||||
InitializrHelper.generate(text_box_name.text,text_box_path.text)
|
||||
}
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ FluWindow {
|
||||
loader.reload()
|
||||
}
|
||||
}
|
||||
FluArea{
|
||||
FluFrame{
|
||||
anchors.fill: parent
|
||||
FluRemoteLoader{
|
||||
id:loader
|
||||
@ -41,7 +41,7 @@ FluWindow {
|
||||
}
|
||||
FluText{
|
||||
text: qsTr("Drag in a qml file")
|
||||
font.pixelSize: 26
|
||||
font: FluTextStyle.Title
|
||||
anchors.centerIn: parent
|
||||
visible: !loader.itemLodaer().item && loader.statusMode === FluStatusLayoutType.Success
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ FluWindow {
|
||||
showError(qsTr("Please feel free to enter a password"))
|
||||
return
|
||||
}
|
||||
onResult({password:textbox_password.text})
|
||||
setResult({password:textbox_password.text})
|
||||
window.close()
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import Qt.labs.platform 1.1
|
||||
import FluentUI 1.0
|
||||
import example 1.0
|
||||
import "../component"
|
||||
import "../viewmodel"
|
||||
import "../global"
|
||||
|
||||
FluWindow {
|
||||
@ -29,37 +28,23 @@ FluWindow {
|
||||
z:7
|
||||
}
|
||||
|
||||
SettingsViewModel{
|
||||
id:viewmodel_settings
|
||||
}
|
||||
|
||||
FluEvent{
|
||||
id:event_checkupdate
|
||||
name: "checkUpdate"
|
||||
onTriggered: {
|
||||
checkUpdate(false)
|
||||
}
|
||||
}
|
||||
|
||||
onFirstVisible: {
|
||||
timer_tour_delay.restart()
|
||||
}
|
||||
|
||||
Timer{
|
||||
id:timer_tour_delay
|
||||
interval: 200
|
||||
onTriggered: {
|
||||
tour.open()
|
||||
}
|
||||
onLazyLoad: {
|
||||
tour.open()
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
checkUpdate(true)
|
||||
FluEventBus.registerEvent(event_checkupdate)
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
FluEventBus.unRegisterEvent(event_checkupdate)
|
||||
FluRouter.exit()
|
||||
}
|
||||
|
||||
SystemTrayIcon {
|
||||
@ -71,7 +56,7 @@ FluWindow {
|
||||
MenuItem {
|
||||
text: "退出"
|
||||
onTriggered: {
|
||||
FluApp.exit()
|
||||
FluRouter.exit()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,7 +91,7 @@ FluWindow {
|
||||
positiveText: qsTr("Quit")
|
||||
neutralText: qsTr("Cancel")
|
||||
onPositiveClicked:{
|
||||
FluApp.exit(0)
|
||||
FluRouter.exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,9 +101,9 @@ FluWindow {
|
||||
width: 186
|
||||
FluMenuItem{
|
||||
text: qsTr("Open in Separate Window")
|
||||
font.pixelSize: 12
|
||||
font: FluTextStyle.Caption
|
||||
onClicked: {
|
||||
FluApp.navigate("/pageWindow",{title:modelData.title,url:modelData.url})
|
||||
FluRouter.navigate("/pageWindow",{title:modelData.title,url:modelData.url})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,14 +160,14 @@ FluWindow {
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
appBar.setHitTestVisible(layout_back_buttons)
|
||||
window.setHitTestVisible(layout_back_buttons)
|
||||
}
|
||||
}
|
||||
FluRemoteLoader{
|
||||
id:loader
|
||||
lazy: true
|
||||
anchors.fill: parent
|
||||
source: "https://zhu-zichu.gitee.io/Qt_168_LieflatPage.qml"
|
||||
source: "https://zhu-zichu.gitee.io/Qt_174_LieflatPage.qml"
|
||||
}
|
||||
}
|
||||
front: Item{
|
||||
@ -197,7 +182,7 @@ FluWindow {
|
||||
z:999
|
||||
//Stack模式,每次切换都会将页面压入栈中,随着栈的页面增多,消耗的内存也越多,内存消耗多就会卡顿,这时候就需要按返回将页面pop掉,释放内存。该模式可以配合FluPage中的launchMode属性,设置页面的启动模式
|
||||
// pageMode: FluNavigationViewType.Stack
|
||||
//NoStack模式,每次切换都会销毁之前的页面然后创建一个新的页面,只需消耗少量内存,可以配合FluViewModel保存页面数据(推荐)
|
||||
//NoStack模式,每次切换都会销毁之前的页面然后创建一个新的页面,只需消耗少量内存
|
||||
pageMode: FluNavigationViewType.NoStack
|
||||
items: ItemsOriginal
|
||||
footerItems:ItemsFooter
|
||||
@ -207,7 +192,7 @@ FluWindow {
|
||||
}
|
||||
return FluTools.isMacos() ? 20 : 0
|
||||
}
|
||||
displayMode:viewmodel_settings.displayMode
|
||||
displayMode: GlobalModel.displayMode
|
||||
logo: "qrc:/example/res/image/favicon.ico"
|
||||
title:"FluentUI"
|
||||
onLogoClicked:{
|
||||
@ -233,9 +218,9 @@ FluWindow {
|
||||
ItemsOriginal.paneItemMenu = nav_item_right_menu
|
||||
ItemsFooter.navigationView = nav_view
|
||||
ItemsFooter.paneItemMenu = nav_item_right_menu
|
||||
appBar.setHitTestVisible(nav_view.buttonMenu)
|
||||
appBar.setHitTestVisible(nav_view.buttonBack)
|
||||
appBar.setHitTestVisible(nav_view.imageLogo)
|
||||
window.setHitTestVisible(nav_view.buttonMenu)
|
||||
window.setHitTestVisible(nav_view.buttonBack)
|
||||
window.setHitTestVisible(nav_view.imageLogo)
|
||||
setCurrentIndex(0)
|
||||
}
|
||||
}
|
||||
@ -268,7 +253,7 @@ FluWindow {
|
||||
}
|
||||
|
||||
function handleDarkChanged(button){
|
||||
if(!FluTheme.enableAnimation || window.fitsAppBarWindows === false){
|
||||
if(!FluTheme.animationEnabled || window.fitsAppBarWindows === false){
|
||||
changeDark()
|
||||
}else{
|
||||
if(loader_reveal.sourceComponent){
|
||||
@ -355,11 +340,11 @@ FluWindow {
|
||||
}
|
||||
}
|
||||
|
||||
FluNetworkCallable{
|
||||
NetworkCallable{
|
||||
id:callable
|
||||
property bool silent: true
|
||||
onStart: {
|
||||
console.debug("satrt check update...")
|
||||
console.debug("start check update...")
|
||||
}
|
||||
onFinish: {
|
||||
console.debug("check update finish")
|
||||
@ -391,7 +376,7 @@ FluWindow {
|
||||
|
||||
function checkUpdate(silent){
|
||||
callable.silent = silent
|
||||
FluNetwork.get("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest")
|
||||
Network.get("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest")
|
||||
.go(callable)
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ FluWindow {
|
||||
onInitArgument:
|
||||
(arg)=>{
|
||||
window.title = arg.title
|
||||
loader.setSource( arg.url,{animDisabled:true})
|
||||
loader.setSource(arg.url,{animationEnabled:false})
|
||||
}
|
||||
FluLoader{
|
||||
id: loader
|
||||
|
BIN
example/res/image/bg_scenic.jpg
Normal file
BIN
example/res/image/bg_scenic.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 854 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.1 MiB |
@ -4,14 +4,14 @@ import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Item {
|
||||
FluLauncher {
|
||||
id: app
|
||||
Component.onCompleted: {
|
||||
FluApp.init(app)
|
||||
FluApp.windowIcon = "qrc:/logo.ico"
|
||||
FluApp.routes = {
|
||||
FluRouter.routes = {
|
||||
"/":"qrc:/main.qml",
|
||||
}
|
||||
FluApp.navigate("/")
|
||||
FluRouter.navigate("/")
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "InitalizrHelper.h"
|
||||
#include "InitializrHelper.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QGuiApplication>
|
||||
|
||||
InitalizrHelper::InitalizrHelper(QObject *parent) : QObject(parent)
|
||||
InitializrHelper::InitializrHelper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
InitalizrHelper::~InitalizrHelper() = default;
|
||||
InitializrHelper::~InitializrHelper() = default;
|
||||
|
||||
bool InitalizrHelper::copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists){
|
||||
bool InitializrHelper::copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists){
|
||||
QDir _formDir = fromDir;
|
||||
QDir _toDir = toDir;
|
||||
if(!_toDir.exists())
|
||||
@ -44,7 +44,7 @@ bool InitalizrHelper::copyDir(const QDir& fromDir, const QDir& toDir, bool cover
|
||||
}
|
||||
|
||||
template <typename...Args>
|
||||
void InitalizrHelper::templateToFile(const QString& source,const QString& dest,Args &&...args){
|
||||
void InitializrHelper::templateToFile(const QString& source,const QString& dest,Args &&...args){
|
||||
QFile file(source);
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&file);
|
||||
@ -67,12 +67,12 @@ void InitalizrHelper::templateToFile(const QString& source,const QString& dest,A
|
||||
}
|
||||
}
|
||||
|
||||
void InitalizrHelper::copyFile(const QString& source,const QString& dest){
|
||||
void InitializrHelper::copyFile(const QString& source,const QString& dest){
|
||||
QFile::copy(source,dest);
|
||||
QFile::setPermissions(dest, QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther);
|
||||
}
|
||||
|
||||
void InitalizrHelper::generate(const QString& name,const QString& path){
|
||||
void InitializrHelper::generate(const QString& name,const QString& path){
|
||||
if(name.isEmpty()){
|
||||
error(tr("The name cannot be empty"));
|
||||
return;
|
@ -1,26 +1,26 @@
|
||||
#ifndef INITALIZRHELPER_H
|
||||
#define INITALIZRHELPER_H
|
||||
#ifndef INITIALIZRHELPER_H
|
||||
#define INITIALIZRHELPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QDir>
|
||||
#include "src/singleton.h"
|
||||
|
||||
class InitalizrHelper : public QObject
|
||||
class InitializrHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
explicit InitalizrHelper(QObject* parent = nullptr);
|
||||
explicit InitializrHelper(QObject* parent = nullptr);
|
||||
bool copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists = true);
|
||||
void copyFile(const QString& source,const QString& dest);
|
||||
template <typename...Args>
|
||||
void templateToFile(const QString& source,const QString& dest,Args &&...args);
|
||||
public:
|
||||
SINGLETON(InitalizrHelper)
|
||||
~InitalizrHelper() override;
|
||||
SINGLETON(InitializrHelper)
|
||||
~InitializrHelper() override;
|
||||
Q_INVOKABLE void generate(const QString& name,const QString& path);
|
||||
Q_SIGNAL void error(const QString& message);
|
||||
Q_SIGNAL void success(const QString& path);
|
||||
};
|
||||
|
||||
#endif // INITALIZRHELPER_H
|
||||
#endif // INITIALIZRHELPER_H
|
@ -1,4 +1,4 @@
|
||||
#include "FluNetwork.h"
|
||||
#include "Network.h"
|
||||
|
||||
#include <QUrlQuery>
|
||||
#include <QBuffer>
|
||||
@ -18,11 +18,11 @@
|
||||
#include <QEventLoop>
|
||||
#include <QGuiApplication>
|
||||
|
||||
FluNetworkCallable::FluNetworkCallable(QObject *parent):QObject{parent}{
|
||||
NetworkCallable::NetworkCallable(QObject *parent):QObject{parent}{
|
||||
|
||||
}
|
||||
|
||||
QString FluNetworkParams::method2String(){
|
||||
QString NetworkParams::method2String(){
|
||||
switch (_method) {
|
||||
case METHOD_GET:
|
||||
return "GET";
|
||||
@ -41,25 +41,25 @@ QString FluNetworkParams::method2String(){
|
||||
}
|
||||
}
|
||||
|
||||
int FluNetworkParams::getTimeout(){
|
||||
int NetworkParams::getTimeout(){
|
||||
if(_timeout != -1){
|
||||
return _timeout;
|
||||
}
|
||||
return FluNetwork::getInstance()->timeout();
|
||||
return Network::getInstance()->timeout();
|
||||
}
|
||||
|
||||
int FluNetworkParams::getRetry(){
|
||||
int NetworkParams::getRetry(){
|
||||
if(_retry != -1){
|
||||
return _retry;
|
||||
}
|
||||
return FluNetwork::getInstance()->retry();
|
||||
return Network::getInstance()->retry();
|
||||
}
|
||||
|
||||
bool FluNetworkParams::getOpenLog(){
|
||||
bool NetworkParams::getOpenLog(){
|
||||
if(!_openLog.isNull()){
|
||||
return _openLog.toBool();
|
||||
}
|
||||
return FluNetwork::getInstance()->openLog();
|
||||
return Network::getInstance()->openLog();
|
||||
}
|
||||
|
||||
FluDownloadParam::FluDownloadParam(QObject *parent)
|
||||
@ -74,12 +74,12 @@ FluDownloadParam::FluDownloadParam(QString destPath,bool append,QObject *parent)
|
||||
this->_append = append;
|
||||
}
|
||||
|
||||
FluNetworkParams::FluNetworkParams(QObject *parent)
|
||||
NetworkParams::NetworkParams(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
}
|
||||
|
||||
FluNetworkParams::FluNetworkParams(QString url,Type type,Method method,QObject *parent)
|
||||
NetworkParams::NetworkParams(QString url,Type type,Method method,QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
this->_method = method;
|
||||
@ -87,62 +87,62 @@ FluNetworkParams::FluNetworkParams(QString url,Type type,Method method,QObject *
|
||||
this->_type = type;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::add(QString key,QVariant val){
|
||||
NetworkParams* NetworkParams::add(QString key,QVariant val){
|
||||
_paramMap.insert(key,val);
|
||||
return this;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::addFile(QString key,QVariant val){
|
||||
NetworkParams* NetworkParams::addFile(QString key,QVariant val){
|
||||
_fileMap.insert(key,val);
|
||||
return this;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::addHeader(QString key,QVariant val){
|
||||
NetworkParams* NetworkParams::addHeader(QString key,QVariant val){
|
||||
_headerMap.insert(key,val);
|
||||
return this;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::addQuery(QString key,QVariant val){
|
||||
NetworkParams* NetworkParams::addQuery(QString key,QVariant val){
|
||||
_queryMap.insert(key,val);
|
||||
return this;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::setBody(QString val){
|
||||
NetworkParams* NetworkParams::setBody(QString val){
|
||||
_body = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::setTimeout(int val){
|
||||
NetworkParams* NetworkParams::setTimeout(int val){
|
||||
_timeout = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::setRetry(int val){
|
||||
NetworkParams* NetworkParams::setRetry(int val){
|
||||
_retry = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::setCacheMode(int val){
|
||||
NetworkParams* NetworkParams::setCacheMode(int val){
|
||||
_cacheMode = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::toDownload(QString destPath,bool append){
|
||||
NetworkParams* NetworkParams::toDownload(QString destPath,bool append){
|
||||
_downloadParam = new FluDownloadParam(destPath,append,this);
|
||||
return this;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::bind(QObject* target){
|
||||
NetworkParams* NetworkParams::bind(QObject* target){
|
||||
_target = target;
|
||||
return this;
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetworkParams::openLog(QVariant val){
|
||||
NetworkParams* NetworkParams::openLog(QVariant val){
|
||||
_openLog = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
QString FluNetworkParams::buildCacheKey(){
|
||||
QString NetworkParams::buildCacheKey(){
|
||||
QJsonObject obj;
|
||||
obj.insert("url",_url);
|
||||
obj.insert("method",method2String());
|
||||
@ -161,30 +161,30 @@ QString FluNetworkParams::buildCacheKey(){
|
||||
return QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex();
|
||||
}
|
||||
|
||||
void FluNetworkParams::go(FluNetworkCallable* callable){
|
||||
void NetworkParams::go(NetworkCallable* callable){
|
||||
QJSValueList data;
|
||||
data<<qjsEngine(callable)->newQObject(this);
|
||||
FluNetwork::getInstance()->_interceptor.call(data);
|
||||
Network::getInstance()->_interceptor.call(data);
|
||||
if(_downloadParam){
|
||||
FluNetwork::getInstance()->handleDownload(this,callable);
|
||||
Network::getInstance()->handleDownload(this,callable);
|
||||
}else{
|
||||
FluNetwork::getInstance()->handle(this,callable);
|
||||
Network::getInstance()->handle(this,callable);
|
||||
}
|
||||
}
|
||||
|
||||
void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
|
||||
QPointer<FluNetworkCallable> callable(c);
|
||||
void Network::handle(NetworkParams* params,NetworkCallable* c){
|
||||
QPointer<NetworkCallable> callable(c);
|
||||
QThreadPool::globalInstance()->start([=](){
|
||||
if(!callable.isNull()){
|
||||
callable->start();
|
||||
}
|
||||
QString cacheKey = params->buildCacheKey();
|
||||
if(params->_cacheMode == FluNetworkType::CacheMode::FirstCacheThenRequest && cacheExists(cacheKey)){
|
||||
if(params->_cacheMode == NetworkType::CacheMode::FirstCacheThenRequest && cacheExists(cacheKey)){
|
||||
if(!callable.isNull()){
|
||||
callable->cache(readCache(cacheKey));
|
||||
}
|
||||
}
|
||||
if(params->_cacheMode == FluNetworkType::CacheMode::IfNoneCacheRequest && cacheExists(cacheKey)){
|
||||
if(params->_cacheMode == NetworkType::CacheMode::IfNoneCacheRequest && cacheExists(cacheKey)){
|
||||
if(!callable.isNull()){
|
||||
callable->cache(readCache(cacheKey));
|
||||
callable->finish();
|
||||
@ -228,7 +228,7 @@ void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
|
||||
disconnect(conn_quit);
|
||||
}
|
||||
QString response;
|
||||
if(params->_method == FluNetworkParams::METHOD_HEAD){
|
||||
if(params->_method == NetworkParams::METHOD_HEAD){
|
||||
response = headerList2String(reply->rawHeaderPairs());
|
||||
}else{
|
||||
if(reply->isOpen()){
|
||||
@ -238,7 +238,7 @@ void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
|
||||
int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if(httpStatus == 200){
|
||||
if(!callable.isNull()){
|
||||
if(params->_cacheMode != FluNetworkType::CacheMode::NoCache){
|
||||
if(params->_cacheMode != NetworkType::CacheMode::NoCache){
|
||||
saveResponse(cacheKey,response);
|
||||
}
|
||||
callable->success(response);
|
||||
@ -248,7 +248,7 @@ void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
|
||||
}else{
|
||||
if(i == params->getRetry()-1){
|
||||
if(!callable.isNull()){
|
||||
if(params->_cacheMode == FluNetworkType::CacheMode::RequestFailedReadCache && cacheExists(cacheKey)){
|
||||
if(params->_cacheMode == NetworkType::CacheMode::RequestFailedReadCache && cacheExists(cacheKey)){
|
||||
if(!callable.isNull()){
|
||||
callable->cache(readCache(cacheKey));
|
||||
}
|
||||
@ -267,8 +267,8 @@ void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
|
||||
});
|
||||
}
|
||||
|
||||
void FluNetwork::handleDownload(FluNetworkParams* params,FluNetworkCallable* c){
|
||||
QPointer<FluNetworkCallable> callable(c);
|
||||
void Network::handleDownload(NetworkParams* params,NetworkCallable* c){
|
||||
QPointer<NetworkCallable> callable(c);
|
||||
QThreadPool::globalInstance()->start([=](){
|
||||
if(!callable.isNull()){
|
||||
callable->start();
|
||||
@ -391,7 +391,7 @@ void FluNetwork::handleDownload(FluNetworkParams* params,FluNetworkCallable* c){
|
||||
});
|
||||
}
|
||||
|
||||
QString FluNetwork::readCache(const QString& key){
|
||||
QString Network::readCache(const QString& key){
|
||||
auto filePath = getCacheFilePath(key);
|
||||
QString result;
|
||||
QFile file(filePath);
|
||||
@ -405,11 +405,11 @@ QString FluNetwork::readCache(const QString& key){
|
||||
return result;
|
||||
}
|
||||
|
||||
bool FluNetwork::cacheExists(const QString& key){
|
||||
bool Network::cacheExists(const QString& key){
|
||||
return QFile(getCacheFilePath(key)).exists();
|
||||
}
|
||||
|
||||
QString FluNetwork::getCacheFilePath(const QString& key){
|
||||
QString Network::getCacheFilePath(const QString& key){
|
||||
QDir cacheDir(_cacheDir);
|
||||
if(!cacheDir.exists()){
|
||||
cacheDir.mkpath(_cacheDir);
|
||||
@ -417,7 +417,7 @@ QString FluNetwork::getCacheFilePath(const QString& key){
|
||||
return cacheDir.absoluteFilePath(key);
|
||||
}
|
||||
|
||||
QString FluNetwork::headerList2String(const QList<QNetworkReply::RawHeaderPair>& data){
|
||||
QString Network::headerList2String(const QList<QNetworkReply::RawHeaderPair>& data){
|
||||
QJsonObject object;
|
||||
for (auto it = data.constBegin(); it != data.constEnd(); ++it) {
|
||||
object.insert(QString(it->first),QString(it->second));
|
||||
@ -425,7 +425,7 @@ QString FluNetwork::headerList2String(const QList<QNetworkReply::RawHeaderPair>&
|
||||
return QJsonDocument(object).toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QString FluNetwork::map2String(const QMap<QString, QVariant>& map){
|
||||
QString Network::map2String(const QMap<QString, QVariant>& map){
|
||||
QStringList parameters;
|
||||
for (auto it = map.constBegin(); it != map.constEnd(); ++it) {
|
||||
parameters << QString("%1=%2").arg(it.key(), it.value().toString());
|
||||
@ -433,10 +433,10 @@ QString FluNetwork::map2String(const QMap<QString, QVariant>& map){
|
||||
return parameters.join(" ");
|
||||
}
|
||||
|
||||
void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<FluNetworkCallable> callable){
|
||||
void Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable){
|
||||
QByteArray verb = params->method2String().toUtf8();
|
||||
switch (params->_type) {
|
||||
case FluNetworkParams::TYPE_FORM:{
|
||||
case NetworkParams::TYPE_FORM:{
|
||||
bool isFormData = !params->_fileMap.isEmpty();
|
||||
if(isFormData){
|
||||
QHttpMultiPart *multiPart = new QHttpMultiPart();
|
||||
@ -484,7 +484,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FluNetworkParams::TYPE_JSON:{
|
||||
case NetworkParams::TYPE_JSON:{
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
|
||||
QJsonObject json;
|
||||
for (const auto& each : params->_paramMap.toStdMap())
|
||||
@ -495,7 +495,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ
|
||||
reply = manager->sendCustomRequest(request,verb,data);
|
||||
break;
|
||||
}
|
||||
case FluNetworkParams::TYPE_JSONARRAY:{
|
||||
case NetworkParams::TYPE_JSONARRAY:{
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
|
||||
QJsonArray jsonArray;
|
||||
for (const auto& each : params->_paramMap.toStdMap())
|
||||
@ -508,7 +508,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ
|
||||
reply = manager->sendCustomRequest(request,params->method2String().toUtf8(),data);
|
||||
break;
|
||||
}
|
||||
case FluNetworkParams::TYPE_BODY:{
|
||||
case NetworkParams::TYPE_BODY:{
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("text/plain;charset=utf-8"));
|
||||
QByteArray data = params->_body.toUtf8();
|
||||
reply = manager->sendCustomRequest(request,verb,data);
|
||||
@ -523,7 +523,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ
|
||||
}
|
||||
}
|
||||
|
||||
void FluNetwork::printRequestStartLog(QNetworkRequest request,FluNetworkParams* params){
|
||||
void Network::printRequestStartLog(QNetworkRequest request,NetworkParams* params){
|
||||
if(!params->getOpenLog()){
|
||||
return;
|
||||
}
|
||||
@ -551,7 +551,7 @@ void FluNetwork::printRequestStartLog(QNetworkRequest request,FluNetworkParams*
|
||||
}
|
||||
}
|
||||
|
||||
void FluNetwork::printRequestEndLog(QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,const QString& response){
|
||||
void Network::printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response){
|
||||
if(!params->getOpenLog()){
|
||||
return;
|
||||
}
|
||||
@ -560,7 +560,7 @@ void FluNetwork::printRequestEndLog(QNetworkRequest request,FluNetworkParams* pa
|
||||
qDebug()<<"<Result>"<<qUtf8Printable(response);
|
||||
}
|
||||
|
||||
void FluNetwork::saveResponse(QString key,QString response){
|
||||
void Network::saveResponse(QString key,QString response){
|
||||
QSharedPointer<QFile> file(new QFile(getCacheFilePath(key)));
|
||||
QIODevice::OpenMode mode = QIODevice::WriteOnly|QIODevice::Truncate;
|
||||
if (!file->open(mode))
|
||||
@ -570,7 +570,7 @@ void FluNetwork::saveResponse(QString key,QString response){
|
||||
file->write(response.toUtf8().toBase64());
|
||||
}
|
||||
|
||||
void FluNetwork::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers){
|
||||
void Network::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers){
|
||||
request->setHeader(QNetworkRequest::UserAgentHeader,QString::fromStdString("Mozilla/5.0 %1/%2").arg(QGuiApplication::applicationName(),QGuiApplication::applicationVersion()));
|
||||
QMapIterator<QString, QVariant> iter(headers);
|
||||
while (iter.hasNext())
|
||||
@ -580,7 +580,7 @@ void FluNetwork::addHeaders(QNetworkRequest* request,const QMap<QString, QVarian
|
||||
}
|
||||
}
|
||||
|
||||
void FluNetwork::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){
|
||||
void Network::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){
|
||||
QMapIterator<QString, QVariant> iter(params);
|
||||
QUrlQuery urlQuery(*url);
|
||||
while (iter.hasNext())
|
||||
@ -591,7 +591,7 @@ void FluNetwork::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){
|
||||
url->setQuery(urlQuery);
|
||||
}
|
||||
|
||||
FluNetwork::FluNetwork(QObject *parent): QObject{parent}
|
||||
Network::Network(QObject *parent): QObject{parent}
|
||||
{
|
||||
timeout(5000);
|
||||
retry(3);
|
||||
@ -599,78 +599,78 @@ FluNetwork::FluNetwork(QObject *parent): QObject{parent}
|
||||
cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network"));
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::get(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_NONE,FluNetworkParams::METHOD_GET,this);
|
||||
NetworkParams* Network::get(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_NONE,NetworkParams::METHOD_GET,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::head(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_NONE,FluNetworkParams::METHOD_HEAD,this);
|
||||
NetworkParams* Network::head(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_NONE,NetworkParams::METHOD_HEAD,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::postBody(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_POST,this);
|
||||
NetworkParams* Network::postBody(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_POST,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::putBody(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_PUT,this);
|
||||
NetworkParams* Network::putBody(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_PUT,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::patchBody(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_PATCH,this);
|
||||
NetworkParams* Network::patchBody(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_PATCH,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::deleteBody(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_DELETE,this);
|
||||
NetworkParams* Network::deleteBody(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_DELETE,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::postForm(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_POST,this);
|
||||
NetworkParams* Network::postForm(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_POST,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::putForm(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_PUT,this);
|
||||
NetworkParams* Network::putForm(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_PUT,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::patchForm(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_PATCH,this);
|
||||
NetworkParams* Network::patchForm(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_PATCH,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::deleteForm(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_DELETE,this);
|
||||
NetworkParams* Network::deleteForm(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_DELETE,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::postJson(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_POST,this);
|
||||
NetworkParams* Network::postJson(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_POST,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::putJson(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_PUT,this);
|
||||
NetworkParams* Network::putJson(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_PUT,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::patchJson(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_PATCH,this);
|
||||
NetworkParams* Network::patchJson(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_PATCH,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::deleteJson(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_DELETE,this);
|
||||
NetworkParams* Network::deleteJson(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_DELETE,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::postJsonArray(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_POST,this);
|
||||
NetworkParams* Network::postJsonArray(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_POST,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::putJsonArray(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_PUT,this);
|
||||
NetworkParams* Network::putJsonArray(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_PUT,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::patchJsonArray(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_PATCH,this);
|
||||
NetworkParams* Network::patchJsonArray(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_PATCH,this);
|
||||
}
|
||||
|
||||
FluNetworkParams* FluNetwork::deleteJsonArray(const QString& url){
|
||||
return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_DELETE,this);
|
||||
NetworkParams* Network::deleteJsonArray(const QString& url){
|
||||
return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_DELETE,this);
|
||||
}
|
||||
|
||||
void FluNetwork::setInterceptor(QJSValue interceptor){
|
||||
void Network::setInterceptor(QJSValue interceptor){
|
||||
this->_interceptor = interceptor;
|
||||
}
|
169
example/src/helper/Network.h
Normal file
169
example/src/helper/Network.h
Normal file
@ -0,0 +1,169 @@
|
||||
#ifndef NETWORK_H
|
||||
#define NETWORK_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QFile>
|
||||
#include <QJsonValue>
|
||||
#include <QJSValue>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include "src/stdafx.h"
|
||||
#include "src/singleton.h"
|
||||
|
||||
namespace NetworkType {
|
||||
Q_NAMESPACE
|
||||
enum CacheMode {
|
||||
NoCache = 0x0000,
|
||||
RequestFailedReadCache = 0x0001,
|
||||
IfNoneCacheRequest = 0x0002,
|
||||
FirstCacheThenRequest = 0x0004,
|
||||
};
|
||||
Q_ENUM_NS(CacheMode)
|
||||
QML_NAMED_ELEMENT(NetworkType)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The NetworkCallable class
|
||||
*/
|
||||
class NetworkCallable : public QObject{
|
||||
Q_OBJECT
|
||||
QML_NAMED_ELEMENT(NetworkCallable)
|
||||
public:
|
||||
explicit NetworkCallable(QObject *parent = nullptr);
|
||||
Q_SIGNAL void start();
|
||||
Q_SIGNAL void finish();
|
||||
Q_SIGNAL void error(int status,QString errorString,QString result);
|
||||
Q_SIGNAL void success(QString result);
|
||||
Q_SIGNAL void cache(QString result);
|
||||
Q_SIGNAL void uploadProgress(qint64 sent, qint64 total);
|
||||
Q_SIGNAL void downloadProgress(qint64 recv, qint64 total);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The FluDownloadParam class
|
||||
*/
|
||||
class FluDownloadParam : public QObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FluDownloadParam(QObject *parent = nullptr);
|
||||
FluDownloadParam(QString destPath,bool append,QObject *parent = nullptr);
|
||||
public:
|
||||
QString _destPath;
|
||||
bool _append;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The NetworkParams class
|
||||
*/
|
||||
class NetworkParams : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_NAMED_ELEMENT(NetworkParams)
|
||||
public:
|
||||
enum Method{
|
||||
METHOD_GET,
|
||||
METHOD_HEAD,
|
||||
METHOD_POST,
|
||||
METHOD_PUT,
|
||||
METHOD_PATCH,
|
||||
METHOD_DELETE
|
||||
};
|
||||
enum Type{
|
||||
TYPE_NONE,
|
||||
TYPE_FORM,
|
||||
TYPE_JSON,
|
||||
TYPE_JSONARRAY,
|
||||
TYPE_BODY
|
||||
};
|
||||
explicit NetworkParams(QObject *parent = nullptr);
|
||||
NetworkParams(QString url,Type type,Method method,QObject *parent = nullptr);
|
||||
Q_INVOKABLE NetworkParams* addQuery(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* addHeader(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* add(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* addFile(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* setBody(QString val);
|
||||
Q_INVOKABLE NetworkParams* setTimeout(int val);
|
||||
Q_INVOKABLE NetworkParams* setRetry(int val);
|
||||
Q_INVOKABLE NetworkParams* setCacheMode(int val);
|
||||
Q_INVOKABLE NetworkParams* toDownload(QString destPath,bool append = false);
|
||||
Q_INVOKABLE NetworkParams* bind(QObject* target);
|
||||
Q_INVOKABLE NetworkParams* openLog(QVariant val);
|
||||
Q_INVOKABLE void go(NetworkCallable* result);
|
||||
QString buildCacheKey();
|
||||
QString method2String();
|
||||
int getTimeout();
|
||||
int getRetry();
|
||||
bool getOpenLog();
|
||||
public:
|
||||
FluDownloadParam* _downloadParam = nullptr;
|
||||
QObject* _target = nullptr;
|
||||
Method _method;
|
||||
Type _type;
|
||||
QString _url;
|
||||
QString _body;
|
||||
QMap<QString, QVariant> _queryMap;
|
||||
QMap<QString, QVariant> _headerMap;
|
||||
QMap<QString, QVariant> _paramMap;
|
||||
QMap<QString, QVariant> _fileMap;
|
||||
int _timeout = -1;
|
||||
int _retry = -1;
|
||||
QVariant _openLog;
|
||||
int _cacheMode = NetworkType::CacheMode::NoCache;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The Network class
|
||||
*/
|
||||
class Network : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int,timeout)
|
||||
Q_PROPERTY_AUTO(int,retry)
|
||||
Q_PROPERTY_AUTO(QString,cacheDir)
|
||||
Q_PROPERTY_AUTO(bool,openLog)
|
||||
QML_NAMED_ELEMENT(Network)
|
||||
QML_SINGLETON
|
||||
private:
|
||||
explicit Network(QObject *parent = nullptr);
|
||||
public:
|
||||
SINGLETON(Network)
|
||||
static Network *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||
Q_INVOKABLE NetworkParams* get(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* head(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* postBody(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* putBody(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* patchBody(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* deleteBody(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* postForm(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* putForm(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* patchForm(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* deleteForm(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* postJson(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* putJson(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* patchJson(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* deleteJson(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* postJsonArray(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* putJsonArray(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* patchJsonArray(const QString& url);
|
||||
Q_INVOKABLE NetworkParams* deleteJsonArray(const QString& url);
|
||||
Q_INVOKABLE void setInterceptor(QJSValue interceptor);
|
||||
void handle(NetworkParams* params,NetworkCallable* result);
|
||||
void handleDownload(NetworkParams* params,NetworkCallable* result);
|
||||
private:
|
||||
void sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable);
|
||||
void addQueryParam(QUrl* url,const QMap<QString, QVariant>& params);
|
||||
void addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers);
|
||||
void saveResponse(QString key,QString response);
|
||||
QString readCache(const QString& key);
|
||||
bool cacheExists(const QString& key);
|
||||
QString getCacheFilePath(const QString& key);
|
||||
QString map2String(const QMap<QString, QVariant>& map);
|
||||
QString headerList2String(const QList<QNetworkReply::RawHeaderPair>& data);
|
||||
void printRequestStartLog(QNetworkRequest request,NetworkParams* params);
|
||||
void printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response);
|
||||
public:
|
||||
QJSValue _interceptor;
|
||||
};
|
||||
|
||||
#endif // Network_H
|
@ -15,8 +15,9 @@
|
||||
#include "src/component/FileWatcher.h"
|
||||
#include "src/component/FpsItem.h"
|
||||
#include "src/helper/SettingsHelper.h"
|
||||
#include "src/helper/InitalizrHelper.h"
|
||||
#include "src/helper/InitializrHelper.h"
|
||||
#include "src/helper/TranslateHelper.h"
|
||||
#include "src/helper/Network.h"
|
||||
|
||||
#ifdef FLUENTUI_BUILD_STATIC_LIB
|
||||
#if (QT_VERSION > QT_VERSION_CHECK(6, 2, 0))
|
||||
@ -31,6 +32,9 @@ Q_IMPORT_QML_PLUGIN(FluentUIPlugin)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *uri = "example";
|
||||
int major = 1;
|
||||
int minor = 0;
|
||||
#ifdef WIN32
|
||||
::SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
|
||||
qputenv("QT_QPA_PLATFORM","windows:darkmode=2");
|
||||
@ -53,8 +57,8 @@ int main(int argc, char *argv[])
|
||||
QGuiApplication::setApplicationVersion(APPLICATION_VERSION);
|
||||
QGuiApplication::setQuitOnLastWindowClosed(false);
|
||||
SettingsHelper::getInstance()->init(argv);
|
||||
Log::setup(argv,"example");
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
||||
Log::setup(argv,uri);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
|
||||
#endif
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
@ -65,18 +69,22 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
#endif
|
||||
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;
|
||||
TranslateHelper::getInstance()->init(&engine);
|
||||
engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance());
|
||||
engine.rootContext()->setContextProperty("SettingsHelper",SettingsHelper::getInstance());
|
||||
engine.rootContext()->setContextProperty("InitalizrHelper",InitalizrHelper::getInstance());
|
||||
engine.rootContext()->setContextProperty("InitializrHelper",InitializrHelper::getInstance());
|
||||
engine.rootContext()->setContextProperty("TranslateHelper",TranslateHelper::getInstance());
|
||||
engine.rootContext()->setContextProperty("Network",Network::getInstance());
|
||||
#ifdef FLUENTUI_BUILD_STATIC_LIB
|
||||
FluentUI::getInstance()->registerTypes(&engine);
|
||||
#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"));
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||
@ -86,7 +94,7 @@ int main(int argc, char *argv[])
|
||||
engine.load(url);
|
||||
const int exec = QGuiApplication::exec();
|
||||
if (exec == 931) {
|
||||
QProcess::startDetached(qApp->applicationFilePath(), QStringList());
|
||||
QProcess::startDetached(qApp->applicationFilePath(), qApp->arguments());
|
||||
}
|
||||
return exec;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
#设置版本号
|
||||
add_definitions(-DFLUENTUI_VERSION=1,7,3,0)
|
||||
add_definitions(-DFLUENTUI_VERSION=1,7,4,0)
|
||||
|
||||
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
|
||||
@ -73,11 +73,15 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
|
||||
endif()
|
||||
|
||||
#遍历所有qml文件
|
||||
file(GLOB_RECURSE QML_PATHS *.qml)
|
||||
file(GLOB_RECURSE QML_PATHS *.qml qmldir)
|
||||
foreach(filepath ${QML_PATHS})
|
||||
if(${filepath} MATCHES "Qt${QT_VERSION_MAJOR}/")
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
|
||||
list(APPEND qml_files ${filename})
|
||||
if(${filename} MATCHES "qmldir")
|
||||
list(APPEND resource_files ${filename})
|
||||
else()
|
||||
list(APPEND qml_files ${filename})
|
||||
endif()
|
||||
endif()
|
||||
endforeach(filepath)
|
||||
|
||||
|
26
src/Def.h
26
src/Def.h
@ -4,26 +4,16 @@
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
|
||||
namespace FluViewModelType {
|
||||
namespace FluSheetType {
|
||||
Q_NAMESPACE
|
||||
enum Scope {
|
||||
Window = 0x0000,
|
||||
Application = 0x0001
|
||||
enum Position {
|
||||
Left = 0x0000,
|
||||
Top = 0x0001,
|
||||
Right = 0x0002,
|
||||
Bottom = 0x0004,
|
||||
};
|
||||
Q_ENUM_NS(Scope)
|
||||
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)
|
||||
Q_ENUM_NS(Position)
|
||||
QML_NAMED_ELEMENT(FluSheetType)
|
||||
}
|
||||
|
||||
namespace FluThemeType {
|
||||
|
@ -10,20 +10,6 @@
|
||||
#include <QClipboard>
|
||||
#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}{
|
||||
useSystemAppBar(false);
|
||||
}
|
||||
@ -45,76 +31,3 @@ void FluApp::init(QObject *target,QLocale locale){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FluApp::run(){
|
||||
navigate(initialRoute());
|
||||
}
|
||||
|
||||
void FluApp::navigate(const QString& route,const QJsonObject& argument,FluWindowRegister* windowRegister){
|
||||
if(!routes().contains(route)){
|
||||
qCritical()<<"Not Found Route "<<route;
|
||||
return;
|
||||
}
|
||||
QQmlComponent component(_engine, routes().value(route).toString());
|
||||
if (component.isError()) {
|
||||
qCritical() << component.errors();
|
||||
return;
|
||||
}
|
||||
QVariantMap properties;
|
||||
properties.insert("_route",route);
|
||||
if(windowRegister){
|
||||
properties.insert("_windowRegister",QVariant::fromValue(windowRegister));
|
||||
}
|
||||
properties.insert("argument",argument);
|
||||
QQuickWindow *win=nullptr;
|
||||
for (const auto& pair : _windows.toStdMap()) {
|
||||
QString r = pair.second->property("_route").toString();
|
||||
if(r == route){
|
||||
win = pair.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(win){
|
||||
int launchMode = win->property("launchMode").toInt();
|
||||
if(launchMode == 1){
|
||||
win->setProperty("",argument);
|
||||
win->show();
|
||||
win->raise();
|
||||
win->requestActivate();
|
||||
return;
|
||||
}else if(launchMode == 2){
|
||||
win->close();
|
||||
}
|
||||
}
|
||||
win = qobject_cast<QQuickWindow*>(component.createWithInitialProperties(properties));
|
||||
if(windowRegister){
|
||||
windowRegister->to(win);
|
||||
}
|
||||
}
|
||||
|
||||
void FluApp::exit(int retCode){
|
||||
for (const auto& pair : _windows.toStdMap()) {
|
||||
pair.second->close();
|
||||
removeWindow(pair.second);
|
||||
}
|
||||
qApp->exit(retCode);
|
||||
}
|
||||
|
||||
void FluApp::addWindow(QQuickWindow* window){
|
||||
_windows.insert(window->winId(),window);
|
||||
}
|
||||
|
||||
void FluApp::removeWindow(QQuickWindow* window){
|
||||
if(window){
|
||||
_windows.remove(window->winId());
|
||||
window->deleteLater();
|
||||
window = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant FluApp::createWindowRegister(QQuickWindow* window,const QString& path){
|
||||
FluWindowRegister *p = new FluWindowRegister(window);
|
||||
p->from(window);
|
||||
p->path(path);
|
||||
return QVariant::fromValue(p);
|
||||
}
|
||||
|
27
src/FluApp.h
27
src/FluApp.h
@ -4,7 +4,6 @@
|
||||
#include <QObject>
|
||||
#include <QWindow>
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QJsonArray>
|
||||
#include <QQmlContext>
|
||||
#include <QJsonObject>
|
||||
#include <QQmlEngine>
|
||||
@ -13,31 +12,12 @@
|
||||
#include "stdafx.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
|
||||
*/
|
||||
class FluApp : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString,initialRoute);
|
||||
Q_PROPERTY_AUTO(QJsonObject,routes);
|
||||
Q_PROPERTY_AUTO(bool,useSystemAppBar);
|
||||
Q_PROPERTY_AUTO(QString,windowIcon);
|
||||
Q_PROPERTY_AUTO(QLocale,locale);
|
||||
@ -49,15 +29,8 @@ private:
|
||||
public:
|
||||
SINGLETON(FluApp)
|
||||
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 exit(int retCode = 0);
|
||||
Q_INVOKABLE QVariant createWindowRegister(QQuickWindow* window,const QString& path);
|
||||
void addWindow(QQuickWindow* window);
|
||||
void removeWindow(QQuickWindow* window);
|
||||
private:
|
||||
QMap<quint64, QQuickWindow*> _windows;
|
||||
QQmlEngine *_engine;
|
||||
QTranslator* _translator = nullptr;
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "FluColors.h"
|
||||
#include "FluTools.h"
|
||||
|
||||
FluColors::FluColors(QObject *parent):QObject{parent}{
|
||||
Transparent(QColor(0, 0, 0, 0));
|
||||
@ -111,17 +112,12 @@ FluColors::FluColors(QObject *parent):QObject{parent}{
|
||||
|
||||
FluAccentColor* FluColors::createAccentColor(QColor primaryColor){
|
||||
FluAccentColor *accentColor = new FluAccentColor(this);
|
||||
accentColor->darkest(withOpacity(primaryColor,0.7));
|
||||
accentColor->darker(withOpacity(primaryColor,0.8));
|
||||
accentColor->dark(withOpacity(primaryColor,0.9));
|
||||
accentColor->darkest(FluTools::getInstance()->withOpacity(primaryColor,0.7));
|
||||
accentColor->darker(FluTools::getInstance()->withOpacity(primaryColor,0.8));
|
||||
accentColor->dark(FluTools::getInstance()->withOpacity(primaryColor,0.9));
|
||||
accentColor->normal(primaryColor);
|
||||
accentColor->light(withOpacity(primaryColor,0.9));
|
||||
accentColor->lighter(withOpacity(primaryColor,0.8));
|
||||
accentColor->lightest(withOpacity(primaryColor,0.7));
|
||||
accentColor->light(FluTools::getInstance()->withOpacity(primaryColor,0.9));
|
||||
accentColor->lighter(FluTools::getInstance()->withOpacity(primaryColor,0.8));
|
||||
accentColor->lightest(FluTools::getInstance()->withOpacity(primaryColor,0.7));
|
||||
return accentColor;
|
||||
}
|
||||
|
||||
QColor FluColors::withOpacity(QColor color,qreal opacity){
|
||||
int alpha = qRound(opacity * 255) & 0xff;
|
||||
return QColor::fromRgba((alpha << 24) | (color.rgba() & 0xffffff));
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
|
||||
#include "FluAccentColor.h"
|
||||
#include "stdafx.h"
|
||||
#include "singleton.h"
|
||||
@ -50,7 +51,6 @@ class FluColors : public QObject
|
||||
QML_SINGLETON
|
||||
private:
|
||||
explicit FluColors(QObject *parent = nullptr);
|
||||
QColor withOpacity(QColor color,qreal opacity);
|
||||
public:
|
||||
SINGLETON(FluColors)
|
||||
Q_INVOKABLE FluAccentColor* createAccentColor(QColor primaryColor);
|
||||
|
@ -1,23 +0,0 @@
|
||||
#include "FluEventBus.h"
|
||||
|
||||
FluEvent::FluEvent(QObject *parent):QObject{parent}{
|
||||
}
|
||||
|
||||
FluEventBus::FluEventBus(QObject *parent):QObject{parent}{
|
||||
}
|
||||
|
||||
void FluEventBus::registerEvent(FluEvent* event){
|
||||
_eventData.append(event);
|
||||
}
|
||||
|
||||
void FluEventBus::unRegisterEvent(FluEvent* event){
|
||||
_eventData.removeOne(event);
|
||||
}
|
||||
|
||||
void FluEventBus::post(const QString& name,const QMap<QString, QVariant>& data){
|
||||
foreach (auto event, _eventData) {
|
||||
if(event->name()==name){
|
||||
Q_EMIT event->triggered(data);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#ifndef FLUEVENTBUS_H
|
||||
#define FLUEVENTBUS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
#include "stdafx.h"
|
||||
#include "singleton.h"
|
||||
|
||||
/**
|
||||
* @brief The FluEvent class
|
||||
*/
|
||||
class FluEvent : public QObject{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString,name);
|
||||
QML_NAMED_ELEMENT(FluEvent)
|
||||
public:
|
||||
explicit FluEvent(QObject *parent = nullptr);
|
||||
Q_SIGNAL void triggered(QMap<QString, QVariant> data);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The FluEventBus class
|
||||
*/
|
||||
class FluEventBus : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_NAMED_ELEMENT(FluEventBus)
|
||||
QML_SINGLETON
|
||||
private:
|
||||
explicit FluEventBus(QObject *parent = nullptr);
|
||||
public:
|
||||
SINGLETON(FluEventBus)
|
||||
static FluEventBus *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||
Q_INVOKABLE void registerEvent(FluEvent* event);
|
||||
Q_INVOKABLE void unRegisterEvent(FluEvent* event);
|
||||
Q_INVOKABLE void post(const QString& name,const QMap<QString, QVariant>& params = {});
|
||||
private:
|
||||
QList<FluEvent*> _eventData;
|
||||
};
|
||||
|
||||
#endif // FLUEVENTBUS_H
|
484
src/FluFrameless.cpp
Normal file
484
src/FluFrameless.cpp
Normal file
@ -0,0 +1,484 @@
|
||||
#include "FluFrameless.h"
|
||||
|
||||
#include <QQuickWindow>
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <QDateTime>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#pragma comment (lib,"user32.lib")
|
||||
#pragma comment (lib,"dwmapi.lib")
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <dwmapi.h>
|
||||
static inline QByteArray qtNativeEventType()
|
||||
{
|
||||
static const auto result = "windows_generic_MSG";
|
||||
return result;
|
||||
}
|
||||
static inline bool isCompositionEnabled(){
|
||||
typedef HRESULT (WINAPI* DwmIsCompositionEnabledPtr)(BOOL *pfEnabled);
|
||||
HMODULE module = ::LoadLibraryW(L"dwmapi.dll");
|
||||
if (module)
|
||||
{
|
||||
BOOL composition_enabled = false;
|
||||
DwmIsCompositionEnabledPtr dwm_is_composition_enabled;
|
||||
dwm_is_composition_enabled= reinterpret_cast<DwmIsCompositionEnabledPtr>(::GetProcAddress(module, "DwmIsCompositionEnabled"));
|
||||
if (dwm_is_composition_enabled)
|
||||
{
|
||||
dwm_is_composition_enabled(&composition_enabled);
|
||||
}
|
||||
return composition_enabled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
FluFrameless::FluFrameless(QQuickItem *parent)
|
||||
: QQuickItem{parent}
|
||||
{
|
||||
appbar(nullptr);
|
||||
maximizeButton(nullptr);
|
||||
minimizedButton(nullptr);
|
||||
closeButton(nullptr);
|
||||
topmost(false);
|
||||
disabled(false);
|
||||
}
|
||||
|
||||
FluFrameless::~FluFrameless(){
|
||||
}
|
||||
|
||||
void FluFrameless::onDestruction(){
|
||||
qApp->removeNativeEventFilter(this);
|
||||
}
|
||||
|
||||
void FluFrameless::componentComplete(){
|
||||
if(_disabled){
|
||||
return;
|
||||
}
|
||||
_current = window()->winId();
|
||||
window()->setFlags(( window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
if(QQuickWindow::sceneGraphBackend() == "software"){
|
||||
window()->setFlag(Qt::FramelessWindowHint,false);
|
||||
}
|
||||
#endif
|
||||
if(!_fixSize){
|
||||
window()->setFlag(Qt::WindowMaximizeButtonHint);
|
||||
}
|
||||
window()->installEventFilter(this);
|
||||
qApp->installNativeEventFilter(this);
|
||||
if(_maximizeButton){
|
||||
setHitTestVisible(_maximizeButton);
|
||||
}
|
||||
if(_minimizedButton){
|
||||
setHitTestVisible(_minimizedButton);
|
||||
}
|
||||
if(_closeButton){
|
||||
setHitTestVisible(_closeButton);
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
|
||||
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||
if(_fixSize){
|
||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
|
||||
for (int i = 0; i < qApp->screens().count(); ++i) {
|
||||
connect( qApp->screens().at(i),&QScreen::logicalDotsPerInchChanged,this,[=]{
|
||||
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
|
||||
});
|
||||
}
|
||||
}else{
|
||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
|
||||
}
|
||||
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
||||
connect(window(),&QQuickWindow::screenChanged,this,[hwnd]{
|
||||
::SetWindowPos(hwnd,0,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
|
||||
::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
|
||||
});
|
||||
#endif
|
||||
connect(this,&FluFrameless::topmostChanged,this,[this]{
|
||||
_setWindowTopmost(topmost());
|
||||
});
|
||||
_setWindowTopmost(topmost());
|
||||
}
|
||||
|
||||
bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result){
|
||||
#ifdef Q_OS_WIN
|
||||
if ((eventType != qtNativeEventType()) || !message) {
|
||||
return false;
|
||||
}
|
||||
const auto msg = static_cast<const MSG *>(message);
|
||||
const HWND hwnd = msg->hwnd;
|
||||
if (!hwnd || !msg) {
|
||||
return false;
|
||||
}
|
||||
const qint64 wid = reinterpret_cast<qint64>(hwnd);
|
||||
if(wid != _current){
|
||||
return false;
|
||||
}
|
||||
const UINT uMsg = msg->message;
|
||||
const WPARAM wParam = msg->wParam;
|
||||
const LPARAM lParam = msg->lParam;
|
||||
static QPoint offsetXY;
|
||||
if(uMsg == WM_WINDOWPOSCHANGING){
|
||||
WINDOWPOS* wp = reinterpret_cast<WINDOWPOS*>(lParam);
|
||||
if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0)
|
||||
{
|
||||
wp->flags |= SWP_NOCOPYBITS;
|
||||
*result = ::DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}else if(uMsg == WM_NCCALCSIZE){
|
||||
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
||||
const LONG originalTop = clientRect->top;
|
||||
const LONG originalLeft = clientRect->left;
|
||||
const LONG originalRight = clientRect->right;
|
||||
const LONG originalBottom = clientRect->bottom;
|
||||
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
|
||||
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
|
||||
*result = hitTestResult;
|
||||
return true;
|
||||
}
|
||||
int offsetSize = 0;
|
||||
bool isMaximum = ::IsZoomed(hwnd);
|
||||
offsetXY = QPoint(abs(clientRect->left - originalLeft),abs(clientRect->top - originalTop));
|
||||
if(isMaximum || _isFullScreen()){
|
||||
offsetSize = 0;
|
||||
}else{
|
||||
offsetSize = 1;
|
||||
}
|
||||
if(!isCompositionEnabled()){
|
||||
offsetSize = 0;
|
||||
}
|
||||
if (!isMaximum || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) {
|
||||
clientRect->top = originalTop + offsetSize;
|
||||
clientRect->bottom = originalBottom - offsetSize;
|
||||
clientRect->left = originalLeft + offsetSize;
|
||||
clientRect->right = originalRight - offsetSize;
|
||||
}
|
||||
_setMaximizeHovered(false);
|
||||
*result = WVR_REDRAW;
|
||||
return true;
|
||||
}else if(uMsg == WM_NCHITTEST){
|
||||
if(_hitMaximizeButton()){
|
||||
if (*result == HTNOWHERE) {
|
||||
*result = HTZOOM;
|
||||
}
|
||||
_setMaximizeHovered(true);
|
||||
return true;
|
||||
}
|
||||
_setMaximizeHovered(false);
|
||||
_setMaximizePressed(false);
|
||||
*result = 0;
|
||||
POINT nativeGlobalPos{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
|
||||
POINT nativeLocalPos = nativeGlobalPos;
|
||||
::ScreenToClient(hwnd, &nativeLocalPos);
|
||||
RECT clientRect{0, 0, 0, 0};
|
||||
::GetClientRect(hwnd, &clientRect);
|
||||
auto clientWidth = clientRect.right-clientRect.left;
|
||||
auto clientHeight = clientRect.bottom-clientRect.top;
|
||||
bool left = nativeLocalPos.x < _margins;
|
||||
bool right = nativeLocalPos.x > clientWidth - _margins;
|
||||
bool top = nativeLocalPos.y < _margins;
|
||||
bool bottom = nativeLocalPos.y > clientHeight - _margins;
|
||||
*result = 0;
|
||||
if (!_fixSize && !_isFullScreen() && !_isMaximized()) {
|
||||
if (left && top) {
|
||||
*result = HTTOPLEFT;
|
||||
} else if (left && bottom) {
|
||||
*result = HTBOTTOMLEFT;
|
||||
} else if (right && top) {
|
||||
*result = HTTOPRIGHT;
|
||||
} else if (right && bottom) {
|
||||
*result = HTBOTTOMRIGHT;
|
||||
} else if (left) {
|
||||
*result = HTLEFT;
|
||||
} else if (right) {
|
||||
*result = HTRIGHT;
|
||||
} else if (top) {
|
||||
*result = HTTOP;
|
||||
} else if (bottom) {
|
||||
*result = HTBOTTOM;
|
||||
}
|
||||
}
|
||||
if (0 != *result) {
|
||||
return true;
|
||||
}
|
||||
if(_hitAppBar()){
|
||||
*result = HTCAPTION;
|
||||
return true;
|
||||
}
|
||||
*result = HTCLIENT;
|
||||
return true;
|
||||
}else if(uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN){
|
||||
if(_hitMaximizeButton()){
|
||||
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
||||
QGuiApplication::sendEvent(_maximizeButton,&event);
|
||||
_setMaximizePressed(true);
|
||||
return true;
|
||||
}
|
||||
}else if(uMsg == WM_NCLBUTTONUP || uMsg == WM_NCRBUTTONUP){
|
||||
if(_hitMaximizeButton()){
|
||||
QMouseEvent event = QMouseEvent(QEvent::MouseButtonRelease, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
||||
QGuiApplication::sendEvent(_maximizeButton,&event);
|
||||
_setMaximizePressed(false);
|
||||
return true;
|
||||
}
|
||||
}else if(uMsg == WM_NCPAINT){
|
||||
*result = FALSE;
|
||||
return true;
|
||||
}else if(uMsg == WM_NCACTIVATE){
|
||||
*result = ::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
|
||||
return true;
|
||||
}else if(uMsg == WM_GETMINMAXINFO){
|
||||
MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
||||
auto pixelRatio = window()->devicePixelRatio();
|
||||
auto geometry = window()->screen()->availableGeometry();
|
||||
RECT rect;
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
|
||||
minmaxInfo->ptMaxPosition.x = rect.left - offsetXY.x();
|
||||
minmaxInfo->ptMaxPosition.y = rect.top - offsetXY.x();
|
||||
minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2;
|
||||
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2;
|
||||
return false;
|
||||
}else if(uMsg == WM_NCRBUTTONDOWN){
|
||||
if (wParam == HTCAPTION) {
|
||||
_showSystemMenu(QCursor::pos());
|
||||
}
|
||||
}else if(uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN){
|
||||
const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0));
|
||||
const bool spacePressed = ((wParam == VK_SPACE) || (::GetKeyState(VK_SPACE) < 0));
|
||||
if (altPressed && spacePressed) {
|
||||
auto pos = window()->position();
|
||||
_showSystemMenu(QPoint(pos.x(),pos.y()+_appbar->height()));
|
||||
}
|
||||
}else if(uMsg == WM_SYSCOMMAND){
|
||||
if(wParam == SC_MINIMIZE){
|
||||
if(window()->transientParent()){
|
||||
window()->transientParent()->showMinimized();
|
||||
}else{
|
||||
window()->showMinimized();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FluFrameless::_isMaximized(){
|
||||
return window()->visibility() == QWindow::Maximized;
|
||||
}
|
||||
|
||||
bool FluFrameless::_isFullScreen(){
|
||||
return window()->visibility() == QWindow::FullScreen;
|
||||
}
|
||||
|
||||
void FluFrameless::_showSystemMenu(QPoint point){
|
||||
#ifdef Q_OS_WIN
|
||||
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
|
||||
DWORD style = ::GetWindowLongPtr(hwnd,GWL_STYLE);
|
||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
|
||||
const HMENU hMenu = ::GetSystemMenu(hwnd, FALSE);
|
||||
if(_isMaximized() || _isFullScreen()){
|
||||
::EnableMenuItem(hMenu,SC_MOVE,MFS_DISABLED);
|
||||
::EnableMenuItem(hMenu,SC_RESTORE,MFS_ENABLED);
|
||||
}else{
|
||||
::EnableMenuItem(hMenu,SC_MOVE,MFS_ENABLED);
|
||||
::EnableMenuItem(hMenu,SC_RESTORE,MFS_DISABLED);
|
||||
}
|
||||
if(!_fixSize && !_isMaximized() && !_isFullScreen()){
|
||||
::EnableMenuItem(hMenu,SC_SIZE,MFS_ENABLED);
|
||||
::EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_ENABLED);
|
||||
}else{
|
||||
::EnableMenuItem(hMenu,SC_SIZE,MFS_DISABLED);
|
||||
::EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_DISABLED);
|
||||
}
|
||||
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), point.x()*window()->devicePixelRatio(), point.y()*window()->devicePixelRatio(), 0, hwnd, nullptr);
|
||||
if (result != FALSE) {
|
||||
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
||||
}
|
||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style &~ WS_SYSMENU);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool FluFrameless::_containsCursorToItem(QQuickItem* item){
|
||||
if(!item || !item->isVisible()){
|
||||
return false;
|
||||
}
|
||||
auto point = QCursor::pos();
|
||||
auto rect = QRectF(item->mapToGlobal(QPoint(0,0)),item->size());
|
||||
if(point.x()>rect.x() && point.x()<(rect.x()+rect.width()) && point.y()>rect.y() && point.y()<(rect.y()+rect.height())){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FluFrameless::_hitAppBar(){
|
||||
foreach (auto item, _hitTestList) {
|
||||
if(_containsCursorToItem(item)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(_containsCursorToItem(_appbar)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FluFrameless::_hitMaximizeButton(){
|
||||
if(_containsCursorToItem(_maximizeButton)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void FluFrameless::_setMaximizePressed(bool val){
|
||||
_maximizeButton->setProperty("down",val);
|
||||
}
|
||||
|
||||
void FluFrameless::_setMaximizeHovered(bool val){
|
||||
_maximizeButton->setProperty("hover",val);
|
||||
}
|
||||
|
||||
void FluFrameless::_updateCursor(int edges){
|
||||
switch (edges) {
|
||||
case 0:
|
||||
window()->setCursor(Qt::ArrowCursor);
|
||||
break;
|
||||
case Qt::LeftEdge:
|
||||
case Qt::RightEdge:
|
||||
window()->setCursor(Qt::SizeHorCursor);
|
||||
break;
|
||||
case Qt::TopEdge:
|
||||
case Qt::BottomEdge:
|
||||
window()->setCursor(Qt::SizeVerCursor);
|
||||
break;
|
||||
case Qt::LeftEdge | Qt::TopEdge:
|
||||
case Qt::RightEdge | Qt::BottomEdge:
|
||||
window()->setCursor(Qt::SizeFDiagCursor);
|
||||
break;
|
||||
case Qt::RightEdge | Qt::TopEdge:
|
||||
case Qt::LeftEdge | Qt::BottomEdge:
|
||||
window()->setCursor(Qt::SizeBDiagCursor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FluFrameless::showFullScreen(){
|
||||
window()->showFullScreen();
|
||||
}
|
||||
|
||||
void FluFrameless::showMaximized(){
|
||||
#ifdef Q_OS_WIN
|
||||
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
|
||||
::ShowWindow(hwnd,3);
|
||||
#else
|
||||
window()->showMaximized();
|
||||
#endif
|
||||
}
|
||||
|
||||
void FluFrameless::showMinimized(){
|
||||
window()->showMinimized();
|
||||
}
|
||||
|
||||
void FluFrameless::showNormal(){
|
||||
window()->showNormal();
|
||||
}
|
||||
|
||||
void FluFrameless::setHitTestVisible(QQuickItem* val){
|
||||
if(!_hitTestList.contains(val)){
|
||||
_hitTestList.append(val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FluFrameless::_setWindowTopmost(bool topmost){
|
||||
#ifdef Q_OS_WIN
|
||||
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
|
||||
if(topmost){
|
||||
::SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
}else{
|
||||
::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
}
|
||||
#else
|
||||
window()->setFlag(Qt::WindowStaysOnTopHint,topmost);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){
|
||||
#ifndef Q_OS_WIN
|
||||
switch (ev->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
if(_edges!=0){
|
||||
QMouseEvent *event = static_cast<QMouseEvent*>(ev);
|
||||
if(event->button() == Qt::LeftButton){
|
||||
_updateCursor(_edges);
|
||||
window()->startSystemResize(Qt::Edges(_edges));
|
||||
}
|
||||
}else{
|
||||
if(_hitAppBar()){
|
||||
qint64 clickTimer = QDateTime::currentMSecsSinceEpoch();
|
||||
qint64 offset = clickTimer - this->_clickTimer;
|
||||
this->_clickTimer = clickTimer;
|
||||
if(offset<300){
|
||||
if(_isMaximized()){
|
||||
showNormal();
|
||||
}else{
|
||||
showMaximized();
|
||||
}
|
||||
}else{
|
||||
window()->startSystemMove();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
_edges = 0;
|
||||
break;
|
||||
case QEvent::MouseMove: {
|
||||
if(_isMaximized() || _isFullScreen()){
|
||||
break;
|
||||
}
|
||||
if(_fixSize){
|
||||
break;
|
||||
}
|
||||
QMouseEvent *event = static_cast<QMouseEvent*>(ev);
|
||||
QPoint p =
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
event->pos();
|
||||
#else
|
||||
event->position().toPoint();
|
||||
#endif
|
||||
if(p.x() >= _margins && p.x() <= (window()->width() - _margins) && p.y() >= _margins && p.y() <= (window()->height() - _margins)){
|
||||
if(_edges != 0){
|
||||
_edges = 0;
|
||||
_updateCursor(_edges);
|
||||
}
|
||||
break;
|
||||
}
|
||||
_edges = 0;
|
||||
if ( p.x() < _margins ) {
|
||||
_edges |= Qt::LeftEdge;
|
||||
}
|
||||
if ( p.x() > (window()->width() - _margins) ) {
|
||||
_edges |= Qt::RightEdge;
|
||||
}
|
||||
if ( p.y() < _margins ) {
|
||||
_edges |= Qt::TopEdge;
|
||||
}
|
||||
if ( p.y() > (window()->height() - _margins) ) {
|
||||
_edges |= Qt::BottomEdge;
|
||||
}
|
||||
_updateCursor(_edges);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return QObject::eventFilter(obj, ev);
|
||||
}
|
61
src/FluFrameless.h
Normal file
61
src/FluFrameless.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef FLUFRAMELESS_H
|
||||
#define FLUFRAMELESS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQuickItem>
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include "stdafx.h"
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
using QT_NATIVE_EVENT_RESULT_TYPE = qintptr;
|
||||
using QT_ENTER_EVENT_TYPE = QEnterEvent;
|
||||
#else
|
||||
using QT_NATIVE_EVENT_RESULT_TYPE = long;
|
||||
using QT_ENTER_EVENT_TYPE = QEvent;
|
||||
#endif
|
||||
|
||||
|
||||
class FluFrameless : public QQuickItem,QAbstractNativeEventFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QQuickItem*,appbar)
|
||||
Q_PROPERTY_AUTO(bool,topmost)
|
||||
Q_PROPERTY_AUTO(QQuickItem*,maximizeButton)
|
||||
Q_PROPERTY_AUTO(QQuickItem*,minimizedButton)
|
||||
Q_PROPERTY_AUTO(QQuickItem*,closeButton)
|
||||
Q_PROPERTY_AUTO(bool,disabled)
|
||||
Q_PROPERTY_AUTO(bool,fixSize)
|
||||
QML_NAMED_ELEMENT(FluFrameless)
|
||||
public:
|
||||
explicit FluFrameless(QQuickItem* parent = nullptr);
|
||||
~FluFrameless();
|
||||
void componentComplete() override;
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
|
||||
Q_INVOKABLE void showFullScreen();
|
||||
Q_INVOKABLE void showMaximized();
|
||||
Q_INVOKABLE void showMinimized();
|
||||
Q_INVOKABLE void showNormal();
|
||||
Q_INVOKABLE void setHitTestVisible(QQuickItem*);
|
||||
Q_INVOKABLE void onDestruction();
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
private:
|
||||
bool _isFullScreen();
|
||||
bool _isMaximized();
|
||||
void _updateCursor(int edges);
|
||||
void _setWindowTopmost(bool topmost);
|
||||
void _showSystemMenu(QPoint point);
|
||||
bool _containsCursorToItem(QQuickItem* item);
|
||||
bool _hitAppBar();
|
||||
bool _hitMaximizeButton();
|
||||
void _setMaximizePressed(bool val);
|
||||
void _setMaximizeHovered(bool val);
|
||||
private:
|
||||
qint64 _current;
|
||||
int _edges = 0;
|
||||
int _margins = 8;
|
||||
qint64 _clickTimer = 0;
|
||||
QList<QPointer<QQuickItem>> _hitTestList;
|
||||
};
|
||||
|
||||
#endif // FLUFRAMELESS_H
|
@ -1,500 +0,0 @@
|
||||
#include "FluFramelessHelper.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <QQuickItem>
|
||||
#include "FluTools.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#pragma comment (lib,"user32.lib")
|
||||
#pragma comment (lib,"dwmapi.lib")
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <dwmapi.h>
|
||||
|
||||
static inline QByteArray qtNativeEventType()
|
||||
{
|
||||
static const auto result = "windows_generic_MSG";
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline bool isCompositionEnabled(){
|
||||
typedef HRESULT (WINAPI* DwmIsCompositionEnabledPtr)(BOOL *pfEnabled);
|
||||
HMODULE module = ::LoadLibraryW(L"dwmapi.dll");
|
||||
if (module)
|
||||
{
|
||||
BOOL composition_enabled = false;
|
||||
DwmIsCompositionEnabledPtr dwm_is_composition_enabled;
|
||||
dwm_is_composition_enabled= reinterpret_cast<DwmIsCompositionEnabledPtr>(::GetProcAddress(module, "DwmIsCompositionEnabled"));
|
||||
if (dwm_is_composition_enabled)
|
||||
{
|
||||
dwm_is_composition_enabled(&composition_enabled);
|
||||
}
|
||||
return composition_enabled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
FramelessEventFilter::FramelessEventFilter(FluFramelessHelper* helper){
|
||||
_helper = helper;
|
||||
_current = _helper->window->winId();
|
||||
}
|
||||
|
||||
bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result){
|
||||
#ifdef Q_OS_WIN
|
||||
if ((eventType != qtNativeEventType()) || !message || _helper.isNull() || _helper->window.isNull()) {
|
||||
return false;
|
||||
}
|
||||
const auto msg = static_cast<const MSG *>(message);
|
||||
const HWND hwnd = msg->hwnd;
|
||||
if (!hwnd || !msg) {
|
||||
return false;
|
||||
}
|
||||
const qint64 wid = reinterpret_cast<qint64>(hwnd);
|
||||
if(wid != _current){
|
||||
return false;
|
||||
}
|
||||
const UINT uMsg = msg->message;
|
||||
const WPARAM wParam = msg->wParam;
|
||||
const LPARAM lParam = msg->lParam;
|
||||
static QPoint offsetXY;
|
||||
if(uMsg == WM_WINDOWPOSCHANGING){
|
||||
WINDOWPOS* wp = reinterpret_cast<WINDOWPOS*>(lParam);
|
||||
if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0)
|
||||
{
|
||||
wp->flags |= SWP_NOCOPYBITS;
|
||||
*result = ::DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}else if(uMsg == WM_NCCALCSIZE){
|
||||
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
||||
const LONG originalTop = clientRect->top;
|
||||
const LONG originalLeft = clientRect->left;
|
||||
const LONG originalRight = clientRect->right;
|
||||
const LONG originalBottom = clientRect->bottom;
|
||||
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
|
||||
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
|
||||
*result = hitTestResult;
|
||||
return true;
|
||||
}
|
||||
int offsetSize = 0;
|
||||
bool isMaximum = ::IsZoomed(hwnd);
|
||||
offsetXY = QPoint(abs(clientRect->left - originalLeft),abs(clientRect->top - originalTop));
|
||||
if(isMaximum || _helper->fullScreen()){
|
||||
offsetSize = 0;
|
||||
}else{
|
||||
offsetSize = 1;
|
||||
}
|
||||
if(!isCompositionEnabled()){
|
||||
offsetSize = 0;
|
||||
}
|
||||
if (!isMaximum || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) {
|
||||
clientRect->top = originalTop + offsetSize;
|
||||
clientRect->bottom = originalBottom - offsetSize;
|
||||
clientRect->left = originalLeft + offsetSize;
|
||||
clientRect->right = originalRight - offsetSize;
|
||||
}
|
||||
*result = WVR_REDRAW;
|
||||
return true;
|
||||
}if(uMsg == WM_NCHITTEST){
|
||||
if(FluTools::getInstance()->isWindows11OrGreater() && _helper->hoverMaxBtn() && _helper->resizeable()){
|
||||
if (*result == HTNOWHERE) {
|
||||
*result = HTZOOM;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*result = 0;
|
||||
POINT nativeGlobalPos{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
|
||||
POINT nativeLocalPos = nativeGlobalPos;
|
||||
::ScreenToClient(hwnd, &nativeLocalPos);
|
||||
RECT clientRect{0, 0, 0, 0};
|
||||
::GetClientRect(hwnd, &clientRect);
|
||||
auto clientWidth = clientRect.right-clientRect.left;
|
||||
auto clientHeight = clientRect.bottom-clientRect.top;
|
||||
int margins = _helper->getMargins();
|
||||
bool left = nativeLocalPos.x < margins;
|
||||
bool right = nativeLocalPos.x > clientWidth - margins;
|
||||
bool top = nativeLocalPos.y < margins;
|
||||
bool bottom = nativeLocalPos.y > clientHeight - margins;
|
||||
*result = 0;
|
||||
if (_helper->resizeable() && !_helper->fullScreen() && !_helper->maximized()) {
|
||||
if (left && top) {
|
||||
*result = HTTOPLEFT;
|
||||
} else if (left && bottom) {
|
||||
*result = HTBOTTOMLEFT;
|
||||
} else if (right && top) {
|
||||
*result = HTTOPRIGHT;
|
||||
} else if (right && bottom) {
|
||||
*result = HTBOTTOMRIGHT;
|
||||
} else if (left) {
|
||||
*result = HTLEFT;
|
||||
} else if (right) {
|
||||
*result = HTRIGHT;
|
||||
} else if (top) {
|
||||
*result = HTTOP;
|
||||
} else if (bottom) {
|
||||
*result = HTBOTTOM;
|
||||
}
|
||||
}
|
||||
if (0 != *result) {
|
||||
return true;
|
||||
}
|
||||
QVariant appBar = _helper->getAppBar();
|
||||
if(!appBar.isNull()&& _helper->hoverAppBar()){
|
||||
*result = HTCAPTION;
|
||||
return true;
|
||||
}
|
||||
*result = HTCLIENT;
|
||||
return true;
|
||||
}else if(uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN){
|
||||
if(_helper->hoverMaxBtn()){
|
||||
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
||||
QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
|
||||
return true;
|
||||
}
|
||||
}else if(uMsg == WM_NCLBUTTONUP || uMsg == WM_NCRBUTTONUP){
|
||||
if(_helper->hoverMaxBtn()){
|
||||
QMouseEvent event = QMouseEvent(QEvent::MouseButtonRelease, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
||||
QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
|
||||
}
|
||||
}else if(uMsg == WM_NCPAINT){
|
||||
*result = FALSE;
|
||||
return true;
|
||||
}else if(uMsg == WM_NCACTIVATE){
|
||||
*result = ::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
|
||||
return true;
|
||||
}else if(uMsg == WM_GETMINMAXINFO){
|
||||
MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
|
||||
minmaxInfo->ptMaxPosition.x = 0;
|
||||
minmaxInfo->ptMaxPosition.y = 0;
|
||||
minmaxInfo->ptMaxSize.x = 0;
|
||||
minmaxInfo->ptMaxSize.y = 0;
|
||||
#else
|
||||
auto pixelRatio = _helper->window->devicePixelRatio();
|
||||
auto geometry = _helper->window->screen()->availableGeometry();
|
||||
RECT rect;
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
|
||||
minmaxInfo->ptMaxPosition.x = rect.left - offsetXY.x();
|
||||
minmaxInfo->ptMaxPosition.y = rect.top - offsetXY.x();
|
||||
minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2;
|
||||
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2;
|
||||
#endif
|
||||
return false;
|
||||
}else if(uMsg == WM_NCRBUTTONDOWN){
|
||||
if (wParam == HTCAPTION) {
|
||||
_helper->showSystemMenu(QCursor::pos());
|
||||
}
|
||||
}else if(uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN){
|
||||
const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0));
|
||||
const bool spacePressed = ((wParam == VK_SPACE) || (::GetKeyState(VK_SPACE) < 0));
|
||||
if (altPressed && spacePressed) {
|
||||
auto pos = _helper->window->position();
|
||||
_helper->showSystemMenu(QPoint(pos.x(),pos.y()+_helper->getAppBarHeight()));
|
||||
}
|
||||
}else if(uMsg == WM_SYSCOMMAND){
|
||||
if(wParam == SC_MINIMIZE){
|
||||
if(_helper->window->transientParent()){
|
||||
_helper->window->transientParent()->showMinimized();
|
||||
}else{
|
||||
_helper->window->showMinimized();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
FluFramelessHelper::FluFramelessHelper(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
}
|
||||
|
||||
void FluFramelessHelper::classBegin(){
|
||||
}
|
||||
|
||||
void FluFramelessHelper::_updateCursor(int edges){
|
||||
switch (edges) {
|
||||
case 0:
|
||||
window->setCursor(Qt::ArrowCursor);
|
||||
break;
|
||||
case Qt::LeftEdge:
|
||||
case Qt::RightEdge:
|
||||
window->setCursor(Qt::SizeHorCursor);
|
||||
break;
|
||||
case Qt::TopEdge:
|
||||
case Qt::BottomEdge:
|
||||
window->setCursor(Qt::SizeVerCursor);
|
||||
break;
|
||||
case Qt::LeftEdge | Qt::TopEdge:
|
||||
case Qt::RightEdge | Qt::BottomEdge:
|
||||
window->setCursor(Qt::SizeFDiagCursor);
|
||||
break;
|
||||
case Qt::RightEdge | Qt::TopEdge:
|
||||
case Qt::LeftEdge | Qt::BottomEdge:
|
||||
window->setCursor(Qt::SizeBDiagCursor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool FluFramelessHelper::eventFilter(QObject *obj, QEvent *ev){
|
||||
if (!window.isNull() && window->flags()) {
|
||||
switch (ev->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
if(_edges!=0){
|
||||
QMouseEvent *event = static_cast<QMouseEvent*>(ev);
|
||||
if(event->button() == Qt::LeftButton){
|
||||
_updateCursor(_edges);
|
||||
window->startSystemResize(Qt::Edges(_edges));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
_edges = 0;
|
||||
break;
|
||||
case QEvent::MouseMove: {
|
||||
if(maximized() || fullScreen()){
|
||||
break;
|
||||
}
|
||||
if(!resizeable()){
|
||||
break;
|
||||
}
|
||||
QMouseEvent *event = static_cast<QMouseEvent*>(ev);
|
||||
QPoint p =
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
event->pos();
|
||||
#else
|
||||
event->position().toPoint();
|
||||
#endif
|
||||
if(p.x() >= _margins && p.x() <= (window->width() - _margins) && p.y() >= _margins && p.y() <= (window->height() - _margins)){
|
||||
if(_edges != 0){
|
||||
_edges = 0;
|
||||
_updateCursor(_edges);
|
||||
}
|
||||
break;
|
||||
}
|
||||
_edges = 0;
|
||||
if ( p.x() < _margins ) {
|
||||
_edges |= Qt::LeftEdge;
|
||||
}
|
||||
if ( p.x() > (window->width() - _margins) ) {
|
||||
_edges |= Qt::RightEdge;
|
||||
}
|
||||
if ( p.y() < _margins ) {
|
||||
_edges |= Qt::TopEdge;
|
||||
}
|
||||
if ( p.y() > (window->height() - _margins) ) {
|
||||
_edges |= Qt::BottomEdge;
|
||||
}
|
||||
_updateCursor(_edges);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(obj, ev);
|
||||
}
|
||||
|
||||
void FluFramelessHelper::componentComplete(){
|
||||
auto o = parent();
|
||||
do {
|
||||
window = qobject_cast<QQuickWindow *>(o);
|
||||
if (window) {
|
||||
break;
|
||||
}
|
||||
o = o->parent();
|
||||
} while (nullptr != o);
|
||||
if(!window.isNull()){
|
||||
_stayTop = QQmlProperty(window,"stayTop");
|
||||
_screen = QQmlProperty(window,"screen");
|
||||
_fixSize = QQmlProperty(window,"fixSize");
|
||||
_realHeight = QQmlProperty(window,"_realHeight");
|
||||
_realWidth = QQmlProperty(window,"_realWidth");
|
||||
_appBarHeight = QQmlProperty(window,"_appBarHeight");
|
||||
_appBar = window->property("appBar");
|
||||
#ifdef Q_OS_WIN
|
||||
if(!_appBar.isNull()){
|
||||
_appBar.value<QObject*>()->setProperty("systemMoveEnable",false);
|
||||
}
|
||||
window->setFlags((window->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
if(FluTools::getInstance()->isSoftware()){
|
||||
window->setFlag(Qt::FramelessWindowHint,false);
|
||||
}
|
||||
#endif
|
||||
if(resizeable()){
|
||||
window->setFlag(Qt::WindowMaximizeButtonHint);
|
||||
}
|
||||
_nativeEvent =new FramelessEventFilter(this);
|
||||
qApp->installNativeEventFilter(_nativeEvent);
|
||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||
if(resizeable()){
|
||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
|
||||
}else{
|
||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
|
||||
for (int i = 0; i < qApp->screens().count(); ++i) {
|
||||
connect( qApp->screens().at(i),&QScreen::logicalDotsPerInchChanged,this,[=]{
|
||||
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
|
||||
});
|
||||
}
|
||||
}
|
||||
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
||||
#else
|
||||
window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window);
|
||||
window->installEventFilter(this);
|
||||
#endif
|
||||
int w = _realWidth.read().toInt();
|
||||
int h = _realHeight.read().toInt()+_appBarHeight.read().toInt();
|
||||
if(!resizeable()){
|
||||
window->setMaximumSize(QSize(w,h));
|
||||
window->setMinimumSize(QSize(w,h));
|
||||
}
|
||||
window->resize(QSize(w,h));
|
||||
_onStayTopChange();
|
||||
_stayTop.connectNotifySignal(this,SLOT(_onStayTopChange()));
|
||||
_screen.connectNotifySignal(this,SLOT(_onScreenChanged()));
|
||||
Q_EMIT loadCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
void FluFramelessHelper::_onScreenChanged(){
|
||||
#ifdef Q_OS_WIN
|
||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||
::SetWindowPos(hwnd,0,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
|
||||
::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
void FluFramelessHelper::showSystemMenu(QPoint point){
|
||||
#ifdef Q_OS_WIN
|
||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||
DWORD style = ::GetWindowLongPtr(hwnd,GWL_STYLE);
|
||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
|
||||
const HMENU hMenu = ::GetSystemMenu(hwnd, FALSE);
|
||||
if(maximized() || fullScreen()){
|
||||
::EnableMenuItem(hMenu,SC_MOVE,MFS_DISABLED);
|
||||
::EnableMenuItem(hMenu,SC_RESTORE,MFS_ENABLED);
|
||||
}else{
|
||||
::EnableMenuItem(hMenu,SC_MOVE,MFS_ENABLED);
|
||||
::EnableMenuItem(hMenu,SC_RESTORE,MFS_DISABLED);
|
||||
}
|
||||
if(resizeable() && !maximized() && !fullScreen()){
|
||||
::EnableMenuItem(hMenu,SC_SIZE,MFS_ENABLED);
|
||||
::EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_ENABLED);
|
||||
}else{
|
||||
::EnableMenuItem(hMenu,SC_SIZE,MFS_DISABLED);
|
||||
::EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_DISABLED);
|
||||
}
|
||||
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), point.x()*window->devicePixelRatio(), point.y()*window->devicePixelRatio(), 0, hwnd, nullptr);
|
||||
if (result != FALSE) {
|
||||
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
||||
}
|
||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style &~ WS_SYSMENU);
|
||||
#endif
|
||||
}
|
||||
|
||||
void FluFramelessHelper::showMaximized(){
|
||||
#ifdef Q_OS_WIN
|
||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||
::ShowWindow(hwnd,3);
|
||||
#endif
|
||||
}
|
||||
|
||||
void FluFramelessHelper::_onStayTopChange(){
|
||||
bool isStayTop = _stayTop.read().toBool();
|
||||
#ifdef Q_OS_WIN
|
||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||
if(isStayTop){
|
||||
::SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
}else{
|
||||
::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
}
|
||||
#else
|
||||
window->setFlag(Qt::WindowStaysOnTopHint,isStayTop);
|
||||
#endif
|
||||
}
|
||||
|
||||
FluFramelessHelper::~FluFramelessHelper(){
|
||||
if (!window.isNull()) {
|
||||
window->setFlags(Qt::Window);
|
||||
#ifdef Q_OS_WIN
|
||||
qApp->removeNativeEventFilter(_nativeEvent);
|
||||
delete _nativeEvent;
|
||||
#endif
|
||||
window->removeEventFilter(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool FluFramelessHelper::hoverMaxBtn(){
|
||||
if(_appBar.isNull()){
|
||||
return false;
|
||||
}
|
||||
QVariant var;
|
||||
QMetaObject::invokeMethod(_appBar.value<QObject*>(), "_maximizeButtonHover",Q_RETURN_ARG(QVariant, var));
|
||||
if(var.isNull()){
|
||||
return false;
|
||||
}
|
||||
return var.toBool();
|
||||
}
|
||||
|
||||
bool FluFramelessHelper::hoverAppBar(){
|
||||
if(_appBar.isNull()){
|
||||
return false;
|
||||
}
|
||||
QVariant var;
|
||||
QMetaObject::invokeMethod(_appBar.value<QObject*>(), "_appBarHover",Q_RETURN_ARG(QVariant, var));
|
||||
if(var.isNull()){
|
||||
return false;
|
||||
}
|
||||
return var.toBool();
|
||||
}
|
||||
|
||||
QVariant FluFramelessHelper::getAppBar(){
|
||||
return _appBar;
|
||||
}
|
||||
|
||||
int FluFramelessHelper::getAppBarHeight(){
|
||||
if(_appBar.isNull()){
|
||||
return 0;
|
||||
}
|
||||
QVariant var = _appBar.value<QObject*>()->property("height");
|
||||
if(var.isNull()){
|
||||
return 0;
|
||||
}
|
||||
return var.toInt();
|
||||
}
|
||||
|
||||
QObject* FluFramelessHelper::maximizeButton(){
|
||||
if(_appBar.isNull()){
|
||||
return nullptr;
|
||||
}
|
||||
QVariant var = _appBar.value<QObject*>()->property("buttonMaximize");
|
||||
if(var.isNull()){
|
||||
return nullptr;
|
||||
}
|
||||
return var.value<QObject*>();
|
||||
}
|
||||
|
||||
bool FluFramelessHelper::resizeable(){
|
||||
return !_fixSize.read().toBool();
|
||||
}
|
||||
|
||||
bool FluFramelessHelper::maximized(){
|
||||
return window->visibility() == QWindow::Maximized;
|
||||
}
|
||||
|
||||
bool FluFramelessHelper::fullScreen(){
|
||||
return window->visibility() == QWindow::FullScreen;
|
||||
}
|
||||
|
||||
int FluFramelessHelper::getMargins(){
|
||||
return _margins;
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
#ifndef FLUFRAMELESSHELPER_H
|
||||
#define FLUFRAMELESSHELPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQuickWindow>
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QQmlProperty>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
using QT_NATIVE_EVENT_RESULT_TYPE = qintptr;
|
||||
using QT_ENTER_EVENT_TYPE = QEnterEvent;
|
||||
#else
|
||||
using QT_NATIVE_EVENT_RESULT_TYPE = long;
|
||||
using QT_ENTER_EVENT_TYPE = QEvent;
|
||||
#endif
|
||||
|
||||
class FluFramelessHelper;
|
||||
|
||||
/**
|
||||
* @brief The FramelessEventFilter class
|
||||
*/
|
||||
class FramelessEventFilter : public QAbstractNativeEventFilter
|
||||
{
|
||||
public:
|
||||
FramelessEventFilter(FluFramelessHelper* helper);
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
|
||||
public:
|
||||
QPointer<FluFramelessHelper> _helper = nullptr;
|
||||
qint64 _current = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The FluFramelessHelper class
|
||||
*/
|
||||
class FluFramelessHelper : public QObject, public QQmlParserStatus
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QQmlParserStatus)
|
||||
QML_NAMED_ELEMENT(FluFramelessHelper)
|
||||
public:
|
||||
explicit FluFramelessHelper(QObject *parent = nullptr);
|
||||
~FluFramelessHelper();
|
||||
void classBegin() override;
|
||||
void componentComplete() override;
|
||||
bool hoverMaxBtn();
|
||||
bool hoverAppBar();
|
||||
bool resizeable();
|
||||
int getMargins();
|
||||
bool maximized();
|
||||
bool fullScreen();
|
||||
int getAppBarHeight();
|
||||
QVariant getAppBar();
|
||||
QObject* maximizeButton();
|
||||
Q_INVOKABLE void showSystemMenu(QPoint point);
|
||||
Q_INVOKABLE void showMaximized();
|
||||
Q_SIGNAL void loadCompleted();
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
private:
|
||||
void _updateCursor(int edges);
|
||||
Q_SLOT void _onStayTopChange();
|
||||
Q_SLOT void _onScreenChanged();
|
||||
public:
|
||||
QPointer<QQuickWindow> window = nullptr;
|
||||
private:
|
||||
FramelessEventFilter* _nativeEvent = nullptr;
|
||||
QQmlProperty _stayTop;
|
||||
QQmlProperty _screen;
|
||||
QQmlProperty _fixSize;
|
||||
QQmlProperty _realHeight;
|
||||
QQmlProperty _realWidth;
|
||||
QQmlProperty _appBarHeight;
|
||||
QVariant _appBar;
|
||||
int _edges = 0;
|
||||
int _margins = 8;
|
||||
};
|
||||
|
||||
#endif // FLUFRAMELESSHELPER_H
|
158
src/FluNetwork.h
158
src/FluNetwork.h
@ -1,158 +0,0 @@
|
||||
#ifndef FLUNETWORK_H
|
||||
#define FLUNETWORK_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QFile>
|
||||
#include <QJsonValue>
|
||||
#include <QJSValue>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include "Def.h"
|
||||
#include "stdafx.h"
|
||||
#include "singleton.h"
|
||||
|
||||
/**
|
||||
* @brief The NetworkCallable class
|
||||
*/
|
||||
class FluNetworkCallable : public QObject{
|
||||
Q_OBJECT
|
||||
QML_NAMED_ELEMENT(FluNetworkCallable)
|
||||
public:
|
||||
explicit FluNetworkCallable(QObject *parent = nullptr);
|
||||
Q_SIGNAL void start();
|
||||
Q_SIGNAL void finish();
|
||||
Q_SIGNAL void error(int status,QString errorString,QString result);
|
||||
Q_SIGNAL void success(QString result);
|
||||
Q_SIGNAL void cache(QString result);
|
||||
Q_SIGNAL void uploadProgress(qint64 sent, qint64 total);
|
||||
Q_SIGNAL void downloadProgress(qint64 recv, qint64 total);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The FluDownloadParam class
|
||||
*/
|
||||
class FluDownloadParam : public QObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FluDownloadParam(QObject *parent = nullptr);
|
||||
FluDownloadParam(QString destPath,bool append,QObject *parent = nullptr);
|
||||
public:
|
||||
QString _destPath;
|
||||
bool _append;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The FluNetworkParams class
|
||||
*/
|
||||
class FluNetworkParams : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_NAMED_ELEMENT(FluNetworkParams)
|
||||
public:
|
||||
enum Method{
|
||||
METHOD_GET,
|
||||
METHOD_HEAD,
|
||||
METHOD_POST,
|
||||
METHOD_PUT,
|
||||
METHOD_PATCH,
|
||||
METHOD_DELETE
|
||||
};
|
||||
enum Type{
|
||||
TYPE_NONE,
|
||||
TYPE_FORM,
|
||||
TYPE_JSON,
|
||||
TYPE_JSONARRAY,
|
||||
TYPE_BODY
|
||||
};
|
||||
explicit FluNetworkParams(QObject *parent = nullptr);
|
||||
FluNetworkParams(QString url,Type type,Method method,QObject *parent = nullptr);
|
||||
Q_INVOKABLE FluNetworkParams* addQuery(QString key,QVariant val);
|
||||
Q_INVOKABLE FluNetworkParams* addHeader(QString key,QVariant val);
|
||||
Q_INVOKABLE FluNetworkParams* add(QString key,QVariant val);
|
||||
Q_INVOKABLE FluNetworkParams* addFile(QString key,QVariant val);
|
||||
Q_INVOKABLE FluNetworkParams* setBody(QString val);
|
||||
Q_INVOKABLE FluNetworkParams* setTimeout(int val);
|
||||
Q_INVOKABLE FluNetworkParams* setRetry(int val);
|
||||
Q_INVOKABLE FluNetworkParams* setCacheMode(int val);
|
||||
Q_INVOKABLE FluNetworkParams* toDownload(QString destPath,bool append = false);
|
||||
Q_INVOKABLE FluNetworkParams* bind(QObject* target);
|
||||
Q_INVOKABLE FluNetworkParams* openLog(QVariant val);
|
||||
Q_INVOKABLE void go(FluNetworkCallable* result);
|
||||
QString buildCacheKey();
|
||||
QString method2String();
|
||||
int getTimeout();
|
||||
int getRetry();
|
||||
bool getOpenLog();
|
||||
public:
|
||||
FluDownloadParam* _downloadParam = nullptr;
|
||||
QObject* _target = nullptr;
|
||||
Method _method;
|
||||
Type _type;
|
||||
QString _url;
|
||||
QString _body;
|
||||
QMap<QString, QVariant> _queryMap;
|
||||
QMap<QString, QVariant> _headerMap;
|
||||
QMap<QString, QVariant> _paramMap;
|
||||
QMap<QString, QVariant> _fileMap;
|
||||
int _timeout = -1;
|
||||
int _retry = -1;
|
||||
QVariant _openLog;
|
||||
int _cacheMode = FluNetworkType::CacheMode::NoCache;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The FluNetwork class
|
||||
*/
|
||||
class FluNetwork : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int,timeout)
|
||||
Q_PROPERTY_AUTO(int,retry)
|
||||
Q_PROPERTY_AUTO(QString,cacheDir)
|
||||
Q_PROPERTY_AUTO(bool,openLog)
|
||||
QML_NAMED_ELEMENT(FluNetwork)
|
||||
QML_SINGLETON
|
||||
private:
|
||||
explicit FluNetwork(QObject *parent = nullptr);
|
||||
public:
|
||||
SINGLETON(FluNetwork)
|
||||
static FluNetwork *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||
Q_INVOKABLE FluNetworkParams* get(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* head(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* postBody(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* putBody(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* patchBody(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* deleteBody(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* postForm(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* putForm(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* patchForm(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* deleteForm(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* postJson(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* putJson(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* patchJson(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* deleteJson(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* postJsonArray(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* putJsonArray(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* patchJsonArray(const QString& url);
|
||||
Q_INVOKABLE FluNetworkParams* deleteJsonArray(const QString& url);
|
||||
Q_INVOKABLE void setInterceptor(QJSValue interceptor);
|
||||
void handle(FluNetworkParams* params,FluNetworkCallable* result);
|
||||
void handleDownload(FluNetworkParams* params,FluNetworkCallable* result);
|
||||
private:
|
||||
void sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<FluNetworkCallable> callable);
|
||||
void addQueryParam(QUrl* url,const QMap<QString, QVariant>& params);
|
||||
void addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers);
|
||||
void saveResponse(QString key,QString response);
|
||||
QString readCache(const QString& key);
|
||||
bool cacheExists(const QString& key);
|
||||
QString getCacheFilePath(const QString& key);
|
||||
QString map2String(const QMap<QString, QVariant>& map);
|
||||
QString headerList2String(const QList<QNetworkReply::RawHeaderPair>& data);
|
||||
void printRequestStartLog(QNetworkRequest request,FluNetworkParams* params);
|
||||
void printRequestEndLog(QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,const QString& response);
|
||||
public:
|
||||
QJSValue _interceptor;
|
||||
};
|
||||
|
||||
#endif // FLUNETWORK_H
|
@ -1,35 +1,47 @@
|
||||
#include "FluTextStyle.h"
|
||||
|
||||
FluTextStyle::FluTextStyle(QObject *parent):QObject{parent}{
|
||||
_family = QFont().defaultFamily();
|
||||
#ifdef Q_OS_WIN
|
||||
_family = "微软雅黑";
|
||||
#endif
|
||||
|
||||
QFont caption;
|
||||
caption.setFamily(_family);
|
||||
caption.setPixelSize(12);
|
||||
Caption(caption);
|
||||
|
||||
QFont body;
|
||||
body.setFamily(_family);
|
||||
body.setPixelSize(13);
|
||||
Body(body);
|
||||
|
||||
QFont bodyStrong;
|
||||
bodyStrong.setFamily(_family);
|
||||
bodyStrong.setPixelSize(13);
|
||||
bodyStrong.setWeight(QFont::DemiBold);
|
||||
BodyStrong(bodyStrong);
|
||||
|
||||
QFont subtitle;
|
||||
subtitle.setFamily(_family);
|
||||
subtitle.setPixelSize(20);
|
||||
subtitle.setWeight(QFont::DemiBold);
|
||||
Subtitle(subtitle);
|
||||
|
||||
QFont title;
|
||||
title.setFamily(_family);
|
||||
title.setPixelSize(28);
|
||||
title.setWeight(QFont::DemiBold);
|
||||
Title(title);
|
||||
|
||||
QFont titleLarge;
|
||||
titleLarge.setFamily(_family);
|
||||
titleLarge.setPixelSize(40);
|
||||
titleLarge.setWeight(QFont::DemiBold);
|
||||
TitleLarge(titleLarge);
|
||||
|
||||
QFont display;
|
||||
display.setFamily(_family);
|
||||
display.setPixelSize(68);
|
||||
display.setWeight(QFont::DemiBold);
|
||||
Display(display);
|
||||
|
@ -14,6 +14,7 @@ class FluTextStyle : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_PROPERTY_AUTO(QString,family)
|
||||
Q_PROPERTY_AUTO(QFont,Caption);
|
||||
Q_PROPERTY_AUTO(QFont,Body);
|
||||
Q_PROPERTY_AUTO(QFont,BodyStrong);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user