Merge lp:~neokore/ubuntu-weather-app/SettingsPage into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Raúl Yeguas
Status: Merged
Approved by: Martin Borho
Approved revision: 44
Merged at revision: 44
Proposed branch: lp:~neokore/ubuntu-weather-app/SettingsPage
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 172 lines (+67/-57)
3 files modified
components/LocationTab.qml (+2/-2)
components/SettingsPage.qml (+59/-53)
ubuntu-weather-app.qml (+6/-2)
To merge this branch: bzr merge lp:~neokore/ubuntu-weather-app/SettingsPage
Reviewer Review Type Date Requested Status
Martin Borho Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+169921@code.launchpad.net

Commit message

SettingsDialog conversion to Page.

Description of the change

SettingsDialog conversion to Page.

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)
Revision history for this message
Martin Borho (martin-borho) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components/LocationTab.qml'
2--- components/LocationTab.qml 2013-06-14 13:11:16 +0000
3+++ components/LocationTab.qml 2013-06-17 19:25:31 +0000
4@@ -77,10 +77,10 @@
5 Action {
6 id: configAction
7 iconSource: Qt.resolvedUrl("../resources/images/refresh_icon.png")
8- text: i18n.tr("Configuration")
9+ text: i18n.tr("Settings")
10
11 onTriggered: {
12- PopupUtils.open(settingsDialog, locationTab);
13+ mainView.showSettingsPage();
14 }
15 }
16 }
17
18=== renamed file 'components/SettingsDialog.qml' => 'components/SettingsPage.qml'
19--- components/SettingsDialog.qml 2013-06-14 10:09:37 +0000
20+++ components/SettingsPage.qml 2013-06-17 19:25:31 +0000
21@@ -2,66 +2,72 @@
22 import Ubuntu.Components 0.1
23 import Ubuntu.Components.Popups 0.1
24
25-// Dialog for settings (units by now)
26-Component {
27- id: settingsDialog
28-
29- Dialog {
30- id: settingsDialogue
31- height: units.gu(10)
32- title: i18n.tr("Settings")
33-
34- Row {
35- Label {
36- id: imperialString
37- width: units.gu(21)
38- anchors.verticalCenter: parent.verticalCenter
39- text: i18n.tr("Use imperial units")
40- }
41- Switch {
42- id: imperialSwitch
43- Component.onCompleted: {
44- storage.getSettings(function(storedSettings) {
45- if (storedSettings['units'] === 'imperial')
46- imperialSwitch.checked = true;
47- else
48- imperialSwitch.checked = false;
49- });
50- }
51- }
52- }
53-
54- Button {
55- id: settingsOkButton
56- text: i18n.tr("Save")
57- onClicked: {
58+// Page for settings (units by now)
59+Page {
60+ id: settingsPage
61+ objectName: "SettingsPage"
62+ title: i18n.tr("Settings")
63+ visible:false
64+
65+ property bool settingsChanged: false
66+
67+ tools: ToolbarActions {
68+ locked: true
69+ opened: true
70+ back.onTriggered: {
71+ if(settingsChanged) {
72 if(imperialSwitch.checked){
73- console.debug("Saving imperial units");
74- storage.saveSetting("units","imperial");
75+ storage.saveSetting("units","imperial");
76 }else{
77- console.debug("Saving metric units");
78- storage.saveSetting("units","metric");
79+ storage.saveSetting("units","metric");
80 }
81- PopupUtils.close(settingsDialogue);
82- //Loading tab
83- var tabsString = "import QtQuick 2.0; import Ubuntu.Components 0.1; import Ubuntu.Components.Popups 0.1;"
84- + "Tabs {id: tabs; anchors.fill: parent; Tab { title: 'Loading...'; LoadingComponent{id:bigLoading; anchors.fill: parent; z: 2;}}}"
85- tabsObject = Qt.createQmlObject(tabsString, tabPage, "tabs");
86- // Refresh settings and Data
87 storage.getSettings(function(storedSettings) {
88 for(var settingName in storedSettings) {
89 settings[settingName] = storedSettings[settingName];
90 }
91- refreshData(true);
92- });
93- }
94- }
95-
96- Button {
97- id:settingsCancelButton
98- text: i18n.tr("Cancel")
99- color: "#C00000"
100- onClicked: PopupUtils.close(settingsDialogue)
101+ refreshData();
102+ });
103+ settingsChanged = false;
104+ }
105+ }
106+ }
107+
108+ Rectangle {
109+ anchors {
110+ right: parent.right
111+ rightMargin: units.gu(1)
112+ left: parent.left
113+ leftMargin: units.gu(1)
114+ top: parent.top
115+ topMargin: units.gu(3)
116+ }
117+ Label {
118+ id: imperialString
119+ width: units.gu(21)
120+ anchors {
121+ verticalCenter: parent.verticalCenter
122+ left: parent.left
123+ }
124+
125+ text: i18n.tr("Use imperial units")
126+ }
127+ Switch {
128+ id: imperialSwitch
129+ anchors {
130+ verticalCenter: parent.verticalCenter
131+ right: parent.right
132+ }
133+ Component.onCompleted: {
134+ storage.getSettings(function(storedSettings) {
135+ if (storedSettings['units'] === 'imperial')
136+ imperialSwitch.checked = true;
137+ else
138+ imperialSwitch.checked = false;
139+ });
140+ }
141+ onCheckedChanged: {
142+ settingsChanged = true;
143+ }
144 }
145 }
146 }
147
148=== modified file 'ubuntu-weather-app.qml'
149--- ubuntu-weather-app.qml 2013-06-14 13:11:16 +0000
150+++ ubuntu-weather-app.qml 2013-06-17 19:25:31 +0000
151@@ -91,6 +91,10 @@
152 locationManager.loadData()
153 }
154
155+ function showSettingsPage() {
156+ pageStack.push(settingsPage)
157+ }
158+
159 Component.onCompleted: {
160 //storage.clearDB();
161 //storage.clearSetting('units');
162@@ -107,8 +111,8 @@
163 id: addLocationDialog
164 }
165
166- Components.SettingsDialog {
167- id: settingsDialog
168+ Components.SettingsPage {
169+ id: settingsPage
170 }
171
172 Components.Storage{

Subscribers

People subscribed via source and target branches