Merge lp:~artmello/gallery-app/gallery-app-improve_album_editor_load into lp:gallery-app

Proposed by Arthur Mello
Status: Merged
Approved by: Bill Filler
Approved revision: 1117
Merged at revision: 1117
Proposed branch: lp:~artmello/gallery-app/gallery-app-improve_album_editor_load
Merge into: lp:gallery-app
Diff against target: 412 lines (+8/-362)
3 files modified
rc/qml/AlbumEditor/AlbumEditorAnimated.qml (+0/-115)
rc/qml/AlbumEditor/AlbumEditorTransition.qml (+0/-239)
rc/qml/AlbumsOverview.qml (+8/-8)
To merge this branch: bzr merge lp:~artmello/gallery-app/gallery-app-improve_album_editor_load
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
Review via email: mp+244078@code.launchpad.net

Commit message

Load the AlbumEditor without the animation to improve the load time

Description of the change

Load the AlbumEditor without the animation to improve the load time

To post a comment you must log in.
Revision history for this message
Bill Filler (bfiller) wrote :

approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file 'rc/qml/AlbumEditor/AlbumEditorAnimated.qml'
--- rc/qml/AlbumEditor/AlbumEditorAnimated.qml 2014-10-13 09:26:44 +0000
+++ rc/qml/AlbumEditor/AlbumEditorAnimated.qml 1970-01-01 00:00:00 +0000
@@ -1,115 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Gallery 1.0
19import Ubuntu.Components 0.1
20
21/*! @brief AlbumEditorAnimated opens the editor for the album
22 *
23 * The album editor enable to edit the title, sub-title and the cover image.
24 * Set the album and origin properties befor calling open()
25 * The first call of open() is slow, as the lazy loading is used for the album editor which is a
26 * big component.
27 */
28Item {
29 id: root
30
31 // True if the album editor is opened
32 property bool isOpen: false
33 /// The album to be shown in that editor
34 property Album album
35 /// Origin (rectangle) where this view is animated from when calling open()
36 /// And where it is animated to when this view is closed
37 property variant origin
38 /// The preview item that was used to open the view, or null, if it was opend another way
39 /// This item will be hidden when this view is opened. And shown again after closing this view
40 property Item previewItem: null
41 /// Is true if the opne or close animation is running
42 property bool animationRunning: loader_albumEditor.status === Loader.Ready ?
43 loader_albumEditor.item.albumEditorTransition.animationRunning ||
44 loader_albumEditor.item.albumEditor.animationRunning
45 : false
46
47 /// Opens the editor for the album with an animation
48 function open() {
49 loader_albumEditor.load()
50 loader_albumEditor.item.albumEditor.album = album
51 loader_albumEditor.item.albumEditorTransition.enterEditor(root.album, root.origin)
52 if (previewItem)
53 previewItem.visible = false
54 isOpen = true;
55 }
56
57 Component {
58 id: component_EditorItem
59 Item {
60 property alias albumEditorTransition: inner_albumEditorTransition
61 property alias albumEditor: inner_albumEditor
62
63 AlbumEditor {
64 id: inner_albumEditor
65 anchors.fill: parent
66 visible: false
67
68 onMediaSelectorHidden: {
69 albumEditorCheckerboardHidden(newScrollPos);
70 }
71
72 onCloseRequested: {
73 root.isOpen = false;
74 if (album && album.newAlbum && album.containedCount == 0) {
75 inner_albumEditor.model.destroyAlbum(album);
76 album = null;
77 }
78 if (album) {
79 inner_albumEditorTransition.exitEditor(album, root.origin);
80 } else {
81 inner_albumEditorTransition.exitEditor(null, null);
82 }
83 }
84 }
85
86 AlbumEditorTransition {
87 id: inner_albumEditorTransition
88 anchors.fill: parent
89 backgroundGlass: inner_albumEditor.backgroundGlass
90 editor: inner_albumEditor
91 onEditorExited: {
92 if (previewItem)
93 previewItem.visible = true;
94 loader_albumEditor.sourceComponent = undefined;
95 }
96 }
97 }
98 }
99 Loader {
100 id: loader_albumEditor
101 anchors.fill: parent
102
103 function load() {
104 if (sourceComponent == undefined) {
105 sourceComponent = component_EditorItem
106 }
107 }
108 }
109
110 MouseArea {
111 id: transitionClickBlocker
112 anchors.fill: parent
113 enabled: root.animationRunning
114 }
115}
1160
=== removed file 'rc/qml/AlbumEditor/AlbumEditorTransition.qml'
--- rc/qml/AlbumEditor/AlbumEditorTransition.qml 2014-05-20 09:34:10 +0000
+++ rc/qml/AlbumEditor/AlbumEditorTransition.qml 1970-01-01 00:00:00 +0000
@@ -1,239 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Charles Lindsay <chaz@yorba.org>
18 */
19
20import QtQuick 2.0
21import "../AlbumViewer"
22import "../Utility"
23
24// Provides a smooth transition between the album overview and album editor.
25Item {
26 id: albumEditorTransition
27
28 /*!
29 */
30 signal editorEntered(variant album)
31 /*!
32 */
33 signal editorExited(variant album)
34
35 /*!
36 */
37 property alias album: thumbnail.album
38
39 /*!
40 */
41 property Rectangle backgroundGlass
42 /*!
43 */
44 property AlbumEditor editor
45
46 /*!
47 */
48 property int duration: 500
49
50 // Read-only
51 /*!
52 */
53 property bool animationRunning: enterFadeAnimation.running ||
54 exitFadeAnimation.running || enterExpandAnimation.running ||
55 exitExpandAnimation.running;
56
57 /*!
58 */
59 function enterEditor(album, thumbnailRect) {
60 albumEditorTransition.album = album || null;
61
62 if (thumbnailRect) {
63 thumbnail.x = thumbnailRect.x;
64 thumbnail.y = thumbnailRect.y;
65 thumbnail.width = thumbnailRect.width;
66 thumbnail.height = thumbnailRect.height;
67
68 overview.pushPage(editor);
69 enterExpandAnimation.restart();
70 } else {
71 overview.pushPage(editor);
72 enterFadeAnimation.restart();
73 }
74 }
75
76 /*!
77 */
78 function exitEditor(album, thumbnailRect) {
79 albumEditorTransition.album = album || null;
80
81 if (thumbnailRect) {
82 exitExpandAnimation.thumbnailRect = thumbnailRect;
83
84 thumbnail.x = editor.editorRect.x;
85 thumbnail.y = editor.editorRect.y;
86 thumbnail.width = editor.editorRect.width;
87 thumbnail.height = editor.editorRect.height;
88
89 overview.popPage();
90 exitExpandAnimation.restart();
91 } else {
92 overview.popPage();
93 exitFadeAnimation.restart();
94 }
95 }
96
97 // internal
98 /*!
99 */
100 function onExitFinished() {
101 editorExited(album);
102 album = null;
103 }
104
105 AlbumOpener {
106 id: thumbnail
107
108 isPreview: true
109 contentHasPreviewFrame: true
110
111 visible: false
112 load: visible
113 }
114
115 ParallelAnimation {
116 id: enterFadeAnimation
117
118 onRunningChanged: {
119 if (!running)
120 editorEntered(albumEditorTransition.album);
121 }
122
123 FadeInAnimation {
124 target: backgroundGlass
125 endOpacity: 0.75
126 duration: albumEditorTransition.duration
127 }
128
129 FadeInAnimation {
130 target: editor
131 duration: albumEditorTransition.duration
132 }
133 }
134
135 ParallelAnimation {
136 id: exitFadeAnimation
137
138 onRunningChanged: {
139 if (!running)
140 onExitFinished();
141 }
142
143 FadeOutAnimation {
144 target: backgroundGlass
145 startOpacity: 0.75
146 duration: albumEditorTransition.duration
147 }
148
149 FadeOutAnimation {
150 target: editor
151 duration: albumEditorTransition.duration
152 }
153 }
154
155 SequentialAnimation {
156 id: enterExpandAnimation
157
158 onRunningChanged: {
159 if (!running)
160 editorEntered(albumEditorTransition.album);
161 }
162
163 PropertyAction { target: thumbnail; property: "visible"; value: true; }
164 PropertyAction { target: editor; property: "showAlbumCover"; value: false; }
165
166 ParallelAnimation {
167 ExpandAnimation {
168 target: thumbnail
169 endX: editor.editorRect.x
170 endY: editor.editorRect.y
171 endWidth: editor.editorRect.width
172 endHeight: editor.editorRect.height
173 duration: albumEditorTransition.duration
174 easingType: Easing.OutQuad
175 }
176
177 NumberAnimation {
178 target: thumbnail
179 property: "openFraction"
180 from: (!album || album.closed ? 0 : 1)
181 to: 0
182 duration: albumEditorTransition.duration
183 easing.type: Easing.OutQuad
184 }
185
186 FadeInAnimation {
187 target: backgroundGlass
188 endOpacity: 0.75
189 duration: albumEditorTransition.duration
190 }
191 }
192
193 PropertyAction { target: thumbnail; property: "visible"; value: false; }
194 PropertyAction { target: editor; property: "showAlbumCover"; value: true; }
195 }
196
197 SequentialAnimation {
198 id: exitExpandAnimation
199
200 property variant thumbnailRect: {"x": 0, "y": 0, "width": 0, "height": 0}
201
202 onRunningChanged: {
203 if (!running)
204 onExitFinished();
205 }
206
207 PropertyAction { target: editor; property: "visible"; value: false; }
208 PropertyAction { target: thumbnail; property: "visible"; value: true; }
209
210 ParallelAnimation {
211 ExpandAnimation {
212 target: thumbnail
213 endX: exitExpandAnimation.thumbnailRect.x
214 endY: exitExpandAnimation.thumbnailRect.y
215 endWidth: exitExpandAnimation.thumbnailRect.width
216 endHeight: exitExpandAnimation.thumbnailRect.height
217 duration: albumEditorTransition.duration
218 easingType: Easing.OutQuad
219 }
220
221 NumberAnimation {
222 target: thumbnail
223 property: "openFraction"
224 from: 0
225 to: (!album || album.closed ? 0 : 1)
226 duration: albumEditorTransition.duration
227 easing.type: Easing.InQuad
228 }
229
230 FadeOutAnimation {
231 target: backgroundGlass
232 startOpacity: 0.75
233 duration: albumEditorTransition.duration
234 }
235 }
236
237 PropertyAction { target: thumbnail; property: "visible"; value: false; }
238 }
239}
2400
=== modified file 'rc/qml/AlbumsOverview.qml'
--- rc/qml/AlbumsOverview.qml 2014-11-06 14:43:21 +0000
+++ rc/qml/AlbumsOverview.qml 2014-12-09 03:00:14 +0000
@@ -130,7 +130,6 @@
130 onLongPressed: {130 onLongPressed: {
131 albumMenu.album = album131 albumMenu.album = album
132 albumMenu.caller = content132 albumMenu.caller = content
133 albumEditor.previewItem = thisDelegate
134 albumMenu.show()133 albumMenu.show()
135 }134 }
136135
@@ -209,8 +208,7 @@
209208
210 onEditClicked: {209 onEditClicked: {
211 albumEditor.album = album210 albumEditor.album = album
212 albumEditor.origin = root.getRectOfAlbumPreview(album, albumEditor)211 overview.pushPage(albumEditor)
213 albumEditor.open()
214 }212 }
215213
216 onDeleteClicked: {214 onDeleteClicked: {
@@ -242,9 +240,7 @@
242 albumCollectionModel.addOrphan(album);240 albumCollectionModel.addOrphan(album);
243241
244 albumEditor.album = album;242 albumEditor.album = album;
245 albumEditor.origin = null;243 overview.pushPage(albumEditor);
246 albumEditor.previewItem = null;
247 albumEditor.open();
248 }244 }
249 }245 }
250 text: i18n.tr("Add") // text in toolbar246 text: i18n.tr("Add") // text in toolbar
@@ -271,9 +267,13 @@
271 onQuickCloseRequested: isAlbumOpened = false;267 onQuickCloseRequested: isAlbumOpened = false;
272 }268 }
273269
274 AlbumEditorAnimated {270 AlbumEditor {
275 id: albumEditor271 id: albumEditor
276 objectName: "albumEditorAnimated"272 objectName: "albumEditor"
277 anchors.fill: parent273 anchors.fill: parent
274 visible: false
275
276 onMediaSelectorHidden: albumEditorCheckerboardHidden(newScrollPos);
277 onCloseRequested: overview.popPage();
278 }278 }
279}279}

Subscribers

People subscribed via source and target branches