diff --git a/mobile/wifi/package/contents/ui/IPAddressSetting.qml b/mobile/wifi/package/contents/ui/IPAddressSetting.qml deleted file mode 100644 index 6c7a9347..00000000 --- a/mobile/wifi/package/contents/ui/IPAddressSetting.qml +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2017 Martin Kacej - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -import QtQuick 2.6 -import QtQuick.Layouts 1.2 -import QtQuick.Controls 2.2 as Controls -import org.kde.kirigami 2.2 as Kirigami - -ColumnLayout { - id: ipmain - - property var ipmap: ({}) - property alias address: manualIPaddress.text - property alias gateway: manualIPgateway.text - property alias prefix: manualIPprefix.text - property alias dns: manualIPdns.text - property bool enabledSave: (ipMethodComb.currentIndex == 0 || ( - ipMethodComb.currentIndex == 1 && manualIPaddress.acceptableInput - && manualIPgateway.acceptableInput && manualIPprefix.acceptableInput - && manualIPdns.acceptableInput )) - 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 { - Controls.Label { - anchors.left: parent.left - text: i18n("IP settings") - font.weight: Font.Bold - } - - 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 - } - } - } - } - - ColumnLayout { - id: manualIPSettings - Layout.fillWidth: true - - Controls.Label { - text: i18n("IP Address") - } - - Controls.TextField { - id: manualIPaddress - placeholderText: "193.168.1.128" - text: address - validator: RegExpValidator { - regExp: ipRegex - } - } - - Controls.Label { - text: i18n("Gateway") - } - - Controls.TextField { - id: manualIPgateway - placeholderText: "192.168.1.1" - text: gateway - validator: RegExpValidator { - regExp: ipRegex - } - } - - Controls.Label { - text: i18n("Network prefix length") - } - - Controls.TextField { - id: manualIPprefix - placeholderText: "32" - text: prefix - validator: IntValidator { bottom: 1; top: 32; } - } - - Controls.Label { - text: i18n("DNS") - } - - Controls.TextField { - id: manualIPdns - placeholderText: "8.8.8.8" - text: dns - validator: RegExpValidator { - regExp: ipRegex - } - } - } - - states: [ - State { - name: "Automatic" - PropertyChanges{ target: ipmain; ipmap: {"method": "auto"} } - }, - - State { - name: "Manual" - PropertyChanges { - target: ipmain; - ipmap : { - "method": "manual", - "address": address, - "prefix": prefix, - "gateway": gateway, - "dns": dns - } - } - } - ] - - 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 - } - } -} diff --git a/mobile/wifi/package/contents/ui/NetworkSettings.qml b/mobile/wifi/package/contents/ui/NetworkSettings.qml index efd7ddec..4a6204e0 100644 --- a/mobile/wifi/package/contents/ui/NetworkSettings.qml +++ b/mobile/wifi/package/contents/ui/NetworkSettings.qml @@ -1,112 +1,273 @@ /* * Copyright 2017 Martin Kacej * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.6 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.2 as Controls -import org.kde.kirigami 2.2 as Kirigami +import org.kde.kirigami 2.3 as Kirigami +import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.kcm 1.1 SimpleKCM { property var path property var settings: ({}) + property var securityMap: ({}) property var activeMap: ({}) - property bool enabledSave: true && detailsIP.enabledSave + property alias password: wepWpaPasswordField.text + + property var ipmap: ({}) + property alias address: manualIPaddress.text + property alias gateway: manualIPgateway.text + property alias prefix: manualIPprefix.text + property alias dns: manualIPdns.text + 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]))$/ + property bool manualIp + + property bool enabledSave: (ipMethodComb.currentIndex == 0 || ( + ipMethodComb.currentIndex == 1 && manualIPaddress.acceptableInput + && manualIPgateway.acceptableInput && manualIPprefix.acceptableInput + && manualIPdns.acceptableInput )) + + actions.main: Kirigami.Action { + icon.name: "dialog-ok" + text: i18n("Save") + onTriggered: { + save() + kcm.pop() + } + } header: ColumnLayout { width: parent.width anchors.leftMargin: Kirigami.Units.largeSpacing * 2 Kirigami.Separator {} RowLayout{ Kirigami.Separator {} Controls.Label { id: detailsName anchors.leftMargin: Kirigami.Units.largeSpacing * 2 text: i18n("Connection Name") font.weight: Font.Bold } } Kirigami.Separator {} Rectangle{ height: 1 Layout.fillWidth: true color: "black" } } - Column { - id: detailsView - spacing: Kirigami.Units.gridUnit - WirelessSecuritySetting { - id: detailsSecuritySection - anchors.bottomMargin: 10 + Kirigami.FormLayout { + + Item { + Kirigami.FormData.label: i18n("Security") + Kirigami.FormData.isSection: true } - IPAddressSetting { - id: detailsIP + Controls.ComboBox { + id: securityCombobox + Kirigami.FormData.label: i18n("Security type:") + model: ListModel { + id: securityTypesModel + // FIXME just placeholder element to set "text" property as default + ListElement { + text: "placeholder" + } + Component.onCompleted: { + clear() + append({ "text": i18n("None"), "type": PlasmaNM.Enums.NoneSecurity }) + append({ "text": i18n("WEP Key"), "type": PlasmaNM.Enums.StaticWep }) + append({ "text": i18n("Dynamic WEP"), "type": PlasmaNM.Enums.DynamicWep }) + append({ "text": i18n("WPA/WPA2 Personal"), "type": PlasmaNM.Enums.Wpa2Psk }) + append({ "text": i18n("WPA/WPA2 Enterprise"), "type": PlasmaNM.Enums.Wpa2Eap }) + securityCombobox.currentIndex = 0 + } + } + onCurrentIndexChanged: { + state = securityTypesModel.get(currentIndex).type; + } } - } - footer: Item { - height: Kirigami.Units.gridUnit * 4 + PasswordField { + id: wepWpaPasswordField + Kirigami.FormData.label: i18n("Password:") + width: parent.width + securityType: securityTypesModel.get(securityCombobox.currentIndex).type + } - RowLayout { - anchors.horizontalCenter: parent.horizontalCenter - spacing: Kirigami.Units.gridUnit + Controls.ComboBox { + id: authComboBox + Kirigami.FormData.label: i18n("Authentication:") + visible: securityCombobox.currentIndex == 2 || securityCombobox.currentIndex == 4 + model: [i18n("TLS"), i18n("LEAP"), i18n("FAST"), i18n("Tunneled TLS"), i18n("Protected EAP")] // more - SIM, AKA, PWD ? + } + Controls.Label { + visible: authComboBox.visible + text: "----Not yet implemented----" + color: "red" + } - Controls.Button { - enabled: enabledSave + Kirigami.Separator { + Kirigami.FormData.label: "IP settings" + Kirigami.FormData.isSection: true + } - icon.name: "document-save" - text: i18n("Save") + Controls.ComboBox { + id: ipMethodComb + width: parent.width + model: [i18n("Automatic"), i18n("Manual")] + onCurrentIndexChanged: { + manualIp = currentIndex == 1 - onPressed: { - save() - applicationWindow().pageStack.pop() + if (manualIp) { + ipmap = { + "method": "manual", + "address": address, + "prefix": prefix, + "gateway": gateway, + "dns": dns + } + } else { + ipmap = {"method": "auto"} } } - Controls.Button { - icon.name: "dialog-cancel" - text: i18n("Cancel") + } - onPressed: { - applicationWindow().pageStack.pop() - } + Controls.TextField { + id: manualIPaddress + visible: manualIp + Kirigami.FormData.label: i18n("IP Address:") + placeholderText: "193.168.1.128" + text: address + validator: RegExpValidator { + regExp: ipRegex + } + } + + Controls.TextField { + id: manualIPgateway + visible: manualIp + Kirigami.FormData.label: i18n("Gateway:") + placeholderText: "192.168.1.1" + text: gateway + validator: RegExpValidator { + regExp: ipRegex } } + + Controls.TextField { + id: manualIPprefix + visible: manualIp + Kirigami.FormData.label: i18n("Network prefix length:") + placeholderText: "32" + text: prefix + validator: IntValidator { bottom: 1; top: 32; } + } + + Controls.TextField { + id: manualIPdns + visible: manualIp + Kirigami.FormData.label: i18n("DNS:") + placeholderText: "8.8.8.8" + text: dns + validator: RegExpValidator { + regExp: ipRegex + } + } + } + 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 + } + + var x = securityMap["key-mgmt"] + switch (x) { + case "none": + securityCombobox.currentIndex = 0 + break; + case "ieee8021x": + securityCombobox.currentIndex = 1 + break; + case "wpa-psk": + securityCombobox.currentIndex = 3 + break; + case "wpa-eap": + securityCombobox.currentIndex = 4 + break; + default: + securityCombobox.currentIndex = -1 + break; + } + wepWpaPasswordField.placeholderText = i18n("(Unchanged)") + securityCombobox.enabled = false + } + + states: [ + State { + name: PlasmaNM.Enums.NoneSecurity + PropertyChanges { + target: securitySectionView; securityMap: {"type" : PlasmaNM.Enums.NoneSecurity } + } + }, + State { + name: PlasmaNM.Enums.StaticWep + PropertyChanges { + target: securitySectionView; securityMap: { "type" : PlasmaNM.Enums.StaticWep, + "password" : password + } + } + }, + State { + name: PlasmaNM.Enums.Wpa2Psk + PropertyChanges { + target: securitySectionView; securityMap: { "type" : PlasmaNM.Enums.Wpa2Psk, + "password" : password + } + } + } + ] + Component.onCompleted: { - console.info(path); settings = kcm.getConnectionSettings(path,"connection"); detailsName.text = settings["id"] - detailsSecuritySection.securityMap = kcm.getConnectionSettings(path,"802-11-wireless-security"); - detailsIP.ipmap = kcm.getConnectionSettings(path,"ipv4"); - detailsSecuritySection.setStateFromMap(); - detailsIP.setStateFromMap(); + securityMap = kcm.getConnectionSettings(path, "802-11-wireless-security"); + ipmap = kcm.getConnectionSettings(path,"ipv4"); + setStateFromMap(); } function save() { - settings = detailsIP.ipmap; - if (detailsSecuritySection.password !== "") { //otherwise password is unchanged + settings = ipmap; + if (password !== "") { //otherwise password is unchanged settings["802-11-wireless-security"] = detailsSecuritySection.securityMap; } kcm.updateConnectionFromQML(path,settings); } } diff --git a/mobile/wifi/package/contents/ui/WirelessSecuritySetting.qml b/mobile/wifi/package/contents/ui/WirelessSecuritySetting.qml deleted file mode 100644 index ab320e19..00000000 --- a/mobile/wifi/package/contents/ui/WirelessSecuritySetting.qml +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2017-2018 Martin Kacej - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -import QtQuick 2.6 -import QtQuick.Layouts 1.2 -import QtQuick.Controls 2.2 as Controls -import org.kde.plasma.networkmanagement 0.2 as PlasmaNM -import org.kde.kirigami 2.2 as Kirigami - -ColumnLayout { - id:securitySectionView - property var securityMap: ({}) - property var enabledSave: !wepWpaPasswordField.visible || (wepWpaPasswordField.visible && wepWpaPasswordField.acceptableInput) - property alias password: wepWpaPasswordField.text - - implicitWidth: Kirigami.Units.gridUnit * 20 - width: implicitWidth - - ColumnLayout { - id: securitySectionHeader - - width: parent.width - anchors { - top:parent.top - topMargin: units.Gridunit - bottomMargin: units.Gridunit - left: parent.left - } - Controls.Label { - text: i18n("Security") - font.weight: Font.Bold - } - Controls.ComboBox { - id: securityCombobox - //anchors.bottomMargin: units.Gridunit - implicitWidth: Kirigami.Units.gridUnit * 15 - //width: parent.width - anchors.bottomMargin: 50 - model: ListModel { - id: securityTypesModel - // FIXME just placeholder element to set "text" property as default - ListElement { - text: "placeholder" - } - Component.onCompleted: { - clear() - append({ "text": i18n("None"), "type": PlasmaNM.Enums.NoneSecurity }) - append({ "text": i18n("WEP Key"), "type": PlasmaNM.Enums.StaticWep }) - append({ "text": i18n("Dynamic WEP"), "type": PlasmaNM.Enums.DynamicWep }) - append({ "text": i18n("WPA/WPA2 Personal"), "type": PlasmaNM.Enums.Wpa2Psk }) - append({ "text": i18n("WPA/WPA2 Enterprise"), "type": PlasmaNM.Enums.Wpa2Eap }) - securityCombobox.currentIndex = 0 - } - } - onCurrentIndexChanged: { - securitySectionView.state = securityTypesModel.get(currentIndex).type; - } - } - } - - Item { - id: wepWpaSecurity - anchors.top: securitySectionHeader.bottom - width: parent.width - visible: securityCombobox.currentIndex == 1 || securityCombobox.currentIndex == 3 - PasswordField { - id: wepWpaPasswordField - width: parent.width - securityType: securityTypesModel.get(securityCombobox.currentIndex).type - } - } - - ColumnLayout { - id: eap - anchors.top: securitySectionHeader.bottom - Column { - visible: securityCombobox.currentIndex == 2 || securityCombobox.currentIndex == 4 - Controls.Label { - text: i18n("Authentication") - } - Controls.ComboBox { - id: authComboBox - model: [i18n("TLS"), i18n("LEAP"), i18n("FAST"), i18n("Tunneled TLS"), i18n("Protected EAP")] // more - SIM, AKA, PWD ? - } - Controls.Label{ - text: "----Not yet implemented----" - color: "red" - } - } - } - - states: [ - State { - name: PlasmaNM.Enums.NoneSecurity - PropertyChanges { - target: securitySectionView; securityMap: {"type" : PlasmaNM.Enums.NoneSecurity } - } - }, - State { - name: PlasmaNM.Enums.StaticWep - PropertyChanges { - target: securitySectionView; securityMap: { "type" : PlasmaNM.Enums.StaticWep, - "password" : password - } - } - }, - State { - name: PlasmaNM.Enums.Wpa2Psk - PropertyChanges { - target: securitySectionView; securityMap: { "type" : PlasmaNM.Enums.Wpa2Psk, - "password" : password - } - } - } - ] - 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 - } -}