Warning, /plasma/plasma-nm/applet/contents/ui/ConnectionListPage.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2013-2017 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.15
0008 import QtQuick.Layouts 1.2
0009 import org.kde.plasma.components 3.0 as PlasmaComponents3
0010 import org.kde.kirigami 2.20 as Kirigami
0011 import org.kde.plasma.extras 2.0 as PlasmaExtras
0012 import org.kde.plasma.networkmanagement as PlasmaNM
0013 import org.kde.networkmanager as NMQt
0014 
0015 ColumnLayout {
0016     id: connectionListPage
0017 
0018     required property PlasmaNM.NetworkStatus nmStatus
0019     property alias model: connectionView.model
0020     property alias count: connectionView.count
0021 
0022     spacing: Kirigami.Units.smallSpacing * 2
0023 
0024     Keys.forwardTo: [connectionView]
0025 
0026     Kirigami.InlineMessage {
0027         id: connectivityMessage
0028         Layout.fillWidth: true
0029         Layout.leftMargin: connectionView.leftMargin
0030         Layout.rightMargin: connectionView.rightMargin
0031         Layout.topMargin: Kirigami.Units.smallSpacing * 2
0032         Layout.preferredHeight: contentItem.implicitHeight + topPadding + bottomPadding
0033         type: Kirigami.MessageType.Information
0034         icon.name: "dialog-password"
0035         text: i18n("You need to log in to this network")
0036         visible: connectionListPage.nmStatus.connectivity === NMQt.NetworkManager.Portal
0037 
0038         actions: Kirigami.Action {
0039             text: i18nc("@action:button", "Log in")
0040             onTriggered: {
0041                 Qt.openUrlExternally(connectionListPage.nmStatus.networkCheckUrl);
0042             }
0043         }
0044     }
0045 
0046     PlasmaComponents3.ScrollView {
0047         id: scrollView
0048 
0049         Layout.fillWidth: true
0050         Layout.fillHeight: true
0051         contentWidth: availableWidth - contentItem.leftMargin - contentItem.rightMargin
0052 
0053         contentItem: ListView {
0054             id: connectionView
0055 
0056             property int currentVisibleButtonIndex: -1
0057             property bool showSeparator: false
0058 
0059             Keys.onDownPressed: event => {
0060                 connectionView.incrementCurrentIndex();
0061                 connectionView.currentItem.forceActiveFocus();
0062             }
0063             Keys.onUpPressed: event => {
0064                 if (connectionView.currentIndex === 0) {
0065                     connectionView.currentIndex = -1;
0066                     toolbar.searchTextField.forceActiveFocus();
0067                     toolbar.searchTextField.selectAll();
0068                 } else {
0069                     event.accepted = false;
0070                 }
0071             }
0072 
0073             // We use the spacing around the connectivity message, if shown.
0074             topMargin: connectivityMessage.visible ? 0 : Kirigami.Units.smallSpacing * 2
0075             bottomMargin: Kirigami.Units.smallSpacing * 2
0076             leftMargin: Kirigami.Units.smallSpacing * 2
0077             rightMargin: Kirigami.Units.smallSpacing * 2
0078             spacing: Kirigami.Units.smallSpacing
0079             model: appletProxyModel
0080             currentIndex: -1
0081             boundsBehavior: Flickable.StopAtBounds
0082             section.property: showSeparator ? "Section" : ""
0083             section.delegate: ListItem {
0084                 separator: true
0085             }
0086             highlight: PlasmaExtras.Highlight { }
0087             highlightMoveDuration: 0
0088             highlightResizeDuration: 0
0089             delegate: ConnectionItem {
0090                 width: connectionView.width - Kirigami.Units.smallSpacing * 4
0091             }
0092 
0093             // Placeholder message
0094             Loader {
0095                 anchors.centerIn: parent
0096                 width: parent.width - (Kirigami.Units.largeSpacing * 4)
0097                 active: connectionView.count === 0
0098                 asynchronous: true
0099                 visible: status === Loader.Ready
0100                 sourceComponent: PlasmaExtras.PlaceholderMessage {
0101                     iconName: {
0102                         if (toolbar.displayplaneModeMessage) {
0103                             return "network-flightmode-on"
0104                         }
0105                         if (toolbar.displayWifiMessage) {
0106                             return "network-wireless-off"
0107                         }
0108                         if (toolbar.displayWwanMessage) {
0109                             return "network-mobile-off"
0110                         }
0111                         return "edit-none"
0112                     }
0113                     text: {
0114                         if (toolbar.displayplaneModeMessage) {
0115                             return i18n("Airplane mode is enabled")
0116                         }
0117                         if (toolbar.displayWifiMessage) {
0118                             if (toolbar.displayWwanMessage) {
0119                                 return i18n("Wireless and mobile networks are deactivated")
0120                             }
0121                             return i18n("Wireless is deactivated")
0122                         }
0123                         if (toolbar.displayWwanMessage) {
0124                             return i18n("Mobile network is deactivated")
0125                         }
0126                         if (toolbar.searchTextField.text.length > 0) {
0127                             return i18n("No matches")
0128                         }
0129                         return i18n("No available connections")
0130                     }
0131                 }
0132             }
0133         }
0134     }
0135 }