Merge lp:~zsombi/ubuntu-ui-toolkit/lambdaSegfault into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Merged
Approved by: Tim Peeters
Approved revision: 1741
Merged at revision: 1739
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/lambdaSegfault
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 428 lines (+139/-71)
9 files modified
examples/ubuntu-ui-toolkit-gallery/BottomEdgePage.qml (+0/-19)
src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml (+13/-20)
src/Ubuntu/Components/plugin/ucbottomedge.cpp (+28/-10)
src/Ubuntu/Components/plugin/ucbottomedge_p.h (+1/-0)
src/Ubuntu/Components/plugin/ucbottomedgehint.cpp (+31/-9)
src/Ubuntu/Components/plugin/ucbottomedgehint.h (+6/-0)
tests/unit_x11/tst_bottomedge/UncoveredByRegion.qml (+48/-0)
tests/unit_x11/tst_bottomedge/tst_bottomedge.cpp (+10/-12)
tests/unit_x11/tst_bottomedge/tst_bottomedge.pro (+2/-1)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/lambdaSegfault
Reviewer Review Type Date Requested Status
Tim Peeters Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+279428@code.launchpad.net

Commit message

Update BottomEdge with UI/UX agreed during the sprint.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

good.

But we should not forget about the header background/clipping for AppHeader.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/ubuntu-ui-toolkit-gallery/BottomEdgePage.qml'
2--- examples/ubuntu-ui-toolkit-gallery/BottomEdgePage.qml 2015-11-26 14:57:05 +0000
3+++ examples/ubuntu-ui-toolkit-gallery/BottomEdgePage.qml 2015-12-03 12:10:20 +0000
4@@ -62,21 +62,6 @@
5 }
6
7 TemplateRow {
8- title: i18n.tr("Hint")
9- Row {
10- spacing: units.gu(1)
11- CheckBox {
12- id: attachHintToContent
13- text: i18n.tr("attach hint to content")
14- }
15- Label {
16- text: attachHintToContent.text
17- anchors.verticalCenter: attachHintToContent.verticalCenter
18- }
19- }
20- }
21-
22- TemplateRow {
23 title: i18n.tr("Regions")
24 Slider {
25 id: regionCount
26@@ -135,10 +120,6 @@
27 }
28 contentComponent: bottomEdgeContent
29
30- StyleHints {
31- attachHintToContent: attachHintToContent.checked
32- }
33-
34 onCommitCompleted: {
35 if (contentToLayout.checked && contentToLayout.enabled) {
36 page.pageStack.addPageToCurrentColumn(page, contentComponent);
37
38=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml'
39--- src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml 2015-11-25 06:27:07 +0000
40+++ src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml 2015-12-03 12:10:20 +0000
41@@ -27,10 +27,9 @@
42 revealThreshold: bottomEdge.hint.height + units.gu(2)
43
44 // own styling properties
45- property color backgroundColor: "transparent"
46- property color panelColor: theme.palette.normal.background
47- property color shadowColor: theme.palette.selected.background
48- property bool attachHintToContent: false
49+ property color backgroundColor: Qt.rgba(0, 0, 0, Math.min(0.25, (height - revealThreshold - panelItem.y) / (height - revealThreshold)))
50+ property color panelColor: theme.palette.normal.overlay
51+ property color shadowColor: "#000000"
52
53 anchors.fill: parent
54
55@@ -41,15 +40,6 @@
56 z: -1
57 }
58
59- states: State {
60- name: "reparentedHint"
61- when: attachHintToContent
62- AnchorChanges {
63- target: bottomEdge.hint
64- anchors.bottom: panelItem.top
65- }
66- }
67-
68 Rectangle {
69 id: panelItem
70 objectName: "bottomedge_panel"
71@@ -67,13 +57,14 @@
72
73 Behavior on anchors.topMargin { UbuntuNumberAnimation { id: panelBehavior } }
74
75- state: bottomEdge.status > BottomEdge.Hidden ? "lock-hint" : ""
76+ state: bottomEdge.status > BottomEdge.Hidden ? "drop-hint" : ""
77 states: [
78 State {
79- name: "lock-hint"
80+ name: "drop-hint"
81 PropertyChanges {
82 target: bottomEdge.hint
83- status: BottomEdgeHint.Locked
84+ restoreEntryValues: false
85+ status: BottomEdgeHint.Inactive
86 }
87 }
88 ]
89@@ -86,10 +77,11 @@
90 left: parent.left
91 right: parent.right
92 }
93- height: units.gu(1)
94+ height: units.gu(1.5)
95 gradient: Gradient {
96 GradientStop { position: 0.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.0) }
97- GradientStop { position: 1.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.3) }
98+ GradientStop { position: 0.75; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.05) }
99+ GradientStop { position: 1.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.1) }
100 }
101 }
102 Rectangle {
103@@ -99,11 +91,12 @@
104 left: parent.left
105 right: parent.right
106 }
107- height: units.gu(1)
108+ height: units.gu(1.5)
109 rotation: 180
110 gradient: Gradient {
111 GradientStop { position: 0.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.0) }
112- GradientStop { position: 1.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.3) }
113+ GradientStop { position: 0.75; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.05) }
114+ GradientStop { position: 1.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.1) }
115 }
116 }
117
118
119=== modified file 'src/Ubuntu/Components/plugin/ucbottomedge.cpp'
120--- src/Ubuntu/Components/plugin/ucbottomedge.cpp 2015-11-27 10:36:08 +0000
121+++ src/Ubuntu/Components/plugin/ucbottomedge.cpp 2015-12-03 12:10:20 +0000
122@@ -282,9 +282,13 @@
123 // proceed with drag completion action
124 void UCBottomEdgePrivate::onDragEnded()
125 {
126- if (!activeRegion || (dragDirection == UCBottomEdge::Downwards)) {
127+ // collapse if we drag downwards, or not in any active region and we did not pass 30% of the BottomEdge height
128+ if (dragDirection == UCBottomEdge::Downwards || (!activeRegion && dragProgress < 0.33)) {
129 q_func()->collapse();
130- } else {
131+ } else if (!activeRegion && dragProgress >= 0.33) {
132+ // commit if we are not in an active region but we passed 30% of the BottomEdge height
133+ q_func()->commit();
134+ } else if (activeRegion) {
135 // emit region's dragEnded first
136 Q_EMIT activeRegion->dragEnded();
137 commit(activeRegion->m_to);
138@@ -374,6 +378,10 @@
139 : UCAction(parent)
140 {
141 QQmlEngine::setObjectOwnership(this, QQmlEngine::objectOwnership(parent));
142+}
143+
144+void UCCollapseAction::activate()
145+{
146 setIconName("down");
147 }
148
149@@ -382,7 +390,7 @@
150 {
151 // ugly, as it can be, as we don't have the PageHeader in cpp to detect the type
152 UCHeader *header = bottomPanel->m_contentItem ? bottomPanel->m_contentItem->findChild<UCHeader*>() : Q_NULLPTR;
153- if (!header || !QuickUtils::inherits(header, "PageHeader") || status != UCBottomEdge::Committed) {
154+ if (!header || !QuickUtils::inherits(header, "PageHeader")) {
155 return;
156 }
157
158@@ -391,13 +399,23 @@
159 QQmlListProperty<UCAction> actions = list.value< QQmlListProperty<UCAction> >();
160 QList<UCAction*> *navigationActions = reinterpret_cast<QList<UCAction*>*>(actions.data);
161
162- // clear the actions first
163- navigationActions->clear();
164-
165- // inject the action
166- UCAction *collapse = new UCCollapseAction(header);
167- QObject::connect(collapse, &UCAction::triggered, q_func(), &UCBottomEdge::collapse, Qt::DirectConnection);
168- navigationActions->append(collapse);
169+ // are we committed?
170+ if (status == UCBottomEdge::Committed) {
171+ // activate the action
172+ UCCollapseAction *collapse = qobject_cast<UCCollapseAction*>(navigationActions->at(0));
173+ collapse->activate();
174+ QObject::connect(collapse, &UCAction::triggered, q_func(), &UCBottomEdge::collapse, Qt::DirectConnection);
175+ } else if (navigationActions->size() <= 0) {
176+ navigationActions->append(new UCCollapseAction(header));
177+ } else {
178+ // we have actions in the navigationActions array, check if those are UCCollapseActions,
179+ // if not, clear them
180+ UCCollapseAction *collapse = qobject_cast<UCCollapseAction*>(navigationActions->at(0));
181+ if (!collapse) {
182+ navigationActions->clear();
183+ navigationActions->append(new UCCollapseAction(header));
184+ }
185+ }
186
187 // invoke PageHeader.navigationActionsChanged signal
188 int signal = header->metaObject()->indexOfSignal("navigationActionsChanged()");
189
190=== modified file 'src/Ubuntu/Components/plugin/ucbottomedge_p.h'
191--- src/Ubuntu/Components/plugin/ucbottomedge_p.h 2015-11-26 15:49:24 +0000
192+++ src/Ubuntu/Components/plugin/ucbottomedge_p.h 2015-12-03 12:10:20 +0000
193@@ -105,6 +105,7 @@
194 Q_OBJECT
195 public:
196 UCCollapseAction(QObject *parent = 0);
197+ void activate();
198 };
199 Q_DECLARE_METATYPE(QQmlListProperty<UCAction>)
200
201
202=== modified file 'src/Ubuntu/Components/plugin/ucbottomedgehint.cpp'
203--- src/Ubuntu/Components/plugin/ucbottomedgehint.cpp 2015-11-20 05:58:34 +0000
204+++ src/Ubuntu/Components/plugin/ucbottomedgehint.cpp 2015-12-03 12:10:20 +0000
205@@ -21,6 +21,7 @@
206 #include "quickutils.h"
207 #include "ucunits.h"
208 #include "gestures/ucswipearea.h"
209+#include "propertychange_p.h"
210 #include <QtQml/private/qqmlproperty_p.h>
211 #include <QtQuick/private/qquickflickable_p.h>
212
213@@ -79,12 +80,7 @@
214
215 // FIXME: use QInputDeviceInfo once available
216 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
217- connect(&QuickUtils::instance(), &QuickUtils::mouseAttachedChanged, [this]() {
218- setStatus(QuickUtils::instance().mouseAttached() ? Locked : Active);
219- if (m_status == Active) {
220- m_deactivationTimer.start(m_deactivateTimeout, this);
221- }
222- });
223+ connect(&QuickUtils::instance(), &QuickUtils::mouseAttachedChanged, this, &UCBottomEdgeHint::onMouseAttached);
224
225 // accept mouse events
226 setAcceptedMouseButtons(Qt::LeftButton);
227@@ -116,15 +112,41 @@
228 m_swipeArea->setDirection(UCSwipeArea::Upwards);
229
230 // grid unit sync
231- connect(&UCUnits::instance(), &UCUnits::gridUnitChanged, [this] {
232- m_swipeArea->setImplicitHeight(UCUnits::instance().gu(SWIPE_AREA_HEIGHT_GU));
233- });
234+ connect(&UCUnits::instance(), &UCUnits::gridUnitChanged, this, &UCBottomEdgeHint::onGridUnitChanged);
235
236 // connect to gesture detection
237 connect(m_swipeArea, &UCSwipeArea::draggingChanged,
238 this, &UCBottomEdgeHint::onDraggingChanged, Qt::DirectConnection);
239 }
240
241+void UCBottomEdgeHint::onMouseAttached()
242+{
243+ setStatus(QuickUtils::instance().mouseAttached() ? Locked : Active);
244+ if (m_status == Active) {
245+ m_deactivationTimer.start(m_deactivateTimeout, this);
246+ if (m_flickableBottomMargin) {
247+ delete m_flickableBottomMargin;
248+ m_flickableBottomMargin = Q_NULLPTR;
249+ }
250+ } else if (m_flickable) {
251+ adjustFlickableBottomMargin();
252+ }
253+}
254+
255+void UCBottomEdgeHint::adjustFlickableBottomMargin()
256+{
257+ if (!m_flickableBottomMargin) {
258+ m_flickableBottomMargin = new PropertyChange(m_flickable, "bottomMargin");
259+ }
260+ PropertyChange::setValue(m_flickableBottomMargin, height());
261+ m_flickable->setContentY(m_flickable->contentY() + height());
262+}
263+
264+void UCBottomEdgeHint::onGridUnitChanged()
265+{
266+ m_swipeArea->setImplicitHeight(UCUnits::instance().gu(SWIPE_AREA_HEIGHT_GU));
267+}
268+
269 void UCBottomEdgeHint::itemChange(ItemChange change, const ItemChangeData &data)
270 {
271 UCActionItem::itemChange(change, data);
272
273=== modified file 'src/Ubuntu/Components/plugin/ucbottomedgehint.h'
274--- src/Ubuntu/Components/plugin/ucbottomedgehint.h 2015-11-17 14:24:24 +0000
275+++ src/Ubuntu/Components/plugin/ucbottomedgehint.h 2015-12-03 12:10:20 +0000
276@@ -23,6 +23,7 @@
277
278 class QQuickFlickable;
279 class UCSwipeArea;
280+class PropertyChange;
281 class UCBottomEdgeHint : public UCActionItem
282 {
283 Q_OBJECT
284@@ -79,16 +80,21 @@
285 void onDraggingChanged(bool dragging);
286
287 void init();
288+ void onMouseAttached();
289+ void onGridUnitChanged();
290
291 private:
292 QBasicTimer m_deactivationTimer;
293 UCSwipeArea *m_swipeArea;
294 QQuickFlickable *m_flickable;
295+ PropertyChange *m_flickableBottomMargin = nullptr;
296 int m_deactivateTimeout;
297 Status m_status;
298 bool m_pressed:1;
299
300 friend class UCBottomEdge;
301+
302+ void adjustFlickableBottomMargin();
303 };
304
305 #endif // UCBOTTOMEDGEHINT_H
306
307=== added file 'tests/unit_x11/tst_bottomedge/UncoveredByRegion.qml'
308--- tests/unit_x11/tst_bottomedge/UncoveredByRegion.qml 1970-01-01 00:00:00 +0000
309+++ tests/unit_x11/tst_bottomedge/UncoveredByRegion.qml 2015-12-03 12:10:20 +0000
310@@ -0,0 +1,48 @@
311+/*
312+ * Copyright 2015 Canonical Ltd.
313+ *
314+ * This program is free software; you can redistribute it and/or modify
315+ * it under the terms of the GNU Lesser General Public License as published by
316+ * the Free Software Foundation; version 3.
317+ *
318+ * This program is distributed in the hope that it will be useful,
319+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
320+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
321+ * GNU Lesser General Public License for more details.
322+ *
323+ * You should have received a copy of the GNU Lesser General Public License
324+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
325+ *
326+ */
327+
328+import QtQuick 2.4
329+import Ubuntu.Components 1.3
330+
331+Item {
332+ id: holder
333+ width: units.gu(40)
334+ height: units.gu(71)
335+
336+ BottomEdge {
337+ id: bottomEdge
338+ hint.text: "Test"
339+ objectName: "testItem"
340+ contentComponent: Rectangle {
341+ objectName: "defaultContent"
342+ width: holder.width
343+ height: holder.height
344+ color: UbuntuColors.green
345+ }
346+
347+ BottomEdgeRegion {
348+ to: 0.5
349+ contentComponent: Rectangle {
350+ objectName: "regionContent"
351+ width: holder.width - units.gu(20)
352+ height: holder.height
353+ color: UbuntuColors.red
354+ }
355+ }
356+ }
357+}
358+
359
360=== modified file 'tests/unit_x11/tst_bottomedge/tst_bottomedge.cpp'
361--- tests/unit_x11/tst_bottomedge/tst_bottomedge.cpp 2015-11-27 10:36:08 +0000
362+++ tests/unit_x11/tst_bottomedge/tst_bottomedge.cpp 2015-12-03 12:10:20 +0000
363@@ -688,17 +688,13 @@
364 {
365 QFETCH(bool, withMouse);
366
367- QScopedPointer<BottomEdgeTestCase> test(new BottomEdgeTestCase("AlternateDefaultRegionContent.qml"));
368+ QScopedPointer<BottomEdgeTestCase> test(new BottomEdgeTestCase("UncoveredByRegion.qml"));
369 UCBottomEdge *bottomEdge = test->testItem();
370 UCBottomEdgePrivate *privateBottomEdge = UCBottomEdgePrivate::get(bottomEdge);
371 UCBottomEdgeRegion *region = privateBottomEdge->regions[0];
372
373- // alter region values to adjust to the test
374- region->m_from = 0.1;
375- region->m_to = 0.5;
376-
377- QPoint from(bottomEdge->width() / 2.0f, bottomEdge->height() - 5);
378- QPoint to = from + QPoint(0, -(bottomEdge->parentItem()->height() - 1));
379+ QPoint from(bottomEdge->width() / 2.0f, bottomEdge->height() - 1);
380+ QPoint to = from + QPoint(0, -(bottomEdge->parentItem()->height() - UCUnits::instance().gu(10)));
381 // let us know when we are out of the region
382 QSignalSpy exitRegion(region, SIGNAL(exited()));
383
384@@ -708,26 +704,28 @@
385 to = bottomEdge->mapToScene(to).toPoint();
386 QTest::mousePress(bottomEdge->window(), Qt::LeftButton, 0, from, 20);
387 QPoint movePos(from);
388- while (movePos.y() > to.y() && !exitRegion.count()) {
389+ while (movePos.y() > to.y()) {
390 QTest::mouseMove(bottomEdge->window(), movePos, 20);
391- movePos += QPoint(0, -10);
392+ movePos += QPoint(0, -20);
393 }
394+ movePos -= QPoint(0, -20);
395 QTest::mouseRelease(bottomEdge->window(),Qt::LeftButton, 0, movePos, 20);
396 } else {
397 UCTestExtras::touchPress(0, bottomEdge, from);
398 QPoint movePos(from);
399- while (movePos.y() > to.y() && !exitRegion.count()) {
400+ while (movePos.y() > to.y()) {
401 QTest::qWait(20);
402 UCTestExtras::touchMove(0, bottomEdge, movePos);
403- movePos += QPoint(0, -10);
404+ movePos += QPoint(0, -20);
405 }
406+ movePos -= QPoint(0, -20);
407 QTest::qWait(20);
408 UCTestExtras::touchRelease(0, bottomEdge, movePos);
409 }
410
411 QVERIFY(!bottomEdge->activeRegion());
412 // we should be collapsing!
413- QTRY_COMPARE_WITH_TIMEOUT(bottomEdge->status(), UCBottomEdge::Hidden, 1000);
414+ QTRY_COMPARE_WITH_TIMEOUT(bottomEdge->status(), UCBottomEdge::Committed, 1000);
415 }
416
417 void test_commit_region_content_data()
418
419=== modified file 'tests/unit_x11/tst_bottomedge/tst_bottomedge.pro'
420--- tests/unit_x11/tst_bottomedge/tst_bottomedge.pro 2015-11-27 10:36:08 +0000
421+++ tests/unit_x11/tst_bottomedge/tst_bottomedge.pro 2015-12-03 12:10:20 +0000
422@@ -20,4 +20,5 @@
423 OverlappingRegions.qml \
424 AutoCollapseInPageHeader.qml \
425 AutoCollapseInPageWithPageHeader.qml \
426- LeanActiveRegionChange.qml
427+ LeanActiveRegionChange.qml \
428+ UncoveredByRegion.qml

Subscribers

People subscribed via source and target branches