2023-04-01 07:09:57 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
2023-09-21 19:02:47 +00:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Layouts
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2023-09-21 19:02:47 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
|
import org.kde.kirigamiaddons.formcard 1 as FormCard
|
2026-02-12 04:19:36 +00:00
|
|
|
import org.kde.plasma.networkmanagement.cellular as Cellular
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
import org.kde.plasma.mobileinitialstart.initialstart
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
InitialStartModule {
|
2024-11-10 06:35:06 +00:00
|
|
|
name: i18n("Cellular")
|
2026-02-12 04:19:36 +00:00
|
|
|
available: modemList.modemAvailable
|
2024-11-07 06:07:50 +00:00
|
|
|
contentItem: Item {
|
|
|
|
|
id: root
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2026-02-12 04:19:36 +00:00
|
|
|
Cellular.CellularModemList {
|
|
|
|
|
id: modemList
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property Cellular.CellularModem modem: modemList.primaryModem
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
readonly property real cardWidth: Math.min(Kirigami.Units.gridUnit * 30, root.width - Kirigami.Units.gridUnit * 2)
|
|
|
|
|
|
|
|
|
|
function toggleMobileData() {
|
2026-02-12 04:19:36 +00:00
|
|
|
if (!root.modem || root.modem.needsAPNAdded || !root.modem.mobileDataSupported) {
|
2024-11-07 06:07:50 +00:00
|
|
|
MobileShell.ShellUtil.executeCommand("plasma-open-settings kcm_cellular_network");
|
|
|
|
|
} else {
|
2026-02-12 04:19:36 +00:00
|
|
|
root.modem.mobileDataEnabled = !root.modem.mobileDataEnabled;
|
2023-04-01 07:09:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
EditProfileDialog {
|
|
|
|
|
id: profileDialog
|
2026-02-12 04:19:36 +00:00
|
|
|
modem: root.modem
|
2024-11-07 06:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
anchors {
|
|
|
|
|
fill: parent
|
|
|
|
|
topMargin: Kirigami.Units.gridUnit
|
|
|
|
|
bottomMargin: Kirigami.Units.largeSpacing
|
|
|
|
|
}
|
|
|
|
|
width: root.width
|
|
|
|
|
spacing: Kirigami.Units.gridUnit
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
Label {
|
|
|
|
|
Layout.leftMargin: Kirigami.Units.gridUnit
|
|
|
|
|
Layout.rightMargin: Kirigami.Units.gridUnit
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
Layout.fillWidth: true
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
text: {
|
2026-02-12 04:19:36 +00:00
|
|
|
if (!root.modem) {
|
|
|
|
|
return i18n("Your device does not have a modem available.");
|
|
|
|
|
} else if (root.modem.needsAPNAdded) {
|
2024-11-07 06:07:50 +00:00
|
|
|
return i18n("Please configure your APN below for mobile data, further information will be available with your carrier.");
|
2026-02-12 04:19:36 +00:00
|
|
|
} else if (root.modem.mobileDataSupported) {
|
2024-11-07 06:07:50 +00:00
|
|
|
return i18n("You are connected to the mobile network.");
|
2026-02-12 04:19:36 +00:00
|
|
|
} else if (root.modem.simEmpty) {
|
2024-11-07 06:07:50 +00:00
|
|
|
return i18n("Please insert a SIM card into your device.");
|
|
|
|
|
} else {
|
|
|
|
|
return i18n("Your device does not have a modem available.");
|
2023-04-01 07:09:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
FormCard.FormCard {
|
2026-02-12 04:19:36 +00:00
|
|
|
visible: root.modem && root.modem.mobileDataSupported
|
2024-11-07 06:07:50 +00:00
|
|
|
maximumWidth: root.cardWidth
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
FormCard.FormSwitchDelegate {
|
|
|
|
|
text: i18n("Mobile Data")
|
2026-02-12 04:19:36 +00:00
|
|
|
checked: root.modem ? root.modem.mobileDataEnabled : false
|
2024-11-07 06:07:50 +00:00
|
|
|
onCheckedChanged: {
|
2026-02-12 04:19:36 +00:00
|
|
|
if (root.modem && checked !== root.modem.mobileDataEnabled) {
|
2024-11-07 06:07:50 +00:00
|
|
|
root.toggleMobileData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FormCard.FormCard {
|
2026-02-12 04:19:36 +00:00
|
|
|
visible: root.modem && !root.modem.simEmpty
|
2024-11-07 06:07:50 +00:00
|
|
|
maximumWidth: root.cardWidth
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2023-09-21 19:02:47 +00:00
|
|
|
Layout.fillHeight: true
|
2024-11-07 06:07:50 +00:00
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
ListView {
|
|
|
|
|
id: listView
|
|
|
|
|
currentIndex: -1
|
|
|
|
|
clip: true
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2026-02-12 04:19:36 +00:00
|
|
|
model: root.modem ? root.modem.profiles : null
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
delegate: FormCard.FormRadioDelegate {
|
2026-02-12 04:19:36 +00:00
|
|
|
required property int index
|
|
|
|
|
required property string connectionName
|
|
|
|
|
required property string connectionAPN
|
|
|
|
|
required property string connectionUni
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
width: listView.width
|
2026-02-12 04:19:36 +00:00
|
|
|
text: connectionName
|
|
|
|
|
description: connectionAPN
|
|
|
|
|
checked: root.modem && root.modem.activeConnectionUni === connectionUni
|
2024-11-07 06:07:50 +00:00
|
|
|
|
|
|
|
|
onCheckedChanged: {
|
2026-02-12 04:19:36 +00:00
|
|
|
if (checked && root.modem) {
|
|
|
|
|
root.modem.activateProfile(connectionUni);
|
|
|
|
|
checked = Qt.binding(() => { return root.modem && root.modem.activeConnectionUni === connectionUni });
|
2023-04-01 07:09:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
2024-11-07 06:07:50 +00:00
|
|
|
|
|
|
|
|
trailing: RowLayout {
|
|
|
|
|
ToolButton {
|
|
|
|
|
icon.name: "entry-edit"
|
|
|
|
|
text: i18n("Edit")
|
|
|
|
|
onClicked: {
|
2026-02-12 04:19:36 +00:00
|
|
|
profileDialog.editConnectionUni = connectionUni;
|
2024-11-07 06:07:50 +00:00
|
|
|
profileDialog.open();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ToolButton {
|
|
|
|
|
icon.name: "delete"
|
|
|
|
|
text: i18n("Delete")
|
2026-02-12 04:19:36 +00:00
|
|
|
onClicked: root.modem.removeProfile(connectionUni)
|
2024-11-07 06:07:50 +00:00
|
|
|
}
|
2023-09-21 19:02:47 +00:00
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
|
icon.name: "list-add"
|
|
|
|
|
text: i18n("Add APN")
|
|
|
|
|
onClicked: {
|
2026-02-12 04:19:36 +00:00
|
|
|
profileDialog.editConnectionUni = "";
|
2024-11-07 06:07:50 +00:00
|
|
|
profileDialog.open();
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|