diff --git a/example/qml.qrc b/example/qml.qrc index 9d268a8..f0c0e66 100644 --- a/example/qml.qrc +++ b/example/qml.qrc @@ -168,5 +168,6 @@ qml/page/T_Tooltip.qml qml/page/T_TreeView.qml qml/page/T_Typography.qml + qml/page/T_BreadcrumbBar.qml diff --git a/example/qml/component/CodeExpander.qml b/example/qml/component/CodeExpander.qml index 98e51c8..95fdda6 100644 --- a/example/qml/component/CodeExpander.qml +++ b/example/qml/component/CodeExpander.qml @@ -119,7 +119,8 @@ FluExpander{ "FluTheme", "FluStatusView", "FluRatingControl", - "FluPasswordBox" + "FluPasswordBox", + "FluBreadcrumbBar" ]; code = code.replace(/\n/g, "
"); code = code.replace(/ /g, " "); diff --git a/example/qml/global/ItemsOriginal.qml b/example/qml/global/ItemsOriginal.qml index ac0c018..30e226b 100644 --- a/example/qml/global/ItemsOriginal.qml +++ b/example/qml/global/ItemsOriginal.qml @@ -187,6 +187,12 @@ FluObject{ navigationView.push("qrc:/qml/page/T_Pivot.qml") } } + FluPaneItem{ + title:"BreadcrumbBar" + onTap:{ + navigationView.push("qrc:/qml/page/T_BreadcrumbBar.qml") + } + } FluPaneItem{ title:"TabView" image:"qrc:/res/image/control/TabView.png" diff --git a/example/qml/page/T_BreadcrumbBar.qml b/example/qml/page/T_BreadcrumbBar.qml new file mode 100644 index 0000000..bf266ac --- /dev/null +++ b/example/qml/page/T_BreadcrumbBar.qml @@ -0,0 +1,98 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Window +import FluentUI +import "../component" + +FluScrollablePage{ + + title:"BreadcurmbBar" + leftPadding:10 + rightPadding:10 + bottomPadding:20 + spacing: 0 + + Component.onCompleted: { + var items = [] + for(var i=0;i<10;i++){ + items.push({title:"Item_"+(i+1)}) + } + breadcrumb_1.items = items + breadcrumb_2.items = items + } + + FluArea{ + Layout.fillWidth: true + height: 68 + paddings: 10 + Layout.topMargin: 20 + + FluBreadcrumbBar{ + id:breadcrumb_1 + width:parent.width + anchors.verticalCenter: parent.verticalCenter + onClickItem: + (model)=>{ + showSuccess(model.title) + } + } + } + + + FluArea{ + Layout.fillWidth: true + height: 100 + paddings: 10 + Layout.topMargin: 20 + + ColumnLayout{ + anchors.verticalCenter: parent.verticalCenter + width:parent.width + spacing: 10 + + FluFilledButton{ + text:"Reset sample" + onClicked:{ + var items = [] + for(var i=0;i<10;i++){ + items.push({title:"Item_"+(i+1)}) + } + breadcrumb_2.items = items + } + } + + FluBreadcrumbBar{ + id:breadcrumb_2 + separator:">" + spacing:8 + textSize:18 + Layout.fillWidth: true + onClickItem: + (model)=>{ + //不是点击最后一个item元素 + if(model.index+1!==count()){ + breadcrumb_2.remove(model.index+1,count()-model.index-1) + } + showSuccess(model.title) + } + } + } + } + + CodeExpander{ + Layout.fillWidth: true + Layout.topMargin: -1 + code:'FluBreadcrumbBar{ + width:parent.width + separator:">" + spacing:8 + textSize:18 + onClickItem: (model)=>{ + + } +}' + } + + +} diff --git a/src/Fluent.cpp b/src/Fluent.cpp index 36c3e41..39933cd 100644 --- a/src/Fluent.cpp +++ b/src/Fluent.cpp @@ -34,6 +34,7 @@ void Fluent::registerTypes(const char *uri){ qmlRegisterType(uri,major,minor,"WindowHelper"); qmlRegisterType(uri,major,minor,"FluColorSet"); + qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluBreadcrumbBar.qml"),uri,major,minor,"FluBreadcrumbBar"); qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluRatingControl.qml"),uri,major,minor,"FluRatingControl"); qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluStatusView.qml"),uri,major,minor,"FluStatusView"); qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPagination.qml"),uri,major,minor,"FluPagination"); diff --git a/src/NativeEventFilter.cpp b/src/NativeEventFilter.cpp index 6ab6fb6..119f28c 100644 --- a/src/NativeEventFilter.cpp +++ b/src/NativeEventFilter.cpp @@ -15,6 +15,9 @@ bool NativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *mes MSG* msg = static_cast(message); if (msg == Q_NULLPTR) return false; + if(!FluApp::getInstance()->wnds.contains((WId)msg->hwnd)){ + return false; + } switch(msg->message) { case WM_NCCALCSIZE:{ NCCALCSIZE_PARAMS& params = *reinterpret_cast(msg->lParam); diff --git a/src/controls/FluBreadcrumbBar.qml b/src/controls/FluBreadcrumbBar.qml new file mode 100644 index 0000000..d89aad2 --- /dev/null +++ b/src/controls/FluBreadcrumbBar.qml @@ -0,0 +1,100 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import FluentUI + +Item { + + property int textSize: 15 + property string separator: "/" + property var items: [] + property int spacing: 5 + signal clickItem(var model) + + id:control + implicitWidth: 300 + height: 30 + + onItemsChanged: { + list_model.clear() + list_model.append(items) + } + + ListModel{ + id:list_model + } + + ListView{ + id:list_view + width: parent.width + height: 30 + orientation: ListView.Horizontal + model: list_model + clip: true + spacing : control.spacing + boundsBehavior: ListView.StopAtBounds + remove: Transition { + NumberAnimation { + properties: "opacity" + from: 1 + to: 0 + duration: 83 + } + } + add: Transition { + NumberAnimation { + properties: "opacity" + from: 0 + to: 1 + duration: 83 + } + } + delegate: Item{ + height: item_layout.height + width: item_layout.width + RowLayout{ + id:item_layout + spacing: list_view.spacing + height: list_view.height + + FluText{ + text:model.title + Layout.alignment: Qt.AlignVCenter + color: { + if(item_mouse.pressed){ + return FluTheme.dark ? Qt.rgba(150/255,150/255,150/235,1) : Qt.rgba(134/255,134/255,134/235,1) + } + if(item_mouse.containsMouse){ + return FluTheme.dark ? Qt.rgba(204/255,204/255,204/235,1) : Qt.rgba(92/255,92/255,92/235,1) + } + return FluTheme.dark ? Qt.rgba(255/255,255/255,255/235,1) : Qt.rgba(26/255,26/255,26/235,1) + } + MouseArea{ + id:item_mouse + anchors.fill: parent + hoverEnabled: true + onClicked: { + control.clickItem(model) + } + } + } + + FluText{ + text:control.separator + font.pixelSize: control.textSize + visible: list_view.count-1 !== index + Layout.alignment: Qt.AlignVCenter + } + } + } + } + + function remove(index,count){ + list_model.remove(index,count) + } + + function count(){ + return list_model.count + } + +} diff --git a/src/res.qrc b/src/res.qrc index c925cdd..004cb30 100644 --- a/src/res.qrc +++ b/src/res.qrc @@ -71,5 +71,6 @@ controls/FluPaneItemEmpty.qml controls/FluRatingControl.qml controls/FluPasswordBox.qml + controls/FluBreadcrumbBar.qml