shift-shell/kcms/cellularnetwork/ui/EditProfilePage.qml
Mr. Athozus 45fa06e3f1 kcms/mobiledata: Move EditProfileDialog to EditProfilePage
As requested in #277 by Devin. I mark this as a draft because there are small issues that need to be fixed, but 75% is working right now.

- [x] Adding connection works
- [x] Loading existing connection works
- [x] Update existing connections works
- [ ] Show updated list of profiles without restarting the kcm
- [ ] Find a way to use that in initial start (because the whole software is going left-to-right, so pushing an edit page to the right might not be intuitive)

I'm still wondering if using checkboxes for 4G/3G/2G might not be better.
2024-06-29 00:48:01 +00:00

87 lines
2.9 KiB
QML

// SPDX-FileCopyrightText: 2020-2022 Devin Lin <espidev@gmail.com>
// 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.19 as Kirigami
import org.kde.kirigamiaddons.formcard 1 as FormCard
import cellularnetworkkcm 1.0
FormCard.FormCardPage {
id: editProfile
title: profile != null ? i18n("Edit APN") : i18n("New APN")
topPadding: Kirigami.Units.gridUnit
bottomPadding: Kirigami.Units.gridUnit
leftPadding: 0
rightPadding: 0
property Modem modem
property ProfileSettings profile
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.gridUnit
FormCard.FormTextFieldDelegate {
id: profileName
label: i18n("Name")
text: profile != null ? profile.name : ""
}
FormCard.FormDelegateSeparator { above: profileName; below: profileApn }
FormCard.FormTextFieldDelegate {
id: profileApn
label: i18n("APN")
text: profile != null ? profile.apn : ""
}
FormCard.FormDelegateSeparator { above: profileApn; below: profileUsername }
FormCard.FormTextFieldDelegate {
id: profileUsername
label: i18n("Username")
text: profile != null ? profile.user : ""
}
FormCard.FormDelegateSeparator { above: profileUsername; below: profilePassword }
FormCard.FormTextFieldDelegate {
id: profilePassword
label: i18n("Password")
text: profile != null ? profile.password : ""
}
FormCard.FormDelegateSeparator { above: profilePassword; below: profileNetworkType }
FormCard.FormComboBoxDelegate {
id: profileNetworkType
text: i18n("Network type")
model: [i18n("4G/3G/2G"), i18n("3G/2G"), i18n("2G"), i18n("Only 4G"), i18n("Only 3G"), i18n("Only 2G"), i18n("Any")]
Component.onCompleted: {
if (profile != null) {
currentIndex = indexOfValue(profile.networkType)
}
}
}
FormCard.FormDelegateSeparator { above: profileNetworkType; below: profileSave }
FormCard.FormButtonDelegate {
id: profileSave
text: i18n("Save profile")
icon.name: "document-save"
onClicked: {
if (profile == null) { // create new profile
modem.addProfile(profileName.text, profileApn.text, profileUsername.text, profilePassword.text, profileNetworkType.currentText);
} else { // edit existing profile
modem.updateProfile(profile.connectionUni, profileName.text, profileApn.text, profileUsername.text, profilePassword.text, profileNetworkType.currentText);
}
kcm.pop()
}
}
}
}