Merge lp:~martin-borho/ubuntu-weather-app/settings-in-a-sheet into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Martin Borho
Status: Merged
Approved by: David Planella
Approved revision: 61
Merged at revision: 63
Proposed branch: lp:~martin-borho/ubuntu-weather-app/settings-in-a-sheet
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 378 lines (+182/-115)
5 files modified
components/LocationTab.qml (+20/-2)
components/SettingsPage.qml (+0/-80)
components/SettingsSheet.qml (+63/-0)
tests/autopilot/ubuntu_weather_app/tests/test_settings.py (+77/-28)
ubuntu-weather-app.qml (+22/-5)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/settings-in-a-sheet
Reviewer Review Type Date Requested Status
David Planella Approve
Günter Schwann (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Raúl Yeguas Pending
Review via email: mp+173312@code.launchpad.net

Commit message

Moved settings dialog into a ComposerSheet.

Description of the change

First steps for solving Bug #1197364

* Settings dialog now moved in a ComposerSheet
* ValueSelector used for switching the temperature units
* updated tests accordingly
* removed SettingsPage, added SettingsSheet component

For resolving Bug #1197364 updated and/or new components are needed from the SDK, see bug report.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
60. By Martin Borho

added settings icon

61. By Martin Borho

smaller modification in SettingsSheet

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Günter Schwann (schwann) wrote :

Looks good, and works fine

review: Approve
Revision history for this message
David Planella (dpm) wrote :

Thanks Martin, nice work!

Just 3 small things: do you think you could address these?

- Make the text in the buttons
- Use Cancel and Done, as in the original wireframe [1]
- Make Cancel grey and Done Ubuntu orange

Once fixed, feel free to top-approve

[1] https://launchpadlibrarian.net/144073911/Weather%20app-settings.png

review: Needs Fixing
Revision history for this message
Martin Borho (martin-borho) wrote :

Hi David,

I'm still waiting for an updated Sheet component from the SDK, which should be the same as mentioned here:

https://bugs.launchpad.net/ubuntu-weather-app/+bug/1195243

Don't know how far that progressed ..

Cheers
Martin

Revision history for this message
David Planella (dpm) wrote :

Al 15/07/13 17:51, En/na David Planella ha escrit:
> Review: Needs Fixing
>
> Thanks Martin, nice work!
>
> Just 3 small things: do you think you could address these?
>
> - Make the text in the buttons

Sorry, that was supposed to mean "Make the text in the buttons start
with a capital letter"

Cheers,
David.

> - Use Cancel and Done, as in the original wireframe [1]
> - Make Cancel grey and Done Ubuntu orange
>
> Once fixed, feel free to top-approve
>
> [1] https://launchpadlibrarian.net/144073911/Weather%20app-settings.png
>

Revision history for this message
Martin Borho (martin-borho) wrote :

>
> Sorry, that was supposed to mean "Make the text in the buttons start
> with a capital letter"
>

I can't, the buttons are predefined fro the SDK

Revision history for this message
David Planella (dpm) wrote :

In that case, it looks good to me. The 3 issues mentioned should come from an update of the sheet component on the SDK, then.

review: Approve
Revision history for this message
David Planella (dpm) wrote :

And really nice work on updating the tests as well!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'components/LocationTab.qml'
--- components/LocationTab.qml 2013-07-10 13:46:10 +0000
+++ components/LocationTab.qml 2013-07-11 18:53:25 +0000
@@ -1,3 +1,21 @@
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 * Authored by: Raúl Yeguas <neokore@gmail.com>
17 * Martin Borho <martin@borho.net>
18 */
1import QtQuick 2.019import QtQuick 2.0
2import Ubuntu.Components.Popups 0.120import Ubuntu.Components.Popups 0.1
3import Ubuntu.Components 0.121import Ubuntu.Components 0.1
@@ -87,11 +105,11 @@
87 objectName: "SettingsButton"105 objectName: "SettingsButton"
88 action:Action {106 action:Action {
89 id: configAction107 id: configAction
90 iconSource: Qt.resolvedUrl("../resources/images/refresh_icon.png")108 iconSource: Qt.resolvedUrl("../resources/images/settings.png")
91 text: i18n.tr("Settings")109 text: i18n.tr("Settings")
92110
93 onTriggered: {111 onTriggered: {
94 mainView.showSettingsPage();112 mainView.showSettings();
95 }113 }
96 }114 }
97 }115 }
98116
=== removed file 'components/SettingsPage.qml'
--- components/SettingsPage.qml 2013-07-03 19:39:29 +0000
+++ components/SettingsPage.qml 1970-01-01 00:00:00 +0000
@@ -1,80 +0,0 @@
1import QtQuick 2.0
2import Ubuntu.Components 0.1
3import Ubuntu.Components.Popups 0.1
4
5// Page for settings (units by now)
6Page {
7 id: settingsPage
8 objectName: "SettingsPage"
9 title: i18n.tr("Settings")
10 visible:false
11
12 property bool settingsChanged: false
13
14 tools: ToolbarItems {
15 locked: true
16 opened: true
17 back: ToolbarButton {
18 objectName: "BackButton"
19 text: i18n.tr("Back")
20 iconSource: Qt.resolvedUrl("../resources/images/back@18.png")
21 onTriggered: {
22 if(settingsChanged) {
23 if(imperialSwitch.checked){
24 storage.saveSetting("units","imperial");
25 }else{
26 storage.saveSetting("units","metric");
27 }
28 storage.getSettings(function(storedSettings) {
29 for(var settingName in storedSettings) {
30 settings[settingName] = storedSettings[settingName];
31 }
32 refreshData(true);
33 });
34 settingsChanged = false;
35 }
36 if(pageStack.depth === 2) pageStack.pop()
37 }
38 }
39 }
40
41 Rectangle {
42 anchors {
43 right: parent.right
44 rightMargin: units.gu(1)
45 left: parent.left
46 leftMargin: units.gu(1)
47 top: parent.top
48 topMargin: units.gu(3)
49 }
50 Label {
51 id: imperialString
52 width: units.gu(21)
53 anchors {
54 verticalCenter: parent.verticalCenter
55 left: parent.left
56 }
57
58 text: i18n.tr("Use imperial units")
59 }
60 Switch {
61 id: imperialSwitch
62 objectName: "ImperialSwitch"
63 anchors {
64 verticalCenter: parent.verticalCenter
65 right: parent.right
66 }
67 Component.onCompleted: {
68 storage.getSettings(function(storedSettings) {
69 if (storedSettings['units'] === 'imperial')
70 imperialSwitch.checked = true;
71 else
72 imperialSwitch.checked = false;
73 });
74 }
75 onCheckedChanged: {
76 settingsChanged = true;
77 }
78 }
79 }
80}
810
=== added file 'components/SettingsSheet.qml'
--- components/SettingsSheet.qml 1970-01-01 00:00:00 +0000
+++ components/SettingsSheet.qml 2013-07-11 18:53:25 +0000
@@ -0,0 +1,63 @@
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 * Authored by: Raúl Yeguas <neokore@gmail.com>
17 * Martin Borho <martin@borho.net>
18 */
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21import Ubuntu.Components.Popups 0.1
22import Ubuntu.Components.ListItems 0.1 as ListItem
23
24Component {
25
26 ComposerSheet {
27 id: sheet
28 objectName: "SettingsSheet"
29 title: i18n.tr("Settings")
30 contentsHeight: parent.height
31
32 container: ListItem.ValueSelector {
33 id: unitsSelector
34 objectName: "UnitsSelector"
35 text: i18n.tr("Temperature unit")
36 values: [i18n.tr("°C"), i18n.tr("°F")]
37 selectedIndex: (settings["units"] === "imperial") ? 1 : 0;
38 }
39
40 onConfirmClicked: {
41 var refresh = false,
42 selectedUnit = (unitsSelector.selectedIndex === 0) ? "metric" : "imperial";
43 // check if temperaure scale was changed
44 if(settings["units"] !== selectedUnit) {
45 storage.saveSetting("units", selectedUnit);
46 refresh = true;
47 }
48 // handling of other settings here
49 // ....
50
51 // a setting was changed, reload settings and refresh the location tabs
52 if(refresh === true) {
53 storage.getSettings(function(storedSettings) {
54 for(var settingName in storedSettings) {
55 settings[settingName] = storedSettings[settingName];
56 }
57 refreshData(true);
58 });
59 }
60 PopupUtils.close(sheet)
61 }
62 }
63}
064
=== added file 'resources/images/settings.png'
1Binary files resources/images/settings.png 1970-01-01 00:00:00 +0000 and resources/images/settings.png 2013-07-11 18:53:25 +0000 differ65Binary files resources/images/settings.png 1970-01-01 00:00:00 +0000 and resources/images/settings.png 2013-07-11 18:53:25 +0000 differ
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_settings.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-07-03 19:41:03 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-07-11 18:53:25 +0000
@@ -24,47 +24,96 @@
24 self.assertThat(24 self.assertThat(
25 self.main_window.get_qml_view().visible, Eventually(Equals(True)))25 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
2626
27 def _open_settings_page(self):27 def _open_settings_sheet(self):
28 """Opens the settings page"""28 """Opens the settings sheet"""
29 self.main_window.open_toolbar()29 self.main_window.open_toolbar()
30 self.assertThat(self.main_window.get_toolbar().opened, Eventually(Equals(True)))30 self.assertThat(self.main_window.get_toolbar().opened, Eventually(Equals(True)))
31 self.main_window.click_toolbar_button("SettingsButton")31 self.main_window.click_toolbar_button("SettingsButton")
3232
33 def _move_pointer_around(self):
34 """Helper method to move the pointer around, to assure selector is opened"""
35 sheet = self.main_window.get_object('ComposerSheet', 'SettingsSheet')
36 self.pointing_device.move_to_object(sheet)
37
38 def _click_confirm(self):
39 """Clicks the confirm button"""
40 self.pointing_device.click_object(self.main_window.app.select_many('Button')[2])
41
42 def _click_cancel(self):
43 """Clicks the cancel button"""
44 self.pointing_device.click_object(self.main_window.app.select_many('Button')[1])
45
46 def _check_units(self, units):
47 """Checks selected units by values from the first location tab"""
48 current_temps = self.main_window.get_objects('QQuickText', 'CurrentTempText')
49 if units == "imperial":
50 self.assertThat(current_temps[0].text, Eventually(Equals(u'69°F')))
51 self.assertThat(current_temps[1].text, Eventually(Equals(u'78°F')))
52 else:
53 self.assertThat(current_temps[0].text, Eventually(Equals(u'21°C')))
54 self.assertThat(current_temps[1].text, Eventually(Equals(u'26°C')))
55
33 def test_switch_scale(self):56 def test_switch_scale(self):
34 """Tests switching the scale in the settings"""57 """Tests switching the scale in the settings"""
35 # first check metric values58 # first check metric values and open the settings sheet
36 current_temps = self.main_window.get_objects('QQuickText', 'CurrentTempText')59 self._check_units('metric')
37 self.assertThat(current_temps[0].text, Eventually(Equals(u'21°C')))60 self._open_settings_sheet()
38 self.assertThat(current_temps[1].text, Eventually(Equals(u'26°C')))61
3962 # open the value selector
40 # open the settings and switch to imperial63 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")
41 self._open_settings_page()64 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
42 switch = self.main_window.get_object('CheckBox', 'ImperialSwitch')65 self.pointing_device.click_object(units_selector)
43 self.assertThat(switch.visible, Eventually(Equals(True)))66
44 self.assertThat(switch.checked, Eventually(Equals(False)))67 # choose second option, fahrenheit
45 self.pointing_device.click_object(switch)68 self._move_pointer_around()
46 self.assertThat(switch.checked, Eventually(Equals(True)))69 imperial_option = units_selector.get_children()[3]
47 self.main_window.click_toolbar_button("BackButton")70 self.pointing_device.click_object(imperial_option)
71 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
72 self._click_confirm()
4873
49 # wait for reload and check the imperial values74 # wait for reload and check the imperial values
50 load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')75 load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')
51 self.assertThat(load_indicator.running, Eventually(Equals(False)))76 self.assertThat(load_indicator.running, Eventually(Equals(False)))
52 current_temps = self.main_window.get_objects('QQuickText', 'CurrentTempText')77 self._check_units('imperial')
53 self.assertThat(current_temps[0].text, Eventually(Equals(u'69°F')))
54 self.assertThat(current_temps[1].text, Eventually(Equals(u'78°F')))
5578
56 # switch back to metric values again79 # switch back to metric values again
57 self._open_settings_page()80 self._open_settings_sheet()
58 switch = self.main_window.get_object('CheckBox', 'ImperialSwitch')81 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")
59 self.assertThat(switch.visible, Eventually(Equals(True)))82 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
60 self.assertThat(switch.checked, Eventually(Equals(True)))83 self.pointing_device.click_object(units_selector)
61 self.pointing_device.click_object(switch)84 self.assertThat(units_selector.expanded, Eventually(Equals(True)))
62 self.assertThat(switch.checked, Eventually(Equals(False)))85
63 self.main_window.click_toolbar_button("BackButton")86 # click celsius option
87 self._move_pointer_around()
88 metric_option = units_selector.get_children()[4]
89 self.pointing_device.click_object(metric_option)
90
91 # confirm
92 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
93 self._click_confirm()
6494
65 # wait for reload and check the metric values again95 # wait for reload and check the metric values again
66 load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')96 load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')
67 self.assertThat(load_indicator.running, Eventually(Equals(False)))97 self.assertThat(load_indicator.running, Eventually(Equals(False)))
68 current_temps = self.main_window.get_objects('QQuickText', 'CurrentTempText')
69 self.assertThat(current_temps[0].text, Eventually(Equals(u'21°C')))
70 self.assertThat(current_temps[1].text, Eventually(Equals(u'26°C')))
71\ No newline at end of file98\ No newline at end of file
99 self._check_units('metric')
100
101 def test_switch_scale_cancel(self):
102 """Test canceling switching scale"""
103 # first check metric values and open the settings sheet
104 self._check_units('metric')
105 self._open_settings_sheet()
106
107 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")
108 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
109 self.pointing_device.click_object(units_selector)
110
111 # choose second option, fahrenheit
112 self._move_pointer_around()
113 imperial_option = units_selector.get_children()[3]
114 self.pointing_device.click_object(imperial_option)
115 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
116
117 # cancel and check
118 self._click_cancel()
119 self._check_units('metric')
120
72121
=== modified file 'ubuntu-weather-app.qml'
--- ubuntu-weather-app.qml 2013-06-26 10:43:49 +0000
+++ ubuntu-weather-app.qml 2013-07-11 18:53:25 +0000
@@ -1,3 +1,21 @@
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 * Authored by: Raúl Yeguas <neokore@gmail.com>
17 * Martin Borho <martin@borho.net>
18 */
1import QtQuick 2.019import QtQuick 2.0
2import Ubuntu.Components 0.120import Ubuntu.Components 0.1
3import "components" as Components21import "components" as Components
@@ -93,14 +111,13 @@
93 locationManager.loadData()111 locationManager.loadData()
94 }112 }
95113
96 function showSettingsPage() {114 function showSettings() {
97 pageStack.push(settingsPage)115 PopupUtils.open(settingsSheet)
98 }116 }
99117
100 Component.onCompleted: {118 Component.onCompleted: {
101 //storage.clearDB();119 //storage.clearDB();
102 //storage.clearSetting('units');120 //storage.clearSetting('units');
103 //storage.saveSetting("units", "imperial")
104 storage.getSettings(function(storedSettings) {121 storage.getSettings(function(storedSettings) {
105 for(var settingName in storedSettings) {122 for(var settingName in storedSettings) {
106 settings[settingName] = storedSettings[settingName];123 settings[settingName] = storedSettings[settingName];
@@ -109,8 +126,8 @@
109 })126 })
110 }127 }
111128
112 Components.SettingsPage {129 Components.SettingsSheet {
113 id: settingsPage130 id: settingsSheet
114 }131 }
115 132
116 Components.Storage{133 Components.Storage{

Subscribers

People subscribed via source and target branches