Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 02cebd6d authored by Martin Kacej's avatar Martin Kacej

saving connection settings UI implementation

parent 7dad890d
......@@ -37,6 +37,8 @@ ColumnLayout {
property var ipRegex: /^(([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))\.){3}([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))$/
spacing: units.gridUnit
implicitWidth: Kirigami.Units.gridUnit * 20
width: implicitWidth
ColumnLayout {
......@@ -48,13 +50,16 @@ ColumnLayout {
Controls.ComboBox {
id: ipMethodComb
width: parent.width
model: [i18n("Automatic"), i18n("Manual")]
onCurrentIndexChanged: {
if (ipMethodComb.currentIndex == 0) {
ipmain.state = "Automatic"
manualIPSettings.visible = false
}
if (ipMethodComb.currentIndex == 1) {
ipmain.state = "Manual"
manualIPSettings.visible = true
}
}
}
......@@ -118,13 +123,11 @@ ColumnLayout {
states: [
State {
name: "Automatic"
PropertyChanges{ target: manualIPSettings; visible: false }
PropertyChanges{ target: ipmain; ipmap: {"method": "auto"} }
},
State {
name:"Manual"
PropertyChanges { target: manualIPSettings; visible: true }
name: "Manual"
PropertyChanges {
target: ipmain;
ipmap : {
......@@ -137,4 +140,18 @@ ColumnLayout {
}
}
]
function setStateFromMap() {
if (!ipmap)
return;
if (ipmap["method"] === "auto")
ipMethodComb.currentIndex = 0
if (ipmap["method"] === "manual"){
address = ipmap["address"];
gateway = ipmap["gateway"];
prefix = ipmap["prefix"];
dns = ipmap["dns"];
ipMethodComb.currentIndex = 1
}
}
}
......@@ -23,7 +23,6 @@ import QtQuick.Layouts 1.2
import org.kde.kirigami 2.2 as Kirigami
Kirigami.ScrollablePage{
property var details
property var path
property alias signal_strength: signalStrengthLabel.text
property alias signal_speed: linkSpeedLabel.text
......@@ -31,9 +30,12 @@ Kirigami.ScrollablePage{
property alias security: securityLabel.text
property var settings: ({})
property var activeMap: ({})
property bool enabledSave: true && detailsIP.enabledSave
Column {
id: detailsView
spacing: Kirigami.Units.gridUnit
Column {
id: staticInfo
anchors.bottomMargin: units.gridUnit
......@@ -93,28 +95,27 @@ Kirigami.ScrollablePage{
SecuritySection {
id: detailsSecuritySection
}
RowLayout {
Controls.Label {
anchors.left: parent.left
text: i18n("Advanced options")
}
Controls.Switch {
id: advancedOptionsSwitch
checked: false
}
anchors.bottomMargin: 10
}
IPDetailsSection {
id: detailsIP
visible: advancedOptionsSwitch.checked
}
}
actions {
left: Kirigami.Action {
iconName: "document-save"
text: i18n("Save")
enabled: enabledSave
onTriggered: {
save()
applicationWindow().pageStack.pop()
}
}
right: Kirigami.Action {
iconName: "dialog-cancel"
text: i18n("Cancel")
onTriggered: {
applicationWindow().pageStack.pop()
}
......@@ -149,6 +150,15 @@ Kirigami.ScrollablePage{
settings = utils.getConnectionSettings(path,"connection");
detailsSecuritySection.securityMap = utils.getConnectionSettings(path,"802-11-wireless-security");
detailsIP.ipmap = utils.getConnectionSettings(path,"ipv4");
console.info(detailsIP.ipmap["method"]);
detailsSecuritySection.setStateFromMap();
detailsIP.setStateFromMap();
}
function save() {
settings = detailsIP.ipmap;
if (detailsSecuritySection.password !== "") { //otherwise password is unchanged
settings["802-11-wireless-security"] = detailsSecuritySection.securityMap;
}
utils.updateConnectionFromQML(path,settings);
}
}
......@@ -21,13 +21,16 @@ import QtQuick 2.6
import QtQuick.Controls 2.2 as Controls
import QtQuick.Layouts 1.2 as Layouts
import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
import org.kde.kirigami 2.2 as Kirigami
Layouts.ColumnLayout {
id:securitySectionView
property var securityMap: ({})
property var enabledSave: !wepWpaPasswordField.visible || (wepWpaPasswordField.visible && wepWpaPasswordField.acceptableInput)
property alias password: wepWpaPasswordField.text
width: parent.width
implicitWidth: Kirigami.Units.gridUnit * 20
width: implicitWidth
Column {
id: securitySectionHeader
......@@ -46,6 +49,8 @@ Layouts.ColumnLayout {
Controls.ComboBox {
id: securityCombobox
//anchors.bottomMargin: units.Gridunit
implicitWidth: Kirigami.Units.gridUnit * 15
//width: parent.width
anchors.bottomMargin: 50
model: ListModel {
id: securityTypesModel
......@@ -67,26 +72,17 @@ Layouts.ColumnLayout {
securitySectionView.state = securityTypesModel.get(currentIndex).type;
}
}
Controls.Label {
anchors.bottomMargin: units.Gridunit
text: securityCombobox.currentText
}
}
Layouts.ColumnLayout {
Item {
id: wepWpaSecurity
anchors.top: securitySectionHeader.bottom
width: parent.width
Column {
visible: securityCombobox.currentIndex == 1 || securityCombobox.currentIndex == 3
PasswordField {
id: wepWpaPasswordField
width: parent.width
visible: securityCombobox.currentIndex == 1 || securityCombobox.currentIndex == 3
PasswordField {
id: wepWpaPasswordField
width: parent.width
securityType: securityTypesModel.get(securityCombobox.currentIndex).type
}
securityType: securityTypesModel.get(securityCombobox.currentIndex).type
}
}
......@@ -132,6 +128,27 @@ Layouts.ColumnLayout {
}
}
}
]
function setStateFromMap(){
var x = securityMap["key-mgmt"]
switch (x) {
case "none":
securityCombobox.currentIndex = 1
break;
case "ieee8021x":
securityCombobox.currentIndex = 2
break;
case "wpa-psk":
securityCombobox.currentIndex = 3
break;
case "wpa-eap":
securityCombobox.currentIndex = 4
break;
default:
securityCombobox.currentIndex = 0
break;
}
wepWpaPasswordField.placeholderText = i18n("(Unchanged)")
securityCombobox.enabled = false
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment