From c22d4a77e993e34300e6ee11ccf77a9021c87c45 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 20 Feb 2021 13:40:07 +0200 Subject: [PATCH] add SmartLauncherItem in a Loader --- .../package/contents/ui/task/TaskIcon.qml | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/plasmoid/package/contents/ui/task/TaskIcon.qml b/plasmoid/package/contents/ui/task/TaskIcon.qml index 6b9f8a72a..3dfad8ea3 100644 --- a/plasmoid/package/contents/ui/task/TaskIcon.qml +++ b/plasmoid/package/contents/ui/task/TaskIcon.qml @@ -43,7 +43,7 @@ Item { readonly property bool smartLauncherEnabled: ((taskItem.isStartup === false) && (root.showInfoBadge || root.showProgressBadge)) readonly property bool progressVisible: smartLauncherItem && smartLauncherItem.progressVisible readonly property real progress: smartLauncherItem && smartLauncherItem.progress ? smartLauncherItem.progress : 0 - property QtObject smartLauncherItem: null + readonly property QtObject smartLauncherItem: smartLauncherLoader.active ? smartLauncherLoader.item : null Rectangle{ id: draggedRectangle @@ -62,6 +62,14 @@ Item { onTempColorChanged: tempColor.a = 0.35; } + Loader { + id: smartLauncherLoader + active: taskIconContainer.smartLauncherEnabled + sourceComponent: TaskManagerApplet.SmartLauncherItem { + launcherUrl: taskItem.launcherUrlWithIcon + } + } + //! Provide icon background and glow colors Loader { id: iconColorsLoader @@ -449,21 +457,6 @@ Item { removingAnimation.removingItem.destroy(); } - onSmartLauncherEnabledChanged: { - if (smartLauncherEnabled && !smartLauncherItem) { - var smartLauncher = Qt.createQmlObject( - " import org.kde.plasma.private.taskmanager 0.1 as TaskManagerApplet; TaskManagerApplet.SmartLauncherItem { }", - taskIcon); - - smartLauncher.launcherUrl = Qt.binding(function() { return taskItem.launcherUrlWithIcon; }); - - smartLauncherItem = smartLauncher; - } else if (!smartLauncherEnabled && smartLauncherItem) { - smartLauncherItem.destroy(); - smartLauncherItem = null; - } - } - Connections{ target: taskItem @@ -610,5 +603,4 @@ Item { } } ] - }