Merge lp:~fboucault/camera-app/bottom_edge_hint into lp:camera-app

Proposed by Florian Boucault
Status: Merged
Approved by: Florian Boucault
Approved revision: 533
Merged at revision: 535
Proposed branch: lp:~fboucault/camera-app/bottom_edge_hint
Merge into: lp:camera-app
Diff against target: 344 lines (+230/-66)
5 files modified
BottomEdgeIndicators.qml (+104/-0)
ViewFinderOverlay.qml (+2/-64)
debian/control (+1/-0)
tests/unittests/CMakeLists.txt (+7/-2)
tests/unittests/tst_BottomEdgeIndicators.qml (+116/-0)
To merge this branch: bzr merge lp:~fboucault/camera-app/bottom_edge_hint
Reviewer Review Type Date Requested Status
Ugo Riboni (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+251940@code.launchpad.net

Commit message

Show placeholder bottom edge hint when no option is set so that the user can always guess the existence of the bottom edge.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ugo Riboni (uriboni) wrote :

Code LGTM and does what it says on the tin

review: Approve
Revision history for this message
Bill Filler (bfiller) wrote :

needs test

Revision history for this message
Florian Boucault (fboucault) wrote :

Test added.

On Wed, Mar 11, 2015 at 3:31 PM, Bill Filler <email address hidden>
wrote:

> needs test
> --
>
> https://code.launchpad.net/~fboucault/camera-app/bottom_edge_hint/+merge/251940
> You are the owner of lp:~fboucault/camera-app/bottom_edge_hint.
>

534. By Florian Boucault

Reverted unrelated change.

Revision history for this message
Florian Boucault (fboucault) wrote :

Tests now successfully pass in CI.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'BottomEdgeIndicators.qml'
2--- BottomEdgeIndicators.qml 1970-01-01 00:00:00 +0000
3+++ BottomEdgeIndicators.qml 2015-03-12 22:36:26 +0000
4@@ -0,0 +1,104 @@
5+/*
6+ * Copyright 2015 Canonical Ltd.
7+ *
8+ * This program is free software; you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License as published by
10+ * the Free Software Foundation; version 3.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
20+
21+import QtQuick 2.2
22+import Ubuntu.Components 1.1
23+
24+Item {
25+ id: bottomEdgeIndicators
26+
27+ property var options
28+ width: indicatorsRow.width + units.gu(2) + emptyIndicatorsHint.width
29+ height: units.gu(3)
30+
31+ Image {
32+ anchors {
33+ left: parent.left
34+ right: parent.right
35+ top: parent.top
36+ }
37+ height: parent.height * 2
38+ opacity: 0.3
39+ source: "assets/ubuntu_shape.svg"
40+ sourceSize.width: width
41+ sourceSize.height: height
42+ cache: false
43+ asynchronous: true
44+ }
45+
46+ Icon {
47+ id: emptyIndicatorsHint
48+ objectName: "emptyIndicatorsHint"
49+ name: "go-up"
50+ opacity: 0.5
51+ color: "white"
52+ visible: indicatorsRow.visibleChildren.length <= 1
53+ anchors {
54+ top: parent.top
55+ topMargin: units.gu(0.5)
56+ bottom: parent.bottom
57+ bottomMargin: units.gu(0.5)
58+ horizontalCenter: parent.horizontalCenter
59+ }
60+ width: visible ? height * 1.5 : 0
61+ }
62+
63+ Row {
64+ id: indicatorsRow
65+ objectName: "indicatorsRow"
66+
67+ anchors {
68+ top: parent.top
69+ bottom: parent.bottom
70+ horizontalCenter: parent.horizontalCenter
71+ }
72+ spacing: units.gu(1)
73+
74+ Repeater {
75+ model: bottomEdgeIndicators.options
76+ delegate: Item {
77+ anchors {
78+ top: parent.top
79+ topMargin: units.gu(0.5)
80+ bottom: parent.bottom
81+ bottomMargin: units.gu(0.5)
82+ }
83+ width: units.gu(2)
84+ visible: modelData.showInIndicators && modelData.available && modelData.visible ? (modelData.isToggle ? modelData.get(model.selectedIndex).value : true) : false
85+ opacity: 0.5
86+
87+ Icon {
88+ id: indicatorIcon
89+ anchors.fill: parent
90+ color: "white"
91+ name: modelData && modelData.isToggle ? modelData.icon : modelData.get(model.selectedIndex).icon
92+ source: name ? "image://theme/%1".arg(name) : (modelData.iconSource || "")
93+ visible: source != ""
94+ }
95+
96+ Label {
97+ id: indicatorLabel
98+ anchors.fill: parent
99+ fontSize: "xx-small"
100+ color: "white"
101+ text: modelData.label
102+ verticalAlignment: Text.AlignVCenter
103+ visible: indicatorIcon.name === ""
104+ }
105+ }
106+ }
107+ }
108+}
109
110=== modified file 'ViewFinderOverlay.qml'
111--- ViewFinderOverlay.qml 2015-01-27 17:37:09 +0000
112+++ ViewFinderOverlay.qml 2015-03-12 22:36:26 +0000
113@@ -413,76 +413,14 @@
114 return -1;
115 }
116
117- Item {
118+ BottomEdgeIndicators {
119+ options: bottomEdge.options
120 anchors {
121 horizontalCenter: parent.horizontalCenter
122 bottom: parent.top
123 }
124- width: indicators.width + units.gu(2)
125- height: units.gu(3)
126 opacity: bottomEdge.pressed || bottomEdge.opened ? 0.0 : 1.0
127 Behavior on opacity { UbuntuNumberAnimation {} }
128-
129- Image {
130- anchors {
131- left: parent.left
132- right: parent.right
133- top: parent.top
134- }
135- height: parent.height * 2
136- opacity: 0.3
137- source: "assets/ubuntu_shape.svg"
138- sourceSize.width: width
139- sourceSize.height: height
140- cache: false
141- asynchronous: true
142- visible: indicators.visibleChildren.length > 1
143- }
144-
145- Row {
146- id: indicators
147-
148- anchors {
149- top: parent.top
150- bottom: parent.bottom
151- horizontalCenter: parent.horizontalCenter
152- }
153- spacing: units.gu(1)
154-
155- Repeater {
156- model: bottomEdge.options
157- delegate: Item {
158- anchors {
159- top: parent.top
160- topMargin: units.gu(0.5)
161- bottom: parent.bottom
162- bottomMargin: units.gu(0.5)
163- }
164- width: units.gu(2)
165- visible: modelData.showInIndicators && modelData.available && modelData.visible ? (modelData.isToggle ? modelData.get(model.selectedIndex).value : true) : false
166- opacity: 0.5
167-
168- Icon {
169- id: indicatorIcon
170- anchors.fill: parent
171- color: "white"
172- name: modelData && modelData.isToggle ? modelData.icon : modelData.get(model.selectedIndex).icon
173- source: name ? "image://theme/%1".arg(name) : (modelData.iconSource || "")
174- visible: source != ""
175- }
176-
177- Label {
178- id: indicatorLabel
179- anchors.fill: parent
180- fontSize: "xx-small"
181- color: "white"
182- text: modelData.label
183- verticalAlignment: Text.AlignVCenter
184- visible: indicatorIcon.name === ""
185- }
186- }
187- }
188- }
189 }
190 }
191
192
193=== modified file 'debian/control'
194--- debian/control 2015-02-12 17:22:13 +0000
195+++ debian/control 2015-03-12 22:36:26 +0000
196@@ -21,6 +21,7 @@
197 libusermetricsinput1-dev,
198 gettext,
199 dh-translations,
200+ xvfb,
201 Standards-Version: 3.9.5
202 Homepage: https://launchpad.net/camera-app
203 # If you aren't a member of ~phablet-team but need to upload packaging changes,
204
205=== modified file 'tests/unittests/CMakeLists.txt'
206--- tests/unittests/CMakeLists.txt 2015-01-23 15:02:49 +0000
207+++ tests/unittests/CMakeLists.txt 2015-03-12 22:36:26 +0000
208@@ -1,8 +1,13 @@
209+find_program(XVFB_RUN_BIN
210+ NAMES xvfb-run
211+)
212+
213+set(XVFB_RUN_CMD ${XVFB_RUN_BIN} -a -s "-screen 0 1024x768x24")
214+
215 add_executable(tst_QmlTests tst_QmlTests.cpp)
216 qt5_use_modules(tst_QmlTests Core Qml Quick Test QuickTest)
217 target_link_libraries(tst_QmlTests ${TPL_QT5_LIBRARIES})
218-add_test(tst_QmlTests ${CMAKE_CURRENT_BINARY_DIR}/tst_QmlTests -import ${CMAKE_SOURCE_DIR})
219-set_tests_properties(tst_QmlTests PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
220+add_test(tst_QmlTests ${XVFB_RUN_CMD} ${CMAKE_CURRENT_BINARY_DIR}/tst_QmlTests -import ${CMAKE_SOURCE_DIR})
221
222 # copy qml test files to build dir
223 file(GLOB qmlTestFiles RELATIVE ${CMAKE_SOURCE_DIR}/tests/unittests/ *qml)
224
225=== added file 'tests/unittests/tst_BottomEdgeIndicators.qml'
226--- tests/unittests/tst_BottomEdgeIndicators.qml 1970-01-01 00:00:00 +0000
227+++ tests/unittests/tst_BottomEdgeIndicators.qml 2015-03-12 22:36:26 +0000
228@@ -0,0 +1,116 @@
229+/*
230+ * Copyright 2015 Canonical Ltd.
231+ *
232+ * This program is free software; you can redistribute it and/or modify
233+ * it under the terms of the GNU General Public License as published by
234+ * the Free Software Foundation; version 3.
235+ *
236+ * This program is distributed in the hope that it will be useful,
237+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
238+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
239+ * GNU General Public License for more details.
240+ *
241+ * You should have received a copy of the GNU General Public License
242+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
243+ *
244+ */
245+
246+import QtQuick 2.0
247+import QtTest 1.0
248+import "../../"
249+import "../../.." //Needed for out of source build
250+
251+TestCase {
252+ name: "BottomEdgeIndicators"
253+ when: windowShown
254+ visible: true
255+
256+ property list<ListModel> noOptions
257+ property list<ListModel> noVisibleOptions: [
258+ ListModel {
259+ property string settingsProperty: "invisibleOption"
260+ property string icon
261+ property string label: ""
262+ property bool isToggle: true
263+ property int selectedIndex
264+ property bool available: true
265+ property bool visible: true
266+ property bool showInIndicators: false
267+
268+ ListElement {
269+ icon: ""
270+ label: QT_TR_NOOP("On")
271+ value: true
272+ }
273+ ListElement {
274+ icon: ""
275+ label: QT_TR_NOOP("Off")
276+ value: false
277+ }
278+ }
279+ ]
280+ property list<ListModel> someVisibleOptions: [
281+ ListModel {
282+ property string settingsProperty: "invisibleOption"
283+ property string icon
284+ property string label: ""
285+ property bool isToggle: true
286+ property int selectedIndex
287+ property bool available: true
288+ property bool visible: true
289+ property bool showInIndicators: false
290+
291+ ListElement {
292+ icon: ""
293+ label: QT_TR_NOOP("On")
294+ value: true
295+ }
296+ ListElement {
297+ icon: ""
298+ label: QT_TR_NOOP("Off")
299+ value: false
300+ }
301+ },
302+ ListModel {
303+ property string settingsProperty: "visibleOption"
304+ property string icon
305+ property string label: ""
306+ property bool isToggle: true
307+ property int selectedIndex
308+ property bool available: true
309+ property bool visible: true
310+ property bool showInIndicators: true
311+
312+ ListElement {
313+ icon: ""
314+ label: QT_TR_NOOP("On")
315+ value: true
316+ }
317+ ListElement {
318+ icon: ""
319+ label: QT_TR_NOOP("Off")
320+ value: false
321+ }
322+ }
323+ ]
324+
325+ function test_options_data() {
326+ return [
327+ {tag: "no options", options: noOptions, visibleChildren: 1, hintVisible: true },
328+ {tag: "no visible options", options: noVisibleOptions, visibleChildren: 1, hintVisible: true },
329+ {tag: "some visible options", options: someVisibleOptions, visibleChildren: 2, hintVisible: false },
330+ ]
331+ }
332+
333+ function test_options(data) {
334+ indicators.options = data.options;
335+ var emptyIndicatorsHint = findChild(indicators, "emptyIndicatorsHint");
336+ var indicatorsRow = findChild(indicators, "indicatorsRow");
337+ compare(indicatorsRow.visibleChildren.length, data.visibleChildren, "Incorrect number of visible children in indicatorsRow");
338+ compare(emptyIndicatorsHint.visible, data.hintVisible, "Incorrect emptyIndicatorsHint's visibility");
339+ }
340+
341+ BottomEdgeIndicators {
342+ id: indicators
343+ }
344+}

Subscribers

People subscribed via source and target branches