Warning, /plasma/plasma-bigscreen/kcms/wifi/ui/DetailsText.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2021 Aditya Mehra <aix.m@outlook.com>
0003     SPDX-FileCopyrightText: 2013-2017 Jan Grulich <jgrulich@redhat.com>
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 import QtQuick 2.14
0008 import QtQuick.Layouts 1.12
0009 import org.kde.plasma.components 3.0 as PlasmaComponents
0010 import org.kde.kirigami 2.12 as Kirigami
0011 
0012 Item {
0013     property bool connected
0014     property var connectionType
0015     property var details: []
0016     property var ipDetails: []
0017     property var networkDetails: []
0018 
0019     onDetailsChanged: {
0020         if(connected){
0021             var detailLength = details.length
0022             ipDetails = details.slice(0, 8);
0023             networkDetails = details.slice(8, detailLength)
0024         } else {
0025             networkDetails = details
0026         }
0027     }
0028 
0029     Kirigami.Heading {
0030         id: ipAddressesLabel
0031         anchors.top: parent.top
0032         anchors.left: parent.left
0033         anchors.right: parent.right
0034         anchors.leftMargin: Kirigami.Units.largeSpacing
0035         text: "IP Address Details"
0036         visible: ipDetails.length > 0 ? 1 : 0
0037         enabled: ipDetails.length > 0 ? 1 : 0
0038     }
0039 
0040     Column {
0041         id: ipAddressBlockColumn
0042         width: parent.width
0043         anchors.top: ipAddressesLabel.bottom
0044         anchors.topMargin: Kirigami.Units.largeSpacing
0045         visible: ipDetails.length > 0 ? 1 : 0
0046         enabled: ipDetails.length > 0 ? 1 : 0
0047 
0048         Repeater {
0049             id: ipAddressBlockRepeater
0050 
0051             property int contentHeight: 0
0052             property int longestString: 0
0053             visible: ipDetails.length > 0 ? 1 : 0
0054             enabled: ipDetails.length > 0 ? 1 : 0
0055 
0056             model: ipDetails.length / 2
0057 
0058             Item {
0059                 anchors {
0060                     left: parent.left
0061                     right: parent.right
0062                 }
0063                 height: Math.max(detailNameLabel.height, detailValueLabel.height)
0064 
0065                 PlasmaComponents.Label {
0066                     id: detailNameLabel
0067                     anchors {
0068                         left: parent.left
0069                         leftMargin: Kirigami.Units.largeSpacing
0070                     }
0071                     height: paintedHeight
0072                     horizontalAlignment: Text.AlignLeft
0073                     text: ipDetails[index*2] + ": "
0074 
0075                     Component.onCompleted: {
0076                         if (paintedWidth > ipAddressBlockRepeater.longestString) {
0077                             ipAddressBlockRepeater.longestString = paintedWidth
0078                         }
0079                     }
0080                 }
0081 
0082                 PlasmaComponents.Label {
0083                     id: detailValueLabel
0084                     anchors {
0085                         left: detailNameLabel.right
0086                         right: parent.right
0087                     }
0088                     height: paintedHeight
0089                     elide: Text.ElideRight
0090                     text: ipDetails[(index*2)+1]
0091                     textFormat: Text.PlainText
0092                     wrapMode: Text.WrapAnywhere
0093                 }
0094             }
0095         }
0096     }
0097 
0098     Kirigami.Separator {
0099         id: detailsSept
0100         anchors.top: ipAddressBlockColumn.bottom
0101         anchors.topMargin: Kirigami.Units.largeSpacing
0102         visible: connected
0103         height: 1
0104         anchors.left: parent.left
0105         anchors.leftMargin: Kirigami.Units.largeSpacing
0106         anchors.right: parent.right
0107         anchors.rightMargin: Kirigami.Units.largeSpacing
0108     }
0109 
0110     Kirigami.Heading {
0111         id: networkInformationLabel
0112         anchors.top: detailsSept.visible ? detailsSept.bottom : parent.top
0113         anchors.topMargin: Kirigami.Units.largeSpacing
0114         anchors.left: parent.left
0115         anchors.right: parent.right
0116         anchors.leftMargin: Kirigami.Units.largeSpacing
0117         text: "Network Information"
0118         visible: networkDetails.length > 0 ? 1 : 0
0119         enabled: networkDetails.length > 0 ? 1 : 0
0120     }
0121 
0122     Column {
0123         id: networkInformationBlockColumn
0124         width: parent.width
0125         anchors.top: networkInformationLabel.bottom
0126         anchors.topMargin: Kirigami.Units.largeSpacing
0127         anchors.bottom: parent.bottom
0128         visible: networkDetails.length > 0 ? 1 : 0
0129         enabled: networkDetails.length > 0 ? 1 : 0
0130 
0131         Repeater {
0132             id: networkInformationRepeater
0133 
0134             property int contentHeight: 0
0135             property int longestString: 0
0136             visible: networkDetails.length > 0 ? 1 : 0
0137             enabled: networkDetails.length > 0 ? 1 : 0
0138 
0139             model: networkDetails.length / 2
0140 
0141             Item {
0142                 anchors {
0143                     left: parent.left
0144                     right: parent.right
0145                 }
0146                 height: Math.max(detailNameLabel.height, detailValueLabel.height)
0147 
0148                 PlasmaComponents.Label {
0149                     id: detailNameLabel
0150                     anchors {
0151                         left: parent.left
0152                         leftMargin: Kirigami.Units.largeSpacing
0153                     }
0154                     height: paintedHeight
0155                     horizontalAlignment: Text.AlignRight
0156                     text: networkDetails[index*2] + ": "
0157 
0158                     Component.onCompleted: {
0159                         if (paintedWidth > networkInformationRepeater.longestString) {
0160                             networkInformationRepeater.longestString = paintedWidth
0161                         }
0162                     }
0163                 }
0164 
0165                 PlasmaComponents.Label {
0166                     id: detailValueLabel
0167                     anchors {
0168                         left: detailNameLabel.right
0169                         right: parent.right
0170                     }
0171                     height: paintedHeight
0172                     elide: Text.ElideRight
0173                     text: networkDetails[(index*2)+1]
0174                     textFormat: Text.PlainText
0175                     wrapMode: Text.Wrap
0176                 }
0177             }
0178         }
0179     }
0180 }
0181