Warning, /system/mycroft-gui/containments/mark2/package/contents/ui/networking/NetworkItem.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright 2018 by Aditya Mehra <aix.m@outlook.com>
0003  *
0004  * Licensed under the Apache License, Version 2.0 (the "License");
0005  * you may not use this file except in compliance with the License.
0006  * You may obtain a copy of the License at
0007  *
0008  *    http://www.apache.org/licenses/LICENSE-2.0
0009  *
0010  * Unless required by applicable law or agreed to in writing, software
0011  * distributed under the License is distributed on an "AS IS" BASIS,
0012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013  * See the License for the specific language governing permissions and
0014  * limitations under the License.
0015  *
0016  */
0017 
0018 import QtQuick 2.2
0019 import QtQuick.Layouts 1.2
0020 import org.kde.plasma.components 2.0 as PlasmaComponents
0021 import org.kde.plasma.core 2.0 as PlasmaCore
0022 import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
0023 import org.kde.kirigami 2.5 as Kirigami
0024 
0025 Kirigami.AbstractListItem {
0026     id: connectionItem
0027 
0028     property bool activating: model.ConnectionState == PlasmaNM.Enums.Activating
0029     property bool deactivating: model.ConnectionState == PlasmaNM.Enums.Deactivating
0030     property bool predictableWirelessPassword: !model.Uuid && model.Type == PlasmaNM.Enums.Wireless &&
0031                                                (model.SecurityType == PlasmaNM.Enums.StaticWep || model.SecurityType == PlasmaNM.Enums.WpaPsk ||
0032                                                 model.SecurityType == PlasmaNM.Enums.Wpa2Psk)
0033     
0034     contentItem: Item {
0035             implicitWidth: delegateLayout.implicitWidth;
0036             implicitHeight: delegateLayout.implicitHeight;
0037     
0038     ColumnLayout {
0039         id: delegateLayout
0040         anchors {
0041             left: parent.left;
0042             top: parent.top;
0043             right: parent.right;
0044         }
0045 
0046         RowLayout {
0047             Layout.fillWidth: true
0048             spacing: Math.round(units.gridUnit / 2)
0049 
0050             Kirigami.Icon {
0051                 id: connectionSvgIcon
0052                 Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
0053                 Layout.preferredHeight: units.iconSizes.medium
0054                 Layout.preferredWidth: units.iconSizes.medium
0055                 //elementId: model.ConnectionIcon
0056                 source: "network-wireless-connected-100"
0057             }
0058 
0059             ColumnLayout {
0060                 Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
0061 
0062                 Kirigami.Heading {
0063                     id: connectionNameLabel
0064                     Layout.alignment: Qt.AlignLeft
0065                     level: 2
0066                     elide: Text.ElideRight
0067                     font.weight: model.ConnectionState == PlasmaNM.Enums.Activated ? Font.DemiBold : Font.Normal
0068                     font.italic: model.ConnectionState == PlasmaNM.Enums.Activating ? true : false
0069                     text: model.ItemUniqueName
0070                     textFormat: Text.PlainText
0071                 }
0072 
0073                 Kirigami.Heading {
0074                     id: connectionStatusLabel
0075                     Layout.alignment: Qt.AlignLeft
0076                     level: 3
0077                     elide: Text.ElideRight
0078                     opacity: 0.6
0079                     text: itemText()
0080                 }
0081             }
0082         }
0083     }
0084 }
0085 
0086     function itemText() {
0087         if (model.ConnectionState == PlasmaNM.Enums.Activating) {
0088             if (model.Type == PlasmaNM.Enums.Vpn)
0089                 return model.VpnState
0090             else
0091                 return model.DeviceState
0092         } else if (model.ConnectionState == PlasmaNM.Enums.Deactivating) {
0093             if (model.Type == PlasmaNM.Enums.Vpn)
0094                 return model.VpnState
0095             else
0096                 return model.DeviceState
0097         } else if (model.ConnectionState == PlasmaNM.Enums.Deactivated) {
0098             var result = model.LastUsed
0099             if (model.SecurityType > PlasmaNM.Enums.NoneSecurity)
0100                 result += ", " + model.SecurityTypeString
0101             return result
0102         } else if (model.ConnectionState == PlasmaNM.Enums.Activated) {
0103                 return i18n("Connected")
0104         }
0105     }
0106 
0107     onClicked: {
0108         console.log(model.ConnectionPath, model.DevicePath, model.SpecificPath)
0109         if(!model.ConnectionPath){
0110             networkingLoader.devicePath = model.DevicePath
0111             networkingLoader.specificPath = model.SpecificPath
0112             networkingLoader.connectionName = connectionNameLabel.text
0113             networkingLoader.securityType = model.SecurityType
0114             networkingLoader.source = "../networking/NetworkConnect.qml"
0115         }
0116         else if (model.ConnectionState == PlasmaNM.Enums.Deactivated) {
0117             networkingLoader.source = "../networking/Connecting.qml"
0118             handler.activateConnection(model.ConnectionPath, model.DevicePath, model.SpecificPath)
0119         }
0120         else {
0121             handler.deactivateConnection(model.ConnectionPath, model.DevicePath)
0122         }
0123     }
0124     
0125     onPressAndHold: {
0126         pathToRemove = model.ConnectionPath
0127         networkActions.open()
0128     }
0129 }