diff --git a/kcm/package/contents/ui/editor/ConnectionEditor.qml b/kcm/package/contents/ui/editor/ConnectionEditor.qml index 7d327ce1..501bfc1a 100644 --- a/kcm/package/contents/ui/editor/ConnectionEditor.qml +++ b/kcm/package/contents/ui/editor/ConnectionEditor.qml @@ -1,120 +1,69 @@ /* Copyright 2018 Jan Grulich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.2 as QtControls import org.kde.kcm 1.2 import org.kde.kirigami 2.0 as Kirigami import org.kde.plasma.networkmanagement 0.2 as PlasmaNM SimpleKCM { id: connectionEditorPage title: connectionSetting.connectionNameTextField.text PlasmaNM.Utils { id: nmUtils } ColumnLayout { - spacing: Kirigami.Units.smallSpacing + id: simpleLayout - StackLayout { - Layout.alignment: Qt.AlignHCenter + ConnectionSetting { + id: connectionSetting Layout.fillWidth: true - Layout.minimumWidth: Kirigami.Units.gridUnit * 25 - Layout.maximumWidth: Kirigami.Units.gridUnit * 40 - - currentIndex: expertModeCheckbox.checked ? 1 : 0 - - ColumnLayout { - id: simpleLayout - //spacing is managed by FormLayout - spacing: 0 - ConnectionSetting { - id: connectionSetting - Layout.fillWidth: true - twinFormLayouts: connectionSpecificSetting.item - } - - Loader { - id: connectionSpecificSetting - Layout.fillWidth: true - } - } - - ColumnLayout { - - QtControls.TabBar { - id: tabBar - Layout.fillWidth: true - - QtControls.TabButton { - text: connectionSetting.settingName - } - - QtControls.TabButton { - text: connectionSpecificSetting.item.settingName - } - - // FIXME just placeholders for now - QtControls.TabButton { - text: i18n("IP") - } - } - - StackLayout { - id: expertLayout - - Layout.fillWidth: true - - currentIndex: tabBar.currentIndex - // Items will be re-parented - } - } + twinFormLayouts: connectionSpecificSetting.item + } - // FIXME this is probably not the best solution - onCurrentIndexChanged: { - tabBar.currentIndex = 0 - connectionSetting.parent = currentIndex ? expertLayout : simpleLayout - connectionSpecificSetting.parent = currentIndex ? expertLayout : simpleLayout - } + Loader { + id: connectionSpecificSetting + Layout.fillWidth: true } } function loadConnectionSettings() { connectionSetting.connectionNameTextField.text = connectionSettingsObject.id // Load general connection setting connectionSetting.loadSettings() // Load connection specific setting if (connectionSettingsObject.connectionType == PlasmaNM.Enums.Wired) { connectionSpecificSetting.source = "WiredSetting.qml" } else if (connectionSettingsObject.connectionType == PlasmaNM.Enums.Wireless) { connectionSpecificSetting.source = "WirelessSetting.qml" } connectionSpecificSetting.item.twinFormLayouts = connectionSetting; connectionSpecificSetting.item.loadSettings() } } diff --git a/kcm/package/contents/ui/editor/ConnectionSetting.qml b/kcm/package/contents/ui/editor/ConnectionSetting.qml index 1a933442..f130e651 100644 --- a/kcm/package/contents/ui/editor/ConnectionSetting.qml +++ b/kcm/package/contents/ui/editor/ConnectionSetting.qml @@ -1,159 +1,137 @@ /* Copyright 2018 Jan Grulich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.6 import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.2 as QtControls +import QtQuick.Controls 2.2 as QQC2 import org.kde.kirigami 2.5 as Kirigami import org.kde.plasma.networkmanagement 0.2 as PlasmaNM Kirigami.FormLayout { id: connectionSetting property string settingName: i18n("Connection") property alias connectionNameTextField: connectionNameTextField - QtControls.TextField { + QQC2.TextField { id: connectionNameTextField focus: true Kirigami.FormData.label: i18n("Network Name:") onTextEdited: connectionSettingsObject.id = text } - QtControls.CheckBox { + QQC2.SpinBox { + id: prioritySpinBox + Kirigami.FormData.label: i18n("Priority:") + value: 0 + + QQC2.ToolTip { + text: i18n("If the connection is set to autoconnect, connections with higher priority will be preferred.\nDefaults to 0. The higher number means higher priority. An negative number can be used to \nindicate priority lower than the default.") + } + + onValueModified: connectionSettingsObject.priority = value + } + + QQC2.CheckBox { id: autoconnectCheckbox checked: true - text: i18n("Automatically connect to this network when it is available") + text: i18n("Automatically connect") onToggled: connectionSettingsObject.autoconnect = checked } - RowLayout { + QQC2.CheckBox { + id: allUsersAllowedCheckbox Layout.fillWidth: true + text: i18n("Allow all users to connect to this network") - QtControls.CheckBox { - id: allUsersAllowedCheckbox - Layout.fillWidth: true - text: i18n("All users may connect to this network") - - onToggled: checked ? connectionSettingsObject.permissions = [] : connectionSettingsObject.permissions = ["replace_current_user"] - } - - // TODO implement advanced configuration - QtControls.Button { - id: advancedPermissionsButton - Layout.alignment: Qt.AlignRight - enabled: !allUsersAllowedCheckbox.checked - text: i18n("Advanced...") - visible: expertModeCheckbox.checked - - QtControls.ToolTip.text: i18n("Edit advanced permissions for this connection") - QtControls.ToolTip.visible: advancedPermissionsButton.hovered - } + onToggled: checked ? connectionSettingsObject.permissions = [] : connectionSettingsObject.permissions = ["replace_current_user"] } - QtControls.CheckBox { - id: autoconnectVpnCheckbox - text: i18n("Automatically connect to VPN when using this connection") + RowLayout { + Layout.fillWidth: true + Kirigami.FormData.label: i18n("Connect to this VPN when active:") - onToggled: checked ? connectionSettingsObject.secondaryConnection = vpnListCombobox.currentText : connectionSettingsObject.secondaryConnection = "" - } + QQC2.CheckBox { + id: autoconnectVpnCheckbox - RowLayout { - Item { - Layout.preferredWidth: Kirigami.Units.gridUnit + Kirigami.Units.smallSpacing + onToggled: checked ? connectionSettingsObject.secondaryConnection = vpnListCombobox.currentText : connectionSettingsObject.secondaryConnection = "" } - QtControls.ComboBox { + QQC2.ComboBox { id: vpnListCombobox enabled: autoconnectVpnCheckbox.checked model: nmUtils.vpnConnections() onActivated: connectionSettingsObject.secondaryConnection = currentText } } - Item { - Kirigami.FormData.isSection: true + QQC2.ComboBox { + id: connectionMeteredCombobox + model: [ i18n("Automatically"), i18n("Always"), i18n("Never") ] + + onActivated: connectionSettingsObject.metered = currentIndex + + Kirigami.FormData.label: i18n("Consider this a metered connection:") } - QtControls.ComboBox { + QQC2.ComboBox { id: firewallZoneCombobox - Kirigami.FormData.label: i18n("Firewall zone:") model: nmUtils.firewallZones() - visible: expertModeCheckbox.checked onActivated: connectionSettingsObject.zone = currentText - } - - QtControls.SpinBox { - id: prioritySpinBox - Kirigami.FormData.label: i18n("Priority:") - value: 0 - QtControls.ToolTip { - text: i18n("If the connection is set to autoconnect, connections with higher priority will be preferred.\nDefaults to 0. The higher number means higher priority. An negative number can be used to \nindicate priority lower than the default.") - } - - onValueModified: connectionSettingsObject.priority = value - } - - QtControls.ComboBox { - id: connectionMeteredCombobox - Kirigami.FormData.label: i18n("Connection metered:") - model: [ i18n("Auto"), i18n("Yes"), i18n("No") ] - visible: expertModeCheckbox.checked - - onActivated: connectionSettingsObject.metered = currentIndex + Kirigami.FormData.label: i18n("Put this network in the firewall zone:") } function loadSettings() { if (connectionSettingsObject.connectionType == PlasmaNM.Enums.Vpn) { autoconnectCheckbox.enabled = false autoconnectVpnCheckbox.enabled = false prioritySpinBox.enabled = false } else { autoconnectCheckbox.enabled = true autoconnectVpnCheckbox.enabled = true prioritySpinBox.enabled = true } autoconnectCheckbox.checked = connectionSettingsObject.autoconnect allUsersAllowedCheckbox.checked = !connectionSettingsObject.permissions.length prioritySpinBox.value = connectionSettingsObject.priority if (connectionSettingsObject.zone.length) { firewallZoneCombobox.currentIndex = firewallZoneCombobox.find(connectionSettingsObject.zone) } else { firewallZoneCombobox.currentIndex = 0 // Default } if (connectionSettingsObject.secondaryConnection.length) { autoconnectVpnCheckbox.checked = true vpnListCombobox.currentIndex = vpnListCombobox.find(connectionSettingsObject.secondaryConnection) } else { autoconnectVpnCheckbox.checked = false } connectionMeteredCombobox.currentIndex = connectionSettingsObject.metered } } diff --git a/kcm/package/contents/ui/editor/WirelessSetting.qml b/kcm/package/contents/ui/editor/WirelessSetting.qml index 0bd20c45..0486da9e 100644 --- a/kcm/package/contents/ui/editor/WirelessSetting.qml +++ b/kcm/package/contents/ui/editor/WirelessSetting.qml @@ -1,252 +1,249 @@ /* Copyright 2018 Jan Grulich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.2 as QtControls import org.kde.kirigami 2.5 as Kirigami import org.kde.plasma.networkmanagement 0.2 as PlasmaNM Kirigami.FormLayout { id: connectionSetting property string settingName: i18n("Wireless") QtControls.ComboBox { id: ssidCombobox Kirigami.FormData.label: i18n("SSID:") delegate: QtControls.ItemDelegate { id: ssidComboDelegate property bool apVisible: typeof(modelData.signal) !== "undefined" height: apVisible ? (Kirigami.Units.gridUnit * 2) + Kirigami.Units.largeSpacing : Kirigami.Units.gridUnit width: parent.width RowLayout { anchors.fill: parent Kirigami.Icon { Layout.alignment: Qt.AlignVCenter height: Kirigami.Units.iconSizes.small width: Kirigami.Units.iconSizes.small source: modelData.security === i18n("Insecure") ? "object-unlocked" : "object-locked" visible: ssidComboDelegate.apVisible } ColumnLayout { spacing: 0 QtControls.Label { Layout.alignment: Qt.AlignLeft Layout.fillWidth: true Layout.leftMargin: apVisible ? 0 : Kirigami.Units.iconSizes.small + Kirigami.Units.smallSpacing text: ssidComboDelegate.apVisible ? i18n("%1 (%2%)", modelData.ssid, modelData.signal) : modelData.ssid } QtControls.Label { Layout.alignment: Qt.AlignLeft Layout.fillWidth: true text: i18n("Security: %1", modelData.security) visible: ssidComboDelegate.apVisible } } } } editable: true model: nmUtils.availableSsids() textRole: "ssid" onCurrentTextChanged: { var currentBssid = bssidCombobox.currentText bssidCombobox.model = nmUtils.availableBssids(ssidCombobox.currentText, currentBssid) bssidCombobox.currentIndex = bssidCombobox.find(currentBssid) } } QtControls.ComboBox { id: modeCombobox Kirigami.FormData.label: i18n("Mode:") model: [i18n("Infrastructure"), i18n("Ad-hoc"), i18n("Access Point")] } QtControls.ComboBox { id: bssidCombobox Kirigami.FormData.label: i18n("Mode:") delegate: QtControls.ItemDelegate { id: bssidComboDelegate property bool apVisible: typeof(modelData.signal) !== "undefined" height: apVisible ? (Kirigami.Units.gridUnit * 3) + Kirigami.Units.largeSpacing : Kirigami.Units.gridUnit width: parent.width ColumnLayout { anchors.fill: parent spacing: 0 QtControls.Label { Layout.alignment: Qt.AlignLeft Layout.fillWidth: true text: bssidComboDelegate.apVisible ? i18n("%1 (%2%)", modelData.bssid, modelData.signal) : modelData.bssid } QtControls.Label { Layout.alignment: Qt.AlignLeft Layout.fillWidth: true text: i18n("Frequency: %1", modelData.frequency) visible: bssidComboDelegate.apVisible } QtControls.Label { Layout.alignment: Qt.AlignLeft Layout.fillWidth: true text: i18n("Channel: %1", modelData.channel) visible: bssidComboDelegate.apVisible } } } model: nmUtils.availableBssids(ssidCombobox.currentText) editable: true opacity: visible ? 1 : 0 - visible: !modeCombobox.currentIndex && expertModeCheckbox.checked + visible: !modeCombobox.currentIndex textRole: "bssid" validator: RegExpValidator { regExp: /([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}/ } } QtControls.ComboBox { id: bandCombobox Kirigami.FormData.label: i18n("Band:") Layout.fillWidth: true model: [i18n("Automatic"), i18n("A (5 GHz)"), i18n("B/G (2.4 GHz)")] opacity: visible ? 1 : 0 - visible: modeCombobox.currentIndex && expertModeCheckbox.checked + visible: modeCombobox.currentIndex } QtControls.ComboBox { id: channelCombobox Kirigami.FormData.label: i18n("Channel:") enabled: bandCombobox.currentIndex model: nmUtils.wirelessChannels(bandCombobox.currentIndex) opacity: visible ? 1 : 0 - visible: modeCombobox.currentIndex && expertModeCheckbox.checked + visible: modeCombobox.currentIndex } QtControls.ComboBox { id: restrictToDeviceCombobox Kirigami.FormData.label: i18n("Restrict to device:") delegate: QtControls.ItemDelegate { height: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing width: parent.width QtControls.Label { id: label anchors { left: parent.left leftMargin: Kirigami.Units.smallSpacing verticalCenter: parent.verticalCenter } text: typeof(modelData.device) !== "undefined" ? i18n("%1 (%2)", modelData.device, modelData.mac) : modelData.mac } } editable: true model: nmUtils.deviceHwAddresses(2) // Wireless device enum is NM_DEVICE_TYPE_WIFI which is 2 validator: RegExpValidator { regExp: /([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}/ } textRole: "mac" - visible: expertModeCheckbox.checked } QtControls.ComboBox { id: assignedMacAddressCombobox Kirigami.FormData.label: i18n("Cloned MAC address:") editable: true model: ["", i18n("Preserve"), i18n("Permanent"), i18n("Random"), i18n("Stable")] validator: RegExpValidator { regExp: /(([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})|Preserve|Permanent|Random|Stable/ } - visible: expertModeCheckbox.checked } QtControls.SpinBox { id: mtuSpinBox Kirigami.FormData.label: i18n("MTU:") from: 0 value: 0 to: 1000 valueFromText: function(text, locale) { return text === "Automatic" ? 0 : Number.fromLocaleString(locale, text); } textFromValue: function(value, locale) { return value ? Number(value).toLocaleString(locale, 'f', 0) : i18n("Automatic")} - visible: expertModeCheckbox.checked } QtControls.CheckBox { id: visibilityCheckbox Kirigami.FormData.label: i18n("Visibility:") text: i18n("Hidden network") } function loadSettings() { // TODO: maybe make this enum exported to QML as well var wirelessSettingObject = connectionSettingsObject.setting(12) // 12 == Wireless // SSID ssidCombobox.model = nmUtils.availableSsids(wirelessSettingObject.ssid) ssidCombobox.currentIndex = ssidCombobox.find(wirelessSettingObject.ssid) // Mode modeCombobox.currentIndex = wirelessSettingObject.mode // BSSID bssidCombobox.model = nmUtils.availableBssids(ssidCombobox.currentText, wirelessSettingObject.bssid) bssidCombobox.currentIndex = bssidCombobox.find(wirelessSettingObject.bssid) // Band bandCombobox.currentIndex = wirelessSettingObject.band // Channel channelCombobox.currentIndex = channelCombobox.find(wirelessSettingObject.channel + " (", Qt.MatchStartsWith) // Mac Address restrictToDeviceCombobox.model = nmUtils.deviceHwAddresses(2, wirelessSettingObject.macAddress) restrictToDeviceCombobox.currentIndex = restrictToDeviceCombobox.find(wirelessSettingObject.macAddress) // Assigned MAC address var assignedMacHwAddress = assignedMacAddressCombobox.find(wirelessSettingObject.assignedMacAddress, Qt.MatchFixedString) if (assignedMacHwAddress > 0) { assignedMacAddressCombobox.currentIndex = assignedMacHwAddress } else { assignedMacAddressCombobox.editText = wirelessSettingObject.assignedMacAddress } // MTU mtuSpinBox.value = wirelessSettingObject.mtu // Hidden visibilityCheckbox.checked = wirelessSettingObject.hidden } }