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