From 6955c9cc6f0d96bea688da432e0acfd1eb2468e7 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Mon, 16 Aug 2021 15:27:21 +0200 Subject: [PATCH 1/6] Scan starts automatically on init --- qml/Connect.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qml/Connect.qml b/qml/Connect.qml index 5f9e802..a5e99c5 100644 --- a/qml/Connect.qml +++ b/qml/Connect.qml @@ -1,8 +1,13 @@ import QtQuick 2.15 import Shared 1.0 + GamePage { + function init() { + deviceFinder.startSearch() + } + errorMessage: deviceFinder.error infoMessage: deviceFinder.info From 8507df1bcf3aeca35a56c6ec82682e89ce996762 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Mon, 16 Aug 2021 17:36:05 +0200 Subject: [PATCH 2/6] Changed the showPage() function. This is because the normal function would take you to the next index, but if you would want to skip a index, you need to change the index to a fixed number (or redo the whole index-tab-system) --- qml/App.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qml/App.qml b/qml/App.qml index ede998f..d70fde9 100644 --- a/qml/App.qml +++ b/qml/App.qml @@ -23,11 +23,13 @@ Item { __currentIndex = lastPages.length-1; } - function showPage(name) + function showPage(name, index = -1) { lastPages.push(name) pageLoader.setSource(name) - __currentIndex = lastPages.length-1; + if(index === -1) + __currentIndex = lastPages.length-1 + else __currentIndex = index } TitleBar { From bb112eeaada64cebd238ffd0385ff73b34ec78a7 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Mon, 16 Aug 2021 17:43:11 +0200 Subject: [PATCH 3/6] Moved setInfo() into the if-statement --- devicefinder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devicefinder.cpp b/devicefinder.cpp index 0d4f1ca..d4e2c80 100644 --- a/devicefinder.cpp +++ b/devicefinder.cpp @@ -51,8 +51,8 @@ void DeviceFinder::addDevice(const QBluetoothDeviceInfo &device) auto info = new DeviceInfo(device); if(info->getName().contains("bobby")) { // Only add devices with "bobby" in device name to list; (filter) m_devices.append(info); + setInfo(tr("Low Energy device found. Scanning more...")); } - setInfo(tr("Low Energy device found. Scanning more...")); //! [devicediscovery-3] emit devicesChanged(); //! [devicediscovery-4] From 0ed37267acd9d3fa547dcc628aa08aad3893ce0d Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Mon, 16 Aug 2021 17:45:17 +0200 Subject: [PATCH 4/6] Added UUIDs for wireless settings --- devicehandler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/devicehandler.cpp b/devicehandler.cpp index 8a2772a..3aad29c 100644 --- a/devicehandler.cpp +++ b/devicehandler.cpp @@ -16,6 +16,9 @@ const QBluetoothUuid bobbycarServiceUuid{QUuid::fromString(QStringLiteral("0335e const QBluetoothUuid livestatsCharacUuid{QUuid::fromString(QStringLiteral("a48321ea-329f-4eab-a401-30e247211524"))}; const QBluetoothUuid remotecontrolCharacUuid{QUuid::fromString(QStringLiteral("4201def0-a264-43e6-946b-6b2d9612dfed"))}; + +const QBluetoothUuid settingsSetterUuid{QUuid::fromString(QStringLiteral("4201def1-a264-43e6-946b-6b2d9612dfed"))}; +const QBluetoothUuid wifiListUuid{QUuid::fromString(QStringLiteral("4201def2-a264-43e6-946b-6b2d9612dfed"))}; } DeviceHandler::DeviceHandler(QObject *parent) : From a3c0a58c470fe5adc9a8c60eabbe1c0dcacad0a1 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Mon, 16 Aug 2021 17:46:24 +0200 Subject: [PATCH 5/6] Added basic stuff to enable developing of settings tab --- qml.qrc | 1 + qml/Livedata.qml | 52 +++++++++++++++++++++++++++++++++++------------- qml/TitleBar.qml | 12 ++++++----- qml/settings.qml | 31 +++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 19 deletions(-) create mode 100644 qml/settings.qml diff --git a/qml.qrc b/qml.qrc index 975919c..b6b41f1 100644 --- a/qml.qrc +++ b/qml.qrc @@ -15,5 +15,6 @@ qml/BottomLine.qml qml/StatsLabel.qml qml/qmldir + qml/settings.qml diff --git a/qml/Livedata.qml b/qml/Livedata.qml index ab48667..e6a96cb 100644 --- a/qml/Livedata.qml +++ b/qml/Livedata.qml @@ -37,6 +37,7 @@ GamePage { contentHeight: contentColumn.height flickableDirection: Flickable.VerticalFlick clip: true + anchors.margins: 5 Column { id: contentColumn @@ -68,7 +69,7 @@ GamePage { wrapMode: Text.WordWrap text: "Front: " + Number(deviceHandler.frontVoltage).toLocaleString(Qt.locale()) + "V / " + Number(deviceHandler.frontTemperature).toLocaleString(Qt.locale()) + "°C" color: GameSettings.textColor - minimumPixelSize: 10 + //minimumPixelSize: 10 font.pixelSize: GameSettings.mediumFontSize } @@ -120,7 +121,7 @@ GamePage { text: "Back: " + Number(deviceHandler.backVoltage).toLocaleString(Qt.locale()) + "V / " + Number(deviceHandler.backTemperature).toLocaleString(Qt.locale()) + "°C" //visible: deviceHandler.alive color: GameSettings.textColor - minimumPixelSize: 10 + //minimumPixelSize: 10 font.pixelSize: GameSettings.mediumFontSize } @@ -153,22 +154,45 @@ GamePage { } } - GameButton { - id: startButton - anchors.horizontalCenter: parent.horizontalCenter + Row { + id: buttonRow anchors.bottom: parent.bottom anchors.bottomMargin: GameSettings.fieldMargin - width: container.width - height: GameSettings.fieldHeight - radius: GameSettings.buttonRadius + spacing: 5 + anchors.horizontalCenter: parent.horizontalCenter - onClicked: app.showPage("RemoteControl.qml") + width: childrenRect.width - Text { - anchors.centerIn: parent - font.pixelSize: GameSettings.tinyFontSize - text: qsTr("REMOTE") - color: startButton.enabled ? GameSettings.textColor : GameSettings.disabledTextColor + GameButton { + id: startButton + width: container.width / 2 + height: GameSettings.fieldHeight + radius: GameSettings.buttonRadius + + onClicked: app.showPage("RemoteControl.qml") + + Text { + anchors.centerIn: parent + font.pixelSize: GameSettings.tinyFontSize + text: qsTr("REMOTE") + color: startButton.enabled ? GameSettings.textColor : GameSettings.disabledTextColor + } + } + + GameButton { + id: settingsButton + width: container.width / 2 + height: GameSettings.fieldHeight + radius: GameSettings.buttonRadius + + onClicked: app.showPage("settings.qml", 3) + + Text { + anchors.centerIn: parent + font.pixelSize: GameSettings.tinyFontSize + text: qsTr("SETTINGS") + color: settingsButton.enabled ? GameSettings.textColor : GameSettings.disabledTextColor + } } } } diff --git a/qml/TitleBar.qml b/qml/TitleBar.qml index 0e9df7f..00fc889 100644 --- a/qml/TitleBar.qml +++ b/qml/TitleBar.qml @@ -8,21 +8,23 @@ Rectangle { height: GameSettings.fieldHeight color: GameSettings.viewColor - property var __titles: ["CONNECT", "LIVEDATA", "REMOTECONTROL"] + property var __titles: ["CONNECT", "LIVEDATA", "REMOTECONTROL", "SETTINGS"] property int currentIndex: 0 signal titleClicked(int index) Repeater { - model: 3 + model: 4 Text { - width: titleBar.width / 3 + width: titleBar.width / 4 height: titleBar.height x: index * width horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter + //text: GameSettings.hugeFontSize * 0.4 + //text: currentIndex text: __titles[index] - font.pixelSize: GameSettings.tinyFontSize + font.pixelSize: GameSettings.hugeFontSize * 0.3 color: titleBar.currentIndex === index ? GameSettings.textColor : GameSettings.disabledTextColor MouseArea { @@ -35,7 +37,7 @@ Rectangle { Item { anchors.bottom: parent.bottom - width: parent.width / 3 + width: parent.width / 4 height: parent.height x: currentIndex * width diff --git a/qml/settings.qml b/qml/settings.qml new file mode 100644 index 0000000..60dc072 --- /dev/null +++ b/qml/settings.qml @@ -0,0 +1,31 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 + +GamePage { + id: livedatePage + + errorMessage: deviceHandler.error + infoMessage: deviceHandler.info + + function close() + { + deviceHandler.disconnectService(); + app.prevPage(); + } + + Rectangle { + id: container + anchors.centerIn: parent + anchors.horizontalCenter: parent.horizontalCenter + width: Math.min(livedatePage.width, livedatePage.height-GameSettings.fieldHeight*4) - 2*GameSettings.fieldMargin + height: livedatePage.height-GameSettings.fieldHeight*4 + radius: GameSettings.buttonRadius + color: GameSettings.viewColor + + Text { + id: test + text: qsTr("text") + color: "white" + } + } +} From f495d3d25342e979d78aa874b043a033be324980 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Mon, 16 Aug 2021 18:18:07 +0200 Subject: [PATCH 6/6] More preparations for wireless settings --- bobbycar-app.pro | 6 ++-- qml/Livedata.qml | 3 ++ qml/settings.qml | 77 +++++++++++++++++++++++++++++++++++++++++++----- settings.cpp | 6 ++++ settings.h | 11 +++++++ 5 files changed, 93 insertions(+), 10 deletions(-) create mode 100644 settings.cpp create mode 100644 settings.h diff --git a/bobbycar-app.pro b/bobbycar-app.pro index 293814d..04e0f14 100644 --- a/bobbycar-app.pro +++ b/bobbycar-app.pro @@ -9,14 +9,16 @@ HEADERS += \ deviceinfo.h \ devicefinder.h \ devicehandler.h \ - bluetoothbaseclass.h + bluetoothbaseclass.h \ + settings.h SOURCES += main.cpp \ connectionhandler.cpp \ deviceinfo.cpp \ devicefinder.cpp \ devicehandler.cpp \ - bluetoothbaseclass.cpp + bluetoothbaseclass.cpp \ + settings.cpp RESOURCES += qml.qrc \ images.qrc diff --git a/qml/Livedata.qml b/qml/Livedata.qml index e6a96cb..f91515e 100644 --- a/qml/Livedata.qml +++ b/qml/Livedata.qml @@ -126,6 +126,8 @@ GamePage { } Row { + anchors.bottomMargin: 30 + spacing: 10 Label { text: 'iMotMax:' color: GameSettings.textColor @@ -139,6 +141,7 @@ GamePage { } Row { + spacing: 10 Label { text: 'iDcMax:' color: GameSettings.textColor diff --git a/qml/settings.qml b/qml/settings.qml index 60dc072..28dd285 100644 --- a/qml/settings.qml +++ b/qml/settings.qml @@ -1,5 +1,6 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 +import Shared 1.0 GamePage { id: livedatePage @@ -14,18 +15,78 @@ GamePage { } Rectangle { - id: container - anchors.centerIn: parent + id: viewContainer + anchors.top: parent.top + anchors.topMargin: GameSettings.fieldMargin + messageHeight + anchors.bottomMargin: GameSettings.fieldMargin anchors.horizontalCenter: parent.horizontalCenter - width: Math.min(livedatePage.width, livedatePage.height-GameSettings.fieldHeight*4) - 2*GameSettings.fieldMargin - height: livedatePage.height-GameSettings.fieldHeight*4 - radius: GameSettings.buttonRadius + width: parent.width - GameSettings.fieldMargin*2 color: GameSettings.viewColor + radius: GameSettings.buttonRadius + Text { - id: test - text: qsTr("text") - color: "white" + id: title + width: parent.width + height: GameSettings.fieldHeight + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: GameSettings.textColor + font.pixelSize: GameSettings.mediumFontSize + text: qsTr("WIFIS") + + BottomLine { + height: 1; + width: parent.width + color: "#898989" + } + } + + + ListView { + id: wifis + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.top: title.bottom + //model: deviceFinder.devices // Needs to be changed + clip: true + + delegate: Rectangle { + id: box + height:GameSettings.fieldHeight * 1.2 + width: parent.width + color: index % 2 === 0 ? GameSettings.delegate1Color : GameSettings.delegate2Color + + MouseArea { + anchors.fill: parent + onClicked: { + //Handle editor + } + } + + Text { + id: device + font.pixelSize: GameSettings.smallFontSize + text: modelData.ssid + anchors.top: parent.top + anchors.topMargin: parent.height * 0.1 + anchors.leftMargin: parent.height * 0.1 + anchors.left: parent.left + color: GameSettings.textColor + } +/* + Text { + id: deviceAddress + font.pixelSize: GameSettings.smallFontSize + text: modelData.deviceAddress + anchors.bottom: parent.bottom + anchors.bottomMargin: parent.height * 0.1 + anchors.rightMargin: parent.height * 0.1 + anchors.right: parent.right + color: Qt.darker(GameSettings.textColor) + }*/ + } } } } diff --git a/settings.cpp b/settings.cpp new file mode 100644 index 0000000..ab1f08d --- /dev/null +++ b/settings.cpp @@ -0,0 +1,6 @@ +#include "settings.h" + +settings::settings() +{ + +} diff --git a/settings.h b/settings.h new file mode 100644 index 0000000..f855612 --- /dev/null +++ b/settings.h @@ -0,0 +1,11 @@ +#ifndef SETTINGS_H +#define SETTINGS_H + + +class settings +{ +public: + settings(); +}; + +#endif // SETTINGS_H