From 1a4873dd84701e18654dcd81a8016df81c003937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Thu, 16 Dec 2021 14:21:19 +0200 Subject: SettingsUI is now simple view of available networks Features it provides: * Control WiFi interface powered option * Manually connect hidden WiFi via SSID * Connect/Disconnect available networks (also WiFi) Task-number: QTBUG-97737 Pick-to: 6.2 6.3 Change-Id: Id79555f4bab221d50765507abe4c2ee905b7a063 Reviewed-by: Samuli Piippo --- .../DeviceUtilities/SettingsUI/CMakeLists.txt | 3 - .../DeviceUtilities/SettingsUI/Globals.qml | 1 + .../SettingsUI/Network/CMakeLists.txt | 1 - .../SettingsUI/Network/CustomSwitch.qml | 7 -- .../SettingsUI/Network/NetworkDetails.qml | 35 ------- .../SettingsUI/Network/NetworkListView.qml | 19 ++-- .../SettingsUI/Network/NetworkSettings.qml | 29 ++++-- .../SettingsUI/Network/PassphraseEnter.qml | 6 +- .../SettingsUI/SettingsDelegate.qml | 80 --------------- .../DeviceUtilities/SettingsUI/SettingsHeader.qml | 111 --------------------- .../SettingsUI/SettingsTitleItem.qml | 57 ----------- .../DeviceUtilities/SettingsUI/SettingsUI.qml | 57 +---------- 12 files changed, 37 insertions(+), 369 deletions(-) delete mode 100644 examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkDetails.qml delete mode 100644 examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsDelegate.qml delete mode 100644 examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsHeader.qml delete mode 100644 examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsTitleItem.qml (limited to 'examples') diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/CMakeLists.txt b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/CMakeLists.txt index c14398d..61791e5 100644 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/CMakeLists.txt +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/CMakeLists.txt @@ -1,8 +1,5 @@ set(qml_files "Globals.qml" - "SettingsDelegate.qml" - "SettingsHeader.qml" - "SettingsTitleItem.qml" "SettingsUI.qml" ) diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Globals.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Globals.qml index cea47d0..de31b89 100644 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Globals.qml +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Globals.qml @@ -28,6 +28,7 @@ ****************************************************************************/ pragma Singleton import QtQuick +import QtDeviceUtilities.NetworkSettings QtObject { id: globals diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CMakeLists.txt b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CMakeLists.txt index 183c9fb..ea3dc22 100644 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CMakeLists.txt +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CMakeLists.txt @@ -5,7 +5,6 @@ set(qml_files "ComboBoxEntry.qml" "EditWiredSettings.qml" "IpAddressTextField.qml" - "NetworkDetails.qml" "NetworkListView.qml" "NetworkSettings.qml" "PassphraseEnter.qml" diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomSwitch.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomSwitch.qml index 34b0421..394629b 100644 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomSwitch.qml +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomSwitch.qml @@ -81,11 +81,6 @@ Switch { when: !mousearea.drag.active } - MouseArea { - anchors.fill: parent - onClicked: control.checked = !control.checked - } - QtButton { id: qtHandle anchors.verticalCenter: parent.verticalCenter @@ -106,8 +101,6 @@ Switch { 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 diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkDetails.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkDetails.qml deleted file mode 100644 index 88b0946..0000000 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkDetails.qml +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** 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 index 68498b5..b4f3d0e 100644 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkListView.qml +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkListView.qml @@ -36,16 +36,16 @@ ListView { clip: true property var connectingService: null property bool retryConnectAfterIdle: false + + focus: true + boundsBehavior: Flickable.DragOverBounds + model: NetworkSettingsManager.services + 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 @@ -61,7 +61,7 @@ ListView { font.pixelSize: Globals.subTitleFontSize font.family: Globals.appFont color: connected ? Globals.buttonGreenColor : "white" - text: name + text: (modelData.type === NetworkSettingsType.Wired) ? modelData["name"] + " (" + modelData["id"] + ")" : name } Row { id: ipRow @@ -107,7 +107,7 @@ ListView { fillColor: connected ? Globals.buttonGrayColor : Globals.buttonGreenColor borderColor: "transparent" text: connected ? qsTr("DISCONNECT") : qsTr("CONNECT") - height: Globals.buttonHeight + enabled: true onClicked: { if (connected) { NetworkSettingsManager.services.itemFromRow(index).disconnectService(); @@ -130,7 +130,6 @@ ListView { anchors.horizontalCenter: networkDelegate.horizontalCenter } Behavior on height { NumberAnimation { duration: 200} } - } Connections { @@ -143,7 +142,7 @@ ListView { // Popup for entering passphrase PassphraseEnter { id: passphraseEnter - parent: root + parent: list.parent visible: false } @@ -166,6 +165,4 @@ ListView { } } } - - focus: true } diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkSettings.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkSettings.qml index 2b59c61..6c486f6 100644 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkSettings.qml +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkSettings.qml @@ -33,12 +33,24 @@ import DeviceUtilities.SettingsUI Item { id: networkSettingsRoot - property string title: qsTr("Network Settings") anchors.fill: parent + Connections { + target: NetworkSettingsManager + function onInterfacesChanged() { + if (NetworkSettingsManager.interface(NetworkSettingsType.Wifi, 0) !== null) { + wifiSwitch.visible = true + wifiSwitch.checked = Qt.binding(function() { return NetworkSettingsManager.interface(NetworkSettingsType.Wifi, 0).powered }) + } else { + wifiSwitch.visible = false + } + } + } + Text { id: wlanText - text: qsTr("WLAN") + visible: wifiSwitch.visible + text: qsTr("WiFi") font.pixelSize: networkSettingsRoot.height * Globals.subTitleFontSize font.family: Globals.appFont font.styleName: "SemiBold" @@ -46,6 +58,7 @@ Item { anchors.top: networkSettingsRoot.top anchors.left: networkSettingsRoot.left } + CustomSwitch { id: wifiSwitch anchors.top: wlanText.bottom @@ -53,8 +66,7 @@ Item { 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 + checkable: visible && !wifiSwitchTimer.running onCheckedChanged: { // Power on/off all WiFi interfaces @@ -77,6 +89,7 @@ Item { anchors.left: wifiSwitch.right anchors.right: manualDisconnect.left anchors.rightMargin: 10 + visible: wifiSwitch.visible enabled: wifiSwitch.checked fillColor: enabled ? Globals.buttonGreenColor : Globals.buttonGrayColor borderColor: "transparent" @@ -86,10 +99,12 @@ Item { networkList.connectBySsid() } } + QtButton { id: manualDisconnect anchors.top: wlanText.bottom anchors.right: networkSettingsRoot.right + visible: wifiSwitch.visible enabled: NetworkSettingsManager.currentWifiConnection fillColor: enabled ? Globals.buttonGreenColor : Globals.buttonGrayColor borderColor: "transparent" @@ -101,16 +116,18 @@ Item { } } } + Text { id: networkListTextItem - text: qsTr("Network list:") + text: qsTr("Available networks:") font.pixelSize: networkSettingsRoot.height * Globals.subTitleFontSize font.family: Globals.appFont font.styleName: "SemiBold" color: "white" - anchors.top: wifiSwitch.bottom + anchors.top: (wifiSwitch.visible === true) ? wifiSwitch.bottom : networkSettingsRoot.top anchors.topMargin: 10 } + NetworkListView { id: networkList anchors.top: networkListTextItem.bottom diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/PassphraseEnter.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/PassphraseEnter.qml index f0978d2..ab85201 100644 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/PassphraseEnter.qml +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/PassphraseEnter.qml @@ -60,7 +60,7 @@ Rectangle { Text { visible: showSsid - font.pixelSize: parent.height * Globals.subTitleFontSize + font.pixelSize: passphrasePopup.height * Globals.subTitleFontSize font.family: Globals.appFont color: "white" text: qsTr("Enter SSID") @@ -80,14 +80,14 @@ Rectangle { } Text { - font.pixelSize: parent.height * Globals.subTitleFontSize + font.pixelSize: passphrasePopup.height * Globals.subTitleFontSize font.family: Globals.appFont color: "white" text: qsTr("Enter Passphrase") } Text { - font.pixelSize: parent.height * Globals.valueFontSize + font.pixelSize: passphrasePopup.height * Globals.valueFontSize font.family: Globals.appFont color: "red" text: extraInfo diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsDelegate.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsDelegate.qml deleted file mode 100644 index b3a1193..0000000 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsDelegate.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** 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 DeviceUtilities.SettingsUI - -Item { - id: delegate - width: parent.width - height: parent.height * 0.08 - - //TODO: Do not expect id from other qml file to work/exist - property bool isSelected: settingsList.currentIndex == index - - Image { - id: img - sourceSize.width: parent.width - sourceSize.height: parent.height - source: icon - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: parent.width * 0.075 - height: Math.min(parent.width * 0.5, parent.height * 0.6) - width: height - fillMode: Image.PreserveAspectFit - } - - Text { - text: title - height: parent.height * 0.75 - anchors.right: parent.right - anchors.left: img.right - anchors.leftMargin: parent.width * 0.025 - anchors.verticalCenter: parent.verticalCenter - fontSizeMode: Text.Fit - minimumPixelSize: 1 - font.pixelSize: Math.min(parent.width * 0.25, parent.height) - color: delegate.isSelected ? Globals.buttonGreenColor : "white" - wrapMode: Text.WordWrap - verticalAlignment: Text.AlignVCenter - font.family: Globals.appFont - font.styleName: delegate.isSelected ? "Bold" : "Regular" - } - - //TODO: Do not expect id from other qml file to work/exist - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - settingsList.currentIndex = index - settingsLoader.source = path + '/' + view + '.qml' - titleItem.title = title - } - } -} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsHeader.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsHeader.qml deleted file mode 100644 index 5667a3c..0000000 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsHeader.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** 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 - -Item { - id: header - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - anchors.margins: margin - height: margin * 4 - - property int margin: Globals.margin(header.width) - property int spacing: margin * 0.5 - - signal clicked() - - Image { - id: networkButton - anchors.left: header.left - anchors.top: header.top - source: "icons/back.svg" - height: header.height * 0.5 - width: height / sourceSize.height * sourceSize.width - MouseArea { - anchors.fill: parent - anchors.margins: -parent.height * 0.2 - onClicked: parent.clicked() - } - visible: false - } - - Text { - id: settingsText - anchors.left: networkButton.right - anchors.verticalCenter: networkButton.verticalCenter - font.pixelSize: header.height * 0.45 - text: qsTr("Settings") - color: "white" - font.family: Globals.appFont - font.styleName: "SemiBold" - MouseArea { - anchors.fill: parent - anchors.margins: -parent.height * 0.2 - onClicked: parent.clicked() - } - } - - Text { - id: ipItem - width: header.width * 0.25 - height: header.height/2 - anchors.top: settingsText.top - anchors.right: header.right - anchors.rightMargin: margin - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - font.pixelSize: header.height * 0.3 - color: "white" - font.family: Globals.appFont - font.styleName: "SemiBold" - text: NetworkSettingsManager.currentWiredConnection ? - qsTr("Wired IP: ") + - NetworkSettingsManager.currentWiredConnection.ipv4.address : "" - } - - Text { - id: wifiIpItem - width: header.width * 0.25 - height: header.height/2 - anchors.top: ipItem.bottom - anchors.right: parent.right - anchors.rightMargin: margin - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - font.pixelSize: header.height * 0.3 - color: "white" - font.family: Globals.appFont - font.styleName: "SemiBold" - text: NetworkSettingsManager.currentWifiConnection ? - qsTr("Wireless IP: ") + - NetworkSettingsManager.currentWifiConnection.ipv4.address : "" - } -} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsTitleItem.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsTitleItem.qml deleted file mode 100644 index d43f8e8..0000000 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsTitleItem.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** 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 - -Column { - id: page - spacing: Globals.margin(page.width) * Globals.spacing - - property alias title: displayText.text - - Text { - id: displayText - font.pixelSize: (page.parent.height * Globals.titleFontSize) - color: "white" - fontSizeMode: Text.Fit - minimumPixelSize: 1 - font.family: Globals.appFont - font.styleName: "Bold" - } - - Rectangle { - id: btmLine - width: page.parent.width * 0.3 - height: 3 - } - - Item { - height: Globals.margin(page.width) - width: 1 - } -} diff --git a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsUI.qml b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsUI.qml index 44ce51d..5fad0ed 100644 --- a/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsUI.qml +++ b/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsUI.qml @@ -34,63 +34,10 @@ Rectangle { anchors.fill: parent color: Globals.backgroundColor opacity: 0.97 - property int margin: Globals.margin(main.width) - signal closed() - Component.onCompleted: { - settingsList.currentIndex = 0 - settingsLoader.source = settingsListModel.get(0).path + '/' + - settingsListModel.get(0).view + '.qml' - titleItem.title = settingsListModel.get(0).title - } - - SettingsHeader { - id: settingsHeader - onClicked: main.closed() - } - - ListModel { - id: settingsListModel - - ListElement { - title: "Network" - view: "NetworkSettings" - path: "Network" - icon: "icons/network.svg" - } - } - - ListView { - id: settingsList - objectName: "settingsList" - anchors.top: settingsHeader.bottom - anchors.left: main.left - anchors.bottom: main.bottom - width: main.width / 3.33 - model: settingsListModel - - delegate: SettingsDelegate {} - } - - SettingsTitleItem { - id: titleItem - anchors.left: settingsList.right - anchors.right: main.right - anchors.top: settingsHeader.bottom - anchors.leftMargin: margin * 2 - } - - Loader { - id: settingsLoader - width: main.width - height: main.height - anchors.top: titleItem.bottom - anchors.left: settingsList.right - anchors.right: main.right - anchors.bottom: main.bottom - anchors.leftMargin: margin * 2 - anchors.rightMargin: margin * 2 + NetworkSettings { + anchors.margins: margin } } -- cgit v1.2.3