diff options
author | Teemu Holappa <teemu.holappa@theqtcompany.com> | 2016-01-28 10:22:43 +0200 |
---|---|---|
committer | Teemu Holappa <teemu.holappa@theqtcompany.com> | 2016-02-08 08:04:36 +0000 |
commit | 3e8998a7d712275891905f9e75a8cd150de86877 (patch) | |
tree | 8f781d0c2926e35c345f63e3c096a02f07f30603 /src/qtdevicesettings/networksettingsplugin/imports | |
parent | 272cdee776d315a4a265a82b7e539cdd9f41ac79 (diff) |
Wifi support to the Network Settings Plugin.
All the network management is done now through the Connman backend. Removed separate wifi settings plugin.
Change-Id: I7b6b7231f1c44727ce0591e11182d25bc43718ed
Reviewed-by: Risto Avila <risto.avila@theqtcompany.com>
Diffstat (limited to 'src/qtdevicesettings/networksettingsplugin/imports')
7 files changed, 340 insertions, 66 deletions
diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/EditWiredSettings.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/EditWiredSettings.qml index a09bdf8..c678c67 100644 --- a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/EditWiredSettings.qml +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/EditWiredSettings.qml @@ -90,15 +90,15 @@ Item { ListElement { text: "DHCP" - method: IPv4Config.Dhcp + method: NetworkSettingsIPv4.Dhcp } ListElement { text: "Manual" - method: IPv4Config.Manual + method: NetworkSettingsIPv4.Manual } ListElement { text: "Off" - method: IPv4Config.Off + method: NetworkSettingsIPv4.Off } } @@ -125,7 +125,7 @@ Item { Column { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.ipv4.method === IPv4Config.Dhcp + visible: service.ipv4.method === NetworkSettingsIPv4.Dhcp Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) @@ -166,7 +166,7 @@ Item { Column { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.ipv4.method === IPv4Config.Manual + visible: service.ipv4.method === NetworkSettingsIPv4.Manual Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) @@ -234,15 +234,15 @@ Item { ListElement { text: qsTr("Auto") - method: IPv6Config.Auto + method: NetworkSettingsIPv6.Auto } ListElement { text: qsTr("Manual") - method: IPv6Config.Manual + method: NetworkSettingsIPv6.Manual } ListElement { text: qsTr("Off") - method: IPv6Config.Off + method: NetworkSettingsIPv6.Off } } @@ -268,7 +268,7 @@ Item { Column { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.ipv6.method === IPv6Config.Auto + visible: service.ipv6.method === NetworkSettingsIPv6.Auto Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) TextLabel { @@ -308,7 +308,7 @@ Item { Column { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.ipv6.method === IPv6Config.Manual + visible: service.ipv6.method === NetworkSettingsIPv6.Manual Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) TextLabel { @@ -497,15 +497,15 @@ Item { ListElement { text: qsTr("Direct") - method: ProxyConfig.Direct + method: NetworkSettingsProxy.Direct } ListElement { text: qsTr("Auto") - method: ProxyConfig.Auto + method: NetworkSettingsProxy.Auto } ListElement { text: qsTr("Manual") - method: ProxyConfig.Manual + method: NetworkSettingsProxy.Manual } } @@ -531,9 +531,10 @@ Item { Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.proxy.method !== ProxyConfig.Direct + visible: service.proxy.method !== NetworkSettingsProxy.Direct TextLabel { - text: service.proxy.method === ProxyConfig.Manual ? qsTr("Proxy address") : qsTr("Automatic configuration URL") + text: service.proxy.method === NetworkSettingsProxy.Manual ? qsTr("Proxy address") : qsTr("Automatic configuration URL") + width: content.titleWidth horizontalAlignment: Text.AlignRight } @@ -546,7 +547,7 @@ Item { } Row { spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: service.proxy.method === ProxyConfig.Manual + visible: service.proxy.method === NetworkSettingsProxy.Manual TextLabel { text: qsTr("No proxy for") @@ -632,7 +633,7 @@ Item { } if (proxyChanged) { proxyUrl.accepted(); - service.setupProxyConfig(); + service.setupNetworkSettingsProxy(); } stackView.pop(); } diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkDetails.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkDetails.qml index 1540e03..3e71be0 100644 --- a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkDetails.qml +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkDetails.qml @@ -37,6 +37,6 @@ import QtQuick 2.5 Loader { id: root - property var service: undefined + property var selectedInterface:undefined anchors.fill: parent } diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkSettings.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkSettings.qml index daf3d1d..dcda5e0 100644 --- a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkSettings.qml +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/NetworkSettings.qml @@ -78,7 +78,7 @@ Item { } Repeater { - model: NetworkSettingsManager.networks + model: NetworkSettingsManager.interfaces Button { implicitWidth: networkSelect.width - Math.round(20 * Flat.FlatStyle.scaleFactor) @@ -105,19 +105,21 @@ Item { } TextLabel { - text: networkSelect.stateToStr(status) + text: networkSelect.stateToStr(modelData.state) font.pixelSize: Math.round(12 * Flat.FlatStyle.scaleFactor) } + } } onCheckedChanged: { if (checked) { - networkDetails.service = NetworkSettingsManager.getService(name, type); - if (type === NetworkType.Wired) { + networkDetails.selectedInterface = modelData + networkDetails.selectedInterface.scanServices() + if (type === NetworkSettingsType.Wired) { networkDetails.source = "WiredSettings.qml"; } - else if (type === NetworkType.Wifi) { + else if (type === NetworkSettingsType.Wifi) { networkDetails.source = "WifiSettings.qml"; } } diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSelectorDelegate.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSelectorDelegate.qml new file mode 100644 index 0000000..bc39ebd --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSelectorDelegate.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.5 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.4 +import com.theqtcompany.settings.common 1.0 +import com.theqtcompany.settings.network 1.0 +import QtQuick.Controls.Styles.Flat 1.0 as Flat + +Item { + id: root + property bool checkable: true + property bool checked: false + property bool pressed: false + property bool connect: modelData["connected"] + signal clicked() + + MouseArea { + id: delegateButton + anchors.fill: parent + hoverEnabled: true + onPressed: root.pressed = true + onClicked: root.clicked() + onEntered: checked = !checked + + Rectangle { + anchors.fill: parent + color: root.checked ? Flat.FlatStyle.disabledColor : "transparent" + opacity: root.checked ? 0.15 : 1.0 + } + Rectangle { + color: Flat.FlatStyle.darkFrameColor + width: parent.width + height: Flat.FlatStyle.onePixel + anchors.bottom: parent.bottom + } + TextLabel { + id: text + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: Math.round(10 * Flat.FlatStyle.scaleFactor) + horizontalAlignment: Text.AlignLeft + text: modelData["name"] + } + WifiSignalMonitor { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.margins: Math.round(10 * Flat.FlatStyle.scaleFactor) + height: Math.round(parent.height * .8) + width: height + signalStrength: modelData["signalStrength"] + connected: modelData["connected"] + } + } +} diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSettings.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSettings.qml index 3221e88..e7c2bda 100644 --- a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSettings.qml +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSettings.qml @@ -39,56 +39,152 @@ import QtQuick.Controls 1.4 import QtQuick.Controls.Styles.Flat 1.0 as Flat import com.theqtcompany.settings.common 1.0 import com.theqtcompany.settings.network 1.0 -import com.theqtcompany.settings.wifi 1.0 Item { id: root anchors.fill: parent anchors.margins: Math.round(20 * Flat.FlatStyle.scaleFactor) + + Component.onCompleted: { + NetworkSettingsManager.services.type = NetworkSettingsType.Wifi; + } GroupBox { id: content title: qsTr("Wireless Settings") anchors.fill: parent Layout.fillWidth: true flat: true - width: parent.width - Row { - id: enableSwitch + ColumnLayout { + spacing: Math.round(20 * Flat.FlatStyle.scaleFactor) width: parent.width - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - TextLabel { - width: root.width*0.382 - horizontalAlignment: Text.AlignRight - text: NetworkSettingsManager.wifiPowered ? qsTr("Disable Wifi") : qsTr("Enable Wifi") + Row { + id: enableSwitch + width: parent.width + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + TextLabel { + width: root.width*0.382 + horizontalAlignment: Text.AlignRight + text: selectedInterface.powered ? qsTr("Disable Wifi") : qsTr("Enable Wifi") + } + Switch { + checked: selectedInterface.powered + onCheckedChanged: selectedInterface.powered = checked + } } - Switch { - checked: NetworkSettingsManager.wifiPowered - onCheckedChanged: NetworkSettingsManager.wifiPowered = checked + + Row { + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + width: parent.width + + TextLabel { + id: labelText + text: qsTr("Selected network ") + width: content.width*0.382 + horizontalAlignment: Text.AlignRight + } + + CustomCombobox { + id: networkSelection + model: NetworkSettingsManager.services + visible: selectedInterface.powered + width: Math.round(200 * Flat.FlatStyle.scaleFactor) + textRole: "name" + onSelectedIndexChanged : if (selectedIndex >= 0) model.itemFromRow(selectedIndex).connectService(); + + delegate: WifiSelectorDelegate { + id: delegate + onConnectChanged: if (connect) networkSelection.setSelectIndexToVal(modelData.name, "name"); + } + } } - } - Item { - id: wifiManagerContainer - anchors.left: parent.left - anchors.right: parent.right - anchors.top: enableSwitch.bottom - anchors.topMargin: Math.round(10 * Flat.FlatStyle.scaleFactor) - anchors.bottom: parent.bottom - Loader { - id: wifiManagerLoader - asynchronous: true - sourceComponent: NetworkSettingsManager.wifiPowered ? wifiManager : undefined + GroupBox { + id: connectView + title: qsTr("Enter a password") + flat: false + visible: false + ColumnLayout { + Row { + id: errorView + property alias text: text.text + visible: text.text !== "" + + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + Image { + source: "../icons/Alert_yellow_1x.png" + } + Text { + id: text + color: "#face20" + text: "" + } + } + Row { + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + visible: false + TextLabel { + text: qsTr("User name") + width: root.width*0.382 + horizontalAlignment: Text.AlignRight + } + TextField { + text: "" + inputMethodHints: Qt.ImhNoPredictiveText + } + } + Row { + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + TextLabel { + text: qsTr("Password") + horizontalAlignment: Text.AlignRight + } + TextField { + id: password + text: "" + echoMode: TextInput.Password + inputMethodHints: Qt.ImhNoPredictiveText + } + } + Row { + spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + Button { + text: qsTr("Connect") + onClicked: { + connectView.visible = false + NetworkSettingsUserAgent.setUserCredentials("", password.text) + } + } + Button { + text: qsTr("Cancel") + onClicked:connectView.visible = false + } + } + } + } + + Button { + id: disconnect + text: qsTr("Disconnect") + visible: selectedInterface.state === NetworkSettingsState.Online || + selectedInterface.state === NetworkSettingsState.Ready + onClicked: { + console.log("disconnect"); + NetworkSettingsManager.services.itemFromRow(networkSelection.selectedIndex).disconnectService(); + networkSelection.selectedIndex = -1; + } } } - } - Component { - id: wifiManager - WifiManagerView { - id: wifiSettings - width: root.width - visible: true + Connections { + target: NetworkSettingsUserAgent + onShowUserCredentialsInput : { + connectView.visible = true + } + onError: { + errorView.visible = true + connectView.visible = true + } } } } diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSignalMonitor.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSignalMonitor.qml new file mode 100644 index 0000000..35d9e53 --- /dev/null +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WifiSignalMonitor.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.5 + +Item { + id: root + + property bool scanning: false + property int signalStrength: 100 + property bool connected: false + + onSignalStrengthChanged: { + sprite.visible = true; + + if (signalStrength < 10) { + sprite.visible = false; + } + else if (signalStrength < 30) { + sprite.currentFrame = 0; + } + else if (signalStrength < 60) { + sprite.currentFrame = 1; + } + else if (signalStrength < 80) { + sprite.currentFrame = 2; + } + else if (signalStrength <= 100) { + sprite.currentFrame = 3; + } + } + + Image { + anchors.fill: parent + source: "Wifi_lightgray_2x.png" + } + + AnimatedSprite { + id: sprite + anchors.fill: parent + source: connected ? "WifiAnim_qt_2x.png" : "WifiAnim_black_2x.png" + frameDuration: 500 + frameCount: 4 + currentFrame: 3 + frameSync: false + frameWidth: 32 + frameHeight: 32 + loops: 40 + running: scanning + } +} diff --git a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WiredSettings.qml b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WiredSettings.qml index 5a7e860..4c07baa 100644 --- a/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WiredSettings.qml +++ b/src/qtdevicesettings/networksettingsplugin/imports/NetworkSettings/WiredSettings.qml @@ -45,10 +45,12 @@ Item { anchors.fill: parent anchors.margins: Math.round(20 * Flat.FlatStyle.scaleFactor) property bool editMode: false + property var service: null + property string title: qsTr("Network"); - onVisibleChanged: { - if (visible) - titlebar.title = qsTr("Network"); + Component.onCompleted: { + NetworkSettingsManager.services.type = NetworkSettingsType.Wired; + root.service = NetworkSettingsManager.services.itemFromRow(0); } ListModel { @@ -56,15 +58,15 @@ Item { ListElement { text: "DHCP" - method: IPv4Config.Dhcp + method: NetworkSettingsIPv4.Dhcp } ListElement { text: "Manual" - method: IPv4Config.Manual + method: NetworkSettingsIPv4.Manual } ListElement { text: "Off" - method: IPv4Config.Off + method: NetworkSettingsIPv4.Off } } @@ -85,7 +87,7 @@ Item { model: methodsModel Component.onCompleted: selectedIndex = service.ipv4.method onSelectedIndexChanged : { - if (model.get(selectedIndex).method !== IPv4Config.Dhcp) { + if (model.get(selectedIndex).method !== NetworkSettingsIPv4.Dhcp) { service.ipv4.method = model.get(selectedIndex).method; editMode = true; } @@ -104,7 +106,7 @@ Item { } Row { - visible: service.ipv4.method !== IPv4Config.Off + visible: service.ipv4.method !== NetworkSettingsIPv4.Off TextLabel { text: qsTr("IP Address: ") } @@ -121,7 +123,7 @@ Item { } Row { - visible: service.ipv4.method !== IPv4Config.Off + visible: service.ipv4.method !== NetworkSettingsIPv4.Off TextLabel { text: qsTr("Mask: ") } @@ -138,7 +140,7 @@ Item { } Row { - visible: service.ipv4.method !== IPv4Config.Off + visible: service.ipv4.method !== NetworkSettingsIPv4.Off TextLabel { text: qsTr("Router: ") } @@ -155,7 +157,7 @@ Item { } Row { - visible: service.ipv4.method !== IPv4Config.Off + visible: service.ipv4.method !== NetworkSettingsIPv4.Off TextLabel { text: qsTr("DNS server: ") } @@ -197,7 +199,7 @@ Item { text: qsTr("Edit") visible: !editMode - onClicked: stackView.push( { item : Qt.resolvedUrl("EditWiredSettings.qml"), properties : { service: service } } ) + onClicked: stackView.push({item: Qt.resolvedUrl("EditWiredSettings.qml"), properties: {service: root.service}}); } } } |