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); }