From 9223d5f937f96eb7d426750b5288145ae5af8b96 Mon Sep 17 00:00:00 2001 From: zhuzichu Date: Fri, 7 Jul 2023 11:47:03 +0800 Subject: [PATCH] update --- example/qml/page/T_ColorPicker.qml | 2 - example/qml/window/MainWindow.qml | 4 +- .../FluentUI/Controls/FluAutoSuggestBox.qml | 56 ++++++------------- src/imports/FluentUI/Controls/FluImage.qml | 56 ++++++++++--------- .../FluentUI/Controls/FluNavigationView.qml | 2 +- src/imports/FluentUI/Controls/FluPaneItem.qml | 2 +- .../FluentUI/Controls/FluPaneItemEmpty.qml | 2 +- .../FluentUI/Controls/FluPaneItemExpander.qml | 2 +- .../FluentUI/Controls/FluPaneItemHeader.qml | 2 +- .../Controls/FluPaneItemSeparator.qml | 2 +- .../FluentUI/Controls/FluStatusView.qml | 2 +- .../FluentUI/Controls/FluTableView.qml | 4 +- 12 files changed, 57 insertions(+), 79 deletions(-) diff --git a/example/qml/page/T_ColorPicker.qml b/example/qml/page/T_ColorPicker.qml index b7e391b0..24954589 100644 --- a/example/qml/page/T_ColorPicker.qml +++ b/example/qml/page/T_ColorPicker.qml @@ -23,8 +23,6 @@ FluScrollablePage{ text:"此颜色组件是Github上的开源项目" } FluTextButton{ - leftPadding: 0 - rightPadding: 0 text:"https://github.com/rshest/qml-colorpicker" onClicked: { Qt.openUrlExternally(text) diff --git a/example/qml/window/MainWindow.qml b/example/qml/window/MainWindow.qml index 069e063b..3c513948 100644 --- a/example/qml/window/MainWindow.qml +++ b/example/qml/window/MainWindow.qml @@ -168,9 +168,9 @@ CustomWindow { width: parent.width height: parent.height z:999 - //NoStack模式,每次切换都会销毁之前的页面然后创建一个新的页面,只需消耗少量内存(推荐) - // pageMode: FluNavigationView.NoStack //Stack模式,每次切换都会将页面压入栈中,随着栈的页面增多,消耗的内存也越多,内存消耗多就会卡顿,这时候就需要按返回将页面pop掉,释放内存。该模式可以配合FluPage中的launchMode属性,设置页面的启动模式 + // pageMode: FluNavigationView.Stack + //NoStack模式,每次切换都会销毁之前的页面然后创建一个新的页面,只需消耗少量内存(推荐) pageMode: FluNavigationView.NoStack items: ItemsOriginal footerItems:ItemsFooter diff --git a/src/imports/FluentUI/Controls/FluAutoSuggestBox.qml b/src/imports/FluentUI/Controls/FluAutoSuggestBox.qml index ab90016b..83675a95 100644 --- a/src/imports/FluentUI/Controls/FluAutoSuggestBox.qml +++ b/src/imports/FluentUI/Controls/FluAutoSuggestBox.qml @@ -30,15 +30,10 @@ FluTextBox{ duration: 83 } } - onVisibleChanged: { - if(visible){ - list_view.currentIndex = -1 - } - } - background: Rectangle{ + background: FluRectangle{ id:container width: control.width - radius: 4 + radius: [4,4,4,4] FluShadow{ radius: 4 } @@ -48,7 +43,7 @@ FluTextBox{ id:list_view anchors.fill: parent clip: true - currentIndex: -1 + boundsBehavior: ListView.StopAtBounds ScrollBar.vertical: FluScrollBar {} header: Item{ width: control.width @@ -63,49 +58,30 @@ FluTextBox{ } } } - delegate:Control{ + delegate:FluControl{ + id:item_control + height: 38 width: control.width - padding:10 + onClicked:{ + handleClick(modelData) + } background: Rectangle{ + FluFocusRectangle{ + visible: item_control.activeFocus + radius:4 + } color: { - if(list_view.currentIndex === index){ - return FluTheme.dark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1) - } if(hovered){ return FluTheme.dark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1) } return FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(0,0,0,0) } - MouseArea{ - id:mouse_area - anchors.fill: parent - Connections{ - target: control - function onHandleClicked(){ - if((list_view.currentIndex === index)){ - handleClick(modelData) - } - } - } - onClicked: handleClick(modelData) - } - Rectangle{ - width: 3 - color:FluTheme.primaryColor.dark - visible: list_view.currentIndex === index - radius: 3 - height: 20 - anchors{ - left: parent.left - verticalCenter: parent.verticalCenter - } - } } contentItem: FluText{ text:modelData.title - anchors{ - verticalCenter: parent.verticalCenter - } + leftPadding: 10 + rightPadding: 10 + verticalAlignment : Qt.AlignVCenter } } } diff --git a/src/imports/FluentUI/Controls/FluImage.qml b/src/imports/FluentUI/Controls/FluImage.qml index 34b48e8c..79b83376 100644 --- a/src/imports/FluentUI/Controls/FluImage.qml +++ b/src/imports/FluentUI/Controls/FluImage.qml @@ -2,43 +2,47 @@ import QtQuick import QtQuick.Controls import FluentUI -Item { - property alias sourceSize : image.sourceSize - property alias fillMode : image.fillMode - property url source +Image { property string errorButtonText: "重新加载" - property var status property var clickErrorListener : function(){ image.source = "" image.source = control.source } + property Component errorItem : com_error + property Component loadingItem: com_loading id: control - Image{ - id:image + Loader{ anchors.fill: parent - source: control.source - opacity: control.status === Image.Ready - onStatusChanged:{ - control.status = image.status - } - Behavior on opacity { - NumberAnimation{ - duration: 83 + sourceComponent: { + if(control.status === Image.Loading){ + return com_loading + }else if(control.status == Image.Error){ + return com_error + }else{ + return undefined } } } - Rectangle{ - anchors.fill: parent - color: FluTheme.dark ? Qt.rgba(1,1,1,0.03) : Qt.rgba(0,0,0,0.03) - FluProgressRing{ - anchors.centerIn: parent - visible: control.status === Image.Loading + Component{ + id:com_loading + Rectangle{ + color: FluTheme.dark ? Qt.rgba(1,1,1,0.03) : Qt.rgba(0,0,0,0.03) + FluProgressRing{ + anchors.centerIn: parent + visible: control.status === Image.Loading + } } - FluFilledButton{ - text: control.errorButtonText - anchors.centerIn: parent - visible: control.status === Image.Error - onClicked: clickErrorListener() + } + Component{ + id:com_error + Rectangle{ + color: FluTheme.dark ? Qt.rgba(1,1,1,0.03) : Qt.rgba(0,0,0,0.03) + FluFilledButton{ + text: control.errorButtonText + anchors.centerIn: parent + visible: control.status === Image.Error + onClicked: clickErrorListener() + } } } } diff --git a/src/imports/FluentUI/Controls/FluNavigationView.qml b/src/imports/FluentUI/Controls/FluNavigationView.qml index 8a34a821..2b6006a3 100644 --- a/src/imports/FluentUI/Controls/FluNavigationView.qml +++ b/src/imports/FluentUI/Controls/FluNavigationView.qml @@ -1097,7 +1097,7 @@ Item { var items = getItems() for(var i=0;i{ - item_loader.sourceComponent = null + item_loader.sourceComponent = undefined if(!(event.modifiers & Qt.ControlModifier)){ selection_model.clear() } @@ -279,7 +279,7 @@ Rectangle { property int column property int row property var tableView: control - sourceComponent: null + sourceComponent: undefined onDisplayChanged: { var obj = table_model.getRow(row) obj[columnSource[column].dataIndex] = display