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/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] 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) : 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/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 { 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 diff --git a/qml/Livedata.qml b/qml/Livedata.qml index ab48667..f91515e 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,11 +121,13 @@ 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 } Row { + anchors.bottomMargin: 30 + spacing: 10 Label { text: 'iMotMax:' color: GameSettings.textColor @@ -138,6 +141,7 @@ GamePage { } Row { + spacing: 10 Label { text: 'iDcMax:' color: GameSettings.textColor @@ -153,22 +157,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..28dd285 --- /dev/null +++ b/qml/settings.qml @@ -0,0 +1,92 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import Shared 1.0 + +GamePage { + id: livedatePage + + errorMessage: deviceHandler.error + infoMessage: deviceHandler.info + + function close() + { + deviceHandler.disconnectService(); + app.prevPage(); + } + + Rectangle { + id: viewContainer + anchors.top: parent.top + anchors.topMargin: GameSettings.fieldMargin + messageHeight + anchors.bottomMargin: GameSettings.fieldMargin + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - GameSettings.fieldMargin*2 + color: GameSettings.viewColor + radius: GameSettings.buttonRadius + + + Text { + 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