Merge lp:~zsombi/ubuntu-ui-toolkit/fixBottoMEdge into lp:ubuntu-ui-toolkit/staging
- fixBottoMEdge
- Merge into staging
Status: | Merged |
---|---|
Approved by: | Zoltan Balogh |
Approved revision: | 1917 |
Merged at revision: | 1917 |
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/fixBottoMEdge |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Diff against target: |
1213 lines (+440/-238) 10 files modified
src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeHintStyle.qml (+2/-2) src/Ubuntu/Components/plugin/plugin.pri (+2/-1) src/Ubuntu/Components/plugin/ucbottomedge.cpp (+39/-37) src/Ubuntu/Components/plugin/ucbottomedgeregion.cpp (+200/-101) src/Ubuntu/Components/plugin/ucbottomedgeregion.h (+19/-45) src/Ubuntu/Components/plugin/ucbottomedgeregion_p.h (+84/-0) src/Ubuntu/UbuntuToolkit/asyncloader.h (+1/-1) tests/unit_x11/tst_bottomedge/BottomEdgeWithAction.qml (+42/-0) tests/unit_x11/tst_bottomedge/tst_bottomedge.cpp (+49/-50) tests/unit_x11/tst_bottomedge/tst_bottomedge.pro (+2/-1) |
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/fixBottoMEdge |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
ubuntu-sdk-build-bot | continuous-integration | Approve | |
Tim Peeters | Approve | ||
Review via email: mp+290681@code.launchpad.net |
Commit message
Fix BottomEdge content discarding.
Description of the change
* Once loaded, never discard BottomEdge default region content.
* Fix hint icon size
* Provide PIMPL for BottomEdgeRegion
* Fix flaky test for altered region commit point
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1916
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1916
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1916
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1916
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Tim Peeters (tpeeters) wrote : | # |
and the hint size is fixed :)
Tim Peeters (tpeeters) wrote : | # |
When I open the gallery app and go to the bottom edge page, then click the icon in the header to reveal the bottom edge, I only see a semi-transparent overlay, no BE contents. See https:/
- 1917. By Zsombor Egri
-
fix Action trigger commit content to be shown
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Tim Peeters (tpeeters) wrote : | # |
Works. But jenkins failed on "Slave went offline during the build".
There are two typos in the comments (two times "teh").
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:1917
https:/
Executed test runs:
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1917
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeHintStyle.qml' |
2 | --- src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeHintStyle.qml 2016-02-16 11:10:35 +0000 |
3 | +++ src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeHintStyle.qml 2016-04-01 13:16:40 +0000 |
4 | @@ -104,8 +104,8 @@ |
5 | |
6 | Icon { |
7 | id: h1 |
8 | - width: units.gu(2) |
9 | - height: width |
10 | + width: units.gu(3) |
11 | + height: units.gu(1.5) |
12 | anchors { |
13 | centerIn: parent |
14 | topMargin: styledItem.height |
15 | |
16 | === modified file 'src/Ubuntu/Components/plugin/plugin.pri' |
17 | --- src/Ubuntu/Components/plugin/plugin.pri 2016-03-11 12:16:11 +0000 |
18 | +++ src/Ubuntu/Components/plugin/plugin.pri 2016-04-01 13:16:40 +0000 |
19 | @@ -116,7 +116,8 @@ |
20 | $$PWD/privates/ucpagewrapper_p.h \ |
21 | $$PWD/privates/ucpagewrapperincubator_p.h \ |
22 | $$PWD/privates/appheaderbase.h \ |
23 | - $$PWD/label_p.h |
24 | + $$PWD/label_p.h \ |
25 | + $$PWD/ucbottomedgeregion_p.h |
26 | |
27 | SOURCES += $$PWD/plugin.cpp \ |
28 | $$PWD/uctheme.cpp \ |
29 | |
30 | === modified file 'src/Ubuntu/Components/plugin/ucbottomedge.cpp' |
31 | --- src/Ubuntu/Components/plugin/ucbottomedge.cpp 2016-03-16 17:20:49 +0000 |
32 | +++ src/Ubuntu/Components/plugin/ucbottomedge.cpp 2016-04-01 13:16:40 +0000 |
33 | @@ -19,6 +19,7 @@ |
34 | #include "ucbottomedge_p.h" |
35 | #include "ucbottomedgestyle.h" |
36 | #include "ucbottomedgeregion.h" |
37 | +#include "ucbottomedgeregion_p.h" |
38 | #include "ucbottomedgehint_p.h" |
39 | #include "ucstyleditembase_p.h" |
40 | #include <QtQml/QQmlEngine> |
41 | @@ -43,7 +44,7 @@ |
42 | |
43 | UCBottomEdgePrivate::UCBottomEdgePrivate() |
44 | : UCStyledItemBasePrivate() |
45 | - , defaultRegion(new UCBottomEdgeRegion(nullptr, true)) |
46 | + , defaultRegion(new DefaultRegion(nullptr)) |
47 | , activeRegion(Q_NULLPTR) |
48 | , hint(new UCBottomEdgeHint) |
49 | , bottomPanel(Q_NULLPTR) |
50 | @@ -69,12 +70,8 @@ |
51 | }); |
52 | |
53 | // create default region |
54 | - // for testing purposes |
55 | - defaultRegion->setObjectName("default_BottomEdgeRegion"); |
56 | // enters in this stage when drag ratio reaches 30% of the area |
57 | - defaultRegion->m_from = 0.33; |
58 | - defaultRegion->m_to = 1.0; |
59 | - defaultRegion->attachToBottomEdge(q); |
60 | + UCBottomEdgeRegionPrivate::get(defaultRegion)->attachToBottomEdge(q); |
61 | |
62 | QObject::connect(defaultRegion, &UCBottomEdgeRegion::contentChanged, |
63 | q, &UCBottomEdge::contentChanged); |
64 | @@ -133,7 +130,7 @@ |
65 | QQml_setParent_noEvent(region, q); |
66 | // take ownership! |
67 | QQmlEngine::setObjectOwnership(region, QQmlEngine::CppOwnership); |
68 | - region->attachToBottomEdge(q); |
69 | + UCBottomEdgeRegionPrivate::get(region)->attachToBottomEdge(q); |
70 | |
71 | if (!defaultRegionsReset) { |
72 | defaultRegionsReset = true; |
73 | @@ -143,13 +140,10 @@ |
74 | // validate the region before we append |
75 | validateRegion(region); |
76 | |
77 | - // if preload is set, load content |
78 | - if (preloadContent) { |
79 | - region->loadRegionContent(); |
80 | - } |
81 | - |
82 | // append region definition |
83 | regions.append(region); |
84 | + |
85 | + LOG << "region added:" << region; |
86 | } |
87 | |
88 | // clears the custom regions list and restores the default ones |
89 | @@ -164,6 +158,8 @@ |
90 | regions.clear(); |
91 | defaultRegionsReset = false; |
92 | regions.append(defaultRegion); |
93 | + |
94 | + LOG << "regions cleared, default restored"; |
95 | } |
96 | |
97 | // validates an added region |
98 | @@ -172,7 +168,7 @@ |
99 | // we should not validate unti the bottom edge is not completed, |
100 | // property changes may invalidate the result of the validation |
101 | // also leave if the region is disabled |
102 | - if (!componentComplete || !region->m_enabled) { |
103 | + if (!componentComplete || !UCBottomEdgeRegionPrivate::get(region)->enabled) { |
104 | return; |
105 | } |
106 | Q_Q(UCBottomEdge); |
107 | @@ -187,7 +183,7 @@ |
108 | const QRectF regionRect(region->rect(boundingRect)); |
109 | for (int i = 0; i < regionsSize; ++i) { |
110 | UCBottomEdgeRegion *stackedRegion = regions[i]; |
111 | - if (region == stackedRegion || !stackedRegion->m_enabled) { |
112 | + if (region == stackedRegion || !UCBottomEdgeRegionPrivate::get(stackedRegion)->enabled) { |
113 | continue; |
114 | } |
115 | QRectF rect(stackedRegion->rect(boundingRect)); |
116 | @@ -197,7 +193,9 @@ |
117 | QRectF intersect = regionRect.intersected(stackedRegion->rect(boundingRect)); |
118 | if (!intersect.isNull()) { |
119 | qmlInfo(region) << QString("Region intersects the one from index %1 having from: %2 and to: %3") |
120 | - .arg(i).arg(stackedRegion->m_from).arg(stackedRegion->m_to); |
121 | + .arg(i) |
122 | + .arg(UCBottomEdgeRegionPrivate::get(stackedRegion)->from) |
123 | + .arg(UCBottomEdgeRegionPrivate::get(stackedRegion)->to); |
124 | } |
125 | } |
126 | } |
127 | @@ -229,6 +227,11 @@ |
128 | break; |
129 | } |
130 | } |
131 | + // if no active region is found, use the default one |
132 | + if (!newActive) { |
133 | + LOG << "no active region found, fall back to the default"; |
134 | + newActive = defaultRegion; |
135 | + } |
136 | if (newActive != activeRegion) { |
137 | setActiveRegion(newActive); |
138 | } |
139 | @@ -288,15 +291,15 @@ |
140 | void UCBottomEdgePrivate::onDragEnded() |
141 | { |
142 | // collapse if we drag downwards, or not in any active region and we did not pass 30% of the BottomEdge height |
143 | - if (dragDirection == UCBottomEdge::Downwards || (!activeRegion && dragProgress < 0.33)) { |
144 | + LOG << "direction:" << dragDirection << ", activeRegion?" << activeRegion << ", dragProgress:" << dragProgress; |
145 | + if (dragDirection == UCBottomEdge::Downwards || (activeRegion && !activeRegion->canCommit(dragProgress))) { |
146 | q_func()->collapse(); |
147 | - } else if (!activeRegion && dragProgress >= 0.33) { |
148 | - // commit if we are not in an active region but we passed 30% of the BottomEdge height |
149 | - q_func()->commit(); |
150 | - } else if (activeRegion) { |
151 | - // emit region's dragEnded first |
152 | - Q_EMIT activeRegion->dragEnded(); |
153 | - commit(activeRegion->m_to); |
154 | + } else { |
155 | + UCBottomEdgeRegion *region = activeRegion ? activeRegion : defaultRegion; |
156 | + if (region->canCommit(dragProgress)) { |
157 | + Q_EMIT region->dragEnded(); |
158 | + commit(UCBottomEdgeRegionPrivate::get(region)->to); |
159 | + } |
160 | } |
161 | } |
162 | |
163 | @@ -745,9 +748,6 @@ |
164 | { |
165 | UCStyledItemBasePrivate::completeComponentInitialization(); |
166 | Q_Q(UCBottomEdge); |
167 | - // trigger default region content loading; the default region content is |
168 | - // always pre-loaded |
169 | - defaultRegion->loadRegionContent(); |
170 | |
171 | // fix the hint's style version as that has no qmlContext of its own |
172 | // and thus import version check will fail; setting the context for |
173 | @@ -957,7 +957,7 @@ |
174 | QUrl UCBottomEdge::contentUrl() const |
175 | { |
176 | Q_D(const UCBottomEdge); |
177 | - return d->defaultRegion->m_url; |
178 | + return d->defaultRegion->url(); |
179 | } |
180 | void UCBottomEdge::setContent(const QUrl &url) |
181 | { |
182 | @@ -973,7 +973,7 @@ |
183 | QQmlComponent *UCBottomEdge::contentComponent() const |
184 | { |
185 | Q_D(const UCBottomEdge); |
186 | - return d->defaultRegion->m_component; |
187 | + return d->defaultRegion->component(); |
188 | } |
189 | void UCBottomEdge::setContentComponent(QQmlComponent *component) |
190 | { |
191 | @@ -1002,6 +1002,11 @@ |
192 | void UCBottomEdge::commit() |
193 | { |
194 | Q_D(UCBottomEdge); |
195 | + // make sure that teh default region's content is loaded! |
196 | + if (!d->activeRegion || d->activeRegion == d->defaultRegion) { |
197 | + // make sure teh default is the active region |
198 | + d->setActiveRegion(d->defaultRegion); |
199 | + } |
200 | d->commit(1.0); |
201 | } |
202 | |
203 | @@ -1111,17 +1116,14 @@ |
204 | // as default one is always preloaded |
205 | for (int i = 0; i < d->regions.size(); i++) { |
206 | UCBottomEdgeRegion *region = d->regions[i]; |
207 | - if (region == d->defaultRegion) { |
208 | - continue; |
209 | - } |
210 | - region->loadRegionContent(); |
211 | + UCBottomEdgeRegionPrivate::get(region)->loadRegionContent(); |
212 | } |
213 | } else { |
214 | // discard all inactive regions content, except default one |
215 | for (int i = 0; i < d->regions.size(); i++) { |
216 | UCBottomEdgeRegion *region = d->regions[i]; |
217 | - if (region != d->activeRegion && region != d->defaultRegion) { |
218 | - region->discardRegionContent(); |
219 | + if (region != d->activeRegion) { |
220 | + UCBottomEdgeRegionPrivate::get(region)->discardRegionContent(); |
221 | } |
222 | } |
223 | } |
224 | @@ -1138,11 +1140,11 @@ |
225 | { |
226 | QQuickItem *newContent = nullptr; |
227 | if (activeRegion) { |
228 | - newContent = activeRegion->regionContent(); |
229 | + newContent = UCBottomEdgeRegionPrivate::get(activeRegion)->contentItem; |
230 | LOG << "ACTIVE REGION CONTENT" << activeRegion->objectName() << newContent; |
231 | } |
232 | if (!newContent) { |
233 | - newContent = defaultRegion->regionContent(); |
234 | + newContent = UCBottomEdgeRegionPrivate::get(defaultRegion)->contentItem; |
235 | LOG << "USING DEFAULT" << newContent; |
236 | } |
237 | resetCurrentContent(newContent); |
238 | @@ -1164,7 +1166,7 @@ |
239 | |
240 | if (!newContent) { |
241 | // try to use the default one |
242 | - newContent = defaultRegion->regionContent(); |
243 | + newContent = UCBottomEdgeRegionPrivate::get(defaultRegion)->contentItem; |
244 | } |
245 | |
246 | // if it is still null, leave - we may not have default content at all! |
247 | |
248 | === modified file 'src/Ubuntu/Components/plugin/ucbottomedgeregion.cpp' |
249 | --- src/Ubuntu/Components/plugin/ucbottomedgeregion.cpp 2016-02-20 15:11:02 +0000 |
250 | +++ src/Ubuntu/Components/plugin/ucbottomedgeregion.cpp 2016-04-01 13:16:40 +0000 |
251 | @@ -19,9 +19,31 @@ |
252 | #include "ucbottomedge.h" |
253 | #include "ucbottomedge_p.h" |
254 | #include "ucbottomedgeregion.h" |
255 | +#include "ucbottomedgeregion_p.h" |
256 | #include "propertychange_p.h" |
257 | #include <QtQml/private/qqmlproperty_p.h> |
258 | |
259 | + |
260 | +UCBottomEdgeRegionPrivate::UCBottomEdgeRegionPrivate() |
261 | + : QObjectPrivate() |
262 | + , bottomEdge(Q_NULLPTR) |
263 | + , component(Q_NULLPTR) |
264 | + , contentItem(Q_NULLPTR) |
265 | + , from(0.0) |
266 | + , to(-1.0) |
267 | + , enabled(true) |
268 | + , active(false) |
269 | +{ |
270 | +} |
271 | + |
272 | +void UCBottomEdgeRegionPrivate::init() |
273 | +{ |
274 | + Q_Q(UCBottomEdgeRegion); |
275 | + bottomEdge = qobject_cast<UCBottomEdge*>(parent); |
276 | + QObject::connect(&loader, SIGNAL(loadingStatus(AsyncLoader::LoadingStatus,QObject*)), |
277 | + q, SLOT(onLoaderStatusChanged(AsyncLoader::LoadingStatus,QObject*))); |
278 | +} |
279 | + |
280 | /*! |
281 | * \qmltype BottomEdgeRegion |
282 | * \instantiates UCBottomEdgeRegion |
283 | @@ -91,131 +113,141 @@ |
284 | * properties will cause unpredictable results. |
285 | */ |
286 | |
287 | -UCBottomEdgeRegion::UCBottomEdgeRegion(QObject *parent, bool isDefault) |
288 | - : QObject(parent) |
289 | - , m_bottomEdge(qobject_cast<UCBottomEdge*>(parent)) |
290 | - , m_component(Q_NULLPTR) |
291 | - , m_contentItem(Q_NULLPTR) |
292 | - , m_from(0.0) |
293 | - , m_to(-1.0) |
294 | - , m_enabled(true) |
295 | - , m_active(false) |
296 | - , m_default(isDefault) |
297 | -{ |
298 | - connect(&m_loader, &UbuntuToolkit::AsyncLoader::loadingStatus, |
299 | - this, &UCBottomEdgeRegion::onLoaderStatusChanged); |
300 | -} |
301 | - |
302 | -void UCBottomEdgeRegion::attachToBottomEdge(UCBottomEdge *bottomEdge) |
303 | -{ |
304 | - QQml_setParent_noEvent(this, bottomEdge); |
305 | - m_bottomEdge = bottomEdge; |
306 | +UCBottomEdgeRegion::UCBottomEdgeRegion(QObject *parent) |
307 | + : QObject(*(new UCBottomEdgeRegionPrivate), parent) |
308 | +{ |
309 | + d_func()->init(); |
310 | +} |
311 | + |
312 | +UCBottomEdgeRegion::UCBottomEdgeRegion(UCBottomEdgeRegionPrivate &dd, QObject *parent) |
313 | + : QObject(dd, parent) |
314 | +{ |
315 | + d_func()->init(); |
316 | +} |
317 | + |
318 | +void UCBottomEdgeRegionPrivate::attachToBottomEdge(UCBottomEdge *bottomEdge) |
319 | +{ |
320 | + Q_Q(UCBottomEdgeRegion); |
321 | + QQml_setParent_noEvent(q, bottomEdge); |
322 | + this->bottomEdge = bottomEdge; |
323 | // adjust to property value if not set yet |
324 | - if (m_to <= 0.0) { |
325 | - m_to = 1.0; |
326 | - Q_EMIT toChanged(); |
327 | + if (to <= 0.0) { |
328 | + to = 1.0; |
329 | + Q_EMIT q->toChanged(); |
330 | + } |
331 | + |
332 | + // if preload is set, load content |
333 | + if (bottomEdge->preloadContent()) { |
334 | + loadRegionContent(); |
335 | } |
336 | } |
337 | |
338 | bool UCBottomEdgeRegion::contains(qreal dragRatio) |
339 | { |
340 | - return (m_enabled && (m_from < m_to) && dragRatio >= m_from && dragRatio <= m_to); |
341 | + Q_D(UCBottomEdgeRegion); |
342 | + return (d->enabled && (d->from < d->to) && dragRatio >= d->from && dragRatio <= d->to); |
343 | +} |
344 | + |
345 | +// Called when drag ends to check whether content can be committed. The default |
346 | +// implementation returns true. |
347 | +bool UCBottomEdgeRegion::canCommit(qreal dragRatio) |
348 | +{ |
349 | + Q_UNUSED(dragRatio); |
350 | + return true; |
351 | } |
352 | |
353 | void UCBottomEdgeRegion::enter() |
354 | { |
355 | - m_active = true; |
356 | + Q_D(UCBottomEdgeRegion); |
357 | + d->active = true; |
358 | Q_EMIT entered(); |
359 | |
360 | LOG << "ENTER REGION" << objectName(); |
361 | // if preloaded, or default(?), set the content |
362 | - if (m_bottomEdge->preloadContent() || m_default) { |
363 | - if (m_loader.status() == UbuntuToolkit::AsyncLoader::Ready) { |
364 | + if (d->bottomEdge->preloadContent()) { |
365 | + if (d->loader.status() == UbuntuToolkit::AsyncLoader::Ready) { |
366 | LOG << "SET REGION CONTENT" << objectName(); |
367 | - UCBottomEdgePrivate::get(m_bottomEdge)->setCurrentContent(); |
368 | + UCBottomEdgePrivate::get(d->bottomEdge)->setCurrentContent(); |
369 | } |
370 | } else { |
371 | // initiate loading, component has priority |
372 | - loadRegionContent(); |
373 | + d->loadRegionContent(); |
374 | } |
375 | } |
376 | |
377 | void UCBottomEdgeRegion::exit() |
378 | { |
379 | - m_active = false; |
380 | + Q_D(UCBottomEdgeRegion); |
381 | + d->active = false; |
382 | Q_EMIT exited(); |
383 | |
384 | // detach content from BottomEdge |
385 | LOG << "EXIT REGION" << objectName(); |
386 | - UCBottomEdgePrivate::get(m_bottomEdge)->resetCurrentContent(nullptr); |
387 | + UCBottomEdgePrivate::get(d->bottomEdge)->resetCurrentContent(nullptr); |
388 | |
389 | // then cleanup |
390 | - if (!m_contentItem) { |
391 | + if (!d->contentItem) { |
392 | return; |
393 | } |
394 | LOG << "RESET REGION CONTENT" << objectName(); |
395 | - if (!m_bottomEdge->preloadContent()) { |
396 | + if (!d->bottomEdge->preloadContent()) { |
397 | LOG << "DISCARD REGION CONTENT" << objectName(); |
398 | - discardRegionContent(); |
399 | + d->discardRegionContent(); |
400 | } |
401 | } |
402 | |
403 | const QRectF UCBottomEdgeRegion::rect(const QRectF &bottomEdgeRect) |
404 | { |
405 | + Q_D(UCBottomEdgeRegion); |
406 | QRectF regionRect( |
407 | - bottomEdgeRect.topLeft() + QPointF(0, bottomEdgeRect.height() * (1.0 - m_to)), |
408 | - QSizeF(bottomEdgeRect.width(), bottomEdgeRect.height() * (m_to - m_from))); |
409 | + bottomEdgeRect.topLeft() + QPointF(0, bottomEdgeRect.height() * (1.0 - d->to)), |
410 | + QSizeF(bottomEdgeRect.width(), bottomEdgeRect.height() * (d->to - d->from))); |
411 | return regionRect; |
412 | } |
413 | |
414 | -void UCBottomEdgeRegion::loadRegionContent() |
415 | +void UCBottomEdgeRegionPrivate::loadRegionContent() |
416 | { |
417 | - if (!m_enabled) { |
418 | + if (!enabled) { |
419 | return; |
420 | } |
421 | - LOG << "LOAD REGION CONTENT" << objectName(); |
422 | - if (m_component) { |
423 | + LOG << "LOAD REGION CONTENT" << q_func()->objectName() << contentItem; |
424 | + if (component) { |
425 | loadContent(LoadingComponent); |
426 | - } else if (m_url.isValid()) { |
427 | + } else if (url.isValid()) { |
428 | loadContent(LoadingUrl); |
429 | } |
430 | } |
431 | |
432 | -void UCBottomEdgeRegion::loadContent(LoadingType type) |
433 | +void UCBottomEdgeRegionPrivate::loadContent(LoadingType type) |
434 | { |
435 | // we must delete the previous content before we (re)initiate loading |
436 | - if (m_contentItem) { |
437 | - m_contentItem->deleteLater();; |
438 | - m_contentItem = nullptr; |
439 | + if (contentItem) { |
440 | + contentItem->deleteLater();; |
441 | + contentItem = nullptr; |
442 | } |
443 | // no need to create new context as we do not set any context properties |
444 | // for which we would need one |
445 | switch (type) { |
446 | case LoadingUrl: |
447 | - m_loader.load(m_url, qmlContext(m_bottomEdge)); |
448 | + loader.load(url, qmlContext(bottomEdge)); |
449 | return; |
450 | case LoadingComponent: |
451 | - m_loader.load(m_component, qmlContext(m_bottomEdge)); |
452 | + loader.load(component, qmlContext(bottomEdge)); |
453 | return; |
454 | } |
455 | } |
456 | |
457 | -void UCBottomEdgeRegion::discardRegionContent() |
458 | +void UCBottomEdgeRegionPrivate::discardRegionContent() |
459 | { |
460 | - m_loader.reset(); |
461 | - if (m_contentItem) { |
462 | - LOG << "DISCARD CONTENT" << objectName(); |
463 | - m_contentItem->deleteLater(); |
464 | + loader.reset(); |
465 | + if (contentItem) { |
466 | + LOG << "DISCARD CONTENT" << q_func()->objectName(); |
467 | + contentItem->deleteLater(); |
468 | } |
469 | - m_contentItem = nullptr; |
470 | -} |
471 | - |
472 | -QQuickItem *UCBottomEdgeRegion::regionContent() |
473 | -{ |
474 | - return m_contentItem; |
475 | -} |
476 | - |
477 | -void UCBottomEdgeRegion::onLoaderStatusChanged(UbuntuToolkit::AsyncLoader::LoadingStatus status, QObject *object) |
478 | + contentItem = nullptr; |
479 | +} |
480 | + |
481 | +void UCBottomEdgeRegionPrivate::onLoaderStatusChanged(AsyncLoader::LoadingStatus status, QObject *object) |
482 | { |
483 | bool emitChange = false; |
484 | LOG << "STATUS" << status << object; |
485 | @@ -223,28 +255,28 @@ |
486 | // if we are no longer active, no need to continue, and discard content |
487 | // this may occur when the component was still in Compiling state while |
488 | // the region was exited, therefore reset() could not cancel the operation. |
489 | - if (!m_active && !m_default && !m_bottomEdge->preloadContent()) { |
490 | - LOG << "DELETE REGION CONTENT" << objectName(); |
491 | + if (!active && !bottomEdge->preloadContent()) { |
492 | + LOG << "DELETE REGION CONTENT" << q_func()->objectName(); |
493 | object->deleteLater(); |
494 | return; |
495 | } |
496 | - m_contentItem = qobject_cast<QQuickItem*>(object); |
497 | - emitChange = m_active || m_default; |
498 | + contentItem = qobject_cast<QQuickItem*>(object); |
499 | + emitChange = active; |
500 | } |
501 | |
502 | if (status == UbuntuToolkit::AsyncLoader::Reset) { |
503 | // de-parent first |
504 | - if (m_contentItem) { |
505 | - m_contentItem->setParentItem(nullptr); |
506 | - LOG << "RESET CONTENT" << objectName(); |
507 | - m_contentItem->deleteLater(); |
508 | + if (contentItem) { |
509 | + contentItem->setParentItem(nullptr); |
510 | + LOG << "RESET CONTENT" << q_func()->objectName(); |
511 | + contentItem->deleteLater(); |
512 | } |
513 | - m_contentItem = nullptr; |
514 | + contentItem = nullptr; |
515 | emitChange = true; |
516 | } |
517 | |
518 | - if (emitChange && m_bottomEdge && m_active) { |
519 | - UCBottomEdgePrivate::get(m_bottomEdge)->setCurrentContent(); |
520 | + if (emitChange && bottomEdge && active) { |
521 | + UCBottomEdgePrivate::get(bottomEdge)->setCurrentContent(); |
522 | } |
523 | } |
524 | |
525 | @@ -253,24 +285,30 @@ |
526 | * Enables the section. Disabled sections do not trigger nor change the BottomEdge |
527 | * content. Defaults to false. |
528 | */ |
529 | +bool UCBottomEdgeRegion::enabled() const |
530 | +{ |
531 | + Q_D(const UCBottomEdgeRegion); |
532 | + return d->enabled; |
533 | +} |
534 | void UCBottomEdgeRegion::setEnabled(bool enabled) |
535 | { |
536 | - if (enabled == m_enabled) { |
537 | + Q_D(UCBottomEdgeRegion); |
538 | + if (enabled == d->enabled) { |
539 | return; |
540 | } |
541 | - m_enabled = enabled; |
542 | - if (m_bottomEdge) { |
543 | - UCBottomEdgePrivate::get(m_bottomEdge)->validateRegion(this); |
544 | + d->enabled = enabled; |
545 | + if (d->bottomEdge) { |
546 | + UCBottomEdgePrivate::get(d->bottomEdge)->validateRegion(this); |
547 | + // load content if preload is set |
548 | + if (d->bottomEdge->preloadContent()) { |
549 | + if (!d->enabled) { |
550 | + d->discardRegionContent(); |
551 | + } else { |
552 | + d->loadRegionContent(); |
553 | + } |
554 | + } |
555 | } |
556 | |
557 | - // load content if preload is set |
558 | - if (m_bottomEdge->preloadContent()) { |
559 | - if (!m_enabled) { |
560 | - discardRegionContent(); |
561 | - } else { |
562 | - loadRegionContent(); |
563 | - } |
564 | - } |
565 | Q_EMIT enabledChanged(); |
566 | } |
567 | |
568 | @@ -279,14 +317,20 @@ |
569 | * Specifies the starting ratio of the bottom erge area. The value must be bigger |
570 | * or equal to 0 but strictly smaller than \l to. Defaults to 0.0. |
571 | */ |
572 | +qreal UCBottomEdgeRegion::from() const |
573 | +{ |
574 | + Q_D(const UCBottomEdgeRegion); |
575 | + return d->from; |
576 | +} |
577 | void UCBottomEdgeRegion::setFrom(qreal from) |
578 | { |
579 | - if (from == m_from) { |
580 | + Q_D(UCBottomEdgeRegion); |
581 | + if (from == d->from) { |
582 | return; |
583 | } |
584 | - m_from = from; |
585 | - if (m_bottomEdge) { |
586 | - UCBottomEdgePrivate::get(m_bottomEdge)->validateRegion(this); |
587 | + d->from = from; |
588 | + if (d->bottomEdge) { |
589 | + UCBottomEdgePrivate::get(d->bottomEdge)->validateRegion(this); |
590 | } |
591 | Q_EMIT fromChanged(); |
592 | } |
593 | @@ -299,14 +343,20 @@ |
594 | * will result in exposing the bottom edge content only till the ration specified |
595 | * by this property. |
596 | */ |
597 | +qreal UCBottomEdgeRegion::to() const |
598 | +{ |
599 | + Q_D(const UCBottomEdgeRegion); |
600 | + return d->to; |
601 | +} |
602 | void UCBottomEdgeRegion::setTo(qreal to) |
603 | { |
604 | - if (to == m_to) { |
605 | + Q_D(UCBottomEdgeRegion); |
606 | + if (to == d->to) { |
607 | return; |
608 | } |
609 | - m_to = to; |
610 | - if (m_bottomEdge) { |
611 | - UCBottomEdgePrivate::get(m_bottomEdge)->validateRegion(this); |
612 | + d->to = to; |
613 | + if (d->bottomEdge) { |
614 | + UCBottomEdgePrivate::get(d->bottomEdge)->validateRegion(this); |
615 | } |
616 | Q_EMIT toChanged(); |
617 | } |
618 | @@ -318,16 +368,22 @@ |
619 | * when the drag gesture enters the section area. The orginal value will be restored |
620 | * once the gesture leaves the section area. |
621 | */ |
622 | +QUrl UCBottomEdgeRegion::url() const |
623 | +{ |
624 | + Q_D(const UCBottomEdgeRegion); |
625 | + return d->url; |
626 | +} |
627 | void UCBottomEdgeRegion::setUrl(const QUrl &url) |
628 | { |
629 | - if (m_url == url) { |
630 | + Q_D(UCBottomEdgeRegion); |
631 | + if (d->url == url) { |
632 | return; |
633 | } |
634 | - m_url = url; |
635 | - Q_EMIT contentChanged(m_url); |
636 | + d->url = url; |
637 | + Q_EMIT contentChanged(d->url); |
638 | // invoke loader if the preload is set |
639 | - if (m_bottomEdge && (m_bottomEdge->preloadContent() || m_default) && !m_url.isValid()) { |
640 | - loadContent(LoadingUrl); |
641 | + if (d->bottomEdge && (d->bottomEdge->preloadContent()) && !d->url.isValid()) { |
642 | + d->loadContent(UCBottomEdgeRegionPrivate::LoadingUrl); |
643 | } |
644 | } |
645 | |
646 | @@ -338,16 +394,22 @@ |
647 | * when the drag gesture enters the section area. The orginal value will be restored |
648 | * once the gesture leaves the section area. |
649 | */ |
650 | +QQmlComponent *UCBottomEdgeRegion::component() const |
651 | +{ |
652 | + Q_D(const UCBottomEdgeRegion); |
653 | + return d->component; |
654 | +} |
655 | void UCBottomEdgeRegion::setComponent(QQmlComponent *component) |
656 | { |
657 | - if (m_component == component) { |
658 | + Q_D(UCBottomEdgeRegion); |
659 | + if (d->component == component) { |
660 | return; |
661 | } |
662 | - m_component = component; |
663 | - Q_EMIT contentComponentChanged(m_component); |
664 | + d->component = component; |
665 | + Q_EMIT contentComponentChanged(d->component); |
666 | // invoke loader if the preload is set |
667 | - if (m_bottomEdge && (m_bottomEdge->preloadContent() || m_default) && m_component) { |
668 | - loadContent(LoadingComponent); |
669 | + if (d->bottomEdge && d->bottomEdge->preloadContent() && d->component) { |
670 | + d->loadContent(UCBottomEdgeRegionPrivate::LoadingComponent); |
671 | } |
672 | } |
673 | |
674 | @@ -366,3 +428,40 @@ |
675 | * \qmlsignal void BottomEdgeRegion::dragEnded() |
676 | * Signal triggered when the drag ends within the active bottom edge section area. |
677 | */ |
678 | + |
679 | +// default region |
680 | + |
681 | +DefaultRegionPrivate::DefaultRegionPrivate() |
682 | +{ |
683 | +} |
684 | + |
685 | +void DefaultRegionPrivate::loadRegionContent() |
686 | +{ |
687 | + if (contentItem) { |
688 | + LOG << "region content loaded, return"; |
689 | + return; |
690 | + } |
691 | + UCBottomEdgeRegionPrivate::loadRegionContent(); |
692 | +} |
693 | + |
694 | +void DefaultRegionPrivate::discardRegionContent() |
695 | +{ |
696 | + // do nothing, do not cleanup the content! |
697 | + LOG << "suppress region discarding!"; |
698 | +} |
699 | + |
700 | +DefaultRegion::DefaultRegion(UCBottomEdge *parent) |
701 | + : UCBottomEdgeRegion(*(new DefaultRegionPrivate), parent) |
702 | +{ |
703 | + UCBottomEdgeRegionPrivate *d = UCBottomEdgeRegionPrivate::get(this); |
704 | + d->from = 0.0; |
705 | + d->to = 1.0; |
706 | + setObjectName("default_BottomEdgeRegion"); |
707 | +} |
708 | + |
709 | +bool DefaultRegion::canCommit(qreal dragRatio) |
710 | +{ |
711 | + return (dragRatio >= 0.33); |
712 | +} |
713 | + |
714 | +#include "moc_ucbottomedgeregion.cpp" |
715 | |
716 | === modified file 'src/Ubuntu/Components/plugin/ucbottomedgeregion.h' |
717 | --- src/Ubuntu/Components/plugin/ucbottomedgeregion.h 2016-02-20 15:11:02 +0000 |
718 | +++ src/Ubuntu/Components/plugin/ucbottomedgeregion.h 2016-04-01 13:16:40 +0000 |
719 | @@ -29,46 +29,39 @@ |
720 | class UCBottomEdge; |
721 | class QQmlComponent; |
722 | class PropertyChange; |
723 | +class UCBottomEdgeRegionPrivate; |
724 | class UCBottomEdgeRegion : public QObject |
725 | { |
726 | Q_OBJECT |
727 | |
728 | - Q_PROPERTY(bool enabled MEMBER m_enabled WRITE setEnabled NOTIFY enabledChanged FINAL) |
729 | - Q_PROPERTY(qreal from MEMBER m_from WRITE setFrom NOTIFY fromChanged FINAL) |
730 | - Q_PROPERTY(qreal to MEMBER m_to WRITE setTo NOTIFY toChanged FINAL) |
731 | - Q_PROPERTY(QUrl contentUrl MEMBER m_url WRITE setUrl NOTIFY contentChanged FINAL) |
732 | - Q_PROPERTY(QQmlComponent* contentComponent MEMBER m_component WRITE setComponent NOTIFY contentComponentChanged FINAL) |
733 | + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL) |
734 | + Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged FINAL) |
735 | + Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged FINAL) |
736 | + Q_PROPERTY(QUrl contentUrl READ url WRITE setUrl NOTIFY contentChanged FINAL) |
737 | + Q_PROPERTY(QQmlComponent* contentComponent READ component WRITE setComponent NOTIFY contentComponentChanged FINAL) |
738 | public: |
739 | - explicit UCBottomEdgeRegion(QObject *parent = 0, bool isDefault = false); |
740 | - void attachToBottomEdge(UCBottomEdge *bottomEdge); |
741 | + explicit UCBottomEdgeRegion(QObject *parent = 0); |
742 | |
743 | // used internally |
744 | + QUrl url() const; |
745 | void setUrl(const QUrl &url); |
746 | + QQmlComponent *component() const; |
747 | void setComponent(QQmlComponent *component); |
748 | + qreal from() const; |
749 | void setFrom(qreal from); |
750 | + qreal to() const; |
751 | void setTo(qreal to); |
752 | + bool enabled() const; |
753 | void setEnabled(bool enabled); |
754 | + |
755 | + // support API |
756 | bool contains(qreal dragRatio); |
757 | + virtual bool canCommit(qreal dragRatio); |
758 | void enter(); |
759 | void exit(); |
760 | const QRectF rect(const QRectF &bottomEdgeRect); |
761 | |
762 | // not exposed to QML |
763 | - bool isActive() |
764 | - { |
765 | - return m_active; |
766 | - } |
767 | - bool isDefault() |
768 | - { |
769 | - return m_default; |
770 | - } |
771 | - |
772 | - QQuickItem *regionContent(); |
773 | - inline const UbuntuToolkit::AsyncLoader *loader() |
774 | - { |
775 | - return const_cast<const UbuntuToolkit::AsyncLoader*>(&m_loader); |
776 | - } |
777 | - |
778 | Q_SIGNALS: |
779 | void enabledChanged(); |
780 | void fromChanged(); |
781 | @@ -81,29 +74,10 @@ |
782 | void dragEnded(); |
783 | |
784 | protected: |
785 | - enum LoadingType { |
786 | - LoadingUrl, |
787 | - LoadingComponent |
788 | - }; |
789 | - UbuntuToolkit::AsyncLoader m_loader; |
790 | - QUrl m_url; |
791 | - QPointer<UCBottomEdge> m_bottomEdge; |
792 | - QQmlComponent *m_component; |
793 | - QQuickItem *m_contentItem; |
794 | - qreal m_from; |
795 | - qreal m_to; |
796 | - bool m_enabled:1; |
797 | - bool m_active:1; |
798 | - const bool m_default:1; |
799 | - |
800 | - friend class UCBottomEdge; |
801 | - friend class UCBottomEdgePrivate; |
802 | - friend class tst_BottomEdge; |
803 | - |
804 | - void loadRegionContent(); |
805 | - void discardRegionContent(); |
806 | - void loadContent(LoadingType type); |
807 | - Q_SLOT void onLoaderStatusChanged(UbuntuToolkit::AsyncLoader::LoadingStatus,QObject*); |
808 | + UCBottomEdgeRegion(UCBottomEdgeRegionPrivate &dd, QObject *parent); |
809 | +private: |
810 | + Q_DECLARE_PRIVATE(UCBottomEdgeRegion) |
811 | + Q_PRIVATE_SLOT(d_func(), void onLoaderStatusChanged(AsyncLoader::LoadingStatus,QObject*)) |
812 | }; |
813 | |
814 | #endif // UCBOTTOMEDGEREGION_H |
815 | |
816 | === added file 'src/Ubuntu/Components/plugin/ucbottomedgeregion_p.h' |
817 | --- src/Ubuntu/Components/plugin/ucbottomedgeregion_p.h 1970-01-01 00:00:00 +0000 |
818 | +++ src/Ubuntu/Components/plugin/ucbottomedgeregion_p.h 2016-04-01 13:16:40 +0000 |
819 | @@ -0,0 +1,84 @@ |
820 | +/* |
821 | + * Copyright 2016 Canonical Ltd. |
822 | + * |
823 | + * This program is free software; you can redistribute it and/or modify |
824 | + * it under the terms of the GNU Lesser General Public License as published by |
825 | + * the Free Software Foundation; version 3. |
826 | + * |
827 | + * This program is distributed in the hope that it will be useful, |
828 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
829 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
830 | + * GNU Lesser General Public License for more details. |
831 | + * |
832 | + * You should have received a copy of the GNU Lesser General Public License |
833 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
834 | + * |
835 | + * Author: Zsombor Egri <zsombor.egri@canonical.com> |
836 | + */ |
837 | + |
838 | +#ifndef UCBOTTOMEDGEREGION_P |
839 | +#define UCBOTTOMEDGEREGION_P |
840 | + |
841 | +#include "ucbottomedgeregion.h" |
842 | +#include <AsyncLoader> |
843 | +#include <QtCore/private/qobject_p.h> |
844 | + |
845 | +using namespace UbuntuToolkit; |
846 | + |
847 | +class UCBottomEdgeRegionPrivate : public QObjectPrivate |
848 | +{ |
849 | + Q_DECLARE_PUBLIC(UCBottomEdgeRegion) |
850 | +public: |
851 | + enum LoadingType { |
852 | + LoadingUrl, |
853 | + LoadingComponent |
854 | + }; |
855 | + |
856 | + UCBottomEdgeRegionPrivate(); |
857 | + void init(); |
858 | + |
859 | + static UCBottomEdgeRegionPrivate *get(UCBottomEdgeRegion *that) |
860 | + { |
861 | + return that->d_func(); |
862 | + } |
863 | + |
864 | + void attachToBottomEdge(UCBottomEdge *bottomEdge); |
865 | + virtual void loadRegionContent(); |
866 | + virtual void discardRegionContent(); |
867 | + void loadContent(LoadingType type); |
868 | + |
869 | + void onLoaderStatusChanged(AsyncLoader::LoadingStatus,QObject*); |
870 | + |
871 | + UbuntuToolkit::AsyncLoader loader; |
872 | + QUrl url; |
873 | + QPointer<UCBottomEdge> bottomEdge; |
874 | + QQmlComponent *component; |
875 | + QQuickItem *contentItem; |
876 | + qreal from; |
877 | + qreal to; |
878 | + bool enabled:1; |
879 | + bool active:1; |
880 | +}; |
881 | + |
882 | +class DefaultRegionPrivate; |
883 | +class DefaultRegion : public UCBottomEdgeRegion |
884 | +{ |
885 | + Q_OBJECT |
886 | +public: |
887 | + DefaultRegion(UCBottomEdge *parent); |
888 | + bool canCommit(qreal dragRatio) Q_DECL_OVERRIDE; |
889 | +private: |
890 | + Q_DECLARE_PRIVATE(DefaultRegion) |
891 | +}; |
892 | + |
893 | +class DefaultRegionPrivate : public UCBottomEdgeRegionPrivate |
894 | +{ |
895 | + Q_DECLARE_PUBLIC(DefaultRegion) |
896 | +public: |
897 | + DefaultRegionPrivate(); |
898 | + void loadRegionContent() Q_DECL_OVERRIDE; |
899 | + void discardRegionContent() Q_DECL_OVERRIDE; |
900 | +}; |
901 | + |
902 | +#endif // UCBOTTOMEDGEREGION_P |
903 | + |
904 | |
905 | === modified file 'src/Ubuntu/UbuntuToolkit/asyncloader.h' |
906 | --- src/Ubuntu/UbuntuToolkit/asyncloader.h 2016-02-25 14:30:46 +0000 |
907 | +++ src/Ubuntu/UbuntuToolkit/asyncloader.h 2016-04-01 13:16:40 +0000 |
908 | @@ -52,7 +52,7 @@ |
909 | void forceCompletion(); |
910 | |
911 | Q_SIGNALS: |
912 | - void loadingStatus(LoadingStatus status, QObject *object); |
913 | + void loadingStatus(AsyncLoader::LoadingStatus status, QObject *object); |
914 | |
915 | protected: |
916 | Q_DECLARE_PRIVATE(AsyncLoader) |
917 | |
918 | === added file 'tests/unit_x11/tst_bottomedge/BottomEdgeWithAction.qml' |
919 | --- tests/unit_x11/tst_bottomedge/BottomEdgeWithAction.qml 1970-01-01 00:00:00 +0000 |
920 | +++ tests/unit_x11/tst_bottomedge/BottomEdgeWithAction.qml 2016-04-01 13:16:40 +0000 |
921 | @@ -0,0 +1,42 @@ |
922 | +/* |
923 | + * Copyright 2016 Canonical Ltd. |
924 | + * |
925 | + * This program is free software; you can redistribute it and/or modify |
926 | + * it under the terms of the GNU Lesser General Public License as published by |
927 | + * the Free Software Foundation; version 3. |
928 | + * |
929 | + * This program is distributed in the hope that it will be useful, |
930 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
931 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
932 | + * GNU Lesser General Public License for more details. |
933 | + * |
934 | + * You should have received a copy of the GNU Lesser General Public License |
935 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
936 | + * |
937 | + */ |
938 | + |
939 | +import QtQuick 2.4 |
940 | +import Ubuntu.Components 1.3 |
941 | + |
942 | +Item { |
943 | + id: holder |
944 | + width: units.gu(40) |
945 | + height: units.gu(71) |
946 | + |
947 | + BottomEdge { |
948 | + id: bottomEdge |
949 | + height: parent.height |
950 | + hint.action: Action { |
951 | + text: "Test Bottom" |
952 | + onTriggered: bottomEdge.commit() |
953 | + } |
954 | + |
955 | + objectName: "testItem" |
956 | + contentComponent: Rectangle { |
957 | + objectName: "default" |
958 | + width: bottomEdge.width |
959 | + height: bottomEdge.height |
960 | + color: UbuntuColors.blue |
961 | + } |
962 | + } |
963 | +} |
964 | |
965 | === modified file 'tests/unit_x11/tst_bottomedge/tst_bottomedge.cpp' |
966 | --- tests/unit_x11/tst_bottomedge/tst_bottomedge.cpp 2016-03-15 12:05:29 +0000 |
967 | +++ tests/unit_x11/tst_bottomedge/tst_bottomedge.cpp 2016-04-01 13:16:40 +0000 |
968 | @@ -18,6 +18,7 @@ |
969 | #include <QtTest/QtTest> |
970 | #include "ucbottomedge.h" |
971 | #include "ucbottomedgeregion.h" |
972 | +#include "ucbottomedgeregion_p.h" |
973 | #include "ucbottomedge_p.h" |
974 | #include "ucbottomedgehint.h" |
975 | #include "private/ucswipearea_p.h" |
976 | @@ -143,8 +144,8 @@ |
977 | QVERIFY(test->regions("testItem")); |
978 | QCOMPARE(test->regions("testItem")->size(), 1); |
979 | QCOMPARE(test->regionAt("testItem", 0)->objectName(), QString("default_BottomEdgeRegion")); |
980 | - QCOMPARE(test->regionAt("testItem", 0)->m_from, 0.33); |
981 | - QCOMPARE(test->regionAt("testItem", 0)->m_to, 1.0); |
982 | + QCOMPARE(UCBottomEdgeRegionPrivate::get(test->regionAt("testItem", 0))->from, 0.0); |
983 | + QCOMPARE(UCBottomEdgeRegionPrivate::get(test->regionAt("testItem", 0))->to, 1.0); |
984 | QVERIFY(!test->testItem()->activeRegion()); |
985 | QVERIFY(!test->testItem()->preloadContent()); |
986 | } |
987 | @@ -526,12 +527,12 @@ |
988 | << "AddCustomRegionOwnedByOtherBottomEdge.qml" |
989 | << "QML BottomEdge: Cannot reuse region owned by other BottomEdge components" |
990 | // we should have the default region still |
991 | - << 0.33 << 1.0 << "default_BottomEdgeRegion"; |
992 | + << 0.0 << 1.0 << "default_BottomEdgeRegion"; |
993 | QTest::newRow("clear") |
994 | << "ClearCustomRegions.qml" |
995 | << QString() |
996 | // we should have the default region back |
997 | - << 0.33 << 1.0 << "default_BottomEdgeRegion"; |
998 | + << 0.0 << 1.0 << "default_BottomEdgeRegion"; |
999 | } |
1000 | |
1001 | void test_region_operations() |
1002 | @@ -553,8 +554,8 @@ |
1003 | QCOMPARE(privateBottomEdge->regions.size(), 1); |
1004 | UCBottomEdgeRegion *region = privateBottomEdge->regions[0]; |
1005 | QVERIFY(region); |
1006 | - QCOMPARE(region->m_from, xFrom); |
1007 | - QCOMPARE(region->m_to, xTo); |
1008 | + QCOMPARE(UCBottomEdgeRegionPrivate::get(region)->from, xFrom); |
1009 | + QCOMPARE(UCBottomEdgeRegionPrivate::get(region)->to, xTo); |
1010 | QCOMPARE(region->objectName(), xName); |
1011 | } |
1012 | |
1013 | @@ -576,9 +577,9 @@ |
1014 | } |
1015 | QTest::qWait(20); |
1016 | UCTestExtras::touchRelease(0, bottomEdge, movePos); |
1017 | - // we should have had 3 active region changes by now |
1018 | - // null -> region #0 -> region #1 -> null |
1019 | - QCOMPARE(spy.count(), 3); |
1020 | + // we should have had 4 active region changes by now |
1021 | + // null -> defaultRegion -> region #0 -> region #1 -> defaultRegion |
1022 | + QCOMPARE(spy.count(), 4); |
1023 | } |
1024 | |
1025 | void test_region_signals_emitted_data() |
1026 | @@ -598,8 +599,8 @@ |
1027 | UCBottomEdgeRegion *region = privateBottomEdge->regions[0]; |
1028 | |
1029 | // change the region so we can get the signals while dragged |
1030 | - region->m_from = 0.1; |
1031 | - region->m_to = 0.2; |
1032 | + UCBottomEdgeRegionPrivate::get(region)->from = 0.1; |
1033 | + UCBottomEdgeRegionPrivate::get(region)->to = 0.2; |
1034 | |
1035 | QPoint from(bottomEdge->width() / 2.0f, bottomEdge->height() - 5); |
1036 | QPoint delta(0, -(bottomEdge->height() / 3 + UCUnits::instance()->gu(6))); |
1037 | @@ -615,7 +616,8 @@ |
1038 | UCTestExtras::touchDrag(0, bottomEdge, from, delta); |
1039 | } |
1040 | QTRY_COMPARE_WITH_TIMEOUT(entered.count(), 1, 500); |
1041 | - QTRY_COMPARE_WITH_TIMEOUT(exited.count(), 1, 500); |
1042 | + // exit should not be emitted as the region is not left when committed |
1043 | + QTRY_COMPARE_WITH_TIMEOUT(exited.count(), 0, 500); |
1044 | } |
1045 | |
1046 | void test_region_dragEnded_emitted_data() |
1047 | @@ -677,39 +679,22 @@ |
1048 | UCBottomEdgeStyle *style = UCBottomEdgePrivate::get(bottomEdge)->bottomPanel; |
1049 | |
1050 | // alter default region for testing |
1051 | - region->m_from = 0.1; |
1052 | - region->m_to = 0.8; |
1053 | + UCBottomEdgeRegionPrivate::get(region)->to = 0.6; |
1054 | |
1055 | QPoint from(bottomEdge->width() / 2.0f, bottomEdge->height() - 5); |
1056 | - QPoint to = from + QPoint(0, -(bottomEdge->parentItem()->height() - 1)); |
1057 | + QPoint delta(0, -(bottomEdge->height() / 2)); |
1058 | |
1059 | if (withMouse) { |
1060 | bottomEdge->hint()->setStatus(UCBottomEdgeHint::Locked); |
1061 | - from = bottomEdge->mapToScene(from).toPoint(); |
1062 | - to = bottomEdge->mapToScene(to).toPoint(); |
1063 | - QTest::mousePress(bottomEdge->window(), Qt::LeftButton, 0, from, 20); |
1064 | - QPoint movePos(from); |
1065 | - while (movePos.y() > to.y() && !bottomEdge->activeRegion()) { |
1066 | - QTest::mouseMove(bottomEdge->window(), movePos, 20); |
1067 | - movePos += QPoint(0, -10); |
1068 | - } |
1069 | - QTest::mouseRelease(bottomEdge->window(),Qt::LeftButton, 0, movePos, 20); |
1070 | + UCTestExtras::mouseDrag(bottomEdge, from, delta, Qt::LeftButton, 0); |
1071 | } else { |
1072 | - UCTestExtras::touchPress(0, bottomEdge, from); |
1073 | - QPoint movePos(from); |
1074 | - while (movePos.y() > to.y() && !bottomEdge->activeRegion()) { |
1075 | - QTest::qWait(20); |
1076 | - UCTestExtras::touchMove(0, bottomEdge, movePos); |
1077 | - movePos += QPoint(0, -10); |
1078 | - } |
1079 | - QTest::qWait(20); |
1080 | - UCTestExtras::touchRelease(0, bottomEdge, movePos); |
1081 | + UCTestExtras::touchDrag(0, bottomEdge, from, delta, 20); |
1082 | } |
1083 | |
1084 | - QVERIFY(bottomEdge->activeRegion()); |
1085 | + QTRY_COMPARE_WITH_TIMEOUT(bottomEdge->status(), UCBottomEdge::Committed, 1000); |
1086 | + QCOMPARE(bottomEdge->activeRegion(), region); |
1087 | // the top of the committed content should not be the top of the bottom edge |
1088 | QVERIFY(style->m_panel->y() > bottomEdge->y()); |
1089 | - QCOMPARE(bottomEdge->status(), UCBottomEdge::Revealed); |
1090 | } |
1091 | |
1092 | void test_drag_ends_in_uncovered_region_collapses_data() |
1093 | @@ -758,7 +743,6 @@ |
1094 | UCTestExtras::touchRelease(0, bottomEdge, movePos); |
1095 | } |
1096 | |
1097 | - QVERIFY(!bottomEdge->activeRegion()); |
1098 | // we should be collapsing! |
1099 | QTRY_COMPARE_WITH_TIMEOUT(bottomEdge->status(), UCBottomEdge::Committed, 1000); |
1100 | } |
1101 | @@ -780,8 +764,8 @@ |
1102 | UCBottomEdgeRegion *region = privateBottomEdge->regions[0]; |
1103 | |
1104 | // alter region for testing |
1105 | - region->m_from = 0.1; |
1106 | - region->m_to = 0.8; |
1107 | + UCBottomEdgeRegionPrivate::get(region)->from = 0.1; |
1108 | + UCBottomEdgeRegionPrivate::get(region)->to = 0.8; |
1109 | // and connect commit to dragEnded |
1110 | connect(region, &UCBottomEdgeRegion::dragEnded, bottomEdge, &UCBottomEdge::commit); |
1111 | |
1112 | @@ -794,7 +778,7 @@ |
1113 | to = bottomEdge->mapToScene(to).toPoint(); |
1114 | QTest::mousePress(bottomEdge->window(), Qt::LeftButton, 0, from, 20); |
1115 | QPoint movePos(from); |
1116 | - while (movePos.y() > to.y() && !bottomEdge->activeRegion()) { |
1117 | + while (movePos.y() > to.y() && (bottomEdge->activeRegion() != region)) { |
1118 | QTest::mouseMove(bottomEdge->window(), movePos, 20); |
1119 | movePos += QPoint(0, -10); |
1120 | } |
1121 | @@ -802,7 +786,7 @@ |
1122 | } else { |
1123 | UCTestExtras::touchPress(0, bottomEdge, from); |
1124 | QPoint movePos(from); |
1125 | - while (movePos.y() > to.y() && !bottomEdge->activeRegion()) { |
1126 | + while (movePos.y() > to.y() && (bottomEdge->activeRegion() != region)) { |
1127 | QTest::qWait(20); |
1128 | UCTestExtras::touchMove(0, bottomEdge, movePos); |
1129 | movePos += QPoint(0, -10); |
1130 | @@ -841,8 +825,8 @@ |
1131 | UCBottomEdgeRegion *region = privateBottomEdge->regions[0]; |
1132 | |
1133 | // adjust region data for the test |
1134 | - region->m_from = 0.4; |
1135 | - region->m_to = 0.2; |
1136 | + UCBottomEdgeRegionPrivate::get(region)->from = 0.4; |
1137 | + UCBottomEdgeRegionPrivate::get(region)->to = 0.2; |
1138 | QPoint from(bottomEdge->width() / 2.0f, bottomEdge->height() - 5); |
1139 | QPoint delta(0, -(bottomEdge->height() / 2.0f)); |
1140 | QSignalSpy activeRegion(bottomEdge, SIGNAL(activeRegionChanged(UCBottomEdgeRegion*))); |
1141 | @@ -941,12 +925,14 @@ |
1142 | } |
1143 | QTest::qWait(20); |
1144 | UCTestExtras::touchRelease(0, bottomEdge, movePos); |
1145 | - // we should have had 3 active region changes by now |
1146 | - // null -> region #0 -> region #1 -> null |
1147 | - QCOMPARE(spy.count(), 3); |
1148 | - QCOMPARE(regionObjects.size(), 5); |
1149 | + // we should have had 4 active region changes by now |
1150 | + // null -> defaultRegion -> region #0 -> region #1 -> null |
1151 | + QCOMPARE(spy.count(), 4); |
1152 | + QCOMPARE(regionObjects.size(), 6); |
1153 | + // the first two regions content is the same |
1154 | int i = 0; |
1155 | QCOMPARE(regionObjects[i++], QString("default")); |
1156 | + QCOMPARE(regionObjects[i++], QString("default")); |
1157 | QCOMPARE(regionObjects[i++], QString("region1")); |
1158 | QCOMPARE(regionObjects[i++], QString("default")); |
1159 | QCOMPARE(regionObjects[i++], QString("region2")); |
1160 | @@ -960,13 +946,13 @@ |
1161 | |
1162 | UCBottomEdgePrivate *d = UCBottomEdgePrivate::get(bottomEdge); |
1163 | for (int i = 0; i < d->regions.size(); i++) { |
1164 | - QVERIFY(d->regions[i]->regionContent()); |
1165 | + QVERIFY(UCBottomEdgeRegionPrivate::get(d->regions[i])->contentItem); |
1166 | } |
1167 | |
1168 | // set preloadContent: false |
1169 | bottomEdge->setPreloadContent(false); |
1170 | for (int i = 0; i < d->regions.size(); i++) { |
1171 | - QVERIFY(!d->regions[i]->regionContent()); |
1172 | + QVERIFY(!UCBottomEdgeRegionPrivate::get(d->regions[i])->contentItem); |
1173 | } |
1174 | } |
1175 | |
1176 | @@ -978,11 +964,24 @@ |
1177 | UCBottomEdgePrivate *d = UCBottomEdgePrivate::get(bottomEdge); |
1178 | // disable a region |
1179 | d->regions[0]->setEnabled(false); |
1180 | - QVERIFY(!d->regions[0]->regionContent()); |
1181 | + QVERIFY(!UCBottomEdgeRegionPrivate::get(d->regions[0])->contentItem); |
1182 | |
1183 | // enable it |
1184 | d->regions[0]->setEnabled(true); |
1185 | - QTRY_VERIFY_WITH_TIMEOUT(d->regions[0]->regionContent() != nullptr, 1000); |
1186 | + QTRY_VERIFY_WITH_TIMEOUT(UCBottomEdgeRegionPrivate::get(d->regions[0])->contentItem != nullptr, 1000); |
1187 | + } |
1188 | + |
1189 | + void test_action_triggered_commits() |
1190 | + { |
1191 | + QScopedPointer<BottomEdgeTestCase> test(new BottomEdgeTestCase("BottomEdgeWithAction.qml")); |
1192 | + UCBottomEdge *bottomEdge = test->testItem(); |
1193 | + UCAction *action = bottomEdge->hint()->action(); |
1194 | + QVERIFY(action); |
1195 | + |
1196 | + // trigger action |
1197 | + action->trigger(); |
1198 | + QTRY_COMPARE_WITH_TIMEOUT(bottomEdge->status(), UCBottomEdge::Committed, 2000); |
1199 | + QVERIFY(bottomEdge->contentItem()); |
1200 | } |
1201 | }; |
1202 | |
1203 | |
1204 | === modified file 'tests/unit_x11/tst_bottomedge/tst_bottomedge.pro' |
1205 | --- tests/unit_x11/tst_bottomedge/tst_bottomedge.pro 2016-02-20 15:11:02 +0000 |
1206 | +++ tests/unit_x11/tst_bottomedge/tst_bottomedge.pro 2016-04-01 13:16:40 +0000 |
1207 | @@ -23,4 +23,5 @@ |
1208 | LeanActiveRegionChange.qml \ |
1209 | UncoveredByRegion.qml \ |
1210 | OverriddenHintTrigger.qml \ |
1211 | - PreloadedContent.qml |
1212 | + PreloadedContent.qml \ |
1213 | + BottomEdgeWithAction.qml |
PASSED: Continuous integration, rev:1916 /jenkins. ubuntu. com/ubuntu- sdk/job/ ubuntu- ui-toolkit- ci-amd64- stable/ 593/ /jenkins. ubuntu. com/ubuntu- sdk/job/ generic- update- mp/2238/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /jenkins. ubuntu. com/ubuntu- sdk/job/ ubuntu- ui-toolkit- ci-amd64- stable/ 593/rebuild
https:/