From 2b52005041912e411dd8f1e1d1e0593bd393b518 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 17 Sep 2014 14:19:45 +0200 Subject: launchersettings: various improvements - make it scale better on screen with different screen sizes and pixel density. For example the current implementation looked bad on Nexus 2013. Lets use "scaled cm" based on visual angle. Tested on 46 inch TV, nexus, nexus 2013, Rpi with samsung desktop monitor, demo looks as expected. - Demo now works as expeced when deployed as stand alone application from QtCreator. Before this change layout was completely broken, because Screen qml element really does not work as expected. - Make handle of Slider more touch-friendly. - Simplify creation of wifi GroupBox. The Loader element was needed at the beginning when we build QtWifi only on Android. - Move custom styles into separate qml files and other cleanups. Task-number: QTEE-769 Change-Id: Ifef1caa7edbfaea14c608f6b8fae43e86b0a2442 Reviewed-by: Eirik Aavitsland --- basicsuite/launchersettings/NetworkList.qml | 190 ---------------- .../launchersettings/SettingsButtonStyle.qml | 68 ++++++ .../launchersettings/SettingsCheckBoxStyle.qml | 61 ++++++ .../launchersettings/SettingsGroupBoxStyle.qml | 81 +++++++ .../launchersettings/SettingsRadioButtonStyle.qml | 66 ++++++ basicsuite/launchersettings/WifiController.qml | 58 ----- basicsuite/launchersettings/WifiGroupBox.qml | 11 +- basicsuite/launchersettings/WifiNetworkList.qml | 200 +++++++++++++++++ basicsuite/launchersettings/main.qml | 240 +++++++-------------- 9 files changed, 555 insertions(+), 420 deletions(-) delete mode 100644 basicsuite/launchersettings/NetworkList.qml create mode 100644 basicsuite/launchersettings/SettingsButtonStyle.qml create mode 100644 basicsuite/launchersettings/SettingsCheckBoxStyle.qml create mode 100644 basicsuite/launchersettings/SettingsGroupBoxStyle.qml create mode 100644 basicsuite/launchersettings/SettingsRadioButtonStyle.qml delete mode 100644 basicsuite/launchersettings/WifiController.qml create mode 100644 basicsuite/launchersettings/WifiNetworkList.qml (limited to 'basicsuite/launchersettings') diff --git a/basicsuite/launchersettings/NetworkList.qml b/basicsuite/launchersettings/NetworkList.qml deleted file mode 100644 index beab37e..0000000 --- a/basicsuite/launchersettings/NetworkList.qml +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of the examples of the Qt Enterprise Embedded. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Controls 1.2 -import Qt.labs.wifi 0.1 - -Item { - Component { - id: listDelegate - Rectangle { - id: delegateBackground - property bool expanded: false - property bool connected: wifiManager.connectedSSID == network.ssid - property bool actingNetwork: networkView.currentNetworkSsid == network.ssid - height: (expanded ? (connected ? 180: 260) : 70) - width: parent.width - clip: true // ### fixme - color: "#5C5C5C" - border.color: "black" - border.width: 1 - - onExpandedChanged: { - if (expanded) { - if (networkView.hasExpandedDelegate) - networkView.expandedDelegate.expanded = false - networkView.expandedDelegate = this - } else { - networkView.expandedDelegate = 0 - } - } - - Component.onDestruction: if (expanded) networkView.expandedDelegate = 0 - onHeightChanged: if (expanded) networkView.positionViewAtIndex(index, ListView.Contain) - - Behavior on height { NumberAnimation { duration: 500; easing.type: Easing.InOutCubic } } - - Text { - id: ssidLabel - anchors.top: parent.top - anchors.left: parent.left - anchors.margins: 10 - font.pixelSize: 20 - font.bold: true - color: "#E6E6E6" - text: network.ssid + (actingNetwork ? networkView.networkStateText : ""); - } - - Text { - id: bssidLabel - anchors.top: ssidLabel.bottom - anchors.left: parent.left - anchors.margins: 5 - anchors.leftMargin: 40 - text: network.bssid - color: "#E6E6E6" - font.pixelSize: ssidLabel.font.pixelSize * 0.5 - } - - Text { - id: flagsLabel - x: 200 - anchors.top: bssidLabel.top - text: (network.supportsWPA2 ? "WPA2 " : "") - + (network.supportsWPA ? "WPA " : "") - + (network.supportsWEP ? "WEP " : "") - + (network.supportsWPS ? "WPS " : ""); - color: "#E6E6E6" - font.pixelSize: ssidLabel.font.pixelSize * 0.5 - font.italic: true - } - - Rectangle { - id: signalStrengthBar - height: 20 - radius: 10 - antialiasing: true - anchors.margins: 20 - anchors.right: parent.right - anchors.top: parent.top - color: "#BF8888" - border.color: "#212126" - - property int strengthBarWidth: Math.max(100 + network.signalStrength, 0) / 100 * parent.width - onStrengthBarWidthChanged: { - if (strengthBarWidth > parent.width * 0.7) - signalStrengthBar.width = parent.width * 0.7 - else - signalStrengthBar.width = strengthBarWidth - } - - } - - MouseArea { - anchors.fill: parent - onClicked: parent.expanded = !expanded - } - - TextField { - id: passwordInput - y: 100 - height: 50 - width: 300 - placeholderText: "Enter Password" - visible: !connected - anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 18 - inputMethodHints: Qt.ImhNoPredictiveText - } - - Button { - style: root.buttonStyle - y: passwordInput.visible ? passwordInput.y + passwordInput.height + 20 : passwordInput.y - anchors.horizontalCenter: parent.horizontalCenter - text: connected ? "Disconnect" : "Connect" - onClicked: connected ? wifiManager.disconnect() - : wifiManager.connect(network, passwordInput.text); - } - } - } - - ListView { - id: networkView - anchors.fill: parent - model: wifiManager.networks - delegate: listDelegate - - property string networkStateText: "" - property string currentNetworkSsid: "" - property variant expandedDelegate: 0 - property bool hasExpandedDelegate: expandedDelegate != 0 - - Connections { - target: wifiManager - onNetworkStateChanged: { - networkView.currentNetworkSsid = network.ssid - var networkStateText = "" - var state = wifiManager.networkState - if (state == WifiManager.ObtainingIPAddress) - networkStateText = " (obtaining ip..)" - else if (state == WifiManager.DhcpRequestFailed) - networkStateText = " (dhcp request failed)" - else if (state == WifiManager.Connected) - networkStateText = " (connected)" - else if (state == WifiManager.Authenticating) - networkStateText = " (authenticating..)" - else if (state == WifiManager.HandshakeFailed) - networkStateText = " (wrong password)" - networkView.networkStateText = networkStateText - } - } - } -} diff --git a/basicsuite/launchersettings/SettingsButtonStyle.qml b/basicsuite/launchersettings/SettingsButtonStyle.qml new file mode 100644 index 0000000..9d0b4b0 --- /dev/null +++ b/basicsuite/launchersettings/SettingsButtonStyle.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +ButtonStyle { + panel: Item { + implicitHeight: engine.smallFontSize() * 2.4 + implicitWidth: engine.centimeter() * 5 + + BorderImage { + anchors.fill: parent + antialiasing: true + border.bottom: 8 + border.top: 8 + border.left: 8 + border.right: 8 + anchors.margins: control.pressed ? -4 : 0 + source: control.pressed ? "images/button_pressed.png" : "images/button_default.png" + Text { + text: control.text + anchors.centerIn: parent + color: "white" + font.pixelSize: engine.smallFontSize() + renderType: Text.NativeRendering + } + } + } +} diff --git a/basicsuite/launchersettings/SettingsCheckBoxStyle.qml b/basicsuite/launchersettings/SettingsCheckBoxStyle.qml new file mode 100644 index 0000000..2f615b7 --- /dev/null +++ b/basicsuite/launchersettings/SettingsCheckBoxStyle.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +CheckBoxStyle { + indicator: Rectangle { + implicitWidth: engine.mm(7) + implicitHeight: engine.mm(7) + radius: 10 + border.color: "black" + border.width: 2 + Rectangle { + visible: control.checked + color: "#45b7e2" + border.color: "darkblue" + radius: 10 + anchors.margins: engine.mm(1) + anchors.fill: parent + } + } +} diff --git a/basicsuite/launchersettings/SettingsGroupBoxStyle.qml b/basicsuite/launchersettings/SettingsGroupBoxStyle.qml new file mode 100644 index 0000000..4758d2c --- /dev/null +++ b/basicsuite/launchersettings/SettingsGroupBoxStyle.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import QtQuick.Controls.Private 1.0 + +// GroupBoxStyle currently is not available as a public API, +// so we write our own by importing private Styles API. +Style { + // The margin from the content item to the groupbox + padding { + top: (control.title.length > 0 ? TextSingleton.implicitHeight : 0) + 30 + left: 8 + right: 8 + bottom: 8 + } + // The groupbox frame + property Component panel: Item { + anchors.fill: parent + + Text { + id: label + anchors.bottom: borderImage.top + anchors.margins: 2 + text: control.title + font.pixelSize: engine.smallFontSize() * 1.1 + color: "white" + renderType: Text.NativeRendering + } + + BorderImage { + id: borderImage + anchors.fill: parent + anchors.topMargin: padding.top - 7 + source: "images/groupbox.png" + border.left: 4 + border.right: 4 + border.top: 4 + border.bottom: 4 + } + } +} diff --git a/basicsuite/launchersettings/SettingsRadioButtonStyle.qml b/basicsuite/launchersettings/SettingsRadioButtonStyle.qml new file mode 100644 index 0000000..9959ea1 --- /dev/null +++ b/basicsuite/launchersettings/SettingsRadioButtonStyle.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +RadioButtonStyle { + indicator: Rectangle { + implicitWidth: engine.mm(7) + implicitHeight: engine.mm(7) + radius: 40 + border.color: "black" + border.width: 2 + Rectangle { + anchors.fill: parent + visible: control.checked + color: "#45b7e2" + border.color: "darkblue" + radius: 40 + anchors.margins: engine.mm(1) + } + } + label: Label { + text: control.text + font.pixelSize: engine.smallFontSize() * 0.8 + color: "white" + } +} diff --git a/basicsuite/launchersettings/WifiController.qml b/basicsuite/launchersettings/WifiController.qml deleted file mode 100644 index 3725478..0000000 --- a/basicsuite/launchersettings/WifiController.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of the examples of the Qt Enterprise Embedded. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import Qt.labs.wifi 0.1 as Wifi - -QtObject { - function createWifiGroupBox() - { - if (Wifi.Interface.wifiSupported()) { - var component = Qt.createComponent("WifiGroupBox.qml"); - var wifi = component.createObject(wifiOptions.contentItem); - if (wifi == null) { - wifiOptions.visible = false - print("Error creating WifiGroupBox"); - } - } else { - wifiOptions.visible = false - } - } -} diff --git a/basicsuite/launchersettings/WifiGroupBox.qml b/basicsuite/launchersettings/WifiGroupBox.qml index a37c741..124a705 100644 --- a/basicsuite/launchersettings/WifiGroupBox.qml +++ b/basicsuite/launchersettings/WifiGroupBox.qml @@ -38,10 +38,9 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.0 - import Qt.labs.wifi 0.1 ColumnLayout { @@ -61,7 +60,7 @@ ColumnLayout { Button { id: wifiOnOffButton Layout.fillWidth: true - style: root.buttonStyle + style: SettingsButtonStyle {} text: (wifiManager.backendReady) ? "Switch Off" : "Switch On" onClicked: { if (wifiManager.backendReady) { @@ -77,7 +76,7 @@ ColumnLayout { Button { id: listNetworksButton Layout.fillWidth: true - style: root.buttonStyle + style: SettingsButtonStyle {} visible: wifiManager.backendReady text: (networkList.visible) ? "Hide wifi networks" : "List available wifi networks" @@ -85,9 +84,9 @@ ColumnLayout { } } - NetworkList { + WifiNetworkList { id: networkList - implicitHeight: 400 + implicitHeight: engine.centimeter(7) Layout.fillWidth: true visible: false clip: true diff --git a/basicsuite/launchersettings/WifiNetworkList.qml b/basicsuite/launchersettings/WifiNetworkList.qml new file mode 100644 index 0000000..40f3874 --- /dev/null +++ b/basicsuite/launchersettings/WifiNetworkList.qml @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import Qt.labs.wifi 0.1 + +Item { + Component { + id: listDelegate + Rectangle { + property bool expanded: false + property bool connected: wifiManager.connectedSSID == network.ssid + property bool actingNetwork: networkView.currentNetworkSsid == network.ssid + property int notExpandedHeight: ssidLabel.height + bssidLabel.height + engine.mm(4) + property int expandedHeight: notExpandedHeight + passwordInput.height + connectionButton.height + engine.mm(7) + property int connectedExpandedHeight: notExpandedHeight + connectionButton.height + engine.mm(4) + height: (expanded ? (connected ? connectedExpandedHeight : expandedHeight) : notExpandedHeight) + width: parent.width + clip: true // ### fixme + color: "#5C5C5C" + border.color: "black" + border.width: 1 + + onExpandedChanged: { + if (expanded) { + if (networkView.hasExpandedDelegate) + networkView.expandedDelegate.expanded = false + networkView.expandedDelegate = this + } else { + networkView.expandedDelegate = 0 + } + } + + Component.onDestruction: if (expanded) networkView.expandedDelegate = 0 + onHeightChanged: if (expanded) networkView.positionViewAtIndex(index, ListView.Contain) + + Behavior on height { NumberAnimation { duration: 500; easing.type: Easing.InOutCubic } } + + Text { + id: ssidLabel + anchors.top: parent.top + anchors.left: parent.left + anchors.margins: engine.mm(1) + anchors.leftMargin: engine.mm(2) + font.pixelSize: engine.smallFontSize() + font.bold: true + color: "#E6E6E6" + text: network.ssid + (actingNetwork ? networkView.networkStateText : ""); + } + + Text { + id: bssidLabel + anchors.top: ssidLabel.bottom + anchors.left: parent.left + anchors.margins: engine.mm(1) + anchors.leftMargin: engine.mm(6) + text: network.bssid + color: "#E6E6E6" + font.pixelSize: ssidLabel.font.pixelSize * 0.8 + } + + Text { + id: flagsLabel + anchors.top: bssidLabel.top + anchors.left: bssidLabel.right + anchors.leftMargin: engine.mm(7) + text: (network.supportsWPA2 ? "WPA2 " : "") + + (network.supportsWPA ? "WPA " : "") + + (network.supportsWEP ? "WEP " : "") + + (network.supportsWPS ? "WPS " : ""); + color: "#E6E6E6" + font.pixelSize: ssidLabel.font.pixelSize * 0.8 + font.italic: true + } + + Rectangle { + id: signalStrengthBar + height: engine.mm(3) + radius: 20 + antialiasing: true + anchors.margins: engine.mm(2) + anchors.right: parent.right + anchors.top: parent.top + color: "#BF8888" + border.color: "#212126" + // ### TODO - Qt Wifi library should provide alternative methods + // of describing signal strength besides dBm. + property int strengthBarWidth: Math.max(100 + network.signalStrength, 0) / 100 * parent.width + onStrengthBarWidthChanged: { + if (strengthBarWidth > parent.width * 0.55) + signalStrengthBar.width = parent.width * 0.55 + else + signalStrengthBar.width = strengthBarWidth + } + + } + + MouseArea { + anchors.fill: parent + onClicked: parent.expanded = !expanded + } + + TextField { + id: passwordInput + anchors.top: flagsLabel.bottom + anchors.topMargin: engine.mm(3) + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width * 0.36 + height: font.pixelSize * 2.4 + placeholderText: "Enter Password" + visible: !connected + font.pixelSize: engine.smallFontSize() * 0.8 + echoMode: TextInput.Password + inputMethodHints: Qt.ImhNoPredictiveText + } + + Button { + id: connectionButton + style: SettingsButtonStyle {} + y: connected ? passwordInput.y + : passwordInput.y + passwordInput.height + engine.mm(2) + width: passwordInput.width + anchors.horizontalCenter: parent.horizontalCenter + text: connected ? "Disconnect" : "Connect" + onClicked: connected ? wifiManager.disconnect() + : wifiManager.connect(network, passwordInput.text); + } + } + } + + ListView { + id: networkView + anchors.fill: parent + model: wifiManager.networks + delegate: listDelegate + + property string networkStateText: "" + property string currentNetworkSsid: "" + property variant expandedDelegate: 0 + property bool hasExpandedDelegate: expandedDelegate != 0 + + Connections { + target: wifiManager + onNetworkStateChanged: { + networkView.currentNetworkSsid = network.ssid + var networkStateText = "" + var state = wifiManager.networkState + if (state == WifiManager.ObtainingIPAddress) + networkStateText = " (obtaining ip..)" + else if (state == WifiManager.DhcpRequestFailed) + networkStateText = " (dhcp request failed)" + else if (state == WifiManager.Connected) + networkStateText = " (connected)" + else if (state == WifiManager.Authenticating) + networkStateText = " (authenticating..)" + else if (state == WifiManager.HandshakeFailed) + networkStateText = " (wrong password)" + networkView.networkStateText = networkStateText + } + } + } +} diff --git a/basicsuite/launchersettings/main.qml b/basicsuite/launchersettings/main.qml index 9d8eca5..b1b1d3d 100644 --- a/basicsuite/launchersettings/main.qml +++ b/basicsuite/launchersettings/main.qml @@ -38,211 +38,94 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.0 - +import QtQuick 2.2 import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.0 +import QtQuick.Layouts 1.1 import QtQuick.Controls.Styles 1.2 -import QtQuick.Controls.Private 1.0 -import QtQuick.Window 2.1 import QtQuick.Enterprise.VirtualKeyboard.Settings 1.2 +import Qt.labs.wifi 0.1 as Wifi Rectangle { - id: root - width: 1280 - height: 800 + anchors.fill: parent color: "#212126" - property alias buttonStyle: buttonStyle - - // ******************************* STYLES ********************************** - Component { - id: buttonStyle - ButtonStyle { - panel: Item { - implicitHeight: 50 - implicitWidth: 320 - BorderImage { - anchors.fill: parent - antialiasing: true - border.bottom: 8 - border.top: 8 - border.left: 8 - border.right: 8 - anchors.margins: control.pressed ? -4 : 0 - source: control.pressed ? "images/button_pressed.png" : "images/button_default.png" - Text { - text: control.text - anchors.centerIn: parent - color: "white" - font.pixelSize: 22 - renderType: Text.NativeRendering - } - } - } - } - } - - // GroupBoxStyle currently is not available as a public API, so we write our own... - Component { - id: groupBoxStyle - Style { - // The margin from the content item to the groupbox - padding { - top: (control.title.length > 0 ? TextSingleton.implicitHeight : 0) + 30 - left: 8 - right: 8 - bottom: 8 - } - // The groupbox frame - property Component panel: Item { - anchors.fill: parent - - Text { - id: label - anchors.bottom: borderImage.top - anchors.margins: 2 - text: control.title - font.pixelSize: 22 - color: "white" - renderType: Text.NativeRendering - } - - BorderImage { - id: borderImage - anchors.fill: parent - anchors.topMargin: padding.top - 7 - source: "images/groupbox.png" - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 - } - } - } - } - - Component { - id: checkboxStyle - CheckBoxStyle { - indicator: Rectangle { - implicitWidth: 36 - implicitHeight: 36 - radius: 10 - border.color: "black" - border.width: 2 - Rectangle { - visible: control.checked - color: "#45b7e2" - border.color: "darkblue" - radius: 10 - anchors.margins: 4 - anchors.fill: parent - } - } - } - } - - Component { - id: radioButtonStyle - RadioButtonStyle { - indicator: Rectangle { - implicitWidth: 36 - implicitHeight: 36 - radius: 20 - border.color: "black" - border.width: 2 - Rectangle { - anchors.fill: parent - visible: control.checked - color: "#45b7e2" - border.color: "darkblue" - radius: 20 - anchors.margins: 4 - } - } - label: Label { - text: control.text - font.pixelSize: 18 - color: "white" - } - } - } - // ******************************** UI **************************************** Loader { id: rebootActionLoader; source: "RebootAction.qml" } Loader { id: poweroffActionLoader; source: "PoweroffAction.qml" } Loader { id: brightnessControllerLoader; source: "BrightnessController.qml" } Loader { id: networkControllerLoader; source: "NetworkController.qml" } - Loader { id: wifiControllerLoader; source: "WifiController.qml" } Flickable { anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter - anchors.margins: 10 - anchors.topMargin: 50 + anchors.topMargin: engine.mm(5) height: parent.height width: parent.width - contentHeight: mainLayout.height + 100 + contentHeight: mainLayout.height + engine.centimeter(2) contentWidth: mainLayout.width flickableDirection: Flickable.VerticalFlick - leftMargin: (width - contentWidth) / 2 + leftMargin: (width - contentWidth) * 0.5 ColumnLayout { id: mainLayout - // can not use size of "root" here, it will shrink UI when virtual keyboard is open - width: Math.min(Screen.width, Screen.height) + width: Math.min(engine.screenWidth(), engine.screenHeight()) height: implicitHeight anchors.left: parent.left anchors.right: parent.right + spacing: engine.mm(4) GroupBox { id: powerOptions title: "Power" Layout.fillWidth: true - style: groupBoxStyle + style: SettingsGroupBoxStyle {} implicitWidth: 0 + height: implicitHeight RowLayout { - id: powerButtonRow - anchors.fill: parent Button { - style: buttonStyle + style: SettingsButtonStyle {} text: "Shut Down" Layout.fillWidth: true action: poweroffActionLoader.item; enabled: action != undefined - } Button { - style: buttonStyle + style: SettingsButtonStyle {} text: "Reboot" Layout.fillWidth: true action: rebootActionLoader.item; enabled: action != undefined } } - } GroupBox { id: displayOptions title: "Display" - style: groupBoxStyle + style: SettingsGroupBoxStyle {} Layout.fillWidth: true implicitWidth: 0 + height: implicitHeight GridLayout { - id: displayGrid - rows: 2 flow: GridLayout.TopToBottom anchors.fill: parent - Label { text: "Brightness: "; font.pixelSize: 18; color: "white" } - Label { text: "Display FPS: "; font.pixelSize: 18; color: "white" } + Label { + text: "Brightness: " + font.pixelSize: engine.smallFontSize() * 0.8 + color: "white" + } + + Label { + text: "Display FPS: " + font.pixelSize: engine.smallFontSize() * 0.8 + color: "white" + } Slider { maximumValue: 255 @@ -254,9 +137,20 @@ Rectangle { brightnessControllerLoader.item.setBrightness(value); } } + style: SliderStyle { + handle: Rectangle { + anchors.centerIn: parent + color: "white" + border.color: "gray" + border.width: 2 + width: engine.mm(6) + height: engine.mm(6) + radius: 20 + } + } } CheckBox { - style: checkboxStyle + style: SettingsCheckBoxStyle {} checked: engine.fpsEnabled onCheckedChanged: engine.fpsEnabled = checked } @@ -266,27 +160,26 @@ Rectangle { GroupBox { id: vkbOptions title: "Virtual Keyboard Style" - style: groupBoxStyle + style: SettingsGroupBoxStyle {} Layout.fillWidth: true - implicitWidth: 0 function updateVKBStyle(styleRadioButton) { VirtualKeyboardSettings.styleName = styleRadioButton.text.toLowerCase() } Row { - spacing: 30 + spacing: engine.mm(6) ExclusiveGroup { id: vkbStyleGroup } RadioButton { id: defaultStyle - style: radioButtonStyle + style: SettingsRadioButtonStyle {} text: "Default" exclusiveGroup: vkbStyleGroup onClicked: vkbOptions.updateVKBStyle(defaultStyle) } RadioButton { id: retroStyle - style: radioButtonStyle + style: SettingsRadioButtonStyle {} text: "Retro" exclusiveGroup: vkbStyleGroup onClicked: vkbOptions.updateVKBStyle(retroStyle) @@ -304,41 +197,48 @@ Rectangle { GroupBox { id: networkOptions title: "Network" - style: groupBoxStyle + style: SettingsGroupBoxStyle {} Layout.fillWidth: true implicitWidth: 0 + height: implicitHeight GridLayout { - id: networkGrid - rows: 2 columns: 3 flow: GridLayout.TopToBottom anchors.fill: parent - Label { text: "Hostname: "; font.pixelSize: 18; color: "white" } - Label { text: "IP address: "; font.pixelSize: 18; color: "white"} + Label { + text: "Hostname: " + font.pixelSize: engine.smallFontSize() * 0.8 + color: "white" + } + + Label { + text: "IP address: " + font.pixelSize: engine.smallFontSize() * 0.8 + color: "white" + } TextField { id: hostname - implicitHeight: hostnameButton.height - 8 text: if (networkControllerLoader.item != undefined) { networkControllerLoader.item.getHostname(); } - font.pixelSize: 18 + font.pixelSize: engine.smallFontSize() Layout.fillWidth: true + Layout.preferredHeight: font.pixelSize * 2.4 } Label { text: if (networkControllerLoader.item != undefined) { networkControllerLoader.item.getIPAddress(); } - font.pixelSize: 18 + font.pixelSize: engine.smallFontSize() color: "white" Layout.columnSpan: 2 } Button { id: hostnameButton - style: buttonStyle + style: SettingsButtonStyle {} text: "Change hostname" - implicitWidth: 260 onClicked: networkControllerLoader.item.setHostname(hostname.text); enabled: networkControllerLoader.item != undefined } @@ -349,15 +249,23 @@ Rectangle { GroupBox { id: wifiOptions title: "Wifi" - style: groupBoxStyle + style: SettingsGroupBoxStyle {} Layout.fillWidth: true - } + visible: false + + function createWifiGroupBox() + { + if (Wifi.Interface.wifiSupported()) { + var component = Qt.createComponent("WifiGroupBox.qml") + var wifi = component.createObject(wifiOptions.contentItem) + if (wifi) + wifiOptions.visible = true + else + print("Error creating WifiGroupBox") + } + } - Component.onCompleted: { - if (wifiControllerLoader.item != undefined) - wifiControllerLoader.item.createWifiGroupBox() - else - wifiOptions.visible = false + Component.onCompleted: wifiOptions.createWifiGroupBox() } } } -- cgit v1.2.3