Warning, /plasma/plasma-bigscreen/kcms/wifi/ui/NetworkItem.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2018 Aditya Mehra <aix.m@outlook.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 0006 */ 0007 0008 import QtQuick 2.14 0009 import QtQuick.Layouts 1.14 0010 import org.kde.plasma.core 2.0 as PlasmaCore 0011 import org.kde.plasma.networkmanagement as PlasmaNM 0012 import org.kde.kirigami 2.12 as Kirigami 0013 0014 Kirigami.AbstractListItem { 0015 id: connectionItem 0016 0017 property bool activating: model.ConnectionState == PlasmaNM.Enums.Activating 0018 property bool deactivating: model.ConnectionState == PlasmaNM.Enums.Deactivating 0019 property bool predictableWirelessPassword: !model.Uuid && model.Type == PlasmaNM.Enums.Wireless && 0020 (model.SecurityType == PlasmaNM.Enums.StaticWep || model.SecurityType == PlasmaNM.Enums.WpaPsk || 0021 model.SecurityType == PlasmaNM.Enums.Wpa2Psk) 0022 0023 checked: connectionView.currentIndex === index && connectionView.activeFocus 0024 contentItem: Item { 0025 implicitWidth: delegateLayout.implicitWidth; 0026 implicitHeight: delegateLayout.implicitHeight; 0027 0028 ColumnLayout { 0029 id: delegateLayout 0030 anchors { 0031 left: parent.left; 0032 top: parent.top; 0033 right: parent.right; 0034 } 0035 0036 RowLayout { 0037 Layout.fillWidth: true 0038 spacing: Math.round(units.gridUnit / 2) 0039 0040 Kirigami.Icon { 0041 id: connectionSvgIcon 0042 Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft 0043 Layout.preferredHeight: PlasmaCore.Units.iconSizes.medium 0044 Layout.preferredWidth: PlasmaCore.Units.iconSizes.medium 0045 color: Kirigami.Theme.textColor 0046 //elementId: model.ConnectionIcon 0047 source: itemSignalIcon(model.Signal) 0048 } 0049 0050 ColumnLayout { 0051 Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft 0052 0053 Kirigami.Heading { 0054 id: connectionNameLabel 0055 Layout.alignment: Qt.AlignLeft 0056 level: 2 0057 elide: Text.ElideRight 0058 font.weight: model.ConnectionState == PlasmaNM.Enums.Activated ? Font.DemiBold : Font.Normal 0059 font.italic: model.ConnectionState == PlasmaNM.Enums.Activating ? true : false 0060 text: model.ItemUniqueName 0061 textFormat: Text.PlainText 0062 } 0063 0064 Kirigami.Heading { 0065 id: connectionStatusLabel 0066 Layout.alignment: Qt.AlignLeft 0067 level: 3 0068 elide: Text.ElideRight 0069 opacity: 0.6 0070 text: itemText() 0071 } 0072 } 0073 } 0074 } 0075 } 0076 0077 function itemText() { 0078 if (model.ConnectionState == PlasmaNM.Enums.Activating) { 0079 if (model.Type == PlasmaNM.Enums.Vpn) 0080 return model.VpnState 0081 else 0082 return model.DeviceState 0083 } else if (model.ConnectionState == PlasmaNM.Enums.Deactivating) { 0084 if (model.Type == PlasmaNM.Enums.Vpn) 0085 return model.VpnState 0086 else 0087 return model.DeviceState 0088 } else if (model.ConnectionState == PlasmaNM.Enums.Deactivated) { 0089 var result = model.LastUsed 0090 if (model.SecurityType > PlasmaNM.Enums.NoneSecurity) 0091 result += ", " + model.SecurityTypeString 0092 return result 0093 } else if (model.ConnectionState == PlasmaNM.Enums.Activated) { 0094 return i18n("Connected") 0095 } 0096 } 0097 0098 function itemSignalIcon(signalState) { 0099 if (signalState <= 25){ 0100 return "network-wireless-connected-25" 0101 } else if (signalState <= 50){ 0102 return "network-wireless-connected-50" 0103 } else if (signalState <= 75){ 0104 return "network-wireless-connected-75" 0105 } else if (signalState <= 100){ 0106 return "network-wireless-connected-100" 0107 } else { 0108 return "network-wireless-connected-00" 0109 } 0110 } 0111 0112 Keys.onReturnPressed: clicked() 0113 onClicked: { 0114 if (!model.ConnectionPath) { 0115 networkSelectionView.devicePath = model.DevicePath 0116 networkSelectionView.specificPath = model.SpecificPath 0117 networkSelectionView.connectionName = connectionNameLabel.text 0118 networkSelectionView.securityType = model.SecurityType 0119 passwordLayer.open(); 0120 } else if (model.ConnectionState == PlasmaNM.Enums.Deactivated) { 0121 handler.activateConnection(model.ConnectionPath, model.DevicePath, model.SpecificPath) 0122 } else { 0123 handler.deactivateConnection(model.ConnectionPath, model.DevicePath) 0124 } 0125 } 0126 0127 onPressAndHold: { 0128 pathToRemove = model.ConnectionPath 0129 nameToRemove = model.ItemUniqueName 0130 networkActions.open() 0131 } 0132 }