Warning, /plasma/plasma-nm/kcm/qml/ConnectionItem.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2016 Jan Grulich <jgrulich@redhat.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 import QtQuick 2.1 0008 import QtQuick.Controls 2.15 as QQC 0009 import org.kde.kirigami 2.5 as Kirigami 0010 import org.kde.plasma.components 3.0 as PlasmaComponents3 0011 import org.kde.plasma.networkmanagement 0.2 as PlasmaNM 0012 0013 ListItem { 0014 id: connectionItem 0015 0016 height: connectionItemBase.height 0017 acceptedButtons: Qt.AllButtons 0018 checked: ConnectionPath === connectionView.currentConnectionPath 0019 0020 signal aboutToChangeConnection(bool exportable, string name, string path) 0021 signal aboutToExportConnection(string path) 0022 signal aboutToRemoveConnection(string name, string path) 0023 0024 onClicked: { 0025 if (mouse.button === Qt.LeftButton) { 0026 aboutToChangeConnection(KcmVpnConnectionExportable, Name, ConnectionPath) 0027 } else if (mouse.button == Qt.RightButton) { 0028 connectionItemMenu.popup() 0029 } 0030 } 0031 0032 Item { 0033 id: connectionItemBase 0034 0035 anchors { 0036 left: parent.left 0037 right: parent.right 0038 top: parent.top 0039 topMargin: -Math.round(Kirigami.Units.gridUnit / 3) 0040 } 0041 height: Math.max(Kirigami.Units.iconSizes.medium, connectionNameLabel.height + connectionStatusLabel.height) + Math.round(Kirigami.Units.gridUnit / 2) 0042 0043 Kirigami.Icon { 0044 id: connectionIcon 0045 0046 anchors { 0047 left: parent.left 0048 verticalCenter: parent.verticalCenter 0049 } 0050 height: Kirigami.Units.iconSizes.medium; width: height 0051 source: KcmConnectionIcon 0052 } 0053 0054 Text { 0055 id: connectionNameLabel 0056 0057 anchors { 0058 bottom: connectionIcon.verticalCenter 0059 left: connectionIcon.right 0060 leftMargin: Math.round(Kirigami.Units.gridUnit / 2) 0061 right: connectingIndicator.visible ? connectingIndicator.left : parent.right 0062 } 0063 color: textColor 0064 height: paintedHeight 0065 elide: Text.ElideRight 0066 font.weight: ConnectionState == PlasmaNM.Enums.Activated ? Font.DemiBold : Font.Normal 0067 font.italic: ConnectionState == PlasmaNM.Enums.Activating ? true : false 0068 text: Name 0069 textFormat: Text.PlainText 0070 } 0071 0072 Text { 0073 id: connectionStatusLabel 0074 0075 anchors { 0076 left: connectionIcon.right 0077 leftMargin: Math.round(Kirigami.Units.gridUnit / 2) 0078 right: connectingIndicator.visible ? connectingIndicator.left : parent.right 0079 top: connectionNameLabel.bottom 0080 } 0081 color: textColor 0082 height: paintedHeight 0083 elide: Text.ElideRight 0084 font.pointSize: Kirigami.Theme.smallFont.pointSize 0085 opacity: 0.6 0086 text: itemText() 0087 } 0088 0089 PlasmaComponents3.BusyIndicator { 0090 id: connectingIndicator 0091 0092 anchors { 0093 right: parent.right 0094 rightMargin: Math.round(Kirigami.Units.gridUnit / 2) 0095 verticalCenter: connectionIcon.verticalCenter 0096 } 0097 height: Kirigami.Units.iconSizes.medium 0098 width: Kirigami.Units.iconSizes.medium 0099 running: ConnectionState == PlasmaNM.Enums.Activating 0100 visible: running 0101 } 0102 } 0103 0104 QQC.Menu { 0105 id: connectionItemMenu 0106 0107 QQC.MenuItem { 0108 text: ConnectionState == PlasmaNM.Enums.Deactivated ? i18n("Connect") : i18n("Disconnect") 0109 visible: ItemType == 1 0110 onTriggered: { 0111 if (ConnectionState == PlasmaNM.Enums.Deactivated) { 0112 handler.activateConnection(ConnectionPath, DevicePath, SpecificPath); 0113 } else { 0114 handler.deactivateConnection(ConnectionPath, DevicePath); 0115 } 0116 } 0117 } 0118 0119 QQC.MenuItem { 0120 icon.name: "list-remove" 0121 text: i18n("Delete"); 0122 0123 onTriggered: { 0124 aboutToRemoveConnection(Name, ConnectionPath) 0125 } 0126 } 0127 0128 QQC.MenuItem { 0129 icon.name: "document-export" 0130 visible: KcmVpnConnectionExportable 0131 text: i18n("Export"); 0132 0133 onTriggered: aboutToExportConnection(ConnectionPath) 0134 } 0135 } 0136 0137 /* This generates the status description under each connection 0138 in the list at the left side of the applet. */ 0139 function itemText() { 0140 if (ConnectionState == PlasmaNM.Enums.Activated) { 0141 return i18n("Connected") 0142 } else if (ConnectionState == PlasmaNM.Enums.Activating) { 0143 return i18n("Connecting") 0144 } else { 0145 return LastUsed 0146 } 0147 } 0148 }