From 6ba27cfc7cec74568acf74db75feb21bafa2baf1 Mon Sep 17 00:00:00 2001 From: uncor3 Date: Mon, 8 Jun 2026 21:04:20 +0000 Subject: [PATCH] refactor(Tabs): lazy loads some tabs --- src/ui/Tabs.qml | 58 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/src/ui/Tabs.qml b/src/ui/Tabs.qml index 8ccc817..a3797b7 100644 --- a/src/ui/Tabs.qml +++ b/src/ui/Tabs.qml @@ -7,29 +7,55 @@ Item { id: root required property int currentIndex + StackLayout { + anchors.fill: parent + currentIndex: root.currentIndex - AnimatedTab { - index: 0 - currentIndex : root.currentIndex - DeviceTab { - anchors.fill: parent + /* + let's not lazy load the main device tab + this way it's a bit faster to show the device + */ + AnimatedTab { + index: 0 + currentIndex : root.currentIndex + DeviceTab { + anchors.fill: parent + } + } + + Loader { + active: root.currentIndex === 1 || item + sourceComponent: appsTabComponent + } + + Loader { + active: root.currentIndex === 2 || item + sourceComponent: toolboxTabComponent } } - AnimatedTab { - index: 1 - currentIndex : root.currentIndex - AppsTab { - anchors.fill: parent + + Component { + id: appsTabComponent + AnimatedTab { + index: 1 + currentIndex : root.currentIndex + AppsTab { + anchors.fill: parent + } } } - AnimatedTab { - index: 2 - currentIndex : root.currentIndex - Toolbox { - anchors.fill: parent + Component { + id: toolboxTabComponent + AnimatedTab { + index: 2 + currentIndex : root.currentIndex + Toolbox { + anchors.fill: parent + } } - } + } + }