2 * Copyright (C) 2013-2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import AccountsService 0.1
19 import QMenuModel 0.1 as QMenuModel
20 import Qt.labs.folderlistmodel 2.1
21 import Ubuntu.Components 1.3
22 import ".." as LocalComponents
24 LocalComponents.Page {
25 objectName: "locationPage"
27 title: i18n.tr("Location")
28 forwardButtonSourceComponent: forwardButton
30 property bool pathSet: AccountsService.hereLicensePathValid
31 skipValid: pathSet && (AccountsService.hereLicensePath === "" || termsModel.count > 0)
32 skip: skipValid && (AccountsService.hereLicensePath === "" || termsModel.count === 2) // no files but . and ..
36 folder: AccountsService.hereLicensePath
37 nameFilters: ["*.html"]
38 showOnlyReadable: true
39 showDotAndDotDot: true // so that count == 0 means we're not done scanning yet
42 QMenuModel.QDBusActionGroup {
43 id: locationActionGroup
44 objectName: "locationActionGroup"
45 busType: QMenuModel.DBus.SessionBus
46 busName: "com.canonical.indicator.location"
47 objectPath: "/com/canonical/indicator/location"
48 property variant location: action("location-detection-enabled")
49 property variant gps: action("gps-detection-enabled")
50 Component.onCompleted: start()
59 anchors.left: parent.left
60 anchors.right: parent.right
62 text: i18n.tr("Let the phone detect your location:")
65 LocalComponents.CheckableSetting {
67 objectName: "gpsCheck"
69 text: i18n.tr("Using GPS only (less accurate)")
71 gpsCheck.checked = true;
72 hereCheck.checked = false;
73 nopeCheck.checked = false;
78 anchors.left: parent.left
79 anchors.right: parent.right
80 height: childrenRect.height
82 LocalComponents.CheckableSetting {
84 objectName: "hereCheck"
86 text: i18n.tr("Using GPS, anonymized Wi-Fi and cellular network info (recommended)")
89 gpsCheck.checked = false;
90 hereCheck.checked = true;
91 nopeCheck.checked = false;
96 objectName: "hereTermsLink"
97 anchors.left: parent.left
98 anchors.leftMargin: hereCheck.labelOffset
99 anchors.right: parent.right
101 linkColor: theme.palette.normal.foregroundText
102 // Translators: HERE is a trademark for Nokia's location service, you probably shouldn't translate it
103 text: i18n.tr("By selecting this option you agree to the Nokia HERE <a href='#'>terms and conditions</a>.")
104 onLinkActivated: pageStack.load(Qt.resolvedUrl("here-terms.qml"))
108 LocalComponents.CheckableSetting {
110 objectName: "nopeCheck"
112 text: i18n.tr("Not at all")
114 gpsCheck.checked = false;
115 hereCheck.checked = false;
116 nopeCheck.checked = true;
121 anchors.left: parent.left
122 anchors.right: parent.right
124 text: i18n.tr("You can change your mind later in <b>System Settings</b>.")
130 LocalComponents.StackButton {
131 text: i18n.tr("Continue")
133 var locationOn = gpsCheck.checked || hereCheck.checked;
134 var gpsOn = gpsCheck.checked || hereCheck.checked;
135 var hereOn = hereCheck.checked;
137 // location service doesn't currently listen to updateState
138 // requests, so we activate the actions if needed.
139 if (locationActionGroup.location.state != locationOn) {
140 locationActionGroup.location.activate();
142 if (locationActionGroup.gps.state != gpsOn) {
143 locationActionGroup.gps.activate();
145 AccountsService.hereEnabled = hereOn;