diff options
Diffstat (limited to 'examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network')
24 files changed, 2113 insertions, 0 deletions
diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/AddressListEntry.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/AddressListEntry.qml new file mode 100644 index 0000000..9701587 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/AddressListEntry.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls + +RowLayout { + id: root + spacing: 10 + property alias model: repeater.model + property bool modified: false + property alias title: label.text + + Label { + id: label + Layout.preferredWidth: content.titleWidth + horizontalAlignment: Text.AlignRight + Layout.alignment: Qt.AlignTop + Layout.topMargin: 10 + } + ColumnLayout { + spacing: 10 + Layout.fillWidth: true + + Repeater { + id: repeater + visible: count > 0 + RowLayout { + spacing: 10 + TextField { + text: edit + Layout.fillWidth: true + onEditingFinished: { + root.modified = true; + edit = text; + } + } + Button { + Layout.preferredWidth: height + text: "-" + visible: repeater.count > 0 + onClicked: { + root.modified = true; + root.model.remove(index); + } + } + Button { + Layout.preferredWidth: height + visible: index === repeater.count - 1 + text: "+" + onClicked: root.model.append("") + + Layout.alignment: Qt.AlignRight + } + } + } + RowLayout { + visible: repeater.count === 0 + spacing: 10 + TextField { + id: nameServerEntryItem + Layout.fillWidth: true + text: "" + onAccepted: root.model.append(text) + } + Button { + Layout.preferredWidth: height + text: "+" + onClicked: nameServerEntryItem.accepted() + } + } + } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CMakeLists.txt b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CMakeLists.txt new file mode 100644 index 0000000..183c9fb --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CMakeLists.txt @@ -0,0 +1,56 @@ +set(qml_files + "CustomSwitch.qml" + "CustomTableView.qml" + "AddressListEntry.qml" + "ComboBoxEntry.qml" + "EditWiredSettings.qml" + "IpAddressTextField.qml" + "NetworkDetails.qml" + "NetworkListView.qml" + "NetworkSettings.qml" + "PassphraseEnter.qml" + "WifiSelectorDelegate.qml" + "WifiSettings.qml" + "WifiSignalMonitor.qml" + "WiredSettings.qml" +) + +# Resources: +set(images + "icons/Alert_yellow_1x.png" + "icons/WifiAnim_black_2x.png" + "icons/Wifi_lightgray_2x.png" +) + +find_package(Qt6 COMPONENTS NetworkSettings QuickControls2) + +qt_add_qml_module(settingsuinetwork + URI "DeviceUtilities.SettingsUI.Network" + VERSION 1.0 + QML_FILES + ${qml_files} + RESOURCES + ${images} +) + +target_link_libraries(settingsuinetwork PRIVATE + Qt::NetworkSettings + Qt::QuickControls2 +) + +set_target_properties(settingsuinetworkplugin PROPERTIES + INSTALL_RPATH $ORIGIN/../../..:$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR} +) + +install(TARGETS settingsuinetwork + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) + +install(TARGETS settingsuinetworkplugin + DESTINATION "${INSTALL_EXAMPLEDIR}/DeviceUtilities/SettingsUI/Network" +) +install(FILES $<TARGET_FILE_DIR:settingsuinetworkplugin>/qmldir + DESTINATION "${INSTALL_EXAMPLEDIR}/DeviceUtilities/SettingsUI/Network" +) diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/ComboBoxEntry.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/ComboBoxEntry.qml new file mode 100644 index 0000000..c7e91b1 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/ComboBoxEntry.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls + +RowLayout { + id: root + spacing: 10 + width: parent.width + + property alias title: label.text + property alias currentIndex: cb.currentIndex + property alias delegate: cb.delegate + property alias textRole: cb.textRole + property alias model: cb.model + property alias count: cb.count + property int titleWidth: -1 + signal activated(int index) + signal highlighted(int index) + + Label { + id: label + Layout.preferredWidth: root.titleWidth + horizontalAlignment: Text.AlignRight + Layout.alignment: Qt.AlignVCenter + } + ComboBox { + id: cb + textRole: "text" + Layout.fillWidth: true + onActivated: root.activated(currentIndex) + onHighlightedIndexChanged: root.highlighted(currentIndex) + } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomSwitch.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomSwitch.qml new file mode 100644 index 0000000..34b0421 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomSwitch.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtQuick.Controls +import DeviceUtilities.SettingsUI +import DeviceUtilities.QtButtonImageProvider + +Switch { + id: control + + property alias indicatorWidth: indicatorImg.width + property alias indicatorHeight: indicatorImg.height + + indicator: Image { + id: indicatorImg + width: 200 + height: 75 + sourceSize: Qt.size(width, height) + anchors.horizontalCenter: control.horizontalCenter + y: parent.height / 2 - height / 2 + source: "image://QtButton/10/#848895/transparent" + Text { + id: offText + anchors.left: parent.left + anchors.leftMargin: parent.width * 0.075 + anchors.verticalCenter: parent.verticalCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + fontSizeMode: Text.Fit + minimumPixelSize: 1 + font.pixelSize: parent.height * 0.55 + color: "#3b4155" + text: "OFF" + font.family: Globals.appFont + } + Text { + id: onText + anchors.right: parent.right + anchors.rightMargin: parent.width * 0.1 + anchors.verticalCenter: parent.verticalCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + fontSizeMode: Text.Fit + minimumPixelSize: 1 + font.pixelSize: parent.height * 0.55 + color: "#3b4155" + text: "ON" + font.family: Globals.appFont + } + + Binding { + target: qtHandle + property: "x" + value: control.checked ? indicatorImg.width - qtHandle.width - indicatorImg.width * 0.025 : indicatorImg.width * 0.025 + when: !mousearea.drag.active + } + + MouseArea { + anchors.fill: parent + onClicked: control.checked = !control.checked + } + + QtButton { + id: qtHandle + anchors.verticalCenter: parent.verticalCenter + width: parent.width * 0.475 + height: parent.height * 0.9 + fillColor: control.checked ? Globals.buttonGreenColor : Globals.buttonGrayColor + text: control.checked ? "ON" : "OFF" + borderColor: "transparent" + Behavior on x { + NumberAnimation { duration: 50 } + } + + MouseArea { + id: mousearea + anchors.fill: parent + drag.target: qtHandle + drag.axis: Drag.XAxis + drag.minimumX: indicatorImg.width * 0.005 + drag.maximumX: indicatorImg.width - width - indicatorImg.width * 0.005 + + onClicked: control.checked = !control.checked + + onReleased: { + if (qtHandle.x > indicatorImg.width / 5 ) { + control.checked = true + } else { + control.checked = false + } + } + } + } + } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomTableView.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomTableView.qml new file mode 100644 index 0000000..059795c --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomTableView.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import DeviceUtilities.SettingsUI + +ColumnLayout { + id: root + + Layout.fillHeight: true + Layout.fillWidth: true + + property var headerTexts: [] + property var roleNames: [] + property alias model: listView.model + property alias localeIndex: listView.currentIndex + signal clicked(int index) + + Timer { //A workaround to position the listView.. + interval: 250 + running: true + onTriggered: listView.positionViewAtIndex(listView.currentIndex, ListView.Beginning) + } + + ListView { + id: listView + Layout.fillHeight: true + Layout.fillWidth: true + clip: true + + onCurrentIndexChanged: { + if (listView.model) { + positionViewAtIndex(listView.currentIndex, ListView.beginning) + } + } + + ScrollBar.vertical: ScrollBar { + contentItem: Rectangle { + implicitWidth: listView.width * 0.0175 + implicitHeight: listView.height * 0.5 + color: Globals.scrollBarColor + } + } + + delegate: Item { + id: delegateRectangle + width: parent.width + height: listView.height * 0.1 + property var delegateData: modelData + + Row { + anchors.fill: parent + anchors.leftMargin: 10 + spacing: 10 + + Repeater { + model: root.roleNames.length + + Text { + width: parent.width / root.roleNames.length + text: delegateData[root.roleNames[index]] + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: delegateRectangle.height * 0.5 + antialiasing: false + smooth: false + renderType: listView.moving ? Text.NativeRendering : Text.QtRendering + color: listView.currentIndex == delegateRectangle.index ? Globals.buttonGreenColor : "white" + font.family: Globals.appFont + } + } + } + MouseArea { + anchors.fill: parent + onClicked: root.clicked(index) + } + } + } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/EditWiredSettings.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/EditWiredSettings.qml new file mode 100644 index 0000000..a59da20 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/EditWiredSettings.qml @@ -0,0 +1,366 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import QtDeviceUtilities.NetworkSettings + +Item { + id: root + property string title: qsTr("Ethernet Settings") + property var service: undefined + property bool ipv4Changed: false + property bool ipv6Changed: false + property bool nameserversChanged: false + property bool domainsChanged: false + property bool proxyChanged: false + + Component.onDestruction: { + //Clear all unsaved changes from models + service.proxy.excludes.resetChanges(); + service.nameservers.resetChanges(); + service.domains.resetChanges(); + } + + Component.onCompleted: titlebar.title = service.name; + + Flickable { + anchors.fill: parent + anchors.top: saveButton.bottom + anchors.margins: 20 + contentHeight: content.height + contentWidth: width + + Column { + id: content + width: parent.width + spacing: 10 + property int titleWidth: width * 0.382 + property int groupWidth: width - saveButton.width - 10 + + //IPv4 Config + GroupBox { + width: content.groupWidth + Layout.fillWidth: true + title: qsTr("IPv4") + + ColumnLayout { + anchors.fill: parent + + ComboBoxEntry { + id: ipv4Method + title: qsTr("Connection method:") + titleWidth: content.titleWidth + model: ListModel { + id: methodsModel + + ListElement { + text: "DHCP" + method: NetworkSettingsIPv4.Dhcp + } + ListElement { + text: "Manual" + method: NetworkSettingsIPv4.Manual + } + ListElement { + text: "Off" + method: NetworkSettingsIPv4.Off + } + } + onCurrentIndexChanged: { + ipv4Changed = true; + service.ipv4.method = model.get(currentIndex).method; + } + } + + GridLayout { + columnSpacing: 10 + rows: 3 + columns: 2 + visible: service.ipv4.method !== NetworkSettingsIPv4.Off + width: parent.width + + Label { + text: qsTr("Address:") + Layout.preferredWidth: content.titleWidth + horizontalAlignment: Text.AlignRight + } + IpAddressTextField { + id: ipv4Address + text: service.ipv4.address + onTextChanged: ipv4Changed = true; + onAccepted: if (text.length > 0) service.ipv4.address = text + enabled: service.ipv4.method === NetworkSettingsIPv4.Manual + } + Label { + text: qsTr("Mask:") + Layout.preferredWidth: content.titleWidth + horizontalAlignment: Text.AlignRight + } + IpAddressTextField { + id: ipv4Mask + text: service.ipv4.mask + onTextChanged: ipv4Changed = true; + onAccepted: if (text.length > 0) service.ipv4.mask = text + enabled: service.ipv4.method === NetworkSettingsIPv4.Manual + } + Label { + text: qsTr("Router:") + Layout.preferredWidth: content.titleWidth + horizontalAlignment: Text.AlignRight + } + IpAddressTextField { + id: ipv4Gateway + text: service.ipv4.gateway + onTextChanged: ipv4Changed = true + onAccepted: if (text.length > 0) service.ipv4.gateway = text + enabled: service.ipv4.method === NetworkSettingsIPv4.Manual + } + } + } + } + + //IPv6 Config + GroupBox { + width: content.groupWidth + Layout.fillWidth: true + title: qsTr("IPv6") + + ColumnLayout { + anchors.fill: parent + + ComboBoxEntry { + id: ipv6Method + title: qsTr("Connection method:") + titleWidth: content.titleWidth + model: ListModel { + id: ipv6methodsmodel + + ListElement { + text: qsTr("Auto") + method: NetworkSettingsIPv6.Auto + } + ListElement { + text: qsTr("Manual") + method: NetworkSettingsIPv6.Manual + } + ListElement { + text: qsTr("Off") + method: NetworkSettingsIPv6.Off + } + } + + onCurrentIndexChanged: { + ipv6Changed = true; + service.ipv6.method = model.get(currentIndex).method; + } + } + GridLayout { + columnSpacing: 10 + rows: 3 + columns: 2 + visible: service.ipv6.method !== NetworkSettingsIPv6.Off + + Label { + text: qsTr("Address:") + Layout.preferredWidth: content.titleWidth + horizontalAlignment: Text.AlignRight + } + TextField { + id: ipv6Address + text: service.ipv6.address + Layout.fillWidth: true + onTextChanged: ipv6Changed = true; + onAccepted: if (text.length > 0) service.ipv6.address = text + enabled: service.ipv6.method === NetworkSettingsIPv6.Manual + } + Label { + text: qsTr("Router:") + Layout.preferredWidth: content.titleWidth + horizontalAlignment: Text.AlignRight + } + TextField { + id: ipv6Gateway + text: service.ipv6.gateway + Layout.fillWidth: true + onTextChanged: ipv6Changed = true; + onAccepted: if (text.length > 0) service.ipv4.gateway = text + enabled: service.ipv6.method === NetworkSettingsIPv6.Manual + } + Label { + text: qsTr("Prefix length:") + Layout.preferredWidth: content.titleWidth + horizontalAlignment: Text.AlignRight + } + TextField { + id: ipv6PrefixLength + text: service.ipv6.prefixLength + Layout.fillWidth: true + validator: IntValidator { bottom: 0; top: 255 } + onTextChanged: ipv6Changed = true + onAccepted: if (text.length > 0) service.ipv6.prefixLength = parseInt(text) + enabled: service.ipv6.method === NetworkSettingsIPv6.Manual + } + } + } + } + GroupBox { + width: content.groupWidth + Layout.fillWidth: true + title: qsTr("Name servers") + + ColumnLayout { + anchors.fill: parent + AddressListEntry { + title: qsTr("Address:") + model: service.nameservers + modified: nameserversChanged + } + } + } + GroupBox { + width: content.groupWidth + Layout.fillWidth: true + title: qsTr("Domains") + + ColumnLayout { + anchors.fill: parent + AddressListEntry { + title: qsTr("Address:") + model: service.domains + modified: domainsChanged + } + } + } + GroupBox { + width: content.groupWidth + Layout.fillWidth: true + title: qsTr("Proxy Settings") + + ColumnLayout { + id: proxyLayout + width: parent.width + + ComboBoxEntry { + title: qsTr("Configuration:") + titleWidth: content.titleWidth + model: ListModel { + id: proxyMethodModel + + ListElement { + text: qsTr("Direct") + method: NetworkSettingsProxy.Direct + } + ListElement { + text: qsTr("Auto") + method: NetworkSettingsProxy.Auto + } + ListElement { + text: qsTr("Manual") + method: NetworkSettingsProxy.Manual + } + } + Component.onCompleted: currentIndex = service.proxy.method + + onCurrentIndexChanged: { + proxyChanged = true; + service.proxy.method = model.get(currentIndex).method; + } + } + RowLayout { + spacing: 10 + visible: service.proxy.method !== NetworkSettingsProxy.Direct + + Label { + text: service.proxy.method === NetworkSettingsProxy.Manual ? qsTr("Proxy address:") : qsTr("Configuration URL:") + Layout.preferredWidth: content.titleWidth + horizontalAlignment: Text.AlignRight + Layout.alignment: Qt.AlignVCenter + elide: Label.ElideRight + } + TextField { + id: proxyUrl + text: service.proxy.url + Layout.fillWidth: true + onTextChanged: proxyChanged = true; + onAccepted: service.proxy.url = text; + } + } + AddressListEntry { + model: service.proxy.excludes + modified: proxyChanged + title: qsTr("No proxy for:") + visible: service.proxy.method === NetworkSettingsProxy.Manual + } + } + } + } + } + Button { + id: saveButton + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 20 + text: qsTr("Save") + + onClicked: { + if (ipv4Changed) { + ipv4Address.accepted(); + ipv4Mask.accepted(); + ipv4Gateway.accepted(); + service.setupIpv4Config(); + } + + if (ipv6Changed) { + ipv6Address.accepted(); + ipv6Gateway.accepted(); + ipv6PrefixLength.accepted(); + service.setupIpv6Config(); + } + + if (nameserversChanged) { + service.setupNameserversConfig(); + } + + if (domainsChanged) { + service.setupDomainsConfig(); + } + + if (proxyChanged) { + proxyUrl.accepted(); + service.setupNetworkSettingsProxy(); + } + stackView.pop(); + } + } + onServiceChanged: { + ipv4Method.currentIndex = service.ipv4.method + ipv6Method.currentIndex = service.ipv6.method + } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/IpAddressTextField.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/IpAddressTextField.qml new file mode 100644 index 0000000..a328775 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/IpAddressTextField.qml @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtQuick.Controls + +TextField { + Layout.fillWidth: true + validator: RegExpValidator { regExp: /^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))$/ } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkDetails.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkDetails.qml new file mode 100644 index 0000000..88b0946 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkDetails.qml @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick + +Loader { + id: root + property var selectedInterface:undefined + anchors.fill: parent +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkListView.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkListView.qml new file mode 100644 index 0000000..68498b5 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkListView.qml @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtDeviceUtilities.NetworkSettings +import DeviceUtilities.SettingsUI +import DeviceUtilities.QtButtonImageProvider + +ListView { + id: list + clip: true + property var connectingService: null + property bool retryConnectAfterIdle: false + function connectBySsid() { + passphraseEnter.showSsid = true + passphraseEnter.visible = true + } + + Component.onCompleted: { + NetworkSettingsManager.services.type = NetworkSettingsType.Unknown; + } + model: NetworkSettingsManager.services + + delegate: Item { + id: networkDelegate + width: list.width + height: list.height * 0.15 + Column { + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + width: parent.width * 0.5 + Text { + id: networkName + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + font.pixelSize: Globals.subTitleFontSize + font.family: Globals.appFont + color: connected ? Globals.buttonGreenColor : "white" + text: name + } + Row { + id: ipRow + height: networkDelegate.height * 0.275 * opacity + spacing: networkDelegate.width * 0.0075 + Item { + width: Globals.margin(list.width) + height: 1 + } + Text { + id: ipAddressLabel + height: parent.height + anchors.verticalCenter: parent.verticalCenter + text: qsTr("IP Address:") + color: connected ? Globals.buttonGreenColor : "white" + font.pixelSize: Globals.valueFontSize + font.family: Globals.appFont + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + } + Text { + id: ipAddress + width: root.width * 0.15 + height: parent.height + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + color: connected ? Globals.buttonGreenColor : "white" + text: connected ? NetworkSettingsManager.services.itemFromRow(index).ipv4.address + : (NetworkSettingsManager.services.itemFromRow(index).state === NetworkSettingsState.Idle) ? + qsTr("Not connected") : qsTr("Connecting") + font.pixelSize: Globals.valueFontSize + font.family: Globals.appFont + font.styleName: connected ? "SemiBold" : "Regular" + } + } + } + QtButton { + id: connectButton + fontFamily: Globals.appFont + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + fillColor: connected ? Globals.buttonGrayColor : Globals.buttonGreenColor + borderColor: "transparent" + text: connected ? qsTr("DISCONNECT") : qsTr("CONNECT") + height: Globals.buttonHeight + onClicked: { + if (connected) { + NetworkSettingsManager.services.itemFromRow(index).disconnectService(); + } else { + list.connectingService = NetworkSettingsManager.services.itemFromRow(index) + if (list.connectingService) { + passphraseEnter.extraInfo = ""; + list.connectingService.connectService(); + list.connectingService.stateChanged.connect(connectingServiceStateChange); + } + } + } + } + Rectangle { + id: delegateBottom + width: networkDelegate.width + color: Globals.borderColor + height: 2 + anchors.bottom: networkDelegate.bottom + anchors.horizontalCenter: networkDelegate.horizontalCenter + } + Behavior on height { NumberAnimation { duration: 200} } + + } + + Connections { + target: NetworkSettingsManager.userAgent + function onShowUserCredentialsInput() { + passphraseEnter.visible = true; + } + } + + // Popup for entering passphrase + PassphraseEnter { + id: passphraseEnter + parent: root + visible: false + } + + function connectingServiceStateChange() { + if (connectingService !== null) { + if (connectingService.state === NetworkSettingsState.Failure) { + // If authentication failed, request connection again. That will + // initiate new passphrase request. + retryConnectAfterIdle = true + } else if (connectingService.state === NetworkSettingsState.Ready) { + // If connection succeeded, we no longer have service connecting + connectingService = null; + retryConnectAfterIdle = false; + } else if (connectingService.state === NetworkSettingsState.Idle) { + if (retryConnectAfterIdle) { + passphraseEnter.extraInfo = qsTr("Invalid passphrase"); + connectingService.connectService(); + } + retryConnectAfterIdle = false; + } + } + } + + focus: true +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkSettings.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkSettings.qml new file mode 100644 index 0000000..2b59c61 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkSettings.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtDeviceUtilities.NetworkSettings +import DeviceUtilities.QtButtonImageProvider +import DeviceUtilities.SettingsUI + +Item { + id: networkSettingsRoot + property string title: qsTr("Network Settings") + anchors.fill: parent + + Text { + id: wlanText + text: qsTr("WLAN") + font.pixelSize: networkSettingsRoot.height * Globals.subTitleFontSize + font.family: Globals.appFont + font.styleName: "SemiBold" + color: "white" + anchors.top: networkSettingsRoot.top + anchors.left: networkSettingsRoot.left + } + CustomSwitch { + id: wifiSwitch + anchors.top: wlanText.bottom + anchors.left: wlanText.left + height: networkSettingsRoot.height * Globals.buttonHeight + indicatorWidth: networkSettingsRoot.height * Globals.buttonWidth + indicatorHeight: networkSettingsRoot.height * Globals.buttonHeight + property bool wiFiAvailable: NetworkSettingsManager.interface(NetworkSettingsType.Wifi, 0) !== null + checkable: wiFiAvailable && !wifiSwitchTimer.running + + onCheckedChanged: { + // Power on/off all WiFi interfaces + for (var i = 0; NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i) !== null; i++) { + NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i).powered = checked + wifiSwitchTimer.start() + } + } + + // At least 1s between switching on/off + Timer { + id: wifiSwitchTimer + interval: 1000 + running: false + } + } + QtButton { + id: manualConnect + anchors.top: wlanText.bottom + anchors.left: wifiSwitch.right + anchors.right: manualDisconnect.left + anchors.rightMargin: 10 + enabled: wifiSwitch.checked + fillColor: enabled ? Globals.buttonGreenColor : Globals.buttonGrayColor + borderColor: "transparent" + height: networkSettingsRoot.height * Globals.buttonHeight + text: qsTr("MANUAL CONNECT") + onClicked: { + networkList.connectBySsid() + } + } + QtButton { + id: manualDisconnect + anchors.top: wlanText.bottom + anchors.right: networkSettingsRoot.right + enabled: NetworkSettingsManager.currentWifiConnection + fillColor: enabled ? Globals.buttonGreenColor : Globals.buttonGrayColor + borderColor: "transparent" + height: networkSettingsRoot.height * Globals.buttonHeight + text: qsTr("DISCONNECT") + onClicked: { + if (NetworkSettingsManager.currentWifiConnection) { + NetworkSettingsManager.currentWifiConnection.disconnectService(); + } + } + } + Text { + id: networkListTextItem + text: qsTr("Network list:") + font.pixelSize: networkSettingsRoot.height * Globals.subTitleFontSize + font.family: Globals.appFont + font.styleName: "SemiBold" + color: "white" + anchors.top: wifiSwitch.bottom + anchors.topMargin: 10 + } + NetworkListView { + id: networkList + anchors.top: networkListTextItem.bottom + anchors.left: networkListTextItem.left + width: networkSettingsRoot.width + height: networkSettingsRoot.height + } +} + diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/PassphraseEnter.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/PassphraseEnter.qml new file mode 100644 index 0000000..f0978d2 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/PassphraseEnter.qml @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtQuick.Controls +import QtDeviceUtilities.NetworkSettings +import DeviceUtilities.SettingsUI +import DeviceUtilities.QtButtonImageProvider + +Rectangle { + id: passphrasePopup + width: parent.width + height: parent.height + color: Globals.backgroundColor + opacity: 0.9 + property string extraInfo: "" + property bool showSsid: false + + property int margin: (width / 3 * 2) * 0.05 + property int spacing: margin * 0.5 + + Rectangle { + id: frame + color: Globals.backgroundColor + border.color: Globals.borderColor + border.width: 3 + anchors.centerIn: parent + width: passphraseColumn.width * 1.1 + height: passphraseColumn.height * 1.1 + + Column { + id: passphraseColumn + anchors.centerIn: parent + spacing: spacing + + Text { + visible: showSsid + font.pixelSize: parent.height * Globals.subTitleFontSize + font.family: Globals.appFont + color: "white" + text: qsTr("Enter SSID") + } + + TextField { + id: ssidField + visible: showSsid + width: passphrasePopup.width * 0.4 + height: passphrasePopup.height * 0.075 + color: "white" + background: Rectangle{ + color: "transparent" + border.color: ssidField.focus ? Globals.buttonGreenColor : Globals.buttonGrayColor + border.width: ssidField.focus ? width * 0.01 : 2 + } + } + + Text { + font.pixelSize: parent.height * Globals.subTitleFontSize + font.family: Globals.appFont + color: "white" + text: qsTr("Enter Passphrase") + } + + Text { + font.pixelSize: parent.height * Globals.valueFontSize + font.family: Globals.appFont + color: "red" + text: extraInfo + visible: (extraInfo !== "") + } + + TextField { + id: passField + width: passphrasePopup.width * 0.4 + height: passphrasePopup.height * 0.075 + color: "white" + echoMode: TextInput.Password + background: Rectangle{ + color: "transparent" + border.color: passField.focus ? Globals.buttonGreenColor : Globals.buttonGrayColor + border.width: passField.focus ? width * 0.01 : 2 + } + } + + Row { + spacing: parent.width * 0.025 + QtButton{ + id: setButton + text: qsTr("SET") + onClicked: { + if (showSsid) { + NetworkSettingsManager.connectBySsid(ssidField.text, passField.text) + showSsid = false + } else { + NetworkSettingsManager.userAgent.setPassphrase(passField.text) + } + passphrasePopup.visible = false; + } + } + QtButton { + id: cancelButton + text: qsTr("CANCEL") + borderColor: "transparent" + fillColor: Globals.buttonGrayColor + onClicked: { + if (!showSsid) { + NetworkSettingsManager.userAgent.cancelInput() + } + showSsid = false + passphrasePopup.visible = false; + } + } + } + } + } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSelectorDelegate.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSelectorDelegate.qml new file mode 100644 index 0000000..9c2ad11 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSelectorDelegate.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls + +ItemDelegate { + id: root + autoExclusive: true + property bool connect: connected + contentItem: Item { + width: root.width + + Label { + id: text + leftPadding: root.spacing + anchors.left: parent.left + anchors.top:parent.top + anchors.right: signalMonitor.left + anchors.bottom:parent.bottom + elide: Text.ElideRight + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + text: modelData["name"] + } + WifiSignalMonitor { + id: signalMonitor + anchors.right: parent.right + height: parent.height + width: height + signalStrength: modelData.wirelessConfig["signalStrength"] + connected: connected + } + } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSettings.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSettings.qml new file mode 100644 index 0000000..7b4f246 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSettings.qml @@ -0,0 +1,252 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import QtDeviceUtilities.NetworkSettings + +Item { + id: root + anchors.fill: parent + Component.onCompleted: NetworkSettingsManager.services.type = NetworkSettingsType.Wifi; + property bool connecting: false + property var selectedInterface: undefined + + Flickable { + anchors.fill: parent + contentHeight: content.height + contentWidth: width + + GroupBox { + title: qsTr("Wireless Settings") + width: parent.width + + ColumnLayout { + id: content + spacing: 20 + width: parent.width + + RowLayout { + spacing: 10 + id: enableSwitch + width: parent.width + + Label { + Layout.preferredWidth: root.width * 0.382 + Layout.alignment: Qt.AlignVCenter + horizontalAlignment: Text.AlignRight + text: selectedInterface.powered ? qsTr("Wi-Fi ON") : qsTr("Wi-Fi OFF") + } + Switch { + checked: selectedInterface.powered + onCheckedChanged: { + selectedInterface.powered = checked + root.connecting = false + connectView.visible = false + } + } + } + RowLayout { + spacing: 10 + width: parent.width + + visible: selectedInterface.powered && networkSelection.count > 0 + Label { + Layout.preferredWidth: root.width * 0.382 + text: qsTr("Current network") + horizontalAlignment: Text.AlignRight + Layout.alignment: Qt.AlignVCenter + + } + ComboBoxEntry { + id: networkSelection + model: NetworkSettingsManager.services + + textRole: "name" + Layout.fillWidth: true + onActivated: function(index) { + if (index >= 0) { + connectView.visible = false + + var service = model.itemFromRow(index) + if (service) { + root.connecting = true + service.connectService(); + } + } + } + + onCountChanged: { + if (count === 0) { + root.connecting = false + connectView.visible = false + } + } + + Component.onCompleted: { + networkSelection.currentIndex = model.activeRow() + } + + delegate: WifiSelectorDelegate { + width: networkSelection.width + onConnectChanged: if (connect) networkSelection.currentIndex = index + } + } + } + + Row { + id: infoRow + spacing: 10 + width: parent.width + visible: selectedInterface.powered && selectedInterface.state !== NetworkSettingsState.Online + Label { + id: scanningText + text: { + if (networkSelection.count == 0) + return qsTr("Searching for Wi-Fi networks...") + else if (root.connecting) + return qsTr("Connecting to the network...") + else + return "" + } + horizontalAlignment: Text.AlignLeft + } + WifiSignalMonitor { + id: scanningIcon + scanning: true + visible: scanningText.text !== "" + height: scanningText.height + width: height + } + } + + GroupBox { + id: connectView + title: qsTr("Enter a passphrase") + visible: false + Layout.fillWidth: true + ColumnLayout { + width: parent.width + + RowLayout { + id: errorView + visible: text.text !== "" + spacing: 10 + property alias text: text.text + + Image { + source: "icons/Alert_yellow_1x.png" + Layout.alignment: Qt.AlignVCenter + } + Text { + id: text + color: "#face20" + text: "" + Layout.alignment: Qt.AlignVCenter + } + } + RowLayout { + spacing: 10 + width: parent.width + + Label { + text: qsTr("Passphrase:") + horizontalAlignment: Text.AlignRight + Layout.preferredWidth: root.width * 0.382 + Layout.alignment: Qt.AlignVCenter + } + TextField { + id: passphrase + text: "" + echoMode: TextInput.Password + inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase | Qt.ImhPreferLowercase | Qt.ImhSensitiveData + Layout.alignment: Qt.AlignVCenter + Layout.fillWidth: true + } + } + RowLayout { + spacing: 10 + + Button { + text: qsTr("Connect") + onClicked: { + connectView.visible = false + NetworkSettingsManager.userAgent.setPassphrase(passphrase.text) + if (networkSelection.currentIndex != -1) { + NetworkSettingsManager.services.itemFromRow(networkSelection.currentIndex).connectService(); + } + } + } + Button { + text: qsTr("Cancel") + onClicked: { + networkSelection.currentIndex = -1 + connectView.visible = false + } + } + } + } + } + ColumnLayout { + spacing: parent.spacing + width: parent.width + visible: selectedInterface.state === NetworkSettingsState.Online || + selectedInterface.state === NetworkSettingsState.Ready + Label { + text: qsTr("IP Address: ") + NetworkSettingsManager.services.itemFromRow(networkSelection.currentIndex).ipv4.address + } + Button { + id: disconnect + text: qsTr("Disconnect") + onClicked: { + NetworkSettingsManager.services.itemFromRow(networkSelection.currentIndex).disconnectService(); + networkSelection.currentIndex = -1; + root.connecting = false + } + } + } + } + Connections { + target: NetworkSettingsManager.userAgent + function onShowUserCredentialsInput() { + connectView.visible = true + root.connecting = false + } + function onError() { + errorView.visible = true + connectView.visible = true + root.connecting = false + if (networkSelection.currentIndex != -1) { + NetworkSettingsManager.services.itemFromRow(networkSelection.currentIndex).removeService(); + } + } + } + } + } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSignalMonitor.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSignalMonitor.qml new file mode 100644 index 0000000..bfbcb1d --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSignalMonitor.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick + +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 { + id: sprite + property int currentFrame: 0 + anchors.fill: parent + source: "icons/Wifi_lightgray_2x.png" + clip: true + + Timer { + id: scanningTimer + running: scanning + interval: 250 + repeat: true + onTriggered: { + if (sprite.currentFrame < 4) + sprite.currentFrame++ + else + sprite.currentFrame = 0 + } + } + + Image { + height: parent.height + width: parent.width * 4 + source: "icons/WifiAnim_black_2x.png" + x: -parent.currentFrame * width / 4 + } + } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WiredSettings.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WiredSettings.qml new file mode 100644 index 0000000..f5d3a8f --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WiredSettings.qml @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import QtDeviceUtilities.NetworkSettings + +Item { + id: root + anchors.fill: parent + property bool editMode: false + property var service: null + property string title: qsTr("Network"); + + Component.onCompleted: { + NetworkSettingsManager.services.type = NetworkSettingsType.Wired; + root.service = NetworkSettingsManager.services.itemFromRow(0); + ipv4Method.currentIndex = service.ipv4.method + } + + onServiceChanged: { + NetworkSettingsManager.services.type = NetworkSettingsType.Wired; + if (!root.service) { + root.service = NetworkSettingsManager.services.itemFromRow(0); + } + } + + GroupBox { + title: qsTr("Ethernet Connection") + anchors.fill: parent + + Column { + spacing: 10 + width: parent.width + + ComboBoxEntry { + id: ipv4Method + title: qsTr("Connection method:") + model: ListModel { + id: methodsModel + + ListElement { + text: "DHCP" + method: NetworkSettingsIPv4.Dhcp + } + ListElement { + text: "Manual" + method: NetworkSettingsIPv4.Manual + } + ListElement { + text: "Off" + method: NetworkSettingsIPv4.Off + } + } + + Component.onCompleted: currentIndex = service.ipv4.method + onCurrentIndexChanged: { + if (model.get(currentIndex).method !== NetworkSettingsIPv4.Dhcp) { + service.ipv4.method = model.get(currentIndex).method; + editMode = true; + } + else if (service){ + //Enable DHCP + if (service.ipv4.method !== model.get(currentIndex).method) { + service.ipv4.method = model.get(currentIndex).method; + service.setupIpv4Config(); + } + editMode = false; + } + } + } + Item { + width: parent.width + height: gridLayout.implicitHeight + GridLayout { + id: gridLayout + columns: 2 + rows: 4 + width: parent.width + visible: service.ipv4.method !== NetworkSettingsIPv4.Off + + Label { + text: qsTr("IP Address: ") + width: parent.width * .3 + } + IpAddressTextField { + id: ipv4Address + text: service.ipv4.address + enabled: editMode + onAccepted: if (text.length > 0) service.ipv4.address = text + } + Label { + text: qsTr("Mask: ") + } + IpAddressTextField { + id: ipv4Mask + text: service.ipv4.mask + enabled: editMode + onAccepted: if (text.length > 0) service.ipv4.mask = text + } + Label { + text: qsTr("Router: ") + } + IpAddressTextField { + id: ipv4Gateway + text: service.ipv4.gateway + enabled: editMode + onAccepted: if (text.length > 0) service.ipv4.gateway = text + } + Label { + Layout.alignment: Qt.AlignTop + text: qsTr("DNS server: ") + } + Column { + spacing: 10 + Layout.fillWidth: true + Layout.alignment: Qt.AlignTop + + Repeater { + model: service.nameservers + + Label { + text: display + } + } + } + } + MouseArea { + anchors.fill: parent + enabled: !editMode + && methodsModel.get(ipv4Method.currentIndex).method === NetworkSettingsIPv4.Manual + onClicked: editMode = true + } + } + Row { + spacing: 10 + Button { + text: qsTr("Save") + visible: editMode + + onClicked: { + ipv4Address.accepted(); + ipv4Mask.accepted(); + ipv4Gateway.accepted(); + service.setupIpv4Config(); + editMode = false; + } + } + Button { + text: qsTr("Cancel") + visible: editMode + onClicked: { + editMode = false; + ipv4Method.currentIndex = service.ipv4.method + } + } + } + Button { + text: qsTr("Edit") + visible: !editMode + onClicked: stackView.push(Qt.resolvedUrl("EditWiredSettings.qml"), {service: root.service}); + } + } + } +} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/Alert_yellow_1x.png b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/Alert_yellow_1x.png Binary files differnew file mode 100644 index 0000000..6fd25cb --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/Alert_yellow_1x.png diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/WifiAnim_black_2x.png b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/WifiAnim_black_2x.png Binary files differnew file mode 100644 index 0000000..c2dc8c5 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/WifiAnim_black_2x.png diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/Wifi_lightgray_2x.png b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/Wifi_lightgray_2x.png Binary files differnew file mode 100644 index 0000000..b71b22e --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/Wifi_lightgray_2x.png diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/generate_icons.sh b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/generate_icons.sh new file mode 100755 index 0000000..7218df0 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/generate_icons.sh @@ -0,0 +1,37 @@ +############################################################################ +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the Device Utilities module of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL$ +## 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 https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +#!/bin/bash +# +# This script resizes and sets correct brand colors for the icons in ref folder +# + +./scripts/cimages.sh ./ref/*.png +./scripts/cimage.sh ./ref/extra/Alert.png red +./scripts/cimage.sh ./ref/extra/Alert.png yellow +./scripts/rimages.sh *.png diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/ref/extra/Alert.png b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/ref/extra/Alert.png Binary files differnew file mode 100644 index 0000000..80914fc --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/ref/extra/Alert.png diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/cimage.sh b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/cimage.sh new file mode 100755 index 0000000..adbbb7f --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/cimage.sh @@ -0,0 +1,55 @@ +############################################################################ +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the Device Utilities module of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL$ +## 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 https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +#!/bin/bash + +fullfile=$1 +filename=$(basename "$fullfile") +extension="${filename##*.}" +filename="${filename%.*}" + +color=$2 +if [ "$color" = "qt" ]; then + fill='rgb(128,195,66)' +elif [ "$color" = "black" ]; then + fill='rgb(32,40,42)' +elif [ "$color" = "white" ]; then + fill='rgb(255,255,255)' +elif [ "$color" = "lightgray" ]; then + fill='rgb(214,214,214)' +elif [ "$color" = "red" ]; then + fill='rgb(228,30,37)' +elif [ "$color" = "yellow" ]; then + fill='rgb(250,206,32)' +else + fill="black" +fi + +separator="_" + +convert $fullfile -fuzz 100% -fill $fill -opaque black $filename$separator$color.$extension diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/cimages.sh b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/cimages.sh new file mode 100755 index 0000000..db1ad04 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/cimages.sh @@ -0,0 +1,38 @@ +############################################################################ +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the Device Utilities module of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL$ +## 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 https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +#!/bin/bash + +for dir in "$@" +do + echo "$dir" + scripts/cimage.sh $dir qt + scripts/cimage.sh $dir black + scripts/cimage.sh $dir white + scripts/cimage.sh $dir lightgray +done diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/rimage.sh b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/rimage.sh new file mode 100755 index 0000000..69b65a3 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/rimage.sh @@ -0,0 +1,47 @@ +############################################################################ +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the Device Utilities module of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL$ +## 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 https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +#!/bin/bash +fullfile=$1 +filename=$(basename "$fullfile") +extension="${filename##*.}" +filename="${filename%.*}" + +postix="_1x" +convert $fullfile -resize x16 $filename$postix.$extension +postix="_2x" +convert $fullfile -resize x32 $filename$postix.$extension +postix="_3x" +convert $fullfile -resize x48 $filename$postix.$extension +postix="_4x" +convert $fullfile -resize x64 $filename$postix.$extension +postix="_5x" +convert $fullfile -resize x80 $filename$postix.$extension +postix="_6x" +convert $fullfile -resize x96 $filename$postix.$extension + diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/rimages.sh b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/rimages.sh new file mode 100755 index 0000000..e9e01b0 --- /dev/null +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/rimages.sh @@ -0,0 +1,35 @@ +############################################################################ +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the Device Utilities module of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL$ +## 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 https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +#!/bin/bash + +for dir in "$@" +do + echo "$dir" + scripts/rimage.sh $dir +done |