2 * Copyright (C) 2013-2016 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 Services")
28 forwardButtonSourceComponent: forwardButton
30 readonly 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()
56 anchors.topMargin: customMargin
57 anchors.leftMargin: wideMode ? parent.leftMargin : 0
58 anchors.rightMargin: wideMode ? parent.rightMargin : 0
67 height: hereCheckLabel.height + hereTermsLabel.height
71 objectName: "hereCheckLabel"
74 right: hereTermsCheck.left
76 leftMargin: column.anchors.leftMargin == 0 ? staticMargin : 0
77 rightMargin: units.gu(2)
80 wrapMode: Text.WordWrap
82 font.weight: checked ? Font.Normal : Font.Light
83 text: i18n.tr("Use GPS, Wi-Fi hotspots and mobile network anonymously to detect location (recommended)")
84 property bool checked: true
89 objectName: "hereTermsLabel"
92 right: hereTermsCheck.left
93 top: hereCheckLabel.bottom
94 topMargin: units.gu(1)
95 leftMargin: column.anchors.leftMargin == 0 ? staticMargin : 0
96 rightMargin: units.gu(2)
99 wrapMode: Text.WordWrap
101 font.weight: Font.Light
104 linkColor: UbuntuColors.orange
105 text: i18n.tr("By selecting this option you agree to the Nokia HERE %1.")
106 .arg("<a href='#'>" + i18n.ctr("part of: Nokia HERE terms and conditions", "terms and conditions") + "</a>")
107 Mouse.forwardTo: hereCheckArea // clicking on the link also selects this group
108 Mouse.priority: Mouse.AfterItem
110 pageStack.load(Qt.resolvedUrl("here-terms.qml"));
116 fillMode: Image.PreserveAspectFit
117 height: units.gu(1.5)
118 source: "data/Tick@30.png"
119 opacity: hereCheckLabel.checked ? 1 : 0
120 anchors.right: parent.right
121 anchors.verticalCenter: hereCheckLabel.verticalCenter
122 anchors.rightMargin: column.anchors.rightMargin == 0 ? staticMargin : 0
128 z: hereCheckGroup.z - 1 // so that the link can be activated
130 if (!hereCheckLabel.checked) {
131 hereCheckLabel.checked = true;
132 gpsCheckLabel.checked = false;
133 nopeCheckLabel.checked = false;
141 anchors.left: parent.left
142 anchors.right: parent.right
143 anchors.top: hereCheckGroup.bottom
144 anchors.topMargin: units.gu(3)
151 objectName: "gpsCheckLabel"
156 topMargin: units.gu(3)
157 leftMargin: column.anchors.leftMargin == 0 ? staticMargin : 0
158 rightMargin: units.gu(2)
160 text: i18n.tr("GPS only")
161 wrapMode: Text.WordWrap
163 font.weight: checked ? Font.Normal : Font.Light
165 property bool checked: false
170 if (!gpsCheckLabel.checked) {
171 hereCheckLabel.checked = false;
172 gpsCheckLabel.checked = true;
173 nopeCheckLabel.checked = false;
180 fillMode: Image.PreserveAspectFit
181 height: units.gu(1.5)
182 source: "data/Tick@30.png"
183 opacity: gpsCheckLabel.checked ? 1 : 0
184 anchors.right: parent.right
185 anchors.verticalCenter: gpsCheckLabel.verticalCenter
186 anchors.rightMargin: column.anchors.rightMargin == 0 ? staticMargin : 0
191 anchors.left: parent.left
192 anchors.right: parent.right
193 anchors.top: gpsCheckLabel.bottom
194 anchors.topMargin: units.gu(3)
201 objectName: "nopeCheckLabel"
206 topMargin: units.gu(3)
207 leftMargin: column.anchors.leftMargin == 0 ? staticMargin : 0
208 rightMargin: units.gu(2)
210 wrapMode: Text.WordWrap
212 font.weight: checked ? Font.Normal : Font.Light
214 text: i18n.tr("Don't use my location")
215 property bool checked: false
220 if (!nopeCheckLabel.checked) {
221 hereCheckLabel.checked = false;
222 gpsCheckLabel.checked = false;
223 nopeCheckLabel.checked = true;
230 fillMode: Image.PreserveAspectFit
231 height: units.gu(1.5)
232 source: "data/Tick@30.png"
233 opacity: nopeCheckLabel.checked ? 1 : 0
234 anchors.right: parent.right
235 anchors.verticalCenter: nopeCheckLabel.verticalCenter
236 anchors.rightMargin: column.anchors.rightMargin == 0 ? staticMargin : 0
241 anchors.left: parent.left
242 anchors.right: parent.right
243 anchors.top: nopeCheckLabel.bottom
244 anchors.topMargin: units.gu(3)
255 topMargin: units.gu(4)
256 leftMargin: column.anchors.leftMargin == 0 ? staticMargin : 0
257 rightMargin: column.anchors.rightMargin == 0 ? staticMargin : 0
260 text: i18n.tr("You can change it later in System Settings.")
263 font.weight: Font.Light
270 LocalComponents.StackButton {
271 text: i18n.tr("Next")
273 var locationOn = gpsCheckLabel.checked || hereCheckLabel.checked;
274 var gpsOn = gpsCheckLabel.checked || hereCheckLabel.checked;
275 var hereOn = hereCheckLabel.checked;
277 // location service doesn't currently listen to updateState
278 // requests, so we activate the actions if needed.
279 if (locationActionGroup.location.state != locationOn) {
280 locationActionGroup.location.activate();
282 if (locationActionGroup.gps.state != gpsOn) {
283 locationActionGroup.gps.activate();
285 AccountsService.hereEnabled = hereOn;