← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~nik90/ubuntu-weather-app/improved-settings-page into lp:ubuntu-weather-app/reboot

 

Nekhelesh Ramananthan has proposed merging lp:~nik90/ubuntu-weather-app/improved-settings-page into lp:ubuntu-weather-app/reboot.

Commit message:
Converted the settings page list items to the design followed by the clock app. In the process, the settings options are now properly translatable.

Requested reviews:
  Ubuntu Weather Developers (ubuntu-weather-dev)

For more details, see:
https://code.launchpad.net/~nik90/ubuntu-weather-app/improved-settings-page/+merge/253619

This MP converts the settings page list items to the design followed by the clock app. In the process, the settings options are now properly translatable.
-- 
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~nik90/ubuntu-weather-app/improved-settings-page into lp:ubuntu-weather-app/reboot.
=== added file 'app/components/ExpandableListItem.qml'
--- app/components/ExpandableListItem.qml	1970-01-01 00:00:00 +0000
+++ app/components/ExpandableListItem.qml	2015-03-20 00:37:45 +0000
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd
+ *
+ * This file is part of Ubuntu Weather App
+ *
+ * Ubuntu Weather App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Ubuntu Weather App is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.3
+import Ubuntu.Components 1.1
+import Ubuntu.Components.ListItems 1.0 as ListItem
+
+/*
+ Component which extends the SDK Expandable list item and provides a easy
+ to use component where the title, subtitle and listview can be displayed. It
+ matches the design specification provided for clock.
+*/
+
+ListItem.Expandable {
+    id: expandableListItem
+
+    property ListModel model
+    property Component delegate
+    property alias text: expandableHeader.text
+    property alias subText: expandableHeader.subText
+    property alias listViewHeight: expandableList.height
+
+    anchors {
+        left: parent.left
+        right: parent.right
+        margins: units.gu(-2)
+    }
+
+    collapseOnClick: true
+    expandedHeight: contentColumn.height + units.gu(1)
+
+    Column {
+        id: contentColumn
+
+        anchors {
+            left: parent.left
+            right: parent.right
+        }
+
+        Item {
+            width: parent.width
+            height: expandableListItem.collapsedHeight
+
+            ListItem.Subtitled {
+                id: expandableHeader
+                onClicked: expandableListItem.expanded = true
+
+                Icon {
+                    id: arrow
+
+                    width: units.gu(2)
+                    height: width
+                    anchors.right: parent.right
+                    anchors.verticalCenter: parent.verticalCenter
+
+                    name: "go-down"
+                    color: "Grey"
+                    rotation: expandableListItem.expanded ? 180 : 0
+
+                    Behavior on rotation {
+                        UbuntuNumberAnimation {}
+                    }
+                }
+            }
+        }
+
+        ListView {
+            id: expandableList
+            width: parent.width
+            interactive: false
+            model: expandableListItem.model
+            delegate: expandableListItem.delegate
+        }
+    }
+}

=== modified file 'app/ui/settings/DataProviderPage.qml'
--- app/ui/settings/DataProviderPage.qml	2015-02-10 14:17:08 +0000
+++ app/ui/settings/DataProviderPage.qml	2015-03-20 00:37:45 +0000
@@ -19,34 +19,40 @@
 import QtQuick 2.3
 import Ubuntu.Components 1.1
 import Ubuntu.Components.ListItems 0.1 as ListItem
-
+import "../../components"
 
 Page {
     title: i18n.tr("Data Provider")
 
-    Flickable {
-        anchors {
-            fill: parent
-        }
-        height: parent.height
-        contentHeight: unitsColumn.childrenRect.height
-
-        Column {
-            id: unitsColumn
-            anchors {
-                fill: parent
+    ListModel {
+        id: dataProviderModel
+        ListElement { text: "openweathermap" }
+        ListElement { text: "weatherchannel" }
+    }
+
+    ExpandableListItem {
+        id: dataProviderSetting
+
+        listViewHeight: dataProviderModel.count*units.gu(6) - units.gu(1)
+        model: dataProviderModel
+        text: i18n.tr("Provider")
+        subText: settings.service
+
+        delegate: ListItem.Standard {
+            text: model.text
+            onClicked: {
+                settings.service = model.text
+                refreshData(false, true)
             }
 
-            ListItem.ItemSelector {
-                expanded: true
-                model: ["openweathermap", "weatherchannel"]  // "geonames", "geoip"]
-                selectedIndex: model.indexOf(settings.service)
-                text: i18n.tr("Provider")
-
-                onDelegateClicked: {
-                    settings.service = model[index]
-                    refreshData(false, true)
-                }
+            Icon {
+                width: units.gu(2)
+                height: width
+                name: "ok"
+                visible: settings.service === model.text
+                anchors.right: parent.right
+                anchors.rightMargin: units.gu(2)
+                anchors.verticalCenter: parent.verticalCenter
             }
         }
     }

=== modified file 'app/ui/settings/RefreshIntervalPage.qml'
--- app/ui/settings/RefreshIntervalPage.qml	2015-03-07 16:47:19 +0000
+++ app/ui/settings/RefreshIntervalPage.qml	2015-03-20 00:37:45 +0000
@@ -19,37 +19,45 @@
 import QtQuick 2.3
 import Ubuntu.Components 1.1
 import Ubuntu.Components.ListItems 0.1 as ListItem
-
+import "../../components"
 
 Page {
     title: i18n.tr("Refresh Interval")
 
-    Flickable {
-        anchors {
-            fill: parent
+    ListModel {
+        id: refreshModel
+        Component.onCompleted: initialize()
+        function initialize() {
+            refreshModel.append({"interval": 600, "text": i18n.tr("%1 minute", "%1 minutes", 10).arg(10)})
+            refreshModel.append({"interval": 900, "text": i18n.tr("%1 minute", "%1 minutes", 15).arg(15)})
+            refreshModel.append({"interval": 1800, "text": i18n.tr("%1 minute", "%1 minutes", 30).arg(30)})
+            refreshModel.append({"interval": 3600, "text": i18n.tr("%1 minute", "%1 minutes", 60).arg(60)})
         }
-        height: parent.height
-        contentHeight: unitsColumn.childrenRect.height
-
-        Column {
-            id: unitsColumn
-            anchors {
-                fill: parent
+    }
+
+    ExpandableListItem {
+        id: dataProviderSetting
+
+        listViewHeight: refreshModel.count*units.gu(6)
+        model: refreshModel
+        text: i18n.tr("Interval")
+        subText: i18n.tr("%1 minute", "%1 minutes", Math.floor(settings.refreshInterval / 60).toString()).arg(Math.floor(settings.refreshInterval / 60).toString())
+
+        delegate: ListItem.Standard {
+            text: model.text
+            onClicked: {
+                settings.refreshInterval = model.interval
+                refreshData(false, true)
             }
 
-            ListItem.ItemSelector {
-                delegate: OptionSelectorDelegate {
-                    text: Math.floor(modelData / 60).toString() + " " + i18n.tr("minutes")
-                }
-                expanded: true
-                model: [600, 900, 1800, 3600]
-                selectedIndex: model.indexOf(settings.refreshInterval)
-                text: i18n.tr("Interval")
-
-                onDelegateClicked: {
-                    settings.refreshInterval = model[index]
-                    refreshData(false, true)
-                }
+            Icon {
+                width: units.gu(2)
+                height: width
+                name: "ok"
+                visible: settings.refreshInterval === model.interval
+                anchors.right: parent.right
+                anchors.rightMargin: units.gu(2)
+                anchors.verticalCenter: parent.verticalCenter
             }
         }
     }

=== modified file 'app/ui/settings/UnitsPage.qml'
--- app/ui/settings/UnitsPage.qml	2015-03-08 17:25:16 +0000
+++ app/ui/settings/UnitsPage.qml	2015-03-20 00:37:45 +0000
@@ -19,57 +19,127 @@
 import QtQuick 2.3
 import Ubuntu.Components 1.1
 import Ubuntu.Components.ListItems 0.1 as ListItem
-
+import "../../components"
 
 Page {
     title: i18n.tr("Units")
 
+    flickable: null
+
     Flickable {
-        anchors {
-            fill: parent
-        }
+        anchors.fill: parent
         height: parent.height
         contentHeight: unitsColumn.childrenRect.height
 
+        ListModel {
+            id: temperatureModel
+            Component.onCompleted: initialize()
+            function initialize() {
+                temperatureModel.append({"text": i18n.tr("°C")})
+                temperatureModel.append({"text": i18n.tr("°F")})
+            }
+        }
+
+        ListModel {
+            id: precipationModel
+            Component.onCompleted: initialize()
+            function initialize() {
+                precipationModel.append({"text": i18n.tr("mm")})
+                precipationModel.append({"text": i18n.tr("in")})
+            }
+        }
+
+        ListModel {
+            id: windSpeeModel
+            Component.onCompleted: initialize()
+            function initialize() {
+                windSpeeModel.append({"text": i18n.tr("kmh")})
+                windSpeeModel.append({"text": i18n.tr("mph")})
+            }
+        }
+
         Column {
             id: unitsColumn
-            anchors {
-                fill: parent
-            }
-
-            ListItem.ItemSelector {
-                expanded: true
-                model: ["°C", "°F"]
-                selectedIndex: model.indexOf(settings.tempScale)
+            anchors.fill: parent
+
+            ExpandableListItem {
+                id: temperatureSetting
+
+                listViewHeight: temperatureModel.count*units.gu(6) - units.gu(0.5)
+                model: temperatureModel
                 text: i18n.tr("Temperature")
-
-                onDelegateClicked: {
-                    settings.tempScale = model[index]
-                    refreshData(true)
+                subText: settings.tempScale
+
+                delegate: ListItem.Standard {
+                    text: model.text
+                    onClicked: {
+                        settings.tempScale = model.text
+                        refreshData(true)
+                    }
+
+                    Icon {
+                        width: units.gu(2)
+                        height: width
+                        name: "ok"
+                        visible: settings.tempScale === model.text
+                        anchors.right: parent.right
+                        anchors.rightMargin: units.gu(2)
+                        anchors.verticalCenter: parent.verticalCenter
+                    }
                 }
             }
 
-            ListItem.ItemSelector {
-                expanded: true
-                model: ["mm", "in"]
-                selectedIndex: model.indexOf(settings.precipUnits)
+            ExpandableListItem {
+                id: precipationSetting
+
+                listViewHeight: precipationModel.count*units.gu(6) - units.gu(0.5)
+                model: precipationModel
                 text: i18n.tr("Precipitation")
-
-                onDelegateClicked: {
-                    settings.precipUnits = model[index]
-                    refreshData(true)
+                subText: settings.precipUnits
+
+                delegate: ListItem.Standard {
+                    text: model.text
+                    onClicked: {
+                        settings.precipUnits = model.text
+                        refreshData(true)
+                    }
+
+                    Icon {
+                        width: units.gu(2)
+                        height: width
+                        name: "ok"
+                        visible: settings.precipUnits === model.text
+                        anchors.right: parent.right
+                        anchors.rightMargin: units.gu(2)
+                        anchors.verticalCenter: parent.verticalCenter
+                    }
                 }
             }
 
-            ListItem.ItemSelector {
-                expanded: true
-                model: ["kmh", "mph"]
+            ExpandableListItem {
+                id: windSetting
+
+                listViewHeight: windSpeeModel.count*units.gu(6) - units.gu(0.5)
+                model: windSpeeModel
                 text: i18n.tr("Wind Speed")
-                selectedIndex: model.indexOf(settings.windUnits)
-
-                onDelegateClicked: {
-                    settings.windUnits = model[index]
-                    refreshData(true)
+                subText: settings.windUnits
+
+                delegate: ListItem.Standard {
+                    text: model.text
+                    onClicked: {
+                        settings.windUnits = model.text
+                        refreshData(true)
+                    }
+
+                    Icon {
+                        width: units.gu(2)
+                        height: width
+                        name: "ok"
+                        visible: settings.windUnits === model.text
+                        anchors.right: parent.right
+                        anchors.rightMargin: units.gu(2)
+                        anchors.verticalCenter: parent.verticalCenter
+                    }
                 }
             }
         }

=== modified file 'po/com.ubuntu.weather.pot'
--- po/com.ubuntu.weather.pot	2015-03-19 10:21:28 +0000
+++ po/com.ubuntu.weather.pot	2015-03-20 00:37:45 +0000
@@ -8,14 +8,15 @@
 msgstr ""
 "Project-Id-Version: ubuntu-weather-app\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-03-19 10:21+0000\n"
+"POT-Creation-Date: 2015-03-20 01:33+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
 "Language: \n"
 "MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
 
 #: ../app/components/HomeTempInfo.qml:38
 msgid "Today"
@@ -89,27 +90,58 @@
 msgid "Refresh Interval"
 msgstr ""
 
-#: ../app/ui/settings/DataProviderPage.qml:44
+#: ../app/ui/settings/DataProviderPage.qml:38
 msgid "Provider"
 msgstr ""
 
-#: ../app/ui/settings/RefreshIntervalPage.qml:42
-msgid "minutes"
-msgstr ""
+#: ../app/ui/settings/RefreshIntervalPage.qml:31
+#: ../app/ui/settings/RefreshIntervalPage.qml:32
+#: ../app/ui/settings/RefreshIntervalPage.qml:33
+#: ../app/ui/settings/RefreshIntervalPage.qml:34
+#: ../app/ui/settings/RefreshIntervalPage.qml:44
+#, qt-format
+msgid "%1 minute"
+msgid_plural "%1 minutes"
+msgstr[0] ""
+msgstr[1] ""
 
-#: ../app/ui/settings/RefreshIntervalPage.qml:47
+#: ../app/ui/settings/RefreshIntervalPage.qml:43
 msgid "Interval"
 msgstr ""
 
-#: ../app/ui/settings/UnitsPage.qml:44
+#: ../app/ui/settings/UnitsPage.qml:38
+msgid "°C"
+msgstr ""
+
+#: ../app/ui/settings/UnitsPage.qml:39
+msgid "°F"
+msgstr ""
+
+#: ../app/ui/settings/UnitsPage.qml:47
+msgid "mm"
+msgstr ""
+
+#: ../app/ui/settings/UnitsPage.qml:48
+msgid "in"
+msgstr ""
+
+#: ../app/ui/settings/UnitsPage.qml:56
+msgid "kmh"
+msgstr ""
+
+#: ../app/ui/settings/UnitsPage.qml:57
+msgid "mph"
+msgstr ""
+
+#: ../app/ui/settings/UnitsPage.qml:70
 msgid "Temperature"
 msgstr ""
 
-#: ../app/ui/settings/UnitsPage.qml:56
+#: ../app/ui/settings/UnitsPage.qml:97
 msgid "Precipitation"
 msgstr ""
 
-#: ../app/ui/settings/UnitsPage.qml:67
+#: ../app/ui/settings/UnitsPage.qml:124
 msgid "Wind Speed"
 msgstr ""
 


Follow ups