From 1a1a19f74e7f55388da043ae1e2e34e334d5f740 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 23 Sep 2014 15:53:49 +0200 Subject: EditMenu: let menu property be a component to lazy load it Since all input fields have a menu assigned to it by default (which in most cases never will be shown), it should be an optimization to await creating it until needed. Change-Id: I5777bbdae42103981e9b2f5ddfdfd763acea07ae Reviewed-by: J-P Nurmi --- src/controls/Private/EditMenu.qml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/controls/Private/EditMenu.qml') diff --git a/src/controls/Private/EditMenu.qml b/src/controls/Private/EditMenu.qml index c0faf9ff..f4d80bd5 100644 --- a/src/controls/Private/EditMenu.qml +++ b/src/controls/Private/EditMenu.qml @@ -47,7 +47,27 @@ Loader { property Item cursorHandle property Item selectionHandle property Flickable flickable - property Menu defaultMenu: item && item.defaultMenu ? item.defaultMenu : null + property Component defaultMenu: item && item.defaultMenu ? item.defaultMenu : null + property Menu menuInstance: null + + Connections { + target: control + onMenuChanged: { + if (menuInstance !== null) { + menuInstance.destroy() + menuInstance = null + } + } + } + + function getMenuInstance() + { + // Lazy load menu when first requested + if (!menuInstance && control.menu) { + menuInstance = control.menu.createObject(input); + } + return menuInstance; + } source: Qt.resolvedUrl("EditMenu_" + (Qt.platform.os === "ios" ? "ios" : "base") + ".qml") } -- cgit v1.2.1