From 31a633bc93eb2eaff4d50596c69db0ad83a3e6cf Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Fri, 23 Oct 2020 15:32:54 +0300 Subject: startupscreen: enable usb mode switch The USB button can be used switch the USB Ethernet driver mode between cdcecm and rndis to work with Linux, Windows and macOS host machines. Task-number: QTBUG-87857 Change-Id: Iab54d7582bdd9c39fca95dfa0bb8637d5ea14e81 Reviewed-by: Rami Potinkara --- startupscreen/CMakeLists.txt | 5 +- startupscreen/MainView.qml | 11 +++- startupscreen/RebootDialog.qml | 77 ++++++++++++++++++++++ startupscreen/UsbButton.qml | 71 ++++++++------------ startupscreen/UsbModeDialog.qml | 98 ++++++++++++++++++++++++++++ startupscreen/WifiButton.qml | 19 +++--- startupscreen/assets/icon_nok.png | Bin 0 -> 2748 bytes startupscreen/main.cpp | 7 +- startupscreen/qml.qrc | 3 + startupscreen/qtquickcontrols2.conf | 8 ++- startupscreen/settingsmanager.cpp | 126 ++++++++++++++++++++++++++++++++++++ startupscreen/settingsmanager.h | 76 ++++++++++++++++++++++ startupscreen/startupscreen.pro | 6 +- 13 files changed, 447 insertions(+), 60 deletions(-) create mode 100644 startupscreen/RebootDialog.qml create mode 100644 startupscreen/UsbModeDialog.qml create mode 100644 startupscreen/assets/icon_nok.png create mode 100644 startupscreen/settingsmanager.cpp create mode 100644 startupscreen/settingsmanager.h (limited to 'startupscreen') diff --git a/startupscreen/CMakeLists.txt b/startupscreen/CMakeLists.txt index 3b9bdf9..87b0238 100644 --- a/startupscreen/CMakeLists.txt +++ b/startupscreen/CMakeLists.txt @@ -11,11 +11,12 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED) +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 qml.qrc ) diff --git a/startupscreen/MainView.qml b/startupscreen/MainView.qml index bed57e4..4e0a234 100644 --- a/startupscreen/MainView.qml +++ b/startupscreen/MainView.qml @@ -182,13 +182,16 @@ Item { id: usbButton height: parent.buttonSize width: height - iconHeight: height * 0.9 + available: SettingsManager.hasQdb + connected: ipAddress.text.indexOf("usb0") !== -1 + onPressed: { + usbModeDialog.open() + } } WifiButton { id: wifiButton height: parent.buttonSize width: height - iconHeight: height * 0.9 visible: false } } @@ -215,6 +218,10 @@ Item { font.family: "Titillium Web" } + UsbModeDialog { + id: usbModeDialog + } + // base state = landscape states: [ State { diff --git a/startupscreen/RebootDialog.qml b/startupscreen/RebootDialog.qml new file mode 100644 index 0000000..12ba5bd --- /dev/null +++ b/startupscreen/RebootDialog.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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.Layouts +import QtQuick.Controls + +Dialog { + id: dialog + + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + parent: Overlay.overlay + + focus: true + modal: true + title: "Reboot Device" + standardButtons: Dialog.Ok | Dialog.Cancel + + ColumnLayout { + spacing: 20 + anchors.fill: parent + Label { + elide: Label.ElideRight + text: "The settings change requires device to be rebooted." + Layout.fillWidth: true + wrapMode: Label.Wrap + } + } +} diff --git a/startupscreen/UsbButton.qml b/startupscreen/UsbButton.qml index 9155de8..355ab0c 100644 --- a/startupscreen/UsbButton.qml +++ b/startupscreen/UsbButton.qml @@ -54,7 +54,11 @@ import StartupScreen Item { id: root - property alias iconHeight: icon.height + property bool available: false + property bool connected: false + signal pressed() + + state: !available ? "" : (connected ? "connected" : "error") Rectangle { id: buttonBackground @@ -72,13 +76,7 @@ Item { } onReleased: { root.scale = 1.0 - - if (root.state == "") - root.state = "working" - else if (root.state == "working") - root.state = "ok" - else - root.state = "" + if (available) root.pressed() } } @@ -88,9 +86,10 @@ Item { source: "assets/icon_usb.png" fillMode: Image.PreserveAspectFit anchors.centerIn: parent + height: parent.height * 0.9 } - // marker for the error, working and OK states + // marker for the states Image { id: markerBackground height: icon.height/2 @@ -104,27 +103,19 @@ Item { Image { id: errorIcon - height: parent.height*0.5 + height: parent.height * 0.5 anchors.centerIn: parent source: "assets/icon_error.png" fillMode: Image.PreserveAspectFit - opacity: 1 + opacity: 0 } Image { - id: workingIcon - height: parent.height *0.75 + id: unavailableIcon + height: parent.height * 0.5 anchors.centerIn: parent - source: "assets/icon_working.png" + source: "assets/icon_nok.png" fillMode: Image.PreserveAspectFit - opacity: 0 - - RotationAnimation on rotation { - from: 0 - to: 360 - loops: Animation.Infinite - duration: 1000 - running: true - } + opacity: 1 } Image { id: okIcon @@ -135,59 +126,51 @@ Item { opacity: 0 } } + states: [ State { - name: "working" + name: "connected" PropertyChanges { target: errorIcon opacity: 0 } PropertyChanges { - target: workingIcon - opacity: 1 + target: unavailableIcon + opacity: 0 } PropertyChanges { target: okIcon - opacity: 0 + opacity: 1 } }, State { - name: "ok" + name: "error" PropertyChanges { target: errorIcon - opacity: 0 + opacity: 1 } PropertyChanges { - target: workingIcon + target: unavailableIcon opacity: 0 } PropertyChanges { target: okIcon - opacity: 1 + opacity: 0 } } ] transitions: [ Transition { - from: "" - to: "working" - PropertyAnimation { - duration: 200 - properties: "opacity" - - } - }, - Transition { - from: "working" - to: "ok" + from: "error" + to: "connected" PropertyAnimation { duration: 200 properties: "opacity" } }, Transition { - from: "" - to: "working" + from: "connected" + to: "error" PropertyAnimation { duration: 200 properties: "opacity" diff --git a/startupscreen/UsbModeDialog.qml b/startupscreen/UsbModeDialog.qml new file mode 100644 index 0000000..10cb3f3 --- /dev/null +++ b/startupscreen/UsbModeDialog.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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.Layouts +import QtQuick.Controls +import StartupScreen + +Dialog { + id: dialog + + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + parent: Overlay.overlay + + focus: true + modal: true + title: "USB Ethernet mode" + standardButtons: Dialog.Ok | Dialog.Cancel + + RebootDialog { + id: reboot + onAccepted: SettingsManager.reboot() + } + + onAccepted: { + SettingsManager.usbMode = combobox.currentText + reboot.open() + } + onRejected: { + combobox.currentIndex = SettingsManager.mode === "cdcecm" ? 0 : 1 + } + + ColumnLayout { + spacing: 20 + anchors.fill: parent + Label { + elide: Label.ElideRight + text: "Switch the USB Ethernet mode used for Qt Creator connection. " + + "CDCECM supports Linux and macOS hosts, " + + "while RNDIS supports Linux and Windows hosts." + Layout.fillWidth: true + wrapMode: Label.Wrap + } + ComboBox { + id: combobox + currentIndex: SettingsManager.mode === "cdcecm" ? 0 : 1 + model: ["cdcecm", "rndis"] + } + } +} diff --git a/startupscreen/WifiButton.qml b/startupscreen/WifiButton.qml index 0f617e5..fd34a90 100644 --- a/startupscreen/WifiButton.qml +++ b/startupscreen/WifiButton.qml @@ -54,7 +54,7 @@ import StartupScreen Item { id: root - property int iconHeight + signal pressed() Rectangle { id: buttonBackground @@ -72,6 +72,7 @@ Item { } onReleased: { root.scale = 1.0 + root.pressed() if (root.state == "") root.state = "working" @@ -85,14 +86,14 @@ Item { // icons for signal strengths (from 0 to 3) Image { id: icon_signal_0 - height: iconHeight-12 + height: parent.height * 0.9 source: "assets/icon_wifi_0.png" fillMode: Image.PreserveAspectFit anchors.centerIn: parent } Image { id: icon_signal_1 - height: iconHeight-12 + height: parent.height * 0.9 source: "assets/icon_wifi_1.png" fillMode: Image.PreserveAspectFit anchors.centerIn: parent @@ -100,7 +101,7 @@ Item { } Image { id: icon_signal_2 - height: iconHeight-12 + height: parent.height * 0.9 source: "assets/icon_wifi_2.png" fillMode: Image.PreserveAspectFit anchors.centerIn: parent @@ -108,7 +109,7 @@ Item { } Image { id: icon_signal_3 - height: iconHeight-12 + height: parent.height * 0.9 source: "assets/icon_wifi_3.png" fillMode: Image.PreserveAspectFit anchors.centerIn: parent @@ -118,7 +119,7 @@ Item { // marker for the error, working and OK states Image { id: markerBackground - height: iconHeight/2 + height: parent.height * 0.5 anchors.right: parent.right anchors.bottom: parent.bottom @@ -129,7 +130,7 @@ Item { Image { id: errorIcon - height: parent.height *0.5 + height: parent.height * 0.5 anchors.centerIn: parent source: "assets/icon_error.png" fillMode: Image.PreserveAspectFit @@ -137,7 +138,7 @@ Item { } Image { id: workingIcon - height: parent.height *0.75 + height: parent.height * 0.75 anchors.centerIn: parent source: "assets/icon_working.png" fillMode: Image.PreserveAspectFit @@ -153,7 +154,7 @@ Item { } Image { id: okIcon - height: parent.height *0.5 + height: parent.height * 0.5 anchors.centerIn: parent source: "assets/icon_ok.png" fillMode: Image.PreserveAspectFit diff --git a/startupscreen/assets/icon_nok.png b/startupscreen/assets/icon_nok.png new file mode 100644 index 0000000..44012e2 Binary files /dev/null and b/startupscreen/assets/icon_nok.png differ diff --git a/startupscreen/main.cpp b/startupscreen/main.cpp index a2c6160..4bbfa04 100644 --- a/startupscreen/main.cpp +++ b/startupscreen/main.cpp @@ -48,9 +48,11 @@ ** ****************************************************************************/ +#include "settingsmanager.h" + +#include #include #include -#include int main(int argc, char *argv[]) { @@ -60,6 +62,9 @@ int main(int argc, char *argv[]) QFontDatabase::addApplicationFont(":/fonts/TitilliumWeb-Light.ttf"); QFontDatabase::addApplicationFont(":/fonts/TitilliumWeb-Regular.ttf"); + SettingsManager settingsManager; + qmlRegisterSingletonInstance("StartupScreen", 1, 0, "SettingsManager", &settingsManager); + QQmlApplicationEngine engine; engine.addImportPath("qrc:/imports"); const QUrl url(QStringLiteral("qrc:/StartupScreen.qml")); diff --git a/startupscreen/qml.qrc b/startupscreen/qml.qrc index ec4c769..1e22972 100644 --- a/startupscreen/qml.qrc +++ b/startupscreen/qml.qrc @@ -8,6 +8,7 @@ assets/icon_error.png assets/icon_markerBackground.png assets/icon_ok.png + assets/icon_nok.png assets/icon_SDcard.png assets/icon_usb.png assets/icon_wifi_0.png @@ -23,8 +24,10 @@ UsbButton.qml WifiButton.qml TextButton.qml + UsbModeDialog.qml fonts/TitilliumWeb-Bold.ttf fonts/TitilliumWeb-Light.ttf fonts/TitilliumWeb-Regular.ttf + RebootDialog.qml diff --git a/startupscreen/qtquickcontrols2.conf b/startupscreen/qtquickcontrols2.conf index db94867..7da18fc 100644 --- a/startupscreen/qtquickcontrols2.conf +++ b/startupscreen/qtquickcontrols2.conf @@ -1,2 +1,8 @@ [Controls] -Style=Basic +Style=Universal + +[Universal] +Theme=Dark +Accent=#41CD52 +Background=#222840 +Foreground=#f3f3f4 diff --git a/startupscreen/settingsmanager.cpp b/startupscreen/settingsmanager.cpp new file mode 100644 index 0000000..4f5f217 --- /dev/null +++ b/startupscreen/settingsmanager.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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$ +** +****************************************************************************/ + +#include "settingsmanager.h" + +#include +#include +#include +#include + +#include +#include + +const QString QdbdFileName(QStringLiteral("/etc/default/qdbd")); +const char *ProtocolSetting("USB_ETHERNET_PROTOCOL="); + +SettingsManager::SettingsManager(QObject *parent) : QObject(parent) {} + +bool SettingsManager::hasQdb() +{ + return QFile::exists(QdbdFileName); +} + +QString SettingsManager::usbMode() +{ + static bool initialized = false; + if (!initialized) { + QFile file(QdbdFileName); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QByteArray line; + while (!(line = file.readLine()).isEmpty()) { + if (line.startsWith(ProtocolSetting)) + m_usbMode = + QString::fromLatin1(line.last(line.length() - strlen(ProtocolSetting))) + .trimmed(); + } + } else { + qWarning() << "Failed to open file" << QdbdFileName; + } + initialized = true; + } + return m_usbMode; +} + +void SettingsManager::setUsbMode(const QString &usbMode) +{ + QFile file(QdbdFileName); + QTemporaryFile newFile(QdbdFileName); + newFile.setAutoRemove(false); + if (!newFile.open()) { + qWarning() << "Failed to save qdbd settings:" << newFile.errorString(); + return; + } + + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream out(&newFile); + QByteArray line; + while (!(line = file.readLine()).isEmpty()) { + if (line.startsWith(ProtocolSetting)) + out << ProtocolSetting << usbMode.toLatin1() << '\n'; + else + out << line; + } + + file.remove(); + if (!newFile.rename(QdbdFileName)) + qWarning() << "Failed to save qdbd settings:" << newFile.errorString(); + + } else { + qWarning() << "Failed to save qdbd settings:" << file.errorString(); + } +} + +void SettingsManager::reboot() +{ + sync(); + ::reboot(RB_AUTOBOOT); + qWarning("reboot failed"); +} diff --git a/startupscreen/settingsmanager.h b/startupscreen/settingsmanager.h new file mode 100644 index 0000000..1801812 --- /dev/null +++ b/startupscreen/settingsmanager.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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$ +** +****************************************************************************/ + +#ifndef SETTINGSMANAGER_H +#define SETTINGSMANAGER_H + +#include +#include + +class SettingsManager : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString usbMode READ usbMode WRITE setUsbMode) + Q_PROPERTY(bool hasQdb READ hasQdb CONSTANT) + +public: + explicit SettingsManager(QObject *parent = nullptr); + + QString usbMode(); + void setUsbMode(const QString &usbMode); + bool hasQdb(); + Q_INVOKABLE void reboot(); + +private: + QString m_usbMode; +}; + +#endif // SETTINGSMANAGER_H diff --git a/startupscreen/startupscreen.pro b/startupscreen/startupscreen.pro index 663b433..5f2a0c2 100644 --- a/startupscreen/startupscreen.pro +++ b/startupscreen/startupscreen.pro @@ -1,8 +1,12 @@ -QT += quick +QT += quick quickcontrols2 SOURCES += \ + settingsmanager.cpp \ main.cpp +HEADERS += \ + settingsmanager.h + RESOURCES += qml.qrc OTHER_FILES += \ -- cgit v1.2.3