Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
Loadable.qml
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-License-Identifier: MPL-2.0
3
4import QtQuick
5
13Item {
14 id: root
15 Accessible.ignored: true
19 property Component component
20
24 property var showAnimation
25
29 property var hideAnimation
30
34 property alias asynchronous: loader.asynchronous
35
39 property alias item: loader.item
40 visible: false
41
42 Loader {
43 id: loader
44 anchors.fill: parent
45 asynchronous: true
46 onStatusChanged: {
47 if (status != Loader.Ready)
48 return;
49 if (item.showAnimation == undefined && root.showAnimation != undefined)
50 item.showAnimation = root.showAnimation;
51 if (item.hideAnimation == undefined && root.hideAnimation != undefined)
52 item.hideAnimation = root.hideAnimation;
53 root.visible = true;
54 if (item.show != undefined)
55 item.show();
56 }
57 }
58
59 Connections {
60 target: loader.item
61
62 function onVisibleChanged() {
63 // Unload component as soon as it's hidden and hide this item as well
64 if (!loader.item.visible) {
65 loader.sourceComponent = undefined;
66 root.visible = false;
67 }
68 }
69 }
70
74 function show() {
75 loader.sourceComponent = root.component;
76 }
77
81 function hide() {
82 if (loader.item && loader.item.hide != undefined)
83 loader.item.hide();
84 }
85}