mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
kcms/cellularnetwork: Improve APN selection and available networks
This commit is contained in:
parent
a816ec5495
commit
09b3964906
2 changed files with 123 additions and 188 deletions
|
|
@ -1,11 +1,14 @@
|
|||
// SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
||||
// SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.2
|
||||
import QtQuick.Controls 2.12 as Controls
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls as Controls
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kcmutils
|
||||
import org.kde.kirigamiaddons.formcard 1 as FormCard
|
||||
|
||||
import cellularnetworkkcm 1.0
|
||||
|
||||
Kirigami.ScrollablePage {
|
||||
|
|
@ -52,39 +55,18 @@ Kirigami.ScrollablePage {
|
|||
|
||||
model: modem.details.networks
|
||||
|
||||
delegate: Kirigami.SwipeListItem {
|
||||
delegate: FormCard.FormRadioDelegate {
|
||||
checked: modelData.isCurrentlyUsed
|
||||
|
||||
onClicked: {
|
||||
if (!modelData.isCurrentlyUsed) {
|
||||
modelData.registerToNetwork();
|
||||
modem.details.scanNetworks();
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: RowLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
ColumnLayout {
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
Kirigami.Heading {
|
||||
level: 3
|
||||
text: modelData.operatorLong + " | " + modelData.operatorShort + "(" + modelData.operatorCode + ")"
|
||||
}
|
||||
Controls.Label {
|
||||
text: modelData.accessTechnology
|
||||
}
|
||||
}
|
||||
Controls.RadioButton {
|
||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||
checked: modelData.isCurrentlyUsed
|
||||
onClicked: {
|
||||
if (!modelData.isCurrentlyUsed) {
|
||||
modelData.registerToNetwork();
|
||||
modem.details.scanNetworks();
|
||||
}
|
||||
checked = modelData.isCurrentlyUsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text: modelData.operatorLong + " | " + modelData.operatorShort + "(" + modelData.operatorCode + ")"
|
||||
description: modelData.accessTechnology
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,178 +1,131 @@
|
|||
// SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.2
|
||||
import QtQuick.Controls 2.12 as Controls
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
import cellularnetworkkcm 1.0
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls as Controls
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
import cellularnetworkkcm
|
||||
|
||||
import org.kde.kirigamiaddons.formcard 1 as FormCard
|
||||
|
||||
Kirigami.ScrollablePage {
|
||||
id: apnlist
|
||||
title: i18n("APNs")
|
||||
|
||||
id: root
|
||||
topPadding: Kirigami.Units.gridUnit
|
||||
bottomPadding: Kirigami.Units.gridUnit
|
||||
leftPadding: 0
|
||||
rightPadding: 0
|
||||
|
||||
property Modem modem
|
||||
property bool editMode: false
|
||||
|
||||
ListView {
|
||||
id: profileListView
|
||||
model: modem.profiles
|
||||
|
||||
Kirigami.PlaceholderMessage {
|
||||
anchors.centerIn: parent
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Kirigami.Units.largeSpacing
|
||||
visible: profileListView.count === 0
|
||||
text: i18n("No APNs configured")
|
||||
icon.name: "globe"
|
||||
title: i18n("APNs")
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
text: i18n("Edit")
|
||||
icon.name: 'entry-edit'
|
||||
checkable: true
|
||||
onCheckedChanged: root.editMode = checked
|
||||
}
|
||||
]
|
||||
|
||||
property var dialog: EditProfileDialog {
|
||||
id: profileDialog
|
||||
parent: root
|
||||
modem: root.modem
|
||||
profile: null
|
||||
pageWidth: root.width
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
|
||||
MessagesList {
|
||||
id: messagesList
|
||||
visible: count != 0
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: Kirigami.Units.largeSpacing
|
||||
model: kcm.messages
|
||||
}
|
||||
|
||||
Kirigami.InlineMessage {
|
||||
id: cannotFindWarning
|
||||
Layout.margins: visible ? Kirigami.Units.largeSpacing : 0
|
||||
Layout.topMargin: visible && !messagesList.visible ? Kirigami.Units.largeSpacing : 0
|
||||
Layout.fillWidth: true
|
||||
|
||||
helpfulAction: Kirigami.Action {
|
||||
icon.name: "list-add"
|
||||
text: i18n("Add Connection")
|
||||
onTriggered: {
|
||||
profileDialog.profile = null;
|
||||
profileDialog.open();
|
||||
visible: false
|
||||
type: Kirigami.MessageType.Warning
|
||||
showCloseButton: true
|
||||
text: i18n("Unable to autodetect connection settings for your carrier. Please find your carrier's APN settings by either contacting support or searching online.")
|
||||
|
||||
Connections {
|
||||
target: modem
|
||||
function onCouldNotAutodetectSettings() {
|
||||
cannotFindWarning.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditProfileDialog {
|
||||
id: profileDialog
|
||||
modem: apnlist.modem
|
||||
profile: null
|
||||
pageWidth: apnlist.width
|
||||
FormCard.FormHeader {
|
||||
title: i18n("APN List")
|
||||
}
|
||||
|
||||
header: ColumnLayout {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
spacing: 0
|
||||
|
||||
MessagesList {
|
||||
id: messagesList
|
||||
visible: count != 0
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: Kirigami.Units.largeSpacing
|
||||
model: kcm.messages
|
||||
}
|
||||
|
||||
Kirigami.InlineMessage {
|
||||
id: cannotFindWarning
|
||||
Layout.margins: visible ? Kirigami.Units.largeSpacing : 0
|
||||
Layout.topMargin: visible && !messagesList.visible ? Kirigami.Units.largeSpacing : 0
|
||||
Layout.fillWidth: true
|
||||
|
||||
visible: false
|
||||
type: Kirigami.MessageType.Warning
|
||||
showCloseButton: true
|
||||
text: qsTr("Unable to autodetect connection settings for your carrier. Please find your carrier's APN settings by either contacting support or searching online.")
|
||||
|
||||
Connections {
|
||||
target: modem
|
||||
function onCouldNotAutodetectSettings() {
|
||||
cannotFindWarning.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Kirigami.SwipeListItem {
|
||||
Layout.fillWidth: true
|
||||
visible: profileListView.count !== 0
|
||||
onClicked: {
|
||||
profileDialog.profile = null;
|
||||
profileDialog.open();
|
||||
}
|
||||
|
||||
contentItem: Row {
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
Kirigami.Icon {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
source: "list-add"
|
||||
height: Kirigami.Units.gridUnit * 1.5
|
||||
width: height
|
||||
}
|
||||
Kirigami.Heading {
|
||||
level: 3
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
text: i18n("Add APN")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Kirigami.SwipeListItem {
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
modem.addDetectedProfileSettings();
|
||||
}
|
||||
|
||||
contentItem: Row {
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
Kirigami.Icon {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
source: "list-add"
|
||||
height: Kirigami.Units.gridUnit * 1.5
|
||||
width: height
|
||||
}
|
||||
Kirigami.Heading {
|
||||
level: 3
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
text: i18n("Autodetect APN")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delegate: Kirigami.SwipeListItem {
|
||||
onClicked: modem.activateProfile(modelData.connectionUni)
|
||||
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
icon.name: "entry-edit"
|
||||
text: i18n("Edit")
|
||||
onTriggered: {
|
||||
profileDialog.profile = modelData;
|
||||
profileDialog.open();
|
||||
}
|
||||
},
|
||||
Kirigami.Action {
|
||||
icon.name: "delete"
|
||||
text: i18n("Delete")
|
||||
onTriggered: modem.removeProfile(modelData.connectionUni)
|
||||
}
|
||||
]
|
||||
|
||||
contentItem: RowLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
Controls.RadioButton {
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
||||
|
||||
FormCard.FormCard {
|
||||
Repeater {
|
||||
id: profilesRepeater
|
||||
model: modem.profiles
|
||||
|
||||
delegate: FormCard.FormRadioDelegate {
|
||||
text: modelData.name
|
||||
description: modelData.apn
|
||||
|
||||
checked: modem.activeConnectionUni == modelData.connectionUni
|
||||
onClicked: {
|
||||
if (!checked) {
|
||||
modem.activateProfile(modelData.connectionUni);
|
||||
}
|
||||
|
||||
modem.activateProfile(modelData.connectionUni);
|
||||
|
||||
// reapply binding
|
||||
checked = Qt.binding(() => { return modem.activeConnectionUni == modelData.connectionUni });
|
||||
}
|
||||
|
||||
trailing: RowLayout {
|
||||
Controls.ToolButton {
|
||||
visible: root.editMode
|
||||
icon.name: "entry-edit"
|
||||
text: i18n("Edit")
|
||||
display: Controls.ToolButton.IconOnly
|
||||
onClicked: {
|
||||
profileDialog.profile = modelData;
|
||||
profileDialog.open();
|
||||
}
|
||||
}
|
||||
|
||||
Controls.ToolButton {
|
||||
visible: root.editMode
|
||||
icon.name: "delete"
|
||||
text: i18n("Delete")
|
||||
display: Controls.ToolButton.IconOnly
|
||||
onClicked: modem.removeProfile(modelData.connectionUni)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
Layout.fillWidth: true
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
Kirigami.Heading {
|
||||
Layout.fillWidth: true
|
||||
level: 3
|
||||
text: modelData.name
|
||||
}
|
||||
Controls.Label {
|
||||
Layout.fillWidth: true
|
||||
text: modelData.apn
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
text: i18n("Add APN")
|
||||
icon.name: 'list-add'
|
||||
onClicked: {
|
||||
profileDialog.profile = null;
|
||||
profileDialog.open();
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
text: i18n("Automatically detect APN")
|
||||
icon.name: 'list-add'
|
||||
onClicked: {
|
||||
modem.addDetectedProfileSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue