diff options
52 files changed, 1424 insertions, 321 deletions
diff --git a/.lfsconfig b/.lfsconfig new file mode 100644 index 0000000..5cacf3c --- /dev/null +++ b/.lfsconfig @@ -0,0 +1,3 @@ +[lfs] +url = https://codereview.qt-project.org/qt-apps/boot2qt-demos/info/lfs +pushurl = ssh://codereview.qt-project.org:29418/qt-apps/boot2qt-demos diff --git a/basicsuite/ebike-ui/app.pro b/basicsuite/ebike-ui/app.pro index 28d73fa..c3c0b41 100644 --- a/basicsuite/ebike-ui/app.pro +++ b/basicsuite/ebike-ui/app.pro @@ -9,7 +9,7 @@ TARGET = ebike DEFINES += QT_DEPRECATED_WARNINGS # Uncomment to build ebike demo as separate which does not rely on shared functionality of B2qt launcher -DEFINES += STANDALONE +#DEFINES += STANDALONE # Uncomment to use only app provided fonts and not common shared fonts # When providing own fonts use fonts.files and fonts.qrc file to provide those diff --git a/metadata/calqlatr/demo.xml b/metadata/calqlatr/demo.xml new file mode 100644 index 0000000..f118127 --- /dev/null +++ b/metadata/calqlatr/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Calqlatr" priority="2" scalable="1" icon="preview.png" binary="/usr/share/examples/demos/calqlatr/calqlatrexample"> + <description> + A Qt Quick app designed for landscape and portrait devices that uses custom components, responsive layouts, and JavaScript for the application logic. + </description> +</application> diff --git a/metadata/calqlatr/preview.png b/metadata/calqlatr/preview.png Binary files differnew file mode 100644 index 0000000..9490814 --- /dev/null +++ b/metadata/calqlatr/preview.png diff --git a/metadata/coffee/demo.xml b/metadata/coffee/demo.xml new file mode 100644 index 0000000..9adf313 --- /dev/null +++ b/metadata/coffee/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Coffee Machine" priority="5" scalable="1" icon="preview.png" binary="/usr/share/examples/demos/coffee/coffeemachine"> + <description> + A Qt Quick application with a state-based custom user interface. + </description> +</application> diff --git a/metadata/coffee/preview.png b/metadata/coffee/preview.png Binary files differnew file mode 100644 index 0000000..7435373 --- /dev/null +++ b/metadata/coffee/preview.png diff --git a/metadata/robotarm/demo.xml b/metadata/robotarm/demo.xml new file mode 100644 index 0000000..5cf84cb --- /dev/null +++ b/metadata/robotarm/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Robot Arm" priority="7" scalable="1" icon="preview.png" binary="/usr/share/examples/demos/robotarm/RobotArmApp"> + <description> + This example demonstrates adding a C++ backend to a 3D project created in Qt Design Studio. The example itself consists of an interactive industrial robot arm in a Qt Quick 3D scene. The 2D UI to control the robot arm is implement using Qt Quick Controls. + </description> +</application> diff --git a/metadata/robotarm/preview.png b/metadata/robotarm/preview.png Binary files differnew file mode 100644 index 0000000..17efae1 --- /dev/null +++ b/metadata/robotarm/preview.png diff --git a/metadata/samegame/demo.xml b/metadata/samegame/demo.xml new file mode 100644 index 0000000..0187c1f --- /dev/null +++ b/metadata/samegame/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Same Game" priority="5" scalable="0" icon="preview.png" binary="/usr/share/examples/demos/samegame/samegame"> + <description> + Same Game demonstrates a QML game with custom types and logic written in JavaScript. The game uses various Qt Quick features such as particles, animation, and loading images. + </description> +</application> diff --git a/metadata/samegame/preview.png b/metadata/samegame/preview.png Binary files differnew file mode 100644 index 0000000..2ddf43e --- /dev/null +++ b/metadata/samegame/preview.png diff --git a/metadata/startupscreen/demo.xml b/metadata/startupscreen/demo.xml new file mode 100644 index 0000000..9eca669 --- /dev/null +++ b/metadata/startupscreen/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Get started with Boot to Qt" priority="10" scalable="1" icon="preview.png" binary="/usr/bin/startupscreen" arguments="-platform wayland-egl"> + <description> + Provides USB and Wi-Fi settings and instructions how to deploy applications from the Qt Creator. + </description> +</application> diff --git a/metadata/startupscreen/preview.png b/metadata/startupscreen/preview.png Binary files differnew file mode 100644 index 0000000..f24be2f --- /dev/null +++ b/metadata/startupscreen/preview.png diff --git a/metadata/stocqt/demo.xml b/metadata/stocqt/demo.xml new file mode 100644 index 0000000..00a7898 --- /dev/null +++ b/metadata/stocqt/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Qt Quick Demo - StocQt" priority="7" scalable="1" icon="preview.png" binary="/usr/share/examples/demos/stocqt/appStocQt"> + <description> + The StocQt application presents a trend chart for the first stock in the list of NASDAQ-100 stocks. It allows the user to choose another stock from the list, and fetches the required data from the offline dataset using XMLHttpRequest. + </description> +</application> diff --git a/metadata/stocqt/preview.png b/metadata/stocqt/preview.png Binary files differnew file mode 100644 index 0000000..6caf3d2 --- /dev/null +++ b/metadata/stocqt/preview.png diff --git a/metadata/thermostat/demo.xml b/metadata/thermostat/demo.xml new file mode 100644 index 0000000..37a2cc1 --- /dev/null +++ b/metadata/thermostat/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Thermostat" priority="8" scalable="1" icon="preview.png" binary="/usr/share/examples/demos/thermostat/ThermostatApp"> + <description> + A user interface for a home thermostat, implemented in Qt Quick. It demonstrates how to create responsive applications that scale from large desktop displays to mobile and small embedded displays. + </description> +</application> diff --git a/metadata/thermostat/preview.png b/metadata/thermostat/preview.png Binary files differnew file mode 100644 index 0000000..20ecf62 --- /dev/null +++ b/metadata/thermostat/preview.png diff --git a/metadata/todolist/demo.xml b/metadata/todolist/demo.xml new file mode 100644 index 0000000..6df08a9 --- /dev/null +++ b/metadata/todolist/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="To Do List" priority="5" scalable="1" icon="preview.png" binary="/usr/share/examples/demos/todolist/ToDoListApp"> + <description> + A QML implementation of to do list application that demonstrates how to create application thats looks native on any platform. + </description> +</application> diff --git a/metadata/todolist/preview.png b/metadata/todolist/preview.png Binary files differnew file mode 100644 index 0000000..ffe90c2 --- /dev/null +++ b/metadata/todolist/preview.png diff --git a/startupscreen/CMakeLists.txt b/startupscreen/CMakeLists.txt index 87b0238..23e008d 100644 --- a/startupscreen/CMakeLists.txt +++ b/startupscreen/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(startupscreen LANGUAGES CXX) @@ -11,15 +11,40 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +# From build settings -> cmake -> variables -> set "QSR_BUILD = ON" to enable QSR Screen +option(QSR_BUILD "Build with QSR" OFF) + +if(QSR_BUILD) + add_definitions(-DQSR) +endif() + find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick QuickControls2 REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick QuickControls2 REQUIRED) add_executable(startupscreen main.cpp settingsmanager.cpp + qtbuttonimageprovider.cpp qml.qrc ) +if(QSR_BUILD) + set_source_files_properties("QSR_MainView.qml" + PROPERTIES QT_RESOURCE_ALIAS "MainView.qml" + ) + # Use QSR_MainView in QSR builds + set(QML_FILES "QSR_MainView.qml") +else() + # For non-QSR builds, use the original MainView.qml + set(QML_FILES "MainView.qml") +endif() + +# Add resources to the project +qt_add_resources(startupscreen "mainview" + PREFIX "/" + FILES ${QML_FILES} +) + target_compile_definitions(startupscreen PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) target_link_libraries(startupscreen diff --git a/startupscreen/GuideView.qml b/startupscreen/GuideView.qml index fb6dd2e..f4c952e 100644 --- a/startupscreen/GuideView.qml +++ b/startupscreen/GuideView.qml @@ -53,7 +53,7 @@ import QtQuick.Layouts import QtQuick.Controls import StartupScreen -Item { +Item { id: root width: parent.width height: parent.height @@ -85,6 +85,7 @@ Item { opacity: 0.5 MouseArea { anchors.fill: parent + anchors.margins: -width onPressed: backButton.scale = 0.4 onReleased: backButton.scale = 0.5 onClicked: root.visible = false diff --git a/startupscreen/MainView.qml b/startupscreen/MainView.qml index c5a18e8..693682b 100644 --- a/startupscreen/MainView.qml +++ b/startupscreen/MainView.qml @@ -54,99 +54,53 @@ import StartupScreen Item { id: root - property var textNormal: panel.height / 9 - property var textLarge: panel.height / 7 - - Image { - id: backgroundImage - source: "assets/background.png" - anchors.fill: parent - } + property int textNormal: panel.height / 9 + property int textLarge: panel.height / 7 Item { id: panel anchors.top: root.top anchors.topMargin: height / 10 - anchors.left: root.left + anchors.leftMargin: panel.width *.1 height: width / 2 width: root.width * 0.6 - Item { - id: headerBackground - - height: parent.height / 3 + Text { + id: headerText_1 + color: "#2cde85" + text: qsTr("Get Started with Boot to Qt ") + Qt.application.version anchors.top: panel.top anchors.left: panel.left - anchors.right: panel.right - - Image { - id: headerBackgroundRight - source: "assets/headerBackgroundRight.png" - width: height - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: parent.bottom - } - Image { - id: headerBackgroundLeft - source: "assets/headerBackgroundLeft.png" - anchors.left: parent.left - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.right: headerBackgroundRight.left - } - Text { - id: headerText_1 - color: "#ffffff" - text: qsTr("Get started with") - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - font.pixelSize: textNormal - font.family: "Titillium Web" - } - Text { - id: headerText_2 - color: "#ffffff" - text: qsTr("Boot to Qt ") - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - font.bold: true - font.pixelSize: textLarge - font.family: "Titillium Web" - } + font.pixelSize: textNormal + font.family: "Titillium Web" } - // body of the text panel - Rectangle { - id: bodyBackground - color: "#000000" - anchors.right: panel.right + Text { + id: bodyText + color: "#ffffff" + text: qsTr("How to install demo application\nfrom Qt Creator?") + font.pixelSize: textNormal + font.family: "Titillium Web" anchors.left: panel.left - anchors.top: headerBackground.bottom - anchors.bottom: panel.bottom - - Text { - id: bodyText - color: "#ffffff" - text: qsTr("How to install demo\napplication from Qt Creator?") - font.pixelSize: textNormal - font.family: "Titillium Web" - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - horizontalAlignment: Text.AlignHCenter - lineHeight: 0.8 - wrapMode: Text.WordWrap - } + anchors.top: headerText_1.bottom + anchors.topMargin: textNormal + wrapMode: Text.WordWrap + } - TextButton { - id: textButton - width: parent.width * 0.9 - height: parent.height / 3 - fontSize: textNormal - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - anchors.bottomMargin: height / 4 + Text { + id: buttonLabel + color: "#2cde85" + text: qsTr("Click to learn more!") + anchors.left: panel.left + anchors.top: bodyText.bottom + anchors.topMargin: textLarge + font.pixelSize: textLarge + font.family: "Titillium Web" + + MouseArea { + anchors.fill: parent + anchors.margins: -height * .5 onPressed: guide.visible = true } } @@ -169,7 +123,6 @@ Item { anchors.topMargin: height * 0.1 } - // Button row Row { id: buttonRow @@ -193,7 +146,10 @@ Item { id: wifiButton height: parent.buttonSize width: height - visible: false + visible: true + onPressed: { + loader.source = "qrc:/NetworkSettings/NetworkSettingsPage.qml" + } } } @@ -227,6 +183,11 @@ Item { } } + Loader { + id: loader + anchors.fill: parent + } + UsbModeDialog { id: usbModeDialog } diff --git a/startupscreen/NetworkSettings/CustomSwitch.qml b/startupscreen/NetworkSettings/CustomSwitch.qml new file mode 100644 index 0000000..fa21d7f --- /dev/null +++ b/startupscreen/NetworkSettings/CustomSwitch.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt for Device Creation. +** +** $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 + +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: viewSettings.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: viewSettings.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 + } + + QtButton { + id: qtHandle + anchors.verticalCenter: parent.verticalCenter + width: parent.width * 0.475 + height: parent.height * 0.9 + fillColor: control.checked ? viewSettings.buttonGreenColor : viewSettings.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 + + onReleased: { + if (qtHandle.x > indicatorImg.width / 5 ) { + control.checked = true + } else { + control.checked = false + } + } + } + } + } +} diff --git a/startupscreen/NetworkSettings/NetworkDelegate.qml b/startupscreen/NetworkSettings/NetworkDelegate.qml new file mode 100644 index 0000000..1f352ed --- /dev/null +++ b/startupscreen/NetworkSettings/NetworkDelegate.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt for Device Creation. +** +** $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 2.0 +import QtDeviceUtilities.NetworkSettings + +Item { + id: networkDelegate + width: list.width + height: networkName.height * 3 + property alias nameLabelText: networkName.text + property alias ipLabelText: ipAddressLabel.text + property alias ipText: ipAddress.text + property bool isConnected: false + + signal clicked() + + 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: networkSettingsRoot.height * viewSettings.subTitleFontSize + font.family: viewSettings.appFont + color: isConnected ? viewSettings.buttonGreenColor : "white" + text: name + } + + Row { + id: ipRow + height: networkDelegate.height * 0.275 * opacity + spacing: networkDelegate.width * 0.0075 + Item { + width: viewSettings.margin(list.width) + height: 1 + } + + Text { + id: ipAddressLabel + height: parent.height + anchors.verticalCenter: parent.verticalCenter + text: qsTr("IP Address:") + color: isConnected ? viewSettings.buttonGreenColor : "white" + font.pixelSize: networkSettingsRoot.height * viewSettings.valueFontSize + font.family: viewSettings.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: isConnected ? viewSettings.buttonGreenColor : "white" + text: qsTr("Not connected") + font.pixelSize: networkSettingsRoot.height * viewSettings.valueFontSize + font.family: viewSettings.appFont + font.styleName: isConnected ? "SemiBold" : "Regular" + } + } + } + + QtButton { + id: connectButton + fontFamily: viewSettings.appFont + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + fillColor: isConnected ? viewSettings.buttonGrayColor : viewSettings.buttonGreenColor + borderColor: "transparent" + text: isConnected ? qsTr("DISCONNECT") : qsTr("CONNECT") + enabled: true + onClicked: networkDelegate.clicked() + } + + Rectangle { + id: delegateBottom + width: networkDelegate.width + color: viewSettings.borderColor + height: 2 + anchors.bottom: networkDelegate.bottom + anchors.horizontalCenter: networkDelegate.horizontalCenter + } + + Behavior on height { NumberAnimation { duration: 200} } +} diff --git a/startupscreen/NetworkSettings/NetworkListView.qml b/startupscreen/NetworkSettings/NetworkListView.qml new file mode 100644 index 0000000..5ac722e --- /dev/null +++ b/startupscreen/NetworkSettings/NetworkListView.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt for Device Creation. +** +** $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: root + + property var connectingService: null + property bool retryConnectAfterIdle: false + + Connections { + target: NetworkSettingsManager.userAgent + function onShowUserCredentialsInput() { + passphraseEnter.visible = true; + } + } + + function connectBySsid() { + passphraseEnter.showSsid = true + passphraseEnter.visible = true + } + + function connectingServiceStateChange() { + if (connectingService) { + 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; + } + } + } + + NetworkDelegate { + id: manualConnectionPane + anchors.top: parent.top + anchors.right: parent.right + visible: wifiSwitch.checked + nameLabelText: qsTr("Manual connection") + ipLabelText: qsTr("Add a new connection manually") + ipText: "" + isConnected: false + onClicked: connectBySsid() + } + + ListView { + id: list + clip: true + focus: true + boundsBehavior: Flickable.DragOverBounds + model: NetworkSettingsManager.services + + anchors.top: manualConnectionPane.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + visible: wifiSwitch.checked + + delegate: NetworkDelegate { + isConnected: connected + ipText: isConnected ? NetworkSettingsManager.services.itemFromRow(index).ipv4.address + : (NetworkSettingsManager.services.itemFromRow(index).state === NetworkSettingsState.Idle) ? + qsTr("Not connected") : qsTr("Connecting") + onClicked: { + if (isConnected) { + NetworkSettingsManager.services.itemFromRow(index).disconnectService(); + } else { + root.connectingService = NetworkSettingsManager.services.itemFromRow(index) + if (root.connectingService) { + passphraseEnter.extraInfo = ""; + root.connectingService.connectService(); + root.connectingService.stateChanged.connect(connectingServiceStateChange); + } + } + } + } + } +} diff --git a/startupscreen/NetworkSettings/NetworkSettings.qml b/startupscreen/NetworkSettings/NetworkSettings.qml new file mode 100644 index 0000000..240dc25 --- /dev/null +++ b/startupscreen/NetworkSettings/NetworkSettings.qml @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt for Device Creation. +** +** $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: networkSettingsRoot + anchors.fill: parent + + Component.onCompleted: NetworkSettingsManager.interfacesChanged() + + 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 + visible: wifiSwitch.visible + text: qsTr("WiFi") + font.pixelSize: networkSettingsRoot.height * viewSettings.subTitleFontSize + font.family: viewSettings.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 * viewSettings.buttonHeight + indicatorWidth: networkSettingsRoot.height * viewSettings.buttonWidth + indicatorHeight: networkSettingsRoot.height * viewSettings.buttonHeight + checkable: visible && !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 + } + } + + Text { + id: networkListTextItem + text: qsTr("Available networks:") + font.pixelSize: networkSettingsRoot.height * viewSettings.subTitleFontSize + font.family: viewSettings.appFont + font.styleName: "SemiBold" + visible: wifiSwitch.checked + color: "white" + anchors.top: (wifiSwitch.visible === true) ? wifiSwitch.bottom : networkSettingsRoot.top + anchors.topMargin: font.pixelSize + } + + NetworkListView { + id: networkList + anchors.top: networkListTextItem.bottom + anchors.left: networkListTextItem.left + width: networkSettingsRoot.width + anchors.bottom: networkSettingsRoot.bottom + } + + // Popup for entering passphrase + PassphraseEnter { + id: passphraseEnter + } +} + diff --git a/startupscreen/NetworkSettings/NetworkSettingsPage.qml b/startupscreen/NetworkSettings/NetworkSettingsPage.qml new file mode 100644 index 0000000..f920145 --- /dev/null +++ b/startupscreen/NetworkSettings/NetworkSettingsPage.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt for Device Creation. +** +** $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.VirtualKeyboard + +Image { + id: root + anchors.fill: parent + source: "../assets/background.png" + + property int margin: viewSettings.margin(root.width) + + signal closed() + + ViewSettings { + id: viewSettings + } + + NetworkSettings { + anchors.margins: margin + } + + Image { + id: backButton + source: "../assets/icon_nok.png" + anchors.top: parent.top + anchors.right: parent.right + scale: 0.5 + opacity: 0.5 + MouseArea { + anchors.fill: parent + anchors.margins: -width + onPressed: backButton.scale = 0.4 + onReleased: backButton.scale = 0.5 + onClicked: loader.source = "" + } + } + + /* Keyboard input panel. + The keyboard is anchored to the bottom of the application. + */ + InputPanel { + id: inputPanel + z: 99 + y: root.height + anchors.left: root.left + anchors.right: root.right + + states: State { + name: "visible" + when: Qt.inputMethod.visible + PropertyChanges { + target: inputPanel + y: root.height - inputPanel.height + } + } + transitions: Transition { + from: "" + to: "visible" + reversible: true + ParallelAnimation { + NumberAnimation { + properties: "y" + duration: 250 + easing.type: Easing.InOutQuad + } + } + } + } +} + diff --git a/startupscreen/NetworkSettings/PassphraseEnter.qml b/startupscreen/NetworkSettings/PassphraseEnter.qml new file mode 100644 index 0000000..2068412 --- /dev/null +++ b/startupscreen/NetworkSettings/PassphraseEnter.qml @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt for Device Creation. +** +** $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 + +Image { + id: passphrasePopup + anchors.fill: parent + source: "../assets/background.png" + visible: false + + property string extraInfo: "" + property bool showSsid: false + property int margin: (width / 3 * 2) * 0.05 + property int spacing: margin * 0.5 + + onVisibleChanged: { + backButton.visible = !visible + if (!visible) { + networkSettingsRoot.forceActiveFocus() + } else { + if (showSsid) { + ssidField.forceActiveFocus() + } else { + passField.forceActiveFocus() + } + } + } + + Rectangle { + id: frame + color: "transparent" + border.color: viewSettings.borderColor + border.width: 3 + anchors.horizontalCenter: parent.horizontalCenter + y: inputPanel.y * .5 - height * .5 - margin + width: passphraseColumn.width * 1.1 + height: passphraseColumn.height * 1.1 + + Column { + id: passphraseColumn + anchors.centerIn: parent + spacing: passphrasePopup.spacing + + Text { + visible: showSsid + font.pixelSize: passphrasePopup.height * viewSettings.subTitleFontSize + font.family: viewSettings.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 ? viewSettings.buttonGreenColor : viewSettings.buttonGrayColor + border.width: ssidField.focus ? width * 0.01 : 2 + } + } + + Text { + font.pixelSize: passphrasePopup.height * viewSettings.subTitleFontSize + font.family: viewSettings.appFont + color: "white" + text: qsTr("Enter Passphrase") + } + + Text { + font.pixelSize: passphrasePopup.height * viewSettings.valueFontSize + font.family: viewSettings.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 ? viewSettings.buttonGreenColor : viewSettings.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: viewSettings.buttonGrayColor + onClicked: { + if (!showSsid) { + NetworkSettingsManager.userAgent.cancelInput() + } + showSsid = false + passphrasePopup.visible = false; + } + } + } + } + } +} diff --git a/startupscreen/NetworkSettings/QtButton.qml b/startupscreen/NetworkSettings/QtButton.qml new file mode 100644 index 0000000..e9f222e --- /dev/null +++ b/startupscreen/NetworkSettings/QtButton.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt for Device Creation. +** +** $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 + +Image { + id: root + width: buttonText.contentWidth + cutSize * 4 + source: "image://QtButton/" + cutSize + "/" + fillColor + "/" + borderColor + sourceSize: Qt.size(width, height) + + property string state: "enabled" + property int cutSize: 10 + property color fillColor: viewSettings.buttonGreenColor + property color borderColor: viewSettings.buttonGreenColor + property alias text: buttonText.text + property alias fontFamily: buttonText.font.family + + signal clicked() + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: root.clicked() + } + + Text { + id: buttonText + anchors.fill: parent + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.pixelSize: parent.height * 0.65 + font.family: viewSettings.appFont + color: "white" + } +} diff --git a/startupscreen/NetworkSettings/ViewSettings.qml b/startupscreen/NetworkSettings/ViewSettings.qml new file mode 100644 index 0000000..99c5a82 --- /dev/null +++ b/startupscreen/NetworkSettings/ViewSettings.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt for Device Creation. +** +** $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 + +QtObject { + id: viewSettings + readonly property string appFont: "Titillium Web" + readonly property color backgroundColor: "#00414a" + readonly property color borderColor: "#9d9faa" + readonly property color buttonGreenColor: "#2cde85" + readonly property color buttonGrayColor: "#9d9faa" + readonly property color buttonActiveColor: "#216729" + readonly property color scrollBarColor: "#2cde85" + + readonly property real spacing: 0.5 + readonly property real titleFontSize: 0.04 + readonly property real subTitleFontSize: 0.035 + readonly property real valueFontSize: 0.025 + readonly property real fieldHeight: 0.07 + readonly property real fieldTextHeight: 0.05 + readonly property real buttonHeight: 0.05 + + function margin(width) { + return (width / 3 * 2) * 0.05; + } +} diff --git a/startupscreen/QSR_MainView.qml b/startupscreen/QSR_MainView.qml new file mode 100644 index 0000000..6cdf71f --- /dev/null +++ b/startupscreen/QSR_MainView.qml @@ -0,0 +1,249 @@ +/**************************************************************************** +** +** Copyright (C) 2024 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qt for Device Creation. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Controls +import StartupScreen +import backend 1.0 + +Item { + id: root + + property int textNormal: panel.height / 9 + property int textLarge: panel.height / 7 + + Item { + id: panel + anchors.top: root.top + anchors.topMargin: height / 10 + anchors.left: root.left + anchors.leftMargin: panel.width *.1 + height: width / 2 + width: root.width * 0.6 + + Text { + id: headerText_1 + color: "#2cde85" + text: qsTr("Get Started with Qt Safe Renderer ") + anchors.top: panel.top + anchors.left: panel.left + font.pixelSize: textNormal * 1.2 + font.family: "Titillium Web" + } + + Text { + id: bodyText + color: "#ffffff" + text: qsTr("How to install demo application\nfrom Qt Creator?") + font.pixelSize: textNormal + font.family: "Titillium Web" + anchors.left: panel.left + anchors.top: headerText_1.bottom + anchors.topMargin: textNormal + wrapMode: Text.WordWrap + } + + Text { + id: buttonLabel + color: "#2cde85" + text: qsTr("Click here to learn more!") + font.underline: true + anchors.left: panel.left + anchors.top: bodyText.bottom + anchors.topMargin: textLarge + font.pixelSize: textLarge + font.family: "Titillium Web" + + MouseArea { + anchors.fill: parent + anchors.margins: -height * .5 + onPressed: guide.visible = true + } + } + } + + Item { + id: demoButtonAlignment + anchors.right: root.right + anchors.left: panel.right + anchors.top: panel.top + anchors.bottom: panel.bottom + } + + Rectangle { + width: parent.width * 0.2 + height: parent.height * 0.2 + radius: height * 0.075 + anchors.horizontalCenter: demoButtonAlignment.horizontalCenter + anchors.verticalCenter: panel.verticalCenter + color: "#2cde85" + + MouseArea { + id: mouseArea + anchors.fill: parent + onPressed: parent.color = "#235866" + var target = "qsrdemo.target"; + onReleased: { + parent.color = "#2cde85" + SettingsManager.runDemoMode(target) + } + } + + Text { + text: "Start Demo" + font.pixelSize: height * 2 + font.family: "Titillium Web" + anchors.centerIn: parent + color: "white" + } + } + + + // Button row + Row { + id: buttonRow + anchors.top: panel.bottom + anchors.horizontalCenter: panel.BottomLeft + spacing: buttonSize / 4 + padding: buttonSize / 4 + property var buttonSize: panel.height / 2 + + UsbButton { + id: usbButton + height: parent.buttonSize + width: height + available: SettingsManager.hasQdb + connected: ipAddress.text.indexOf("usb0") !== -1 + onPressed: { + usbModeDialog.open() + } + } + WifiButton { + id: wifiButton + height: parent.buttonSize + width: height + visible: true + onPressed: { + loader.source = "qrc:/NetworkSettings/NetworkSettingsPage.qml" + } + } + } + + // label and IP address + Text { + id: ipLabel + color: "grey" + text: qsTr("Networks:") + anchors.bottom: ipAddress.top + anchors.horizontalCenter: ipAddress.horizontalCenter + font.pixelSize: textNormal + font.family: "Titillium Web" + visible: ipAddress.text !== "" + } + Text { + id: ipAddress + color: "grey" + text: SettingsManager.networks + anchors.bottom: root.bottom + anchors.right: root.right + anchors.rightMargin: 5 + font.pixelSize: textNormal + font.bold: true + font.family: "Titillium Web" + + Timer { + interval: 3000 + onTriggered: ipAddress.text = SettingsManager.networks + running: true + repeat: true + } + } + + Loader { + id: loader + anchors.fill: parent + } + + UsbModeDialog { + id: usbModeDialog + } + + GuideView { + id: guide + visible: false + } + + // base state = landscape + states: [ + State { + name: "portrait" + + PropertyChanges { + target: panel + width: root.width * 0.9 + } + AnchorChanges { + target: panel + anchors.top: clock.bottom + } + AnchorChanges { + target: clock + anchors.top: root.top + anchors.horizontalCenter: root.horizontalCenter + anchors.verticalCenter: undefined + } + AnchorChanges { + target: buttonRow + anchors.horizontalCenter: undefined + anchors.left: root.left + } + } + ] +} diff --git a/startupscreen/SplashView.ui.qml b/startupscreen/SplashView.ui.qml index 07b339b..831ef8c 100644 --- a/startupscreen/SplashView.ui.qml +++ b/startupscreen/SplashView.ui.qml @@ -51,17 +51,12 @@ import QtQuick import QtQuick.Controls -Rectangle { +Image { id: root + source: "assets/background.png" Image { - id: backgroundImage - source: "assets/background.png" - anchors.fill: root - } - - Image { - id: builtwithQtImage + id: logo source: "assets/builtwithQt.png" anchors.centerIn: root } diff --git a/startupscreen/StartupScreen.qml b/startupscreen/StartupScreen.qml index 36730bf..e749812 100644 --- a/startupscreen/StartupScreen.qml +++ b/startupscreen/StartupScreen.qml @@ -61,6 +61,12 @@ ApplicationWindow { width: 960 height: 540 + Image { + id: backgroundImage + source: "assets/background.png" + anchors.fill: parent + } + Timer { interval: 1000 running: true @@ -103,7 +109,6 @@ ApplicationWindow { duration: 2000 } } - } diff --git a/startupscreen/UsbButton.qml b/startupscreen/UsbButton.qml index 315f9c8..ce4a554 100644 --- a/startupscreen/UsbButton.qml +++ b/startupscreen/UsbButton.qml @@ -60,13 +60,6 @@ Item { state: !available ? "" : (connected ? "connected" : "error") - Rectangle { - id: buttonBackground - anchors.fill: parent - color: "#3a4055" - radius: 0 - } - // changing button state MouseArea { anchors.fill: parent diff --git a/startupscreen/WifiButton.qml b/startupscreen/WifiButton.qml index fd34a90..9ae76ac 100644 --- a/startupscreen/WifiButton.qml +++ b/startupscreen/WifiButton.qml @@ -50,77 +50,36 @@ import QtQuick import StartupScreen +import QtDeviceUtilities.NetworkSettings Item { id: root - + scale: mouseArea.pressed ? .9 : 1.0 signal pressed() - Rectangle { - id: buttonBackground - anchors.fill: parent - color: "#3a4055" - radius: 0 - } + Component.onCompleted: NetworkSettingsManager.services.type = NetworkSettingsType.Wifi; - // changing button state MouseArea { + id: mouseArea anchors.fill: parent - - onPressed: { - root.scale = 0.9 - } - onReleased: { - root.scale = 1.0 - root.pressed() - - if (root.state == "") - root.state = "working" - else if (root.state == "working") - root.state = "ok" - else - root.state = "" - } + onClicked: root.pressed() } // icons for signal strengths (from 0 to 3) + + property int signalStrength: NetworkSettingsManager.currentWifiConnection ? NetworkSettingsManager.currentWifiConnection.wirelessConfig.signalStrength / 25 : 0 + Image { - id: icon_signal_0 - height: parent.height * 0.9 - source: "assets/icon_wifi_0.png" - fillMode: Image.PreserveAspectFit - anchors.centerIn: parent - } - Image { - id: icon_signal_1 - height: parent.height * 0.9 - source: "assets/icon_wifi_1.png" - fillMode: Image.PreserveAspectFit - anchors.centerIn: parent - opacity: 0 - } - Image { - id: icon_signal_2 - height: parent.height * 0.9 - source: "assets/icon_wifi_2.png" - fillMode: Image.PreserveAspectFit - anchors.centerIn: parent - opacity: 0 - } - Image { - id: icon_signal_3 + id: icon_signal height: parent.height * 0.9 - source: "assets/icon_wifi_3.png" + source: "assets/icon_wifi_" + signalStrength + ".png" fillMode: Image.PreserveAspectFit anchors.centerIn: parent - opacity: 0 } - // marker for the error, working and OK states Image { id: markerBackground height: parent.height * 0.5 - anchors.right: parent.right anchors.bottom: parent.bottom source: "assets/icon_markerBackground.png" @@ -129,157 +88,12 @@ Item { fillMode: Image.PreserveAspectFit Image { - id: errorIcon + id: icon height: parent.height * 0.5 anchors.centerIn: parent - source: "assets/icon_error.png" + source: NetworkSettingsManager.currentWifiConnection ? "assets/icon_ok.png" : "assets/icon_error.png" fillMode: Image.PreserveAspectFit opacity: 1 } - Image { - id: workingIcon - height: parent.height * 0.75 - anchors.centerIn: parent - source: "assets/icon_working.png" - fillMode: Image.PreserveAspectFit - opacity: 0 - - RotationAnimation on rotation { - from: 0 - to: 360 - loops: Animation.Infinite - duration: 1000 - running: true - } - } - Image { - id: okIcon - height: parent.height * 0.5 - anchors.centerIn: parent - source: "assets/icon_ok.png" - fillMode: Image.PreserveAspectFit - opacity: 0 - } } - states: [ - State { - name: "working" - PropertyChanges { - target: errorIcon - opacity: 0 - } - PropertyChanges { - target: workingIcon - opacity: 1 - } - PropertyChanges { - target: okIcon - opacity: 0 - } - }, - State { - name: "ok" - PropertyChanges { - target: errorIcon - opacity: 0 - } - PropertyChanges { - target: workingIcon - opacity: 0 - } - PropertyChanges { - target: okIcon - opacity: 1 - } - PropertyChanges { - target: markerBackground - opacity: 0 - } - PropertyChanges { - target: icon_signal_0 - opacity: 0 - } - PropertyChanges { - target: icon_signal_1 - opacity: 1 - } - PropertyChanges { - target: icon_signal_2 - opacity: 1 - } - PropertyChanges { - target: icon_signal_3 - opacity: 1 - } - } - ] - transitions: [ - Transition { - from: "" - to: "working" - PropertyAnimation { - duration: 200 - properties: "opacity" - - } - }, - Transition { - from: "working" - to: "ok" - SequentialAnimation { - PropertyAnimation { - target: workingIcon - duration: 200 - properties: "opacity" - } - PropertyAnimation { - target: okIcon - duration: 100 - properties: "opacity" - } - ParallelAnimation { - PropertyAnimation { - target: icon_signal_0 - duration: 300 - properties: "opacity" - } - PropertyAnimation { - target: icon_signal_1 - duration: 300 - properties: "opacity" - } - } - PropertyAnimation { - target: icon_signal_2 - duration: 300 - properties: "opacity" - } - PropertyAnimation { - target: icon_signal_3 - duration: 200 - properties: "opacity" - } - PropertyAnimation { - target: markerBackground - duration: 1000 - properties: "opacity" - } - } - }, - Transition { - from: "" - to: "working" - PropertyAnimation { - duration: 200 - properties: "opacity" - - } - } - ] -} - -/*##^## -Designer { - D{i:0;autoSize:true;height:480;width:640} } -##^##*/ diff --git a/startupscreen/assets/Application_Logo.png b/startupscreen/assets/Application_Logo.png Binary files differnew file mode 100644 index 0000000..7f4f0a9 --- /dev/null +++ b/startupscreen/assets/Application_Logo.png diff --git a/startupscreen/assets/QSR_Logo.png b/startupscreen/assets/QSR_Logo.png Binary files differnew file mode 100644 index 0000000..7f4f0a9 --- /dev/null +++ b/startupscreen/assets/QSR_Logo.png diff --git a/startupscreen/assets/background.png b/startupscreen/assets/background.png Binary files differindex e15fc1b..b91de6f 100644 --- a/startupscreen/assets/background.png +++ b/startupscreen/assets/background.png diff --git a/startupscreen/assets/builtwithQt.png b/startupscreen/assets/builtwithQt.png Binary files differindex cbec44b..976ead7 100644 --- a/startupscreen/assets/builtwithQt.png +++ b/startupscreen/assets/builtwithQt.png diff --git a/startupscreen/assets/headerBackgroundLeft.png b/startupscreen/assets/headerBackgroundLeft.png Binary files differdeleted file mode 100644 index f6981a9..0000000 --- a/startupscreen/assets/headerBackgroundLeft.png +++ /dev/null diff --git a/startupscreen/assets/headerBackgroundRight.png b/startupscreen/assets/headerBackgroundRight.png Binary files differdeleted file mode 100644 index 5d409f5..0000000 --- a/startupscreen/assets/headerBackgroundRight.png +++ /dev/null diff --git a/startupscreen/assets/icon_ok.png b/startupscreen/assets/icon_ok.png Binary files differindex 14b1eae..6a9b683 100644 --- a/startupscreen/assets/icon_ok.png +++ b/startupscreen/assets/icon_ok.png diff --git a/startupscreen/fonts/TitilliumWeb-Bold.ttf b/startupscreen/fonts/TitilliumWeb-Bold.ttf deleted file mode 100644 index d854ea0..0000000 --- a/startupscreen/fonts/TitilliumWeb-Bold.ttf +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:794cb1239d5d6a1da0cbced1fe93aeb0fc78a68f51e9f1b5811241205e708380 -size 59908 diff --git a/startupscreen/fonts/TitilliumWeb-Light.ttf b/startupscreen/fonts/TitilliumWeb-Light.ttf deleted file mode 100644 index 907afb5..0000000 --- a/startupscreen/fonts/TitilliumWeb-Light.ttf +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a42074ecc8fa9be8cda36bed16a4a0ae5bd3451abfc9e1aa3bd957809c1b9cb6 -size 64032 diff --git a/startupscreen/fonts/TitilliumWeb-Regular.ttf b/startupscreen/fonts/TitilliumWeb-Regular.ttf deleted file mode 100644 index d235334..0000000 --- a/startupscreen/fonts/TitilliumWeb-Regular.ttf +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:89535fa5e2d707abc3a5becff17810789d73c827916ca8be714cfe6504ef9974 -size 63752 diff --git a/startupscreen/main.cpp b/startupscreen/main.cpp index 4bbfa04..77d3e02 100644 --- a/startupscreen/main.cpp +++ b/startupscreen/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of Qt for Device Creation. @@ -49,6 +49,7 @@ ****************************************************************************/ #include "settingsmanager.h" +#include "qtbuttonimageprovider.h" #include <QFontDatabase> #include <QGuiApplication> @@ -56,16 +57,24 @@ int main(int argc, char *argv[]) { - QGuiApplication app(argc, argv); + qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); - QFontDatabase::addApplicationFont(":/fonts/TitilliumWeb-Bold.ttf"); - QFontDatabase::addApplicationFont(":/fonts/TitilliumWeb-Light.ttf"); - QFontDatabase::addApplicationFont(":/fonts/TitilliumWeb-Regular.ttf"); + QGuiApplication app(argc, argv); + app.setApplicationVersion(QLatin1String(qVersion())); SettingsManager settingsManager; + qmlRegisterSingletonInstance("StartupScreen", 1, 0, "SettingsManager", &settingsManager); + QtButtonImageProvider imageProvider; QQmlApplicationEngine engine; + +#ifdef QSR + if (app.windowIcon().isNull()) { + app.setWindowIcon(QIcon(":/assets/QSR_Logo.png")); + } +#endif + engine.addImageProvider("QtButton", &imageProvider); engine.addImportPath("qrc:/imports"); const QUrl url(QStringLiteral("qrc:/StartupScreen.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, @@ -73,6 +82,7 @@ int main(int argc, char *argv[]) if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); + engine.load(url); return app.exec(); diff --git a/startupscreen/qml.qrc b/startupscreen/qml.qrc index e195e96..0b59285 100644 --- a/startupscreen/qml.qrc +++ b/startupscreen/qml.qrc @@ -2,7 +2,6 @@ <qresource prefix="/"> <file>AnalogClock.qml</file> <file>GuideView.qml</file> - <file>MainView.qml</file> <file>RebootDialog.qml</file> <file>SplashView.ui.qml</file> <file>StartupScreen.qml</file> @@ -18,8 +17,6 @@ <file>assets/background.png</file> <file>assets/builtwithQt.png</file> <file>assets/clockFace.png</file> - <file>assets/headerBackgroundLeft.png</file> - <file>assets/headerBackgroundRight.png</file> <file>assets/icon_SDcard.png</file> <file>assets/icon_error.png</file> <file>assets/icon_markerBackground.png</file> @@ -31,9 +28,15 @@ <file>assets/icon_wifi_2.png</file> <file>assets/icon_wifi_3.png</file> <file>assets/icon_working.png</file> - <file>fonts/TitilliumWeb-Bold.ttf</file> - <file>fonts/TitilliumWeb-Light.ttf</file> - <file>fonts/TitilliumWeb-Regular.ttf</file> <file>qtquickcontrols2.conf</file> + <file>NetworkSettings/CustomSwitch.qml</file> + <file>NetworkSettings/NetworkListView.qml</file> + <file>NetworkSettings/NetworkSettings.qml</file> + <file>NetworkSettings/NetworkSettingsPage.qml</file> + <file>NetworkSettings/PassphraseEnter.qml</file> + <file>NetworkSettings/ViewSettings.qml</file> + <file>NetworkSettings/QtButton.qml</file> + <file>NetworkSettings/NetworkDelegate.qml</file> + <file>assets/QSR_Logo.png</file> </qresource> </RCC> diff --git a/startupscreen/qtbuttonimageprovider.cpp b/startupscreen/qtbuttonimageprovider.cpp new file mode 100644 index 0000000..65566a5 --- /dev/null +++ b/startupscreen/qtbuttonimageprovider.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +#include <QImage> +#include <QPainter> +#include <QPainterPath> + +#include "qtbuttonimageprovider.h" + +QtButtonImageProvider::QtButtonImageProvider() + : QQuickImageProvider(QQuickImageProvider::Pixmap) +{ +} + +QPixmap QtButtonImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) +{ + bool ok = false; + + QStringList params = id.split("/"); + + int cutSize = params.at(0).toInt(&ok); + + if (!ok) + cutSize = 10; + + QColor fillColor; + QColor borderColor; + + if (params.length() > 1) { + fillColor = QColor(params.at(1)); + } + + if (params.length() > 2) + borderColor = QColor(params.at(2)); + + if (!fillColor.isValid()) + fillColor = "#00eb00"; + + if (!borderColor.isValid()) + borderColor ="white"; + + int width = 100; + int height = 50; + + if (size) + *size = QSize(requestedSize.width(), requestedSize.height()); + + QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, + requestedSize.height() > 0 ? requestedSize.height() : height); + pixmap.fill(Qt::transparent); + + QPainter painter(&pixmap); + const qreal borderPenWidth = 2; + QPen borderPen(QBrush(borderColor), borderPenWidth); + borderPen.setJoinStyle(Qt::MiterJoin); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(borderPen); + painter.setBrush(fillColor); + + QPainterPath path; + qreal top = borderPenWidth - 1; + qreal left = borderPenWidth - 1; + qreal bottom = pixmap.height() - borderPenWidth; + qreal right = pixmap.width() - borderPenWidth; + path.moveTo(left + cutSize, top); + path.lineTo(right, top); + path.lineTo(right, bottom - cutSize); + path.lineTo(right - cutSize, bottom); + path.lineTo(left, bottom); + path.lineTo(left, top + cutSize); + path.lineTo(left + cutSize, top); + painter.drawPath(path); + + return pixmap; +} diff --git a/startupscreen/qtbuttonimageprovider.h b/startupscreen/qtbuttonimageprovider.h new file mode 100644 index 0000000..94f410e --- /dev/null +++ b/startupscreen/qtbuttonimageprovider.h @@ -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$ +** +****************************************************************************/ +#ifndef QTBUTTONIMAGEPROVIDER_H +#define QTBUTTONIMAGEPROVIDER_H + +#include <QQuickImageProvider> +#include <QPixmap> + +class QtButtonImageProvider : public QQuickImageProvider +{ +public: + QtButtonImageProvider(); + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override; + + void setCutSize(int size) { m_cutSize = size; } +private: + int m_cutSize; +}; + +#endif // QTBUTTONIMAGEPROVIDER_H diff --git a/startupscreen/qtquickcontrols2.conf b/startupscreen/qtquickcontrols2.conf index 7da18fc..7e4bead 100644 --- a/startupscreen/qtquickcontrols2.conf +++ b/startupscreen/qtquickcontrols2.conf @@ -3,6 +3,6 @@ Style=Universal [Universal] Theme=Dark -Accent=#41CD52 -Background=#222840 +Accent=#2cde85 +Background=#002e34 Foreground=#f3f3f4 diff --git a/startupscreen/settingsmanager.cpp b/startupscreen/settingsmanager.cpp index e732734..ddd964b 100644 --- a/startupscreen/settingsmanager.cpp +++ b/startupscreen/settingsmanager.cpp @@ -55,6 +55,7 @@ #include <QFile> #include <QTemporaryFile> #include <QNetworkInterface> +#include <QProcess> #include <sys/reboot.h> #include <unistd.h> @@ -161,3 +162,26 @@ QByteArray SettingsManager::guideText() return QByteArrayLiteral("Guide not found"); } } + +void SettingsManager::runDemoMode(const QString& target) +{ + QProcess process; + QString program = "systemctl"; + QStringList arguments; + + arguments << "start" << target; + + process.start(program, arguments); + process.waitForFinished(-1); + + if (process.exitStatus() == QProcess::NormalExit && process.exitCode() == 0) { + qInfo() << "Successfully started target: " << target; + } else { + qWarning() << "Command execution failed with exit code: " << process.exitCode() << " for target: " << target; + qWarning() << "Error message: " << process.errorString(); + } +} + + + + diff --git a/startupscreen/settingsmanager.h b/startupscreen/settingsmanager.h index fe254d7..6f524cf 100644 --- a/startupscreen/settingsmanager.h +++ b/startupscreen/settingsmanager.h @@ -70,6 +70,7 @@ public: void setUsbMode(const QString &usbMode); bool hasQdb(); Q_INVOKABLE void reboot(); + Q_INVOKABLE void runDemoMode(const QString& target); QString networks(); QByteArray guideText(); diff --git a/startupscreen/startupscreen.pro b/startupscreen/startupscreen.pro index 5f2a0c2..a30dea2 100644 --- a/startupscreen/startupscreen.pro +++ b/startupscreen/startupscreen.pro @@ -2,10 +2,12 @@ QT += quick quickcontrols2 SOURCES += \ settingsmanager.cpp \ - main.cpp + main.cpp \ + qtbuttonimageprovider.cpp HEADERS += \ - settingsmanager.h + settingsmanager.h \ + qtbuttonimageprovider.h RESOURCES += qml.qrc |