Warning, /plasma/bluedevil/src/kcm/package/contents/ui/Device.qml is written in an unsupported language. File is not indexed.
0001 /** 0002 * SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de> 0003 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 import QtQuick 2.2 0007 import QtQuick.Layouts 1.1 0008 import QtQuick.Controls 2.0 as QQC2 0009 0010 import org.kde.kirigami 2.10 as Kirigami 0011 import org.kde.kcm 1.2 0012 0013 import org.kde.bluezqt 1.0 as BluezQt 0014 0015 SimpleKCM { 0016 0017 property var device 0018 0019 title: device.name 0020 0021 Connections { 0022 target: kcm 0023 function onNetworkAvailable(service, available) { 0024 0025 if (service === "dun") { 0026 dunButton.visible = available && device.connected 0027 } 0028 0029 if (service === "nap") { 0030 napButton.visible = available && device.connected 0031 } 0032 } 0033 } 0034 0035 Connections { 0036 target: device 0037 0038 function onConnectedChanged() { 0039 kcm.checkNetworkConnection(device.uuids, device.address) 0040 } 0041 } 0042 0043 Component.onCompleted: { 0044 kcm.checkNetworkConnection(device.uuids, device.address) 0045 } 0046 0047 header: Kirigami.InlineMessage { 0048 id: errorMessage 0049 type: Kirigami.MessageType.Error 0050 showCloseButton: true 0051 } 0052 0053 ColumnLayout { 0054 0055 Kirigami.Icon { 0056 source: device.icon 0057 Layout.preferredWidth: Kirigami.Units.iconSizes.enormous 0058 Layout.preferredHeight: Layout.preferredWidth 0059 Layout.alignment: Qt.AlignHCenter 0060 } 0061 0062 Kirigami.FormLayout { 0063 0064 Row { 0065 QQC2.Button { 0066 id: connectButton 0067 enabled: !indicator.running 0068 text: device.connected ? i18n("Disconnect") : i18n("Connect") 0069 icon.name: device.connected ? "network-disconnect" : "network-connect" 0070 0071 onClicked: { 0072 if (device.connected) { 0073 makeCall(device.disconnectFromDevice()) 0074 } else { 0075 makeCall(device.connectToDevice()) 0076 } 0077 } 0078 0079 function makeCall(call) { 0080 indicator.running = true 0081 call.finished.connect(call => { 0082 indicator.running = false 0083 if (call.error) { 0084 errorMessage.text = call.errorText 0085 errorMessage.visible = true 0086 } 0087 }) 0088 } 0089 } 0090 0091 QQC2.BusyIndicator { 0092 id: indicator 0093 running: false 0094 height: connectButton.height 0095 } 0096 } 0097 0098 QQC2.Label { 0099 text: deviceTypeToString(device.type) 0100 Kirigami.FormData.label: i18n("Type:") 0101 } 0102 0103 QQC2.Label { 0104 text: device.address 0105 Kirigami.FormData.label: i18n("Address:") 0106 } 0107 0108 QQC2.Label { 0109 text: device.adapter.name 0110 Kirigami.FormData.label: i18n("Adapter:") 0111 } 0112 0113 QQC2.TextField { 0114 text: device.name 0115 onTextEdited: device.name = text 0116 Kirigami.FormData.label: i18n("Name:") 0117 } 0118 0119 QQC2.CheckBox { 0120 text: i18n("Trusted") 0121 checked: device.trusted 0122 onClicked: device.trusted = !device.trusted 0123 } 0124 0125 QQC2.CheckBox { 0126 text: i18n("Blocked") 0127 checked: device.blocked 0128 onClicked: device.blocked = !device.blocked 0129 } 0130 0131 QQC2.Button { 0132 text: i18n("Send File") 0133 visible: device.uuids.includes(BluezQt.Services.ObexObjectPush) && device.connected 0134 onClicked: kcm.runSendFile(device.ubi) 0135 } 0136 0137 QQC2.Button { 0138 id: napButton 0139 text: i18n("Setup NAP Network…") 0140 visible: false 0141 onClicked: kcm.setupNetworkConnection("nap", device.address, device.name) 0142 } 0143 0144 QQC2.Button { 0145 id: dunButton 0146 text: i18n("Setup DUN Network…") 0147 visible: false 0148 onClicked: kcm.setupNetworkConnection("dun", device.address, device.name) 0149 } 0150 } 0151 } 0152 0153 function deviceTypeToString(type) { 0154 switch (type) { 0155 case BluezQt.Device.Phone: 0156 return i18nc("This device is a Phone", "Phone"); 0157 case BluezQt.Device.Modem: 0158 return i18nc("This device is a Modem", "Modem"); 0159 case BluezQt.Device.Computer: 0160 return i18nc("This device is a Computer", "Computer"); 0161 case BluezQt.Device.Network: 0162 return i18nc("This device is of type Network", "Network"); 0163 case BluezQt.Device.Headset: 0164 return i18nc("This device is a Headset", "Headset"); 0165 case BluezQt.Device.Headphones: 0166 return i18nc("This device is a Headphones", "Headphones"); 0167 case BluezQt.Device.AudioVideo: 0168 return i18nc("This device is an Audio/Video device", "Multimedia Device"); 0169 case BluezQt.Device.Keyboard: 0170 return i18nc("This device is a Keyboard", "Keyboard"); 0171 case BluezQt.Device.Mouse: 0172 return i18nc("This device is a Mouse", "Mouse"); 0173 case BluezQt.Device.Joypad: 0174 return i18nc("This device is a Joypad", "Joypad"); 0175 case BluezQt.Device.Tablet: 0176 return i18nc("This device is a Graphics Tablet (input device)", "Tablet"); 0177 case BluezQt.Device.Peripheral: 0178 return i18nc("This device is a Peripheral device", "Peripheral"); 0179 case BluezQt.Device.Camera: 0180 return i18nc("This device is a Camera", "Camera"); 0181 case BluezQt.Device.Printer: 0182 return i18nc("This device is a Printer", "Printer"); 0183 case BluezQt.Device.Imaging: 0184 return i18nc("This device is an Imaging device (printer, scanner, camera, display, …)", "Imaging"); 0185 case BluezQt.Device.Wearable: 0186 return i18nc("This device is a Wearable", "Wearable"); 0187 case BluezQt.Device.Toy: 0188 return i18nc("This device is a Toy", "Toy"); 0189 case BluezQt.Device.Health: 0190 return i18nc("This device is a Health device", "Health"); 0191 default: 0192 return i18nc("Type of device: could not be determined", "Unknown"); 0193 } 0194 } 0195 }