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.Layouts 1.2 0009 import org.kde.plasma.components 3.0 as PlasmaComponents3 0010 import org.kde.plasma.core 2.0 as PlasmaCore 0011 import org.kde.plasma.extras 2.0 as PlasmaExtras 0012 import org.kde.plasma.networkmanagement 0.2 as PlasmaNM 0013 0014 PlasmaExtras.Representation { 0015 id: full 0016 collapseMarginsHint: true 0017 property alias toolbarValues: toolbar 0018 0019 Component { 0020 id: networkModelComponent 0021 PlasmaNM.NetworkModel {} 0022 } 0023 0024 property PlasmaNM.NetworkModel connectionModel: null 0025 0026 PlasmaNM.AppletProxyModel { 0027 id: appletProxyModel 0028 0029 sourceModel: full.connectionModel 0030 } 0031 0032 header: PlasmaExtras.PlasmoidHeading { 0033 focus: true 0034 leftPadding: PlasmaCore.Units.smallSpacing 0035 contentItem: Toolbar { 0036 id: toolbar 0037 width: parent.width 0038 } 0039 } 0040 0041 Keys.forwardTo: [connectionView] 0042 Keys.onPressed: { 0043 if (event.modifiers & Qt.ControlModifier && event.key == Qt.Key_F) { 0044 toolbar.searchTextField.forceActiveFocus(); 0045 toolbar.searchTextField.selectAll(); 0046 event.accepted = true; 0047 } else { 0048 event.accepted = false; 0049 } 0050 } 0051 0052 PlasmaComponents3.ScrollView { 0053 id: scrollView 0054 anchors.fill: parent 0055 0056 // HACK: workaround for https://bugreports.qt.io/browse/QTBUG-83890 0057 PlasmaComponents3.ScrollBar.horizontal.policy: PlasmaComponents3.ScrollBar.AlwaysOff 0058 0059 contentWidth: availableWidth - contentItem.leftMargin - contentItem.rightMargin 0060 0061 contentItem: ListView { 0062 id: connectionView 0063 0064 property int currentVisibleButtonIndex: -1 0065 property bool showSeparator: false 0066 0067 Keys.onDownPressed: { 0068 connectionView.incrementCurrentIndex(); 0069 connectionView.currentItem.forceActiveFocus(); 0070 } 0071 Keys.onUpPressed: { 0072 if (connectionView.currentIndex === 0) { 0073 connectionView.currentIndex = -1; 0074 toolbar.searchTextField.forceActiveFocus(); 0075 toolbar.searchTextField.selectAll(); 0076 } else { 0077 event.accepted = false; 0078 } 0079 } 0080 0081 Loader { 0082 anchors.centerIn: parent 0083 width: parent.width - (PlasmaCore.Units.largeSpacing * 4) 0084 active: connectionView.count === 0 0085 asynchronous: true 0086 visible: status == Loader.Ready 0087 sourceComponent: PlasmaExtras.PlaceholderMessage { 0088 iconName: { 0089 if (toolbarValues.displayplaneModeMessage) { 0090 return "network-flightmode-on" 0091 } 0092 if (toolbarValues.displayWifiMessage) { 0093 return "network-wireless-off" 0094 } 0095 if (toolbarValues.displayWwanMessage) { 0096 return "network-mobile-off" 0097 } 0098 return "edit-none" 0099 } 0100 text: { 0101 if (toolbarValues.displayplaneModeMessage) { 0102 return i18n("Airplane mode is enabled") 0103 } 0104 if (toolbarValues.displayWifiMessage) { 0105 if (toolbarValues.displayWwanMessage) { 0106 return i18n("Wireless and mobile networks are deactivated") 0107 } 0108 return i18n("Wireless is deactivated") 0109 } 0110 if (toolbarValues.displayWwanMessage) { 0111 return i18n("Mobile network is deactivated") 0112 } 0113 if (toolbar.searchTextField.text.length > 0) { 0114 return i18n("No matches") 0115 } 0116 return i18n("No available connections") 0117 } 0118 } 0119 } 0120 0121 topMargin: PlasmaCore.Units.smallSpacing * 2 0122 bottomMargin: PlasmaCore.Units.smallSpacing * 2 0123 leftMargin: PlasmaCore.Units.smallSpacing * 2 0124 rightMargin: PlasmaCore.Units.smallSpacing * 2 0125 spacing: PlasmaCore.Units.smallSpacing 0126 model: appletProxyModel 0127 currentIndex: -1 0128 boundsBehavior: Flickable.StopAtBounds 0129 section.property: showSeparator ? "Section" : "" 0130 section.delegate: ListItem { 0131 separator: true 0132 } 0133 highlight: PlasmaExtras.Highlight { } 0134 highlightMoveDuration: 0 0135 highlightResizeDuration: 0 0136 delegate: ConnectionItem { 0137 width: connectionView.width - PlasmaCore.Units.smallSpacing * 4 0138 } 0139 } 0140 } 0141 0142 Connections { 0143 target: plasmoid 0144 function onExpandedChanged(expanded) { 0145 connectionView.currentVisibleButtonIndex = -1; 0146 0147 if (expanded) { 0148 handler.requestScan(); 0149 if (!full.connectionModel) { 0150 full.connectionModel = networkModelComponent.createObject(full); 0151 } 0152 } else { 0153 if (full.connectionModel) { 0154 full.connectionModel.destroy(); 0155 full.connectionModel = null; 0156 } 0157 } 0158 } 0159 } 0160 }