From 80619f697439d294c18d707b94b09bd37c5af725 Mon Sep 17 00:00:00 2001 From: zhuzichu Date: Thu, 6 Jul 2023 18:17:52 +0800 Subject: [PATCH] update --- example/qml/page/T_Buttons.qml | 1 + example/qml/window/MainWindow.qml | 5 +- src/Def.h | 6 +- .../FluentUI/Controls/FluStatusView.qml | 133 ++++++++++-------- src/imports/FluentUI/Controls/FluTextBox.qml | 1 + 5 files changed, 82 insertions(+), 64 deletions(-) diff --git a/example/qml/page/T_Buttons.qml b/example/qml/page/T_Buttons.qml index 9d00ab41..be466de7 100644 --- a/example/qml/page/T_Buttons.qml +++ b/example/qml/page/T_Buttons.qml @@ -24,6 +24,7 @@ FluScrollablePage{ FluTextButton{ disabled:text_button_switch.checked text:"Text Button" + contentDescription: "文本按钮" onClicked: { showInfo("点击Text Button") } diff --git a/example/qml/window/MainWindow.qml b/example/qml/window/MainWindow.qml index 1da8c5d1..069e063b 100644 --- a/example/qml/window/MainWindow.qml +++ b/example/qml/window/MainWindow.qml @@ -168,7 +168,10 @@ CustomWindow { width: parent.width height: parent.height z:999 -// pageMode: FluNavigationView.NoStack + //NoStack模式,每次切换都会销毁之前的页面然后创建一个新的页面,只需消耗少量内存(推荐) + // pageMode: FluNavigationView.NoStack + //Stack模式,每次切换都会将页面压入栈中,随着栈的页面增多,消耗的内存也越多,内存消耗多就会卡顿,这时候就需要按返回将页面pop掉,释放内存。该模式可以配合FluPage中的launchMode属性,设置页面的启动模式 + pageMode: FluNavigationView.NoStack items: ItemsOriginal footerItems:ItemsFooter topPadding:FluTools.isMacos() ? 20 : 5 diff --git a/src/Def.h b/src/Def.h index 3d24f635..5beb5249 100644 --- a/src/Def.h +++ b/src/Def.h @@ -7,9 +7,9 @@ namespace Fluent_DarkMode { Q_NAMESPACE enum Fluent_DarkModeType { - System = 0x0, - Light = 0x1, - Dark = 0x2, + System = 0x0, + Light = 0x1, + Dark = 0x2, }; Q_ENUM_NS(Fluent_DarkModeType) QML_NAMED_ELEMENT(FluDarkMode) diff --git a/src/imports/FluentUI/Controls/FluStatusView.qml b/src/imports/FluentUI/Controls/FluStatusView.qml index 89ae280f..a0deebd4 100644 --- a/src/imports/FluentUI/Controls/FluStatusView.qml +++ b/src/imports/FluentUI/Controls/FluStatusView.qml @@ -19,77 +19,90 @@ Item{ property string errorButtonText: "重新加载" property color color: FluTheme.dark ? Window.active ? Qt.rgba(38/255,44/255,54/255,1) : Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1) signal errorClicked + property Component loadingItem : com_loading + property Component emptyItem : com_empty + property Component errorItem : com_error + Item{ id:container anchors.fill: parent - visible: statusMode === FluStatusView.Success + visible: statusMode===FluStatusView.Success } - FluArea{ - paddings: 0 - border.width: 0 - anchors.fill: container - visible: opacity - opacity: statusMode === FluStatusView.Loading - Behavior on opacity { - NumberAnimation { duration: 83 } - } - color:control.color - ColumnLayout{ - anchors.centerIn: parent - visible: statusMode === FluStatusView.Loading - FluProgressRing{ - indeterminate: true - Layout.alignment: Qt.AlignHCenter + Loader{ + id:loader + anchors.fill: parent + visible: statusMode!==FluStatusView.Success + sourceComponent: { + if(statusMode === FluStatusView.Loading){ + return loadingItem } - FluText{ - text:control.loadingText - Layout.alignment: Qt.AlignHCenter + if(statusMode === FluStatusView.Empty){ + return emptyItem + } + if(statusMode === FluStatusView.Error){ + return errorItem + } + return null + } + } + Component{ + id:com_loading + FluArea{ + paddings: 0 + border.width: 0 + radius: 0 + color:control.color + ColumnLayout{ + anchors.centerIn: parent + FluProgressRing{ + indeterminate: true + Layout.alignment: Qt.AlignHCenter + } + FluText{ + text:control.loadingText + Layout.alignment: Qt.AlignHCenter + } } } } - FluArea{ - paddings: 0 - border.width: 0 - anchors.fill: container - visible: opacity - color:control.color - opacity: statusMode === FluStatusView.Empty - Behavior on opacity { - NumberAnimation { duration: 83 } - } - ColumnLayout{ - anchors.centerIn: parent - visible: statusMode === FluStatusView.Empty - FluText{ - text:control.emptyText - font: FluTextStyle.BodyStrong - Layout.alignment: Qt.AlignHCenter + Component { + id:com_empty + FluArea{ + paddings: 0 + border.width: 0 + radius: 0 + color:control.color + ColumnLayout{ + anchors.centerIn: parent + FluText{ + text:control.emptyText + font: FluTextStyle.BodyStrong + Layout.alignment: Qt.AlignHCenter + } } } } - FluArea{ - paddings: 0 - border.width: 0 - anchors.fill: container - visible: opacity - color:control.color - opacity: statusMode === FluStatusView.Error - Behavior on opacity { - NumberAnimation { duration: 83 } - } - ColumnLayout{ - anchors.centerIn: parent - FluText{ - text:control.errorText - font: FluTextStyle.BodyStrong - Layout.alignment: Qt.AlignHCenter - } - FluFilledButton{ - id:btn_error - Layout.alignment: Qt.AlignHCenter - text:control.errorButtonText - onClicked:{ - control.errorClicked() + Component{ + id:com_error + FluArea{ + paddings: 0 + border.width: 0 + radius: 0 + color:control.color + ColumnLayout{ + anchors.centerIn: parent + FluText{ + text:control.errorText + font: FluTextStyle.BodyStrong + Layout.alignment: Qt.AlignHCenter + } + FluFilledButton{ + id:btn_error + Layout.alignment: Qt.AlignHCenter + text:control.errorButtonText + onClicked:{ + control.errorClicked() + } } } } diff --git a/src/imports/FluentUI/Controls/FluTextBox.qml b/src/imports/FluentUI/Controls/FluTextBox.qml index b3155a2e..5438023a 100644 --- a/src/imports/FluentUI/Controls/FluTextBox.qml +++ b/src/imports/FluentUI/Controls/FluTextBox.qml @@ -83,6 +83,7 @@ TextField{ right: parent.right rightMargin: closeRightMargin } + contentDescription:"清空" onClicked:{ control.text = "" }