Merge remote-tracking branch 'origin/comr'

This commit is contained in:
2021-08-17 12:47:51 +02:00
11 changed files with 175 additions and 24 deletions

View File

@ -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

View File

@ -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]

View File

@ -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) :

View File

@ -15,5 +15,6 @@
<file>qml/BottomLine.qml</file>
<file>qml/StatsLabel.qml</file>
<file>qml/qmldir</file>
<file>qml/settings.qml</file>
</qresource>
</RCC>

View File

@ -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 {

View File

@ -1,8 +1,13 @@
import QtQuick 2.15
import Shared 1.0
GamePage {
function init() {
deviceFinder.startSearch()
}
errorMessage: deviceFinder.error
infoMessage: deviceFinder.info

View File

@ -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
}
}
}
}

View File

@ -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

92
qml/settings.qml Normal file
View File

@ -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)
}*/
}
}
}
}

6
settings.cpp Normal file
View File

@ -0,0 +1,6 @@
#include "settings.h"
settings::settings()
{
}

11
settings.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef SETTINGS_H
#define SETTINGS_H
class settings
{
public:
settings();
};
#endif // SETTINGS_H