82
82
delegate: unitsSelectorDelegate
83
83
model: precipitationUnitsSelectorModel
84
84
selectedIndex: (settings["precip_units"] === "in") ? 1 : 0;
85
// Precipitation units not available at TWC
86
visible: (serviceSelector.selectedIndex !== 0) ? 1 : 0
87
opacity: (serviceSelector.selectedIndex !== 0) ? 1 : 0
89
enabled: (serviceSelector.selectedIndex === 0)
90
NumberAnimation { duration: 1500}
94
easing: UbuntuAnimation.StandardEasingReverse;
95
duration: UbuntuAnimation.SlowDuration
101
id: serviceSelectorModel
102
ListElement { name: "twcOption"; label: "The Weather Channel" }
103
ListElement { name: "owmOption"; label: "Openweathermap" }
108
objectName: "ServiceSelector"
109
text: i18n.tr("Weather Service")
110
delegate: unitsSelectorDelegate
111
model: serviceSelectorModel
112
selectedIndex: (settings["service"] === "openweathermap") ? 1 : 0;
99
127
Connections { target: mainView; onEscapeKey: cancelSheet() }
101
129
onConfirmClicked: {
130
var refresh_from_storage = false,
131
refresh_from_service = false,
103
132
selectedUnit = (temperatureUnitsSelector.selectedIndex === 0) ? "metric" : "imperial",
104
133
selectedWindUnit = (windUnitsSelector.selectedIndex === 0) ? "kmh" : "mph",
105
selectedPrecipUnit = (precipitationUnitsSelector.selectedIndex === 0) ? "mm" : "in";
134
selectedPrecipUnit = (precipitationUnitsSelector.selectedIndex === 0) ? "mm" : "in",
135
selectedService = (serviceSelector.selectedIndex === 0) ? "weatherchannel" : "openweathermap";
106
136
// check if temperaure scale was changed
107
137
if(settings["units"] !== selectedUnit) {
108
138
storage.saveSetting("units", selectedUnit);
139
refresh_from_storage = true;
112
142
if(settings["wind_units"] !== selectedWindUnit) {
113
143
storage.saveSetting("wind_units", selectedWindUnit);
144
refresh_from_storage = true;
117
147
if(settings["precip_units"] !== selectedPrecipUnit) {
118
148
storage.saveSetting("precip_units", selectedPrecipUnit);
149
refresh_from_storage = true;
152
if(settings["service"] !== selectedService) {
153
storage.saveSetting("service", selectedService);
154
refresh_from_service = true;
121
156
// handling of other settings here
124
159
// a setting was changed, reload settings and refresh the location tabs
125
if(refresh === true) {
160
if(refresh_from_storage === true || refresh_from_service === true) {
126
161
storage.getSettings(function(storedSettings) {
127
162
for(var settingName in storedSettings) {
128
163
settings[settingName] = storedSettings[settingName];
165
refreshData(refresh_from_storage, refresh_from_service);
133
168
Theme.palette.selected.backgroundText = "#f4f4e8"