Warning, /plasma/plasma-mobile/kcms/cellularnetwork/ui/main.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2018 Martin Kacej <m.kacej@atlas.sk> 0002 // SPDX-FileCopyrightText: 2020 Dimitris Kardarakos <dimkard@posteo.net> 0003 // SPDX-FileCopyrightText: 2021-2022 Devin Lin <espidev@gmail.com> 0004 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu> 0005 // SPDX-License-Identifier: GPL-2.0-or-later 0006 0007 import QtQuick 2.12 0008 import QtQuick.Layouts 1.2 0009 import QtQuick.Controls 2.12 as Controls 0010 0011 import org.kde.plasma.networkmanagement as PlasmaNM 0012 import org.kde.kirigami as Kirigami 0013 import org.kde.kcmutils as KCM 0014 import org.kde.kirigamiaddons.formcard 1 as FormCard 0015 0016 import cellularnetworkkcm 1.0 0017 0018 KCM.SimpleKCM { 0019 id: root 0020 0021 objectName: "mobileDataMain" 0022 0023 leftPadding: 0 0024 rightPadding: 0 0025 topPadding: 0 0026 bottomPadding: 0 0027 0028 PlasmaNM.Handler { 0029 id: nmHandler 0030 } 0031 0032 PlasmaNM.AvailableDevices { 0033 id: availableDevices 0034 } 0035 0036 PlasmaNM.EnabledConnections { 0037 id: enabledConnections 0038 } 0039 0040 SimPage { 0041 id: simPage 0042 visible: false 0043 } 0044 0045 Kirigami.PlaceholderMessage { 0046 id: noModem 0047 anchors.centerIn: parent 0048 width: parent.width - Kirigami.Units.gridUnit * 4 0049 0050 visible: !enabledConnections.wwanHwEnabled || !availableDevices.modemDeviceAvailable || !kcm.modemFound 0051 icon.name: "auth-sim-missing" 0052 text: i18n("Modem not available") 0053 } 0054 0055 ColumnLayout { 0056 spacing: 0 0057 width: root.width 0058 visible: !noModem.visible 0059 0060 MessagesList { 0061 Layout.fillWidth: true 0062 Layout.margins: Kirigami.Units.largeSpacing 0063 model: kcm.messages 0064 } 0065 0066 FormCard.FormCard { 0067 Layout.topMargin: Kirigami.Units.gridUnit 0068 0069 FormCard.FormSwitchDelegate { 0070 id: mobileDataSwitch 0071 text: i18n("Mobile data") 0072 description: { 0073 if (!kcm.modemFound) { 0074 return ""; 0075 } else if (!kcm.selectedModem.hasSim) { 0076 return i18n("No SIM is inserted.") 0077 } if (!kcm.selectedModem.mobileDataSupported) { 0078 return i18n("Mobile data is not available with this modem.") 0079 } else if (kcm.selectedModem.needsAPNAdded) { 0080 return i18n("An APN needs to be configured to have mobile data."); 0081 } else { 0082 return i18n("Whether mobile data is enabled."); 0083 } 0084 } 0085 0086 property bool manuallySet: false 0087 property bool shouldBeChecked: kcm.selectedModem && kcm.selectedModem.mobileDataEnabled 0088 onShouldBeCheckedChanged: { 0089 checked = shouldBeChecked; 0090 } 0091 0092 enabled: kcm.selectedModem && kcm.selectedModem.mobileDataSupported && !kcm.selectedModem.needsAPNAdded 0093 checked: shouldBeChecked 0094 0095 onCheckedChanged: { 0096 // prevent binding loops 0097 if (manuallySet) { 0098 manuallySet = false; 0099 return; 0100 } 0101 0102 if (kcm.selectedModem.mobileDataEnabled != checked) { 0103 manuallySet = true; 0104 kcm.selectedModem.mobileDataEnabled = checked; 0105 } 0106 } 0107 } 0108 0109 FormCard.FormDelegateSeparator { above: mobileDataSwitch; below: dataUsageButton } 0110 0111 FormCard.FormButtonDelegate { 0112 id: dataUsageButton 0113 text: i18n("Data Usage") 0114 description: i18n("View data usage.") 0115 icon.name: "office-chart-bar" 0116 0117 enabled: false 0118 } 0119 } 0120 0121 FormCard.FormHeader { 0122 title: i18np("SIM", "SIMs", kcm.sims.count) 0123 visible: repeater.count > 0 0124 } 0125 0126 FormCard.FormCard { 0127 visible: repeater.count > 0 0128 0129 Repeater { 0130 id: repeater 0131 model: kcm.sims 0132 0133 delegate: ColumnLayout { 0134 Layout.fillWidth: true 0135 0136 FormCard.FormDelegateSeparator { 0137 visible: model.index !== 0 0138 opacity: (!(model.index && repeater.itemAt(model.index - 1).controlHovered) && !simDelegate.controlHovered) ? 0.5 : 0 0139 } 0140 0141 FormCard.FormButtonDelegate { 0142 id: simDelegate 0143 text: i18n("SIM %1", modelData.displayId) 0144 description: i18n("View SIM %1 details.", modelData.displayId) 0145 icon.name: "auth-sim-symbolic" 0146 onClicked: { 0147 simPage.sim = modelData; 0148 simPage.visible = true; 0149 kcm.push(simPage); 0150 } 0151 } 0152 } 0153 } 0154 } 0155 } 0156 }