Warning, /plasma/plasma-nm/applet/contents/ui/PopupDialog.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.Controls 2.15 as QQC2
0009 import QtQuick.Layouts 1.2
0010 import org.kde.plasma.components 3.0 as PlasmaComponents3
0011 import org.kde.plasma.extras 2.0 as PlasmaExtras
0012 import org.kde.plasma.networkmanagement as PlasmaNM
0013 import org.kde.plasma.plasmoid 2.0
0014 
0015 PlasmaExtras.Representation {
0016     id: full
0017 
0018     required property PlasmaNM.Handler nmHandler
0019     required property PlasmaNM.NetworkStatus nmStatus
0020 
0021     collapseMarginsHint: true
0022 
0023     Component {
0024         id: networkModelComponent
0025         PlasmaNM.NetworkModel {}
0026     }
0027 
0028     property PlasmaNM.NetworkModel connectionModel: null
0029 
0030     PlasmaNM.AppletProxyModel {
0031         id: appletProxyModel
0032 
0033         sourceModel: full.connectionModel
0034     }
0035 
0036     header: PlasmaExtras.PlasmoidHeading {
0037         focus: true
0038         contentItem: RowLayout {
0039             Layout.fillWidth: true
0040 
0041             Toolbar {
0042                 id: toolbar
0043                 Layout.fillWidth: true
0044                 hasConnections: connectionListPage.count > 0
0045                 visible: stack.depth === 1
0046             }
0047 
0048             PlasmaComponents3.Button {
0049                 Layout.fillWidth: true
0050                 icon.name: mirrored ? "go-next" : "go-previous"
0051                 text: i18nc("@action:button", "Return to Network Connections")
0052                 visible: stack.depth > 1
0053                 onClicked: {
0054                     stack.pop()
0055                 }
0056             }
0057 
0058             Loader {
0059                 sourceComponent: stack.currentItem?.headerItems
0060                 visible: !!item
0061             }
0062         }
0063     }
0064 
0065     Connections {
0066         target: full.nmHandler
0067         function onWifiCodeReceived(data, ssid) {
0068             if (data.length === 0) {
0069                 console.error("Cannot create QR code component: Unsupported connection");
0070                 return;
0071             }
0072 
0073             const showQRComponent = Qt.createComponent("ShareNetworkQrCodePage.qml");
0074             if (showQRComponent.status === Component.Error) {
0075                 console.warn("Cannot create QR code component:", showQRComponent.errorString());
0076                 return;
0077             }
0078 
0079             mainWindow.expanded = true; // just in case.
0080             stack.push(showQRComponent, {
0081                 content: data,
0082                 ssid
0083             });
0084         }
0085     }
0086 
0087     Keys.forwardTo: [stack.currentItem]
0088     Keys.onPressed: event => {
0089         if (event.modifiers & Qt.ControlModifier && event.key == Qt.Key_F) {
0090             toolbar.searchTextField.forceActiveFocus();
0091             toolbar.searchTextField.selectAll();
0092             event.accepted = true;
0093         } else if (event.key === Qt.Key_Back || (event.modifiers & Qt.AltModifier && event.key == Qt.Key_Left)) {
0094             if (stack.depth > 1) {
0095                 stack.pop();
0096                 event.accepted = true;
0097             }
0098         } else {
0099             event.accepted = false;
0100         }
0101     }
0102 
0103     QQC2.StackView {
0104         id: stack
0105         anchors.fill: parent
0106         initialItem: ConnectionListPage {
0107             id: connectionListPage
0108             model: appletProxyModel
0109             nmStatus: full.nmStatus
0110         }
0111     }
0112 
0113     Connections {
0114         target: mainWindow
0115         function onExpandedChanged(expanded) {
0116             if (expanded) {
0117                 handler.requestScan();
0118                 if (!full.connectionModel) {
0119                     full.connectionModel = networkModelComponent.createObject(full);
0120                 }
0121             } else {
0122                 if (full.connectionModel) {
0123                     full.connectionModel.destroy();
0124                     full.connectionModel = null;
0125                 }
0126             }
0127         }
0128     }
0129 }