From ac602c5afad16fa44c914c4474e2d4e29ee0c63b Mon Sep 17 00:00:00 2001 From: zhuzihcu Date: Tue, 13 Jun 2023 10:26:14 +0800 Subject: [PATCH] update --- example/qml/page/T_RemoteLoader.qml | 2 +- .../FluentUI/Controls/FluContentPage.qml | 4 +-- .../FluentUI/Controls/FluNavigationView.qml | 11 +++++--- .../FluentUI/Controls/FluRemoteLoader.qml | 25 +++++++++++-------- .../FluentUI/Controls/FluScrollablePage.qml | 4 +-- .../FluentUI/Controls/FluStatusView.qml | 16 +++++++++--- 6 files changed, 39 insertions(+), 23 deletions(-) diff --git a/example/qml/page/T_RemoteLoader.qml b/example/qml/page/T_RemoteLoader.qml index 72831e20..de4125e7 100644 --- a/example/qml/page/T_RemoteLoader.qml +++ b/example/qml/page/T_RemoteLoader.qml @@ -6,7 +6,7 @@ import FluentUI import "qrc:///example/qml/component" FluRemoteLoader{ - property int pageMode: FluNavigationView.Standard + property int pageMode: FluNavigationView.SingleTop property string url: '' source: "https://zhu-zichu.gitee.io/T_RemoteLoader.qml" } diff --git a/src/imports/FluentUI/Controls/FluContentPage.qml b/src/imports/FluentUI/Controls/FluContentPage.qml index 1f0fd9a4..a117d2d5 100644 --- a/src/imports/FluentUI/Controls/FluContentPage.qml +++ b/src/imports/FluentUI/Controls/FluContentPage.qml @@ -11,13 +11,13 @@ Item { property int topPadding: 0 property int rightPadding: 10 property int bottomPadding: 10 - property int pageMode: FluNavigationView.Standard + property int pageMode: FluNavigationView.SingleTop property string url: '' id:control FluText{ id:text_title visible: text !== "" - height: visible ? implicitHeight : 0 + height: visible ? contentHeight : 0 font: FluTextStyle.Title anchors{ top: parent.top diff --git a/src/imports/FluentUI/Controls/FluNavigationView.qml b/src/imports/FluentUI/Controls/FluNavigationView.qml index df995730..379c7f1c 100644 --- a/src/imports/FluentUI/Controls/FluNavigationView.qml +++ b/src/imports/FluentUI/Controls/FluNavigationView.qml @@ -14,7 +14,8 @@ Item { } enum PageModeFlag{ Standard = 0, - SingleTask = 1 + SingleTask = 1, + SingleTop = 2 } property url logo property string title: "" @@ -893,9 +894,6 @@ Item { return nav_list.model } function push(url,argument={}){ - if(nav_swipe.currentItem && nav_swipe.currentItem.url === url && nav_swipe.currentItem.pageMode === FluNavigationView.SingleTask){ - return - } let page = nav_swipe.find(function(item) { return item.url === url; }) @@ -909,6 +907,11 @@ Item { d.stackItems.pop() } return + case FluNavigationView.SingleTop: + if (nav_swipe.currentItem.url === url){ + return + } + break case FluNavigationView.Standard: default: } diff --git a/src/imports/FluentUI/Controls/FluRemoteLoader.qml b/src/imports/FluentUI/Controls/FluRemoteLoader.qml index bd63426a..a50eedcd 100644 --- a/src/imports/FluentUI/Controls/FluRemoteLoader.qml +++ b/src/imports/FluentUI/Controls/FluRemoteLoader.qml @@ -2,25 +2,30 @@ import QtQuick import QtQuick.Controls import FluentUI -Item { - id:control +FluStatusView { property url source: "" - + color:"transparent" + id:control + onErrorClicked: { + reload() + } Loader{ id:loader anchors.fill: parent source: control.source asynchronous: true + onStatusChanged: { + if(status === Loader.Error){ + control.statusMode = FluStatusView.Error + }else if(status === Loader.Loading){ + control.statusMode = FluStatusView.Loading + }else{ + control.statusMode = FluStatusView.Success + } + } } - - FluProgressRing{ - anchors.centerIn: parent - visible: loader.status === Loader.Loading - } - function reload(){ var timestamp = Date.now(); loader.source = control.source+"?"+timestamp } - } diff --git a/src/imports/FluentUI/Controls/FluScrollablePage.qml b/src/imports/FluentUI/Controls/FluScrollablePage.qml index 09cf226d..841d681c 100644 --- a/src/imports/FluentUI/Controls/FluScrollablePage.qml +++ b/src/imports/FluentUI/Controls/FluScrollablePage.qml @@ -12,14 +12,14 @@ Item { property int topPadding: 0 property int rightPadding: 10 property int bottomPadding: 10 - property int pageMode: FluNavigationView.Standard + property int pageMode: FluNavigationView.SingleTop property string url: '' id:control FluText{ id:text_title font: FluTextStyle.Title visible: text !== "" - height: visible ? implicitHeight : 0 + height: visible ? contentHeight : 0 padding: 0 anchors{ top: parent.top diff --git a/src/imports/FluentUI/Controls/FluStatusView.qml b/src/imports/FluentUI/Controls/FluStatusView.qml index 8eac9577..89ae280f 100644 --- a/src/imports/FluentUI/Controls/FluStatusView.qml +++ b/src/imports/FluentUI/Controls/FluStatusView.qml @@ -13,6 +13,11 @@ Item{ } default property alias content: container.data property int statusMode: FluStatusView.Loading + property string loadingText:"正在加载..." + property string emptyText: "空空如也" + property string errorText: "页面出错了.." + 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 Item{ id:container @@ -28,6 +33,7 @@ Item{ Behavior on opacity { NumberAnimation { duration: 83 } } + color:control.color ColumnLayout{ anchors.centerIn: parent visible: statusMode === FluStatusView.Loading @@ -36,7 +42,7 @@ Item{ Layout.alignment: Qt.AlignHCenter } FluText{ - text:"正在加载..." + text:control.loadingText Layout.alignment: Qt.AlignHCenter } } @@ -46,6 +52,7 @@ Item{ border.width: 0 anchors.fill: container visible: opacity + color:control.color opacity: statusMode === FluStatusView.Empty Behavior on opacity { NumberAnimation { duration: 83 } @@ -54,7 +61,7 @@ Item{ anchors.centerIn: parent visible: statusMode === FluStatusView.Empty FluText{ - text:"空空如也" + text:control.emptyText font: FluTextStyle.BodyStrong Layout.alignment: Qt.AlignHCenter } @@ -65,6 +72,7 @@ Item{ border.width: 0 anchors.fill: container visible: opacity + color:control.color opacity: statusMode === FluStatusView.Error Behavior on opacity { NumberAnimation { duration: 83 } @@ -72,14 +80,14 @@ Item{ ColumnLayout{ anchors.centerIn: parent FluText{ - text:"页面出错了..." + text:control.errorText font: FluTextStyle.BodyStrong Layout.alignment: Qt.AlignHCenter } FluFilledButton{ id:btn_error Layout.alignment: Qt.AlignHCenter - text:"重新加载" + text:control.errorButtonText onClicked:{ control.errorClicked() }