22
24
import Ubuntu.Components.ListItems 1.3 as ListItem
23
25
import Ubuntu.Components.Popups 1.3
24
26
import Ubuntu.Connectivity 1.0
25
import Ubuntu.Settings.Components 0.1 as USC
26
import Ubuntu.SystemSettings.Cellular 1.0
28
/* This is a temporary solution to the issue of Hotspots failing on mako. If
29
the device is mako, we hide the hotspot entry. Will be removed once lp:1434591
31
import Ubuntu.SystemSettings.Update 1.0
31
36
objectName: "hotspotPage"
33
// TRANSLATORS: “Hotspot” is hidden.
34
title: showAllUI ? i18n.tr("Hotspot") : i18n.tr("Wi-Fi hotspot")
36
// We disable the back action while a hotspot is in the process of either
37
// being enabled or disabled.
38
head.backAction: Action {
40
enabled: !Connectivity.unstoppableOperationHappening
37
title: i18n.tr("Hotspot")
42
// Undefined WifiEnabled means Connectivity is unavailable.
43
// Disable for mako (see lp:1434591).
44
when: (typeof Connectivity.wifiEnabled === "undefined" ||
45
UpdateManager.deviceName === "mako") ||
46
Connectivity.FlightMode
52
target: hotspotSetupButton
58
when: Connectivity.wifiEnabled === false
60
target: hotspotSwitchWhenWifiDisabled
48
68
asynchronous: false
53
74
anchors.fill: parent
57
text: i18n.tr("Hotspot")
58
enabled: Connectivity.hotspotStored
61
objectName: "hotspotSwitch"
62
enabled: !switchSync.syncWaiting
64
USC.ServerPropertySynchroniser {
66
userTarget: hotspotSwitch
67
userProperty: "checked"
68
serverTarget: Connectivity
69
serverProperty: "hotspotEnabled"
72
// Since this blocks the UI thread, we wait until
73
// the UI has completed the checkbox animation before we
74
// ask the server to uipdate.
76
triggerTimer.value = value;
84
interval: 250; repeat: false
85
onTriggered: Connectivity.hotspotEnabled = value
75
contentWidth: parent.width
76
contentHeight: contentItem.childrenRect.height
77
boundsBehavior: (contentHeight > root.height) ?
78
Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
93
83
right: parent.right
94
leftMargin: units.gu(2)
95
rightMargin: units.gu(2)
97
text : hotspotSwitch.stored ?
98
i18n.tr("When hotspot is on, other devices can use your cellular data connection over Wi-Fi. Normal data charges apply.")
99
: i18n.tr("Other devices can use your cellular data connection over the Wi-Fi network. Normal data charges apply.")
89
text: i18n.tr("Hotspot")
90
enabled: Connectivity.hotspotStored
91
onClicked: hotspotSwitch.trigger()
94
objectName: "hotspotSwitch"
95
enabled: parent.enabled
96
checked: Connectivity.hotspotEnabled
97
onTriggered: Connectivity.hotspotEnabled = checked
99
// Catch taps if Wi-Fi is disable and prompt user.
101
id: hotspotSwitchWhenWifiDisabled
104
onClicked: enableWifiAction.diag = PopupUtils.open(
116
text : Connectivity.hotspotStored ?
117
i18n.tr("When hotspot is on, other devices can use your cellular data connection over Wi-Fi. Normal data charges apply.")
118
: i18n.tr("Other devices can use your cellular data connection over the Wi-Fi network. Normal data charges apply.")
122
id: hotspotSetupButton
123
objectName: "hotspotSetupButton"
124
anchors.horizontalCenter: parent.horizontalCenter
125
width: parent.width - units.gu(4)
126
text: Connectivity.hotspotStored ?
127
i18n.tr("Change password/setup…") : i18n.tr("Set up hotspot…")
129
setup.setSource(Qt.resolvedUrl("HotspotSetup.qml"));
130
PopupUtils.open(setup.item, root, {});
103
objectName: "hotspotSetupEntry"
104
anchors.horizontalCenter: parent.horizontalCenter
105
width: parent.width - units.gu(4)
106
text: Connectivity.hotspotStored ?
107
i18n.tr("Change password/setup…") : i18n.tr("Set up hotspot…")
110
setup.setSource(Qt.resolvedUrl("HotspotSetup.qml"));
111
PopupUtils.open(setup.item, hotspot, {
140
// As soon as Wi-Fi has been turned on, enable the hotspot.
141
function wifiUpdated (updated) {
142
Connectivity.wifiEnabledUpdated.disconnect(wifiUpdated);
143
Connectivity.hotspotEnabled = true;
144
PopupUtils.close(diag);
147
Connectivity.wifiEnabledUpdated.connect(wifiUpdated);
148
hotspotSwitch.checked = true;
149
Connectivity.wifiEnabled = true;