21
21
import GSettings 1.0
22
22
import QMenuModel 0.1
24
import Ubuntu.Components 0.1
23
import Qt.labs.folderlistmodel 2.1
25
import Ubuntu.Components 1.1
25
26
import Ubuntu.Components.ListItems 0.1 as ListItem
27
import Ubuntu.SystemSettings.SecurityPrivacy 1.0
26
28
import SystemSettings 1.0
30
32
title: i18n.tr("Location")
33
anchors.left: parent.left
34
anchors.right: parent.right
37
id: locationActionGroup
38
busType: DBus.SessionBus
39
busName: "com.canonical.indicator.location"
40
objectPath: "/com/canonical/indicator/location"
42
property variant enabled: action("location-detection-enabled")
44
Component.onCompleted: start()
48
text: i18n.tr("Location detection")
51
onClicked: locationActionGroup.enabled.activate()
53
visible: locationActionGroup.enabled.state !== undefined
54
Component.onCompleted:
55
clicked.connect(locationOn.clicked)
61
value: locationActionGroup.enabled.state
65
/* TODO: replace by real info from the location service */
66
property int locationInfo: 0
69
if (locationInfo === 0) /* GPS only */
70
return i18n.tr("Uses GPS to detect your rough location. When off, GPS turns off to save battery.")
71
else if (locationInfo === 1) /* GPS, wi-fi on */
72
return i18n.tr("Uses wi-fi and GPS to detect your rough location. Turning off location detection saves battery.")
73
else if (locationInfo === 2) /* GPS, wi-fi off */
74
return i18n.tr("Uses wi-fi (currently off) and GPS to detect your rough location. Turning off location detection saves battery.")
75
else if (locationInfo === 3) /* GPS, wi-fi and cellular on */
76
return i18n.tr("Uses wi-fi, cell tower locations, and GPS to detect your rough location. Turning off location detection saves battery.")
77
else if (locationInfo === 4) /* GPS, wi-fi on, cellular off */
78
return i18n.tr("Uses wi-fi, cell tower locations (no current cellular connection), and GPS to detect your rough location. Turning off location detection saves battery.")
79
else if (locationInfo === 5) /* GPS, wi-fi off, cellular on */
80
return i18n.tr("Uses wi-fi (currently off), cell tower locations, and GPS to detect your rough location. Turning off location detection saves battery.")
81
else if (locationInfo === 6) /* GPS, wi-fi and cellular off */
82
return i18n.tr("Uses wi-fi (currently off), cell tower locations (no current cellular connection), and GPS to detect your rough location. Turning off location detection saves battery.")
89
text: i18n.tr("Allow access to location:")
90
visible: showAllUI && locationOn.checked
94
model: ["Browser", "Camera", "Clock", "Weather"]
97
control: Switch { checked: true; enabled: false}
98
visible: showAllUI && locationOn.checked
33
flickable: scrollWidget
35
property bool useNone: !useLocation
36
property bool canLocate: locationActionGroup.enabled.state !== undefined
37
property bool useLocation: canLocate && locationActionGroup.enabled.state
38
property bool hereInstalled: securityPrivacy.hereLicensePath !== "" && termsModel.count > 0
39
property bool useHere: hereInstalled && securityPrivacy.hereEnabled
41
onUseLocationChanged: {
44
newIndex = useHere ? 1 : 0;
46
newIndex = detection.model.count - 1;
48
detection.selectedIndex = newIndex;
52
optionsModel.createModel();
55
onHereInstalledChanged: {
56
optionsModel.createModel();
59
UbuntuSecurityPrivacyPanel {
65
folder: securityPrivacy.hereLicensePath
66
nameFilters: ["*.html"]
68
showOnlyReadable: true
72
id: locationActionGroup
73
busType: DBus.SessionBus
74
busName: "com.canonical.indicator.location"
75
objectPath: "/com/canonical/indicator/location"
76
property variant enabled: action("location-detection-enabled")
77
Component.onCompleted: start()
83
contentHeight: contentItem.childrenRect.height
84
boundsBehavior: (contentHeight > locationPage.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
85
/* Set the direction to workaround https://bugreports.qt-project.org/browse/QTBUG-31905
86
otherwise the UI might end up in a situation where scrolling doesn't work */
87
flickableDirection: Flickable.VerticalFlick
90
anchors.left: parent.left
91
anchors.right: parent.right
93
ListItem.ItemSelector {
96
/* Helper that toggles location detection and HERE based on
97
what selector element was tapped. */
98
function activate (key) {
99
var usingLocation = locationActionGroup.enabled.state;
100
if (key === 'none' && usingLocation) {
101
// turns OFF location detection
102
locationActionGroup.enabled.activate();
104
if ( (key === 'gps' || key === 'here') && !usingLocation) {
105
// turns ON location detection
106
locationActionGroup.enabled.activate();
108
if (locationPage.hereInstalled) {
109
// toggles whether HERE is enabled
110
securityPrivacy.hereEnabled = key === 'here';
113
property bool allow: selectedIndex !== (model.count - 1)
115
text: i18n.tr("Let the phone detect your location:")
118
delegate: optionsDelegate
120
if (model.count === 0) return 0; // re-creating
121
if (useNone) return model.count - 1;
122
if (useLocation && !useHere) return 0;
123
if (useHere && useLocation) return 1;
126
activate(model.get(index).key);
132
OptionSelectorDelegate {
143
rightMargin: units.gu(6)
145
textFormat: Text.StyledText
147
wrapMode: Text.WordWrap
148
verticalAlignment: Text.AlignVCenter
149
height: contentHeight + units.gu(4)
151
pageStack.push(Qt.resolvedUrl(link))
154
dlgt.height = label.height
164
function createModel () {
168
optionsModel.append({
169
name: hereInstalled ?
170
i18n.tr("Using GPS only (less accurate)") :
171
i18n.tr("Using GPS"),
177
optionsModel.append({
178
/* TRANSLATORS: %1 is the resource wherein HERE
179
terms and conditions reside (typically a qml file).
180
HERE is a Nokia trademark, so it should probably
181
not be translated. */
182
name: i18n.tr("Using GPS, anonymized Wi-Fi and cellular network info.<br>By selecting this option you accept the <a href='%1'>Nokia HERE terms and conditions</a>.").arg("here-terms.qml"),
187
optionsModel.append({
188
name: i18n.tr("Not at all"),
194
Component.onCompleted: {
200
/* TODO: replace by real info from the location service */
201
property int locationInfo: 0
204
if (locationInfo === 0) /* GPS only */
205
return i18n.tr("Uses GPS to detect your rough location. When off, GPS turns off to save battery.")
206
else if (locationInfo === 1) /* GPS, wi-fi on */
207
return i18n.tr("Uses wi-fi and GPS to detect your rough location. Turning off location detection saves battery.")
208
else if (locationInfo === 2) /* GPS, wi-fi off */
209
return i18n.tr("Uses wi-fi (currently off) and GPS to detect your rough location. Turning off location detection saves battery.")
210
else if (locationInfo === 3) /* GPS, wi-fi and cellular on */
211
return i18n.tr("Uses wi-fi, cell tower locations, and GPS to detect your rough location. Turning off location detection saves battery.")
212
else if (locationInfo === 4) /* GPS, wi-fi on, cellular off */
213
return i18n.tr("Uses wi-fi, cell tower locations (no current cellular connection), and GPS to detect your rough location. Turning off location detection saves battery.")
214
else if (locationInfo === 5) /* GPS, wi-fi off, cellular on */
215
return i18n.tr("Uses wi-fi (currently off), cell tower locations, and GPS to detect your rough location. Turning off location detection saves battery.")
216
else if (locationInfo === 6) /* GPS, wi-fi and cellular off */
217
return i18n.tr("Uses wi-fi (currently off), cell tower locations (no current cellular connection), and GPS to detect your rough location. Turning off location detection saves battery.")
220
visible: showAllUI /* hide until the information is real */
226
text: i18n.tr("Allow access to location:")
227
enabled: detection.allow
232
serviceName: "UbuntuLocationService"
236
model: trustStoreModel
238
text: model.applicationName
239
iconSource: model.iconName
241
checked: model.granted
242
onClicked: trustStoreModel.setEnabled(index, !model.granted)
244
enabled: detection.allow
249
text: i18n.tr("None requested")
250
visible: trustStoreModel.count === 0