From 2d501dca5a647f4e96618c7fb5b65ca90cdd1866 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 15 Dec 2019 05:37:14 -0400 Subject: [PATCH] Use a Loader for HTile context menus --- src/qml/Base/HTile.qml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/qml/Base/HTile.qml b/src/qml/Base/HTile.qml index ee1eb637..99cbb8b8 100644 --- a/src/qml/Base/HTile.qml +++ b/src/qml/Base/HTile.qml @@ -15,7 +15,7 @@ HButton { readonly property alias rightInfo: rightInfo readonly property alias subtitle: subtitle - property HMenu contextMenu: HMenu {} + property alias contextMenu: contextMenuLoader.sourceComponent property Component image @@ -88,7 +88,19 @@ HButton { acceptedButtons: Qt.RightButton onTapped: { rightClicked() - if (contextMenu.count > 0) contextMenu.popup() + if (contextMenu) contextMenuLoader.active = true } } + + Connections { + enabled: contextMenuLoader.status === Loader.Ready + target: contextMenuLoader.item + onClosed: contextMenuLoader.active = false + } + + HLoader { + id: contextMenuLoader + active: false + onLoaded: item.popup() + } }