Warning, /plasma/bluedevil/src/kcm/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.kcmutils 0012 0013 import org.kde.bluezqt 1.0 as BluezQt 0014 0015 import "script.js" as Script; 0016 0017 SimpleKCM { 0018 0019 property var device 0020 0021 title: device.name 0022 0023 Connections { 0024 target: kcm 0025 function onNetworkAvailable(service, available) { 0026 0027 if (service === "dun") { 0028 dunButton.visible = available && device.connected 0029 } 0030 0031 if (service === "nap") { 0032 napButton.visible = available && device.connected 0033 } 0034 } 0035 } 0036 0037 Connections { 0038 target: device 0039 0040 function onConnectedChanged() { 0041 kcm.checkNetworkConnection(device.uuids, device.address) 0042 } 0043 } 0044 0045 Component.onCompleted: { 0046 kcm.checkNetworkConnection(device.uuids, device.address) 0047 } 0048 0049 header: Kirigami.InlineMessage { 0050 id: errorMessage 0051 type: Kirigami.MessageType.Error 0052 showCloseButton: true 0053 } 0054 0055 ColumnLayout { 0056 0057 Kirigami.Icon { 0058 source: device.icon 0059 Layout.preferredWidth: Kirigami.Units.iconSizes.enormous 0060 Layout.preferredHeight: Layout.preferredWidth 0061 Layout.alignment: Qt.AlignHCenter 0062 } 0063 0064 Kirigami.FormLayout { 0065 0066 Row { 0067 QQC2.Button { 0068 id: connectButton 0069 enabled: !indicator.running 0070 text: device.connected ? i18n("Disconnect") : i18n("Connect") 0071 icon.name: device.connected ? "network-disconnect-symbolic" : "network-connect-symbolic" 0072 0073 onClicked: { 0074 if (device.connected) { 0075 makeCall(device.disconnectFromDevice()) 0076 } else { 0077 makeCall(device.connectToDevice()) 0078 } 0079 } 0080 0081 function makeCall(call) { 0082 indicator.running = true 0083 call.finished.connect(call => { 0084 indicator.running = false 0085 if (call.error) { 0086 errorMessage.text = call.errorText 0087 errorMessage.visible = true 0088 } 0089 }) 0090 } 0091 } 0092 0093 QQC2.BusyIndicator { 0094 id: indicator 0095 running: false 0096 height: connectButton.height 0097 } 0098 } 0099 0100 QQC2.Label { 0101 text: Script.deviceTypeToString(device.type) 0102 Kirigami.FormData.label: i18n("Type:") 0103 } 0104 0105 QQC2.Label { 0106 text: { 0107 if (device.battery) { 0108 return i18n("%1%", device.battery.percentage) 0109 } 0110 } 0111 visible: device.battery && device.battery.percentage 0112 Kirigami.FormData.label: i18n("Battery:") 0113 } 0114 0115 QQC2.Label { 0116 text: device.address 0117 Kirigami.FormData.label: i18n("Address:") 0118 } 0119 0120 QQC2.Label { 0121 text: device.adapter.name 0122 Kirigami.FormData.label: i18n("Adapter:") 0123 } 0124 0125 QQC2.TextField { 0126 text: device.name 0127 onTextEdited: device.name = text 0128 Kirigami.FormData.label: i18n("Name:") 0129 } 0130 0131 QQC2.CheckBox { 0132 text: i18n("Trusted") 0133 checked: device.trusted 0134 onClicked: device.trusted = !device.trusted 0135 } 0136 0137 QQC2.CheckBox { 0138 text: i18n("Blocked") 0139 checked: device.blocked 0140 onClicked: device.blocked = !device.blocked 0141 } 0142 0143 QQC2.Button { 0144 text: i18n("Send File") 0145 visible: device.uuids.includes(BluezQt.Services.ObexObjectPush) && device.connected 0146 onClicked: kcm.runSendFile(device.ubi) 0147 } 0148 0149 QQC2.Button { 0150 id: napButton 0151 text: i18n("Setup NAP Network…") 0152 visible: false 0153 onClicked: kcm.setupNetworkConnection("nap", device.address, device.name) 0154 } 0155 0156 QQC2.Button { 0157 id: dunButton 0158 text: i18n("Setup DUN Network…") 0159 visible: false 0160 onClicked: kcm.setupNetworkConnection("dun", device.address, device.name) 0161 } 0162 } 0163 } 0164 }