From 4819739af82ee162d4cfb96dca18aa1476e691c8 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Mon, 12 Sep 2016 15:04:28 +0200 Subject: [PATCH] [System Tray] Call Qt.createComponent for PlasmoidItem only once I slapped a console.time in there and it would show 1ms even on some of the subsequent invocations, so while QML engine should do some caching magic, calling it once is better anway. Differential Revision: https://phabricator.kde.org/D2719 --- applets/systemtray/package/contents/ui/main.qml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/applets/systemtray/package/contents/ui/main.qml b/applets/systemtray/package/contents/ui/main.qml index 63197325c..9c6640f02 100644 --- a/applets/systemtray/package/contents/ui/main.qml +++ b/applets/systemtray/package/contents/ui/main.qml @@ -46,6 +46,8 @@ MouseArea { property alias statusNotifierModel: statusNotifierModel + property Component plasmoidItemComponent + function updateItemVisibility(item) { //Invisible @@ -86,8 +88,10 @@ MouseArea { } Containment.onAppletAdded: { - var component = Qt.createComponent("items/PlasmoidItem.qml") - var plasmoidContainer = component.createObject(invisibleEntriesContainer, {"x": x, "y": y, "applet": applet}); + if (!plasmoidItemComponent) { + plasmoidItemComponent = Qt.createComponent("items/PlasmoidItem.qml"); + } + var plasmoidContainer = plasmoidItemComponent.createObject(invisibleEntriesContainer, {"x": x, "y": y, "applet": applet}); applet.parent = plasmoidContainer applet.anchors.left = plasmoidContainer.left