Warning, /network/kdeconnect-kde/plasmoid/package/contents/ui/Connectivity.qml is written in an unsupported language. File is not indexed.
0001 /** 0002 * SPDX-FileCopyrightText: 2021 David Shlemayev <david.shlemayev@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 import QtQuick 0008 import org.kde.plasma.core as PlasmaCore 0009 import org.kde.kdeconnect 0010 0011 QtObject { 0012 0013 id: root 0014 0015 property alias device: checker.device 0016 readonly property alias available: checker.available 0017 readonly property bool ready: connectivity 0018 0019 readonly property PluginChecker pluginChecker: PluginChecker { 0020 id: checker 0021 pluginName: "connectivity_report" 0022 } 0023 0024 /** 0025 * Reports a string indicating the network type. Possible values: 0026 * 5G 0027 * LTE 0028 * HSPA 0029 * UMTS 0030 * CDMA2000 0031 * EDGE 0032 * GPRS 0033 * GSM 0034 * CDMA 0035 * iDEN 0036 * 0037 * The parsing from Android values into these strings is handled in the 0038 * [ConnectivityReportPlugin.networkTypeToString method](https://invent.kde.org/network/kdeconnect-android/-/blob/master/src/org/kde/kdeconnect/Plugins/ConnectivityReportPlugin/ConnectivityReportPlugin.java#L82) 0039 */ 0040 readonly property string networkType: connectivity ? connectivity.cellularNetworkType : i18n("Unknown") 0041 0042 /** 0043 * Reports a value between 0 and 4 (inclusive) which represents the strength of the cellular connection 0044 */ 0045 readonly property int signalStrength: connectivity ? connectivity.cellularNetworkStrength : -1 0046 property string displayString: { 0047 if (ready) { 0048 return `${networkType} ${signalStrength}/4`; 0049 } else { 0050 return i18n("No signal"); 0051 } 0052 } 0053 property variant connectivity: null 0054 0055 /** 0056 * Suggests an icon name to use for the current signal level 0057 * 0058 * Returns names which correspond to Plasma Framework's network.svg: 0059 * https://invent.kde.org/frameworks/plasma-framework/-/blob/master/src/desktoptheme/breeze/icons/network.svg 0060 */ 0061 readonly property string iconName: { 0062 // Firstly, get the name prefix which represents the signal strength 0063 var signalStrengthIconName = 0064 (signalStrength < 0 || !ready) ? 0065 // As long as the signal strength is nonsense or the plugin reports as non-ready, 0066 // show us as disconnected 0067 "network-mobile-off" : 0068 (signalStrength == 0) ? 0069 "network-mobile-0" : 0070 (signalStrength == 1) ? 0071 "network-mobile-20" : 0072 (signalStrength == 2) ? 0073 "network-mobile-60" : 0074 (signalStrength == 3) ? 0075 "network-mobile-80" : 0076 (signalStrength == 4) ? 0077 "network-mobile-100" : 0078 // Since all possible values are enumerated above, this default case should never be hit. 0079 // However, I need it in order for my ternary syntax to be valid! 0080 "network-mobile-available" 0081 0082 // If we understand the network type, append to the icon name to show the type 0083 var networkTypeSuffix = 0084 (networkType === "5G") ? 0085 // No icon for this case! 0086 "" : 0087 (networkType === "LTE") ? 0088 "-lte" : 0089 (networkType === "HSPA") ? 0090 "-hspa" : 0091 (networkType === "UMTS") ? 0092 "-umts" : 0093 (networkType === "CDMA2000") ? 0094 // GSconnect just uses the 3g icon 0095 // No icon for this case! 0096 "" : 0097 (networkType === "EDGE") ? 0098 "-edge" : 0099 (networkType === "GPRS") ? 0100 "-gprs" : 0101 (networkType === "GSM") ? 0102 // GSconnect just uses the 2g icon 0103 // No icon for this case! 0104 "" : 0105 (networkType === "CDMA") ? 0106 // GSconnect just uses the 2g icon 0107 // No icon for this case! 0108 "" : 0109 (networkType === "iDEN") ? 0110 // GSconnect just uses the 2g icon 0111 // No icon for this case! 0112 "" : 0113 "" // We didn't recognize the network type. Don't append anything. 0114 return signalStrengthIconName + networkTypeSuffix 0115 } 0116 0117 onAvailableChanged: { 0118 if (available) { 0119 connectivity = DeviceConnectivityReportDbusInterfaceFactory.create(device.id()) 0120 } else { 0121 connectivity = null 0122 } 0123 } 0124 }