on xenial help sign in
Update LazyImage to support item
e63b276Andrea Cimitan
qml/Components/LazyImage.qml+23−3
@@ -37,7 +37,8 @@ Item {
37 property alias horizontalAlignment: image.horizontalAlignment
37 property alias horizontalAlignment: image.horizontalAlignment
38 property alias verticalAlignment: image.verticalAlignment
38 property alias verticalAlignment: image.verticalAlignment
39 property alias sourceImage: image
39 property alias sourceImage: image
40− property alias borderSource: shape.borderSource
40+ property bool useUbuntuShape: true
41+ property string borderSource: "radius_idle.sci"
41
42
42 state: "default"
43 state: "default"
43
44
@@ -78,7 +79,7 @@ Item {
78 }
79 }
79 }
80 }
80
81
81− UbuntuShape {
82+ Loader {
82 id: shape
83 id: shape
83 objectName: "shape"
84 objectName: "shape"
84 height: root.initialHeight
85 height: root.initialHeight
@@ -88,13 +89,22 @@ Item {
88 opacity: 0
89 opacity: 0
89 visible: opacity != 0
90 visible: opacity != 0
90
91
92+ sourceComponent: useUbuntuShape ? ubuntuShapeComponent : itemComponent
93+ onLoaded: {
94+ if (sourceComponent === ubuntuShapeComponent) {
95+ item.image = image;
96+ item.borderSource = Qt.binding(function() { return root.borderSource })
97+ }
98+ }
99+
91− image: Image {
100+ Image {
92 id: image
101 id: image
93 objectName: "image"
102 objectName: "image"
94
103
95 property url nextSource
104 property url nextSource
96 property string format: image.implicitWidth > image.implicitHeight ? "landscape" : "portrait"
105 property string format: image.implicitWidth > image.implicitHeight ? "landscape" : "portrait"
97
106
107+ visible: !useUbuntuShape
98 fillMode: Image.PreserveAspectFit
108 fillMode: Image.PreserveAspectFit
99 asynchronous: true
109 asynchronous: true
100 cache: false
110 cache: false
@@ -109,6 +119,16 @@ Item {
109 }
119 }
110 }
120 }
111
121
122+ Component {
123+ id: itemComponent
124+ Item {}
125+ }
126+
127+ Component {
128+ id: ubuntuShapeComponent
129+ UbuntuShape {}
130+ }
131+
112 states: [
132 states: [
113 State {
133 State {
114 name: "default"
134 name: "default"