From 8a1e1e6cecbeb9bfd54e93077146b5f16a0d139f Mon Sep 17 00:00:00 2001 From: hewenfei Date: Thu, 29 Jun 2023 10:48:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=89=A9=E5=B1=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=8F=9C=E5=8D=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/AppUI/Sidebar.qml | 23 ++++++++++++++++++- .../ukui/menu/extension/UkuiMenuExtension.qml | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/qml/AppUI/Sidebar.qml b/qml/AppUI/Sidebar.qml index 4eb182a..e1357a4 100644 --- a/qml/AppUI/Sidebar.qml +++ b/qml/AppUI/Sidebar.qml @@ -48,7 +48,7 @@ Item { RowLayout { anchors.fill: parent - // spacing: 5 + spacing: 4 ListView { id: extensionInfoList @@ -78,6 +78,14 @@ Item { } } + Loader { + id: extensionMenuLoader + visible: sourceComponent !== undefined + Layout.preferredWidth: 34 + Layout.preferredHeight: 34 + Layout.alignment: Qt.AlignVCenter + } + AppControls2.StyleBackground { id: fullScreenbutton Layout.preferredWidth: 34 @@ -125,10 +133,23 @@ Item { onLoaded: { item.send.connect(extensionInfoList.send); sidebarLayout.updateSidebarLayout(extensionInfoList.currentItem.extensionOptions); + updateMenu(); + item.extensionMenuChanged.connect(updateMenu); } Keys.onTabPressed: { extensionInfoList.focus = true } + + function updateMenu() { + if (item === null) { + return; + } + if (item.extensionMenu !== null) { + extensionMenuLoader.sourceComponent = item.extensionMenu; + } else { + extensionMenuLoader.sourceComponent = undefined; + } + } } } diff --git a/qml/org/ukui/menu/extension/UkuiMenuExtension.qml b/qml/org/ukui/menu/extension/UkuiMenuExtension.qml index ef817fe..7c805e0 100644 --- a/qml/org/ukui/menu/extension/UkuiMenuExtension.qml +++ b/qml/org/ukui/menu/extension/UkuiMenuExtension.qml @@ -2,5 +2,6 @@ import QtQuick 2.0 Item { property var extensionData; + property Component extensionMenu: null; signal send(var data); }