From 5ca1b715f3f5d98f83820d98e1ee72f0941133d2 Mon Sep 17 00:00:00 2001 From: zhuzihcu Date: Wed, 12 Apr 2023 11:55:39 +0800 Subject: [PATCH] update --- example/global/ItemsOriginal.qml | 9 ++++- example/qml.qrc | 1 + example/res/svg/home.svg | 1 + src/controls/FluNavigationView.qml | 59 +++++++++++++++++++++------- src/controls/FluPaneItem.qml | 1 + src/controls/FluPaneItemExpander.qml | 3 +- src/controls/FluWindow.qml | 2 + 7 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 example/res/svg/home.svg diff --git a/example/global/ItemsOriginal.qml b/example/global/ItemsOriginal.qml index 31e5c9e..81a92c7 100644 --- a/example/global/ItemsOriginal.qml +++ b/example/global/ItemsOriginal.qml @@ -9,7 +9,14 @@ FluObject{ FluPaneItem{ title:"Home" - icon:FluentIcons.Home + // icon:FluentIcons.Home + cusIcon: Image{ + anchors.centerIn: parent + source: "qrc:/res/svg/home.svg" + sourceSize: Qt.size(30,30) + width: 18 + height: 18 + } onTap:{ navigationView.push("qrc:/T_Home.qml") } diff --git a/example/qml.qrc b/example/qml.qrc index 343900b..53e542d 100644 --- a/example/qml.qrc +++ b/example/qml.qrc @@ -160,5 +160,6 @@ T_StatusView.qml T_Settings.qml global/MainEvent.qml + res/svg/home.svg diff --git a/example/res/svg/home.svg b/example/res/svg/home.svg new file mode 100644 index 0000000..6502662 --- /dev/null +++ b/example/res/svg/home.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/controls/FluNavigationView.qml b/src/controls/FluNavigationView.qml index 4bff317..5c07d68 100644 --- a/src/controls/FluNavigationView.qml +++ b/src/controls/FluNavigationView.qml @@ -246,22 +246,37 @@ Item { return Qt.rgba(0,0,0,0) } } - FluIcon{ - id:item_icon - iconSource: { - if(model.icon){ - return model.icon + Component{ + id:com_icon + FluIcon{ + iconSource: { + if(model.icon){ + return model.icon + } + return 0 } - return 0 + iconSize: 15 } + } + + Item{ + id:item_icon width: 30 height: 30 - iconSize: 15 anchors{ verticalCenter: parent.verticalCenter left:parent.left leftMargin: 3 } + Loader{ + anchors.centerIn: parent + sourceComponent: { + if(model.cusIcon){ + return model.cusIcon + } + return com_icon + } + } } FluText{ id:item_title @@ -382,23 +397,39 @@ Item { return Qt.rgba(0,0,0,0) } } - FluIcon{ - id:item_icon - iconSource: { - if(model.icon){ - return model.icon + Component{ + id:com_icon + FluIcon{ + iconSource: { + if(model.icon){ + return model.icon + } + return 0 } - return 0 + iconSize: 15 } + } + + Item{ + id:item_icon width: 30 height: 30 - iconSize: 15 anchors{ verticalCenter: parent.verticalCenter left:parent.left leftMargin: 3 } + Loader{ + anchors.centerIn: parent + sourceComponent: { + if(model.cusIcon){ + return model.cusIcon + } + return com_icon + } + } } + FluText{ id:item_title text:model.title diff --git a/src/controls/FluPaneItem.qml b/src/controls/FluPaneItem.qml index ff99799..93e5e92 100644 --- a/src/controls/FluPaneItem.qml +++ b/src/controls/FluPaneItem.qml @@ -7,6 +7,7 @@ QtObject { property string title property int order : 0 property int icon + property Component cusIcon property bool recentlyAdded: false property bool recentlyUpdated: false property string desc diff --git a/src/controls/FluPaneItemExpander.qml b/src/controls/FluPaneItemExpander.qml index 600df94..abdc8d6 100644 --- a/src/controls/FluPaneItemExpander.qml +++ b/src/controls/FluPaneItemExpander.qml @@ -4,7 +4,8 @@ import FluentUI FluObject { readonly property string key : FluApp.uuid() property string title - property int icon + property var icon + property Component cusIcon property bool isExpand: false property var parent property int idx diff --git a/src/controls/FluWindow.qml b/src/controls/FluWindow.qml index b8adfa7..fb60469 100644 --- a/src/controls/FluWindow.qml +++ b/src/controls/FluWindow.qml @@ -56,6 +56,8 @@ ApplicationWindow { Component.onCompleted: { helper.initWindow(window) initArgument(argument) + window.x = (Screen.width - window.width)/2 + window.y = (Screen.desktopAvailableHeight - window.height)/2 } function showSuccess(text,duration,moremsg){