Warning, /plasma/plasma-mobile/kcms/wifi/ui/ConnectionItemDelegate.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2017 Martin Kacej <m.kacej@atlas.sk> 0002 // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org> 0003 // SPDX-License-Identifier: LGPL-2.0-or-later 0004 0005 import QtQuick 0006 import QtQuick.Layouts 0007 import QtQuick.Window 0008 import QtQuick.Controls as Controls 0009 0010 import org.kde.plasma.networkmanagement as PlasmaNM 0011 import org.kde.kirigami as Kirigami 0012 import org.kde.ksvg as KSvg 0013 import org.kde.kirigamiaddons.formcard 1 as FormCard 0014 0015 FormCard.AbstractFormDelegate { 0016 id: root 0017 0018 property bool editMode 0019 property var map : [] 0020 property bool predictableWirelessPassword: !Uuid && Type == PlasmaNM.Enums.Wireless && 0021 (SecurityType == PlasmaNM.Enums.StaticWep || 0022 SecurityType == PlasmaNM.Enums.WpaPsk || 0023 SecurityType == PlasmaNM.Enums.Wpa2Psk || 0024 SecurityType == PlasmaNM.Enums.SAE) 0025 0026 verticalPadding: Kirigami.Units.largeSpacing 0027 0028 contentItem: RowLayout { 0029 spacing: 0 0030 0031 Item { 0032 Layout.rightMargin: Kirigami.Units.gridUnit 0033 implicitWidth: Kirigami.Units.iconSizes.smallMedium 0034 implicitHeight: Kirigami.Units.iconSizes.smallMedium 0035 0036 Kirigami.Icon { 0037 implicitWidth: Kirigami.Units.iconSizes.smallMedium 0038 implicitHeight: Kirigami.Units.iconSizes.smallMedium 0039 visible: ConnectionState !== PlasmaNM.Enums.Activating 0040 anchors.centerIn: parent 0041 source: mobileProxyModel.showSavedMode ? "network-wireless-connected-100" : ConnectionIcon 0042 } 0043 0044 Controls.BusyIndicator { 0045 anchors.fill: parent 0046 running: ConnectionState === PlasmaNM.Enums.Activating 0047 } 0048 } 0049 0050 Controls.Label { 0051 id: internalTextItem 0052 Layout.fillWidth: true 0053 text: ItemUniqueName 0054 elide: Text.ElideRight 0055 font.bold: ConnectionState === PlasmaNM.Enums.Activated 0056 Accessible.ignored: true // base class sets this text on root already 0057 } 0058 0059 RowLayout { 0060 Kirigami.Icon { 0061 Layout.alignment: Qt.AlignVCenter 0062 Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium 0063 Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium 0064 visible: ConnectionState === PlasmaNM.Enums.Activated 0065 source: 'checkmark' 0066 } 0067 0068 // ensure that the row is always of same height 0069 Controls.ToolButton { 0070 id: heightMetrics 0071 opacity: 0 0072 implicitWidth: 0 0073 icon.name: 'network-connect' 0074 enabled: false 0075 } 0076 Controls.ToolButton { 0077 icon.name: "network-connect" 0078 text: i18n('Connect') 0079 visible: ConnectionState != PlasmaNM.Enums.Activated && root.editMode 0080 display: Controls.ToolButton.IconOnly 0081 onClicked: changeState() 0082 } 0083 Controls.ToolButton { 0084 icon.name: "network-disconnect" 0085 text: i18n('Disconnect') 0086 visible: ConnectionState == PlasmaNM.Enums.Activated && root.editMode 0087 display: Controls.ToolButton.IconOnly 0088 onClicked: handler.deactivateConnection(ConnectionPath, DevicePath) 0089 } 0090 Controls.ToolButton { 0091 icon.name: "configure" 0092 text: i18n('Configure') 0093 visible: (Uuid != "") && root.editMode 0094 display: Controls.ToolButton.IconOnly 0095 onClicked: { 0096 kcm.push("NetworkSettings.qml", {path: ConnectionPath}) 0097 } 0098 } 0099 Controls.ToolButton { 0100 icon.name: "entry-delete" 0101 text: i18n('Delete') 0102 visible: (Uuid != "") && root.editMode 0103 display: Controls.ToolButton.IconOnly 0104 onClicked: handler.removeConnection(ConnectionPath) 0105 } 0106 } 0107 } 0108 0109 onClicked: { 0110 changeState() 0111 } 0112 0113 function changeState() { 0114 if (Uuid || !predictableWirelessPassword) { 0115 if (ConnectionState == PlasmaNM.Enums.Deactivated) { 0116 if (!predictableWirelessPassword && !Uuid) { 0117 handler.addAndActivateConnection(DevicePath, SpecificPath); 0118 } else { 0119 handler.activateConnection(ConnectionPath, DevicePath, SpecificPath); 0120 } 0121 } else{ 0122 //show popup 0123 } 0124 } else if (predictableWirelessPassword) { 0125 connectionDialog.headingText = i18n("Connect to") + " " + ItemUniqueName; 0126 connectionDialog.devicePath = DevicePath; 0127 connectionDialog.specificPath = SpecificPath; 0128 connectionDialog.securityType = SecurityType; 0129 connectionDialog.openAndClear(); 0130 } 0131 } 0132 }