From 70f048f629a39ab31aa867bb16484a37b20cd8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Mon, 10 Apr 2023 22:05:20 +0800 Subject: [PATCH] update --- example/T_Settings.qml | 3 +- example/global/MainEvent.qml | 2 +- example/page/MainPage.qml | 4 +- src/Fluent.cpp | 1 - src/controls/FluAutoSuggestBox.qml | 2 +- src/controls/FluNavigationView.qml | 506 +++++++++++++++------ src/controls/FluNavigationView2.qml | 668 ---------------------------- src/controls/FluScrollBar.qml | 9 +- src/res.qrc | 1 - 9 files changed, 381 insertions(+), 815 deletions(-) delete mode 100644 src/controls/FluNavigationView2.qml diff --git a/example/T_Settings.qml b/example/T_Settings.qml index dd1ed941..81e40ea0 100644 --- a/example/T_Settings.qml +++ b/example/T_Settings.qml @@ -35,13 +35,12 @@ FluScrollablePage{ Repeater{ id:repeater - model: [{title:"Top",mode:FluNavigationView2.Top},{title:"Open",mode:FluNavigationView2.Open},{title:"Compact",mode:FluNavigationView2.Compact},{title:"Minimal",mode:FluNavigationView2.Minimal},{title:"Auto",mode:FluNavigationView2.Auto}] + model: [{title:"Open",mode:FluNavigationView.Open},{title:"Compact",mode:FluNavigationView.Compact},{title:"Minimal",mode:FluNavigationView.Minimal},{title:"Auto",mode:FluNavigationView.Auto}] delegate: FluRadioButton{ selected : MainEvent.displayMode===modelData.mode text:modelData.title onClicked:{ MainEvent.displayMode = modelData.mode - console.debug(modelData.mode) } } } diff --git a/example/global/MainEvent.qml b/example/global/MainEvent.qml index aae1ca34..f2cc5fa4 100644 --- a/example/global/MainEvent.qml +++ b/example/global/MainEvent.qml @@ -5,6 +5,6 @@ import FluentUI QtObject { - property int displayMode : FluNavigationView2.Open + property int displayMode : FluNavigationView.Auto } diff --git a/example/page/MainPage.qml b/example/page/MainPage.qml index e3122321..b97e7a4c 100644 --- a/example/page/MainPage.qml +++ b/example/page/MainPage.qml @@ -21,7 +21,7 @@ FluWindow { darkText: "Dark Mode" } - FluNavigationView2{ + FluNavigationView{ id:nav_view anchors.fill: parent items: ItemsOriginal @@ -33,7 +33,7 @@ FluWindow { autoSuggestBox:FluAutoSuggestBox{ width: 280 anchors.centerIn: parent - iconSource: FluentIcons.Zoom + iconSource: FluentIcons.Search items: ItemsOriginal.getSearchData() placeholderText: "Search" onItemClicked: diff --git a/src/Fluent.cpp b/src/Fluent.cpp index 831160d0..75512415 100644 --- a/src/Fluent.cpp +++ b/src/Fluent.cpp @@ -33,7 +33,6 @@ void Fluent::registerTypes(const char *uri){ qmlRegisterType(uri,major,minor,"WindowHelper"); qmlRegisterType(uri,major,minor,"FluColorSet"); - qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluNavigationView2.qml"),uri,major,minor,"FluNavigationView2"); qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluStatusView.qml"),uri,major,minor,"FluStatusView"); qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPagination.qml"),uri,major,minor,"FluPagination"); qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluToggleButton.qml"),uri,major,minor,"FluToggleButton"); diff --git a/src/controls/FluAutoSuggestBox.qml b/src/controls/FluAutoSuggestBox.qml index 29ce597d..32ba2c24 100644 --- a/src/controls/FluAutoSuggestBox.qml +++ b/src/controls/FluAutoSuggestBox.qml @@ -5,7 +5,7 @@ import FluentUI FluTextBox{ property var items:[] property string emptyText: "没有找到结果" - property int autoSuggestBoxReplacement: FluentIcons.Zoom + property int autoSuggestBoxReplacement: FluentIcons.Search signal itemClicked(var data) signal handleClicked QtObject{ diff --git a/src/controls/FluNavigationView.qml b/src/controls/FluNavigationView.qml index c39f0ff0..0c1a7a3c 100644 --- a/src/controls/FluNavigationView.qml +++ b/src/controls/FluNavigationView.qml @@ -6,48 +6,112 @@ import FluentUI Item { - property alias logo : image_logo.source - property string title: "" - property FluObject items - property FluObject footerItems - property int displayMode: width<=700 ? FluNavigationView.Minimal : FluNavigationView.Open - property bool displaMinimalMenu : false - property Component autoSuggestBox - - id:root - - onDisplayModeChanged: { - if(displayMode === FluNavigationView.Minimal){ - anim_navi.enabled = false - displaMinimalMenu = false - timer_anim_enable.restart() - } - } - - Timer{ - id:timer_anim_enable - interval: 150 - onTriggered: { - anim_navi.enabled = true - } - } - enum DisplayMode { - Minimal, Open, + Compact, + Minimal, Auto } + property url logo + property string title: "" + property FluObject items + property FluObject footerItems + property int displayMode: FluNavigationView.Auto + property Component autoSuggestBox property var window : { if(Window.window == null) return null return Window.window } + id:control + + QtObject{ + id:d + property bool enableStack: true + property int displayMode: { + if(control.displayMode !==FluNavigationView.Auto){ + return control.displayMode + } + if(control.width<=700){ + return FluNavigationView.Minimal + }else if(control.width<=900){ + return FluNavigationView.Compact + }else{ + return FluNavigationView.Open + } + } + property var stackItems: [] + property bool enableNavigationPanel: false + property bool isCompact: d.displayMode === FluNavigationView.Compact + property bool isMinimal: d.displayMode === FluNavigationView.Minimal + property bool isCompactAndPanel: d.displayMode === FluNavigationView.Compact && d.enableNavigationPanel + property bool isCompactAndNotPanel:d.displayMode === FluNavigationView.Compact && !d.enableNavigationPanel + property bool isMinimalAndPanel: d.displayMode === FluNavigationView.Minimal && d.enableNavigationPanel + + onIsCompactAndNotPanelChanged: { + collapseAll() + } + + onDisplayModeChanged: { + if(d.displayMode === FluNavigationView.Compact){ + collapseAll() + } + if(d.displayMode === FluNavigationView.Minimal){ + anim_layout_list_x.enabled = false + d.enableNavigationPanel = false + timer_anim_x_enable.restart() + } + } + + function handleItems(){ + var idx = 0 + var data = [] + if(items){ + for(var i=0;icontrols/FluPagination.qml controls/FluToggleButton.qml controls/FluStatusView.qml - controls/FluNavigationView2.qml controls/FluPaneItemEmpty.qml