68
function getDisplayName(connection, displayName) {
69
if (connection == Device.Connecting)
70
// TRANSLATORS: %1 is the display name of the device that is connecting
71
return i18n.tr("%1 (Connecting…)").arg(displayName);
72
else if (connection == Device.Disconnecting)
73
// TRANSLATORS: %1 is the display name of the device that is disconnecting
74
return i18n.tr("%1 (Disconnecting…)").arg(displayName);
68
function getDisplayName(type, displayName) {
69
/* TODO: If the device requires a PIN, show ellipsis.
70
* Right now we don't have a way to check this, just return the name
76
72
return displayName;
75
function getStatusString(connection) {
77
case Device.Connected: return i18n.tr("Connected");
78
case Device.Connecting: return i18n.tr("Connecting…");
79
case Device.Disconnecting: return i18n.tr("Disconnecting…");
80
case Device.Disconnected: return i18n.tr("Disconnected");
81
default: return i18n.tr("Unknown");
79
85
function getTypeString(type) {
81
87
case Device.Computer: return i18n.tr("Computer");
205
215
model: backend.connectedDevices
206
216
delegate: ListItem.Standard {
208
text: getDisplayName(connection, displayName)
219
text: getDisplayName(type, displayName)
220
control: ActivityIndicator {
221
visible: connection == Device.Connecting
210
225
backend.setSelectedDevice(addressName);
211
226
pageStack.push(connectedDevicePage);
218
234
ListItem.Standard {
219
235
id: disconnectedHeader
220
text: connectedList.visible ? i18n.tr("Connect a different device:") : i18n.tr("Connect another device:")
236
text: connectedList.visible ? i18n.tr("Connect another device:") : i18n.tr("Connect a device:")
221
237
enabled: bluetoothActionGroup.enabled
222
238
control: ActivityIndicator {
223
visible: backend.discovering
239
visible: backend.powered && backend.discovering
235
251
model: backend.disconnectedDevices
236
252
delegate: ListItem.Standard {
238
text: getDisplayName(connection, displayName)
255
text: getDisplayName(type, displayName)
256
enabled: backend.isSupportedType(type)
240
backend.stopDiscovery();
241
backend.connectDevice(addressName);
258
backend.setSelectedDevice(addressName);
259
pageStack.push(connectedDevicePage);
245
264
ListItem.Standard {
246
265
id: disconnectedNone
247
266
text: i18n.tr("None detected")
248
267
visible: !disconnectedList.visible
249
enabled: !backend.discovering
271
// Devices that connect automatically
273
id: autoconnectHeader
274
text: i18n.tr("Connect automatically when detected:")
275
visible: autoconnectList.visible
276
enabled: bluetoothActionGroup.enabled
281
height: autoconnectHeader.height * count
283
visible: bluetoothActionGroup.enabled && (count > 0)
285
model: backend.autoconnectDevices
286
delegate: ListItem.Standard {
289
text: getDisplayName(type, displayName)
291
backend.setSelectedDevice(addressName);
292
pageStack.push(connectedDevicePage);
263
309
text: i18n.tr("Name")
264
310
value: backend.selectedDevice ? backend.selectedDevice.name : i18n.tr("None")
316
anchors.topMargin: units.gu(1)
317
anchors.leftMargin: units.gu(2)
318
anchors.rightMargin: units.gu(2)
324
topMargin: units.gu(1)
327
text: i18n.tr("Type")
331
right: deviceType.left
332
rightMargin: units.gu(1)
336
source: backend.selectedDevice ? backend.selectedDevice.iconName : ""
343
topMargin: units.gu(1)
346
text: getTypeString(backend.selectedDevice ? backend.selectedDevice.type : Device.OTHER)
266
350
ListItem.SingleValue {
267
text: i18n.tr("Type")
268
value: getTypeString(backend.selectedDevice ? backend.selectedDevice.type : Device.OTHER)
351
text: i18n.tr("Status")
352
value: getStatusString(backend.selectedDevice ? backend.selectedDevice.connection : Device.Disconnected)
270
354
ListItem.SingleValue {
271
355
text: i18n.tr("Signal Strength")
272
356
value: getSignalString(backend.selectedDevice ? backend.selectedDevice.strength : Device.None)
274
ListItem.SingleControl {
276
text: i18n.tr("Disconnect")
277
width: parent.width - units.gu(8)
279
backend.disconnectDevice();
360
text: i18n.tr("Connect automatically when detected:")
363
if (backend.selectedDevice) {
364
backend.selectedDevice.trusted = !backend.selectedDevice.trusted
367
checked: backend.selectedDevice ? backend.selectedDevice.trusted : false
369
Component.onCompleted:
370
clicked.connect(trustedCheck.clicked)
372
ListItem.SingleControl {
374
text: backend.selectedDevice && (backend.selectedDevice.connection == Device.Connected || backend.selectedDevice.connection == Device.Connecting) ? i18n.tr("Disconnect") : i18n.tr("Connect")
375
width: parent.width - units.gu(8)
377
if (backend.selectedDevice
378
&& (backend.selectedDevice.connection == Device.Connected
379
|| backend.selectedDevice.connection == Device.Connecting)) {
380
backend.disconnectDevice();
382
backend.stopDiscovery()
383
backend.connectDevice(backend.selectedDevice.address);
387
visible: backend.selectedDevice ? true : false
390
ListItem.SingleControl {
392
text: i18n.tr("Forget this device")
393
width: parent.width - units.gu(8)
395
backend.removeDevice();
398
enabled: backend.selectedDevice && backend.selectedDevice.path.length > 0 ? true : false