Merge lp:~martin-borho/ubuntu-weather-app/new-toolbar-items into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Martin Borho on 2013-07-04
Status: Merged
Approved by: Raúl Yeguas on 2013-07-04
Approved revision: 58
Merged at revision: 55
Proposed branch: lp:~martin-borho/ubuntu-weather-app/new-toolbar-items
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 292 lines (+96/-69)
8 files modified
components/AddLocationPage.qml (+9/-1)
components/LocationManagerPage.qml (+16/-9)
components/LocationTab.qml (+38/-27)
components/SettingsPage.qml (+20/-14)
tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py (+7/-12)
tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py (+2/-2)
tests/autopilot/ubuntu_weather_app/tests/test_mainview.py (+1/-1)
tests/autopilot/ubuntu_weather_app/tests/test_settings.py (+3/-3)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/new-toolbar-items
Reviewer Review Type Date Requested Status
Raúl Yeguas 2013-07-04 Approve on 2013-07-04
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2013-07-04
Review via email: mp+173075@code.launchpad.net

Commit message

Replaced deprecated ToolbarAction with new ToolbarItems with named ToolbarButton components

Description of the change

* Replaced ToolbarAction with new ToolbarItems with named ToolbarButton components.
* Temporary fix in ubuntusdk.py to get autopilot tests work with new ToolbarItems and objectNames, will be replaced when new emulator will land.

To post a comment you must log in.
Raúl Yeguas (neokore) wrote :

It works as good as before, so good replace!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components/AddLocationPage.qml'
2--- components/AddLocationPage.qml 2013-06-17 18:44:20 +0000
3+++ components/AddLocationPage.qml 2013-07-04 18:27:28 +0000
4@@ -7,9 +7,17 @@
5 objectName: "AddLocationPage"
6 title: i18n.tr("Add city")
7 visible: false
8- tools: ToolbarActions{
9+ tools: ToolbarItems{
10 locked: true
11 opened: true
12+ back: ToolbarButton {
13+ objectName: "BackButton"
14+ iconSource: Qt.resolvedUrl("../resources/images/back@18.png")
15+ text: i18n.tr("Back")
16+ onTriggered: {
17+ if(pageStack.depth === 3) pageStack.pop()
18+ }
19+ }
20 }
21
22 WorkerScript {
23
24=== modified file 'components/LocationManagerPage.qml'
25--- components/LocationManagerPage.qml 2013-06-17 18:44:20 +0000
26+++ components/LocationManagerPage.qml 2013-07-04 18:27:28 +0000
27@@ -11,18 +11,25 @@
28
29 property bool locationsChanged: false
30
31- tools: ToolbarActions {
32+ tools: ToolbarItems {
33 locked: true
34 opened: (locationModel.count > 0) ? true : false
35- back.onTriggered: {
36- if(locationsChanged) {
37- mainView.refreshData()
38- locationsChanged = false;
39+ back: ToolbarButton {
40+ objectName: "BackButton"
41+ text: i18n.tr("Back")
42+ iconSource: Qt.resolvedUrl("../resources/images/back@18.png")
43+ onTriggered: {
44+ if(locationsChanged) {
45+ mainView.refreshData()
46+ locationsChanged = false;
47+ }
48+ // handle dummy "current location" item
49+ currentLocationItem.visible = false
50+ locationLookupItem.visible = true
51+ lookupItemAddButton.visible = true
52+
53+ if(pageStack.depth === 2) pageStack.pop()
54 }
55- // handle dummy "current location" item
56- currentLocationItem.visible = false
57- locationLookupItem.visible = true
58- lookupItemAddButton.visible = true
59 }
60 }
61
62
63=== modified file 'components/LocationTab.qml'
64--- components/LocationTab.qml 2013-06-20 11:18:17 +0000
65+++ components/LocationTab.qml 2013-07-04 18:27:28 +0000
66@@ -55,33 +55,44 @@
67
68 // Menu for options
69 page: Page {
70-
71- tools: ToolbarActions {
72- Action {
73- id: refreshAction
74- iconSource: Qt.resolvedUrl("../resources/images/refresh_icon.png")
75- text: i18n.tr("Refresh")
76-
77- onTriggered: {
78- mainView.refreshData(false, true);
79- }
80- }
81- Action {
82- id: editLocationAction
83- iconSource: Qt.resolvedUrl("../resources/images/add_icon.png")
84- text: i18n.tr("Edit")
85-
86- onTriggered: {
87- mainView.showLocationManager()
88- }
89- }
90- Action {
91- id: configAction
92- iconSource: Qt.resolvedUrl("../resources/images/refresh_icon.png")
93- text: i18n.tr("Settings")
94-
95- onTriggered: {
96- mainView.showSettingsPage();
97+ id: locationPage
98+ tools: ToolbarItems {
99+ id: pageTools
100+ ToolbarButton {
101+ objectName: "RefreshButton"
102+ action:Action {
103+ id: refreshAction
104+ objectName: "RefreshAction"
105+ iconSource: Qt.resolvedUrl("../resources/images/refresh_icon.png")
106+ text: i18n.tr("Refresh")
107+
108+ onTriggered: {
109+ mainView.refreshData(false, true);
110+ }
111+ }
112+ }
113+ ToolbarButton {
114+ objectName: "EditButton"
115+ action:Action {
116+ id: editLocationAction
117+ iconSource: Qt.resolvedUrl("../resources/images/add_icon.png")
118+ text: i18n.tr("Edit")
119+
120+ onTriggered: {
121+ mainView.showLocationManager()
122+ }
123+ }
124+ }
125+ ToolbarButton {
126+ objectName: "SettingsButton"
127+ action:Action {
128+ id: configAction
129+ iconSource: Qt.resolvedUrl("../resources/images/refresh_icon.png")
130+ text: i18n.tr("Settings")
131+
132+ onTriggered: {
133+ mainView.showSettingsPage();
134+ }
135 }
136 }
137 }
138
139=== modified file 'components/SettingsPage.qml'
140--- components/SettingsPage.qml 2013-06-26 11:23:17 +0000
141+++ components/SettingsPage.qml 2013-07-04 18:27:28 +0000
142@@ -11,23 +11,29 @@
143
144 property bool settingsChanged: false
145
146- tools: ToolbarActions {
147+ tools: ToolbarItems {
148 locked: true
149 opened: true
150- back.onTriggered: {
151- if(settingsChanged) {
152- if(imperialSwitch.checked){
153- storage.saveSetting("units","imperial");
154- }else{
155- storage.saveSetting("units","metric");
156+ back: ToolbarButton {
157+ objectName: "BackButton"
158+ text: i18n.tr("Back")
159+ iconSource: Qt.resolvedUrl("../resources/images/back@18.png")
160+ onTriggered: {
161+ if(settingsChanged) {
162+ if(imperialSwitch.checked){
163+ storage.saveSetting("units","imperial");
164+ }else{
165+ storage.saveSetting("units","metric");
166+ }
167+ storage.getSettings(function(storedSettings) {
168+ for(var settingName in storedSettings) {
169+ settings[settingName] = storedSettings[settingName];
170+ }
171+ refreshData(true);
172+ });
173+ settingsChanged = false;
174 }
175- storage.getSettings(function(storedSettings) {
176- for(var settingName in storedSettings) {
177- settings[settingName] = storedSettings[settingName];
178- }
179- refreshData(true);
180- });
181- settingsChanged = false;
182+ if(pageStack.depth === 2) pageStack.pop()
183 }
184 }
185 }
186
187=== added file 'resources/images/back@18.png'
188Binary files resources/images/back@18.png 1970-01-01 00:00:00 +0000 and resources/images/back@18.png 2013-07-04 18:27:28 +0000 differ
189=== modified file 'tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py'
190--- tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py 2013-06-26 09:57:48 +0000
191+++ tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py 2013-07-04 18:27:28 +0000
192@@ -63,27 +63,22 @@
193 """Returns the toolbar in the main events view."""
194 return self.app.select_single("Toolbar")
195
196- def get_toolbar_button(self, buttonLabel):
197+ def get_toolbar_button(self, buttonName):
198 """Returns the toolbar button at position index"""
199 toolbar = self.get_toolbar()
200 if not toolbar.opened:
201 self.open_toolbar()
202- row = toolbar.select_single("ToolbarActions")
203- loaderList = row.select_many("QQuickLoader")
204- for loader in loaderList:
205- buttonList = loader.select_many("Button")
206- for button in buttonList:
207- if button.text == buttonLabel:
208- return button
209+ button = self.get_object('ActionItem', buttonName)
210+ return button
211
212- def click_toolbar_button(self, buttonLabel):
213+ def click_toolbar_button(self, buttonName):
214 """Clicks the toolbar button with buttonLabel"""
215 #The toolbar button is assumed to be the following format
216- #ToolbarActions {
217- # Action {
218+ #ToolbarItems {
219+ # ToolbarButton {
220 # objectName: "name"
221 # text: value
222- button = self.get_toolbar_button(buttonLabel)
223+ button = self.get_toolbar_button(buttonName)
224 self.autopilot.pointing_device.click_object(button)
225
226 def open_toolbar(self):
227
228=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py'
229--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-06-26 09:58:37 +0000
230+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-07-04 18:27:28 +0000
231@@ -99,7 +99,7 @@
232 def test_cancel_adding_location(self):
233 """Cancel the cities search"""
234 self._open_add_location_page()
235- self.main_window.click_toolbar_button("Back")
236+ self.main_window.click_toolbar_button("BackButton")
237 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
238 self.assertThat(locationList.visible, Eventually(Equals(True)))
239
240@@ -117,7 +117,7 @@
241 """Opens the location manager"""
242 self.main_window.open_toolbar()
243 self.assertThat(self.main_window.get_toolbar().opened, Eventually(Equals(True)))
244- self.main_window.click_toolbar_button("Edit")
245+ self.main_window.click_toolbar_button("EditButton")
246
247 def test_remove_location(self):
248 """Removes location"""
249
250=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_mainview.py'
251--- tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-06-26 11:12:34 +0000
252+++ tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-07-04 18:27:28 +0000
253@@ -55,7 +55,7 @@
254 tab2_curr_date = curr_dates[1].text
255
256 # refresh and wait till loading has finished
257- self.main_window.click_toolbar_button("Refresh")
258+ self.main_window.click_toolbar_button("RefreshButton")
259 load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')
260 self.assertThat(load_indicator.running, Eventually(Equals(False)))
261
262
263=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_settings.py'
264--- tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-06-26 10:43:49 +0000
265+++ tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-07-04 18:27:28 +0000
266@@ -28,7 +28,7 @@
267 """Opens the settings page"""
268 self.main_window.open_toolbar()
269 self.assertThat(self.main_window.get_toolbar().opened, Eventually(Equals(True)))
270- self.main_window.click_toolbar_button("Settings")
271+ self.main_window.click_toolbar_button("SettingsButton")
272
273 def test_switch_scale(self):
274 """Tests switching the scale in the settings"""
275@@ -44,7 +44,7 @@
276 self.assertThat(switch.checked, Eventually(Equals(False)))
277 self.pointing_device.click_object(switch)
278 self.assertThat(switch.checked, Eventually(Equals(True)))
279- self.main_window.click_toolbar_button("Back")
280+ self.main_window.click_toolbar_button("BackButton")
281
282 # wait for reload and check the imperial values
283 load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')
284@@ -60,7 +60,7 @@
285 self.assertThat(switch.checked, Eventually(Equals(True)))
286 self.pointing_device.click_object(switch)
287 self.assertThat(switch.checked, Eventually(Equals(False)))
288- self.main_window.click_toolbar_button("Back")
289+ self.main_window.click_toolbar_button("BackButton")
290
291 # wait for reload and check the metric values again
292 load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')

Subscribers

People subscribed via source and target branches