8 Commits
fixes ... main

16 changed files with 409 additions and 158 deletions

View File

@ -1,33 +1,26 @@
#include "bluetoothbaseclass.h"
BluetoothBaseClass::BluetoothBaseClass(QObject *parent) : QObject(parent)
BluetoothBaseClass::BluetoothBaseClass(QObject *parent) :
QObject{parent}
{
}
QString BluetoothBaseClass::error() const
{
return m_error;
}
QString BluetoothBaseClass::info() const
{
return m_info;
}
void BluetoothBaseClass::setError(const QString &error)
{
if (m_error != error) {
m_error = error;
emit errorChanged();
}
if (m_error == error)
return;
m_error = error;
emit errorChanged();
}
void BluetoothBaseClass::setInfo(const QString &info)
{
if (m_info != info) {
m_info = info;
emit infoChanged();
}
if (m_info == info)
return;
m_info = info;
emit infoChanged();
}
void BluetoothBaseClass::clearMessages()

View File

@ -1,6 +1,6 @@
#ifndef BLUETOOTHBASECLASS_H
#define BLUETOOTHBASECLASS_H
#pragma once
// Qt includes
#include <QObject>
class BluetoothBaseClass : public QObject
@ -12,10 +12,10 @@ class BluetoothBaseClass : public QObject
public:
explicit BluetoothBaseClass(QObject *parent = nullptr);
QString error() const;
QString error() const { return m_error; }
void setError(const QString& error);
QString info() const;
QString info() const { return m_info; }
void setInfo(const QString& info);
void clearMessages();
@ -28,5 +28,3 @@ private:
QString m_error;
QString m_info;
};
#endif // BLUETOOTHBASECLASS_H

View File

@ -9,21 +9,29 @@ HEADERS += \
deviceinfo.h \
devicefinder.h \
devicehandler.h \
bluetoothbaseclass.h
bluetoothbaseclass.h \
settings.h
SOURCES += main.cpp \
SOURCES += \
main.cpp \
connectionhandler.cpp \
deviceinfo.cpp \
devicefinder.cpp \
devicehandler.cpp \
bluetoothbaseclass.cpp
bluetoothbaseclass.cpp \
settings.cpp
RESOURCES += qml.qrc \
RESOURCES += \
qml.qrc \
images.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
CONFIG += qmltypes
QML_IMPORT_NAME = bobbycar
QML_IMPORT_MAJOR_VERSION = 1
DISTFILES += \
android/AndroidManifest.xml \
android/build.gradle \

View File

@ -1,112 +1,190 @@
#include "devicefinder.h"
// system includes
#include <algorithm>
// local includes
#include "devicehandler.h"
#include "deviceinfo.h"
DeviceFinder::DeviceFinder(DeviceHandler *handler, QObject *parent):
BluetoothBaseClass(parent),
m_deviceHandler(handler)
DeviceFinder::DeviceFinder(QObject *parent):
QAbstractItemModel{parent},
m_deviceDiscoveryAgent{this}
{
//! [devicediscovery-1]
m_deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
m_deviceDiscoveryAgent->setLowEnergyDiscoveryTimeout(5000);
m_deviceDiscoveryAgent.setLowEnergyDiscoveryTimeout(5000);
connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &DeviceFinder::addDevice);
connect(m_deviceDiscoveryAgent, static_cast<void (QBluetoothDeviceDiscoveryAgent::*)(QBluetoothDeviceDiscoveryAgent::Error)>(&QBluetoothDeviceDiscoveryAgent::error),
connect(&m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &DeviceFinder::addDevice);
connect(&m_deviceDiscoveryAgent, qOverload<QBluetoothDeviceDiscoveryAgent::Error>(&QBluetoothDeviceDiscoveryAgent::error),
this, &DeviceFinder::scanError);
connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &DeviceFinder::scanFinished);
connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::canceled, this, &DeviceFinder::scanFinished);
//! [devicediscovery-1]
connect(&m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &DeviceFinder::scanFinished);
connect(&m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::canceled, this, &DeviceFinder::scanFinished);
}
DeviceFinder::~DeviceFinder()
QModelIndex DeviceFinder::index(int row, int column, const QModelIndex &parent) const
{
qDeleteAll(m_devices);
m_devices.clear();
Q_UNUSED(parent)
return createIndex(row, column);
}
QModelIndex DeviceFinder::parent(const QModelIndex &child) const
{
Q_UNUSED(child)
return {};
}
int DeviceFinder::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return m_devices.size();
}
int DeviceFinder::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return 1;
}
QVariant DeviceFinder::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
{
qWarning() << "invalid index";
return {};
}
if (index.row() < 0 ||
index.row() >= m_devices.size() ||
index.column() != 0)
{
qWarning() << "index out of bounds" << index;
return {};
}
const auto &device = m_devices.at(index.row());
switch (role)
{
case Qt::DisplayRole:
case Qt::EditRole:
case Qt::UserRole + 1:
return device.name();
case Qt::UserRole + 2:
return device.address().toString();
}
return {};
}
QMap<int, QVariant> DeviceFinder::itemData(const QModelIndex &index) const
{
if (!index.isValid())
{
qWarning() << "invalid index";
return {};
}
if (index.row() < 0 ||
index.row() >= m_devices.size() ||
index.column() != 0)
{
qWarning() << "index out of bounds" << index;
return {};
}
const auto &device = m_devices.at(index.row());
return QMap<int, QVariant> {
{ Qt::UserRole + 1, device.name() },
{ Qt::UserRole + 2, device.address().toString() }
};
}
QHash<int, QByteArray> DeviceFinder::roleNames() const
{
return QHash<int, QByteArray> {
{ Qt::UserRole + 1, QByteArrayLiteral("deviceName") },
{ Qt::UserRole + 2, QByteArrayLiteral("deviceAddress") }
};
}
void DeviceFinder::startSearch()
{
clearMessages();
m_deviceHandler->setDevice(nullptr);
qDeleteAll(m_devices);
beginResetModel();
m_devices.clear();
endResetModel();
emit devicesChanged();
//! [devicediscovery-2]
m_deviceDiscoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
//! [devicediscovery-2]
m_deviceDiscoveryAgent.start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
emit scanningChanged();
setInfo(tr("Scanning for devices..."));
}
//! [devicediscovery-3]
void DeviceFinder::addDevice(const QBluetoothDeviceInfo &device)
{
// If device is LowEnergy-device, add it to the list
if (device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) {
//m_devices.append(new DeviceInfo(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..."));
//! [devicediscovery-3]
emit devicesChanged();
//! [devicediscovery-4]
}
//...
if (!(device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration))
return;
//if (!device.name().contains("bobby"))
// return;
beginInsertRows({}, m_devices.size(), m_devices.size());
m_devices.push_back(device);
endInsertRows();
setInfo(tr("Low Energy device found. Scanning more..."));
}
//! [devicediscovery-4]
void DeviceFinder::scanError(QBluetoothDeviceDiscoveryAgent::Error error)
{
if (error == QBluetoothDeviceDiscoveryAgent::PoweredOffError)
switch (error)
{
case QBluetoothDeviceDiscoveryAgent::PoweredOffError:
setError(tr("The Bluetooth adaptor is powered off."));
else if (error == QBluetoothDeviceDiscoveryAgent::InputOutputError)
break;
case QBluetoothDeviceDiscoveryAgent::InputOutputError:
setError(tr("Writing or reading from the device resulted in an error."));
else
break;
default:
setError(tr("An unknown error has occurred."));
}
}
void DeviceFinder::scanFinished()
{
if (m_devices.isEmpty())
if (m_devices.empty())
setError(tr("No Low Energy devices found."));
else
setInfo(tr("Scanning done."));
emit scanningChanged();
emit devicesChanged();
}
void DeviceFinder::connectToService(const QString &address)
{
m_deviceDiscoveryAgent->stop();
m_deviceDiscoveryAgent.stop();
DeviceInfo *currentDevice = nullptr;
for (QObject *entry : qAsConst(m_devices)) {
auto device = qobject_cast<DeviceInfo *>(entry);
if (device && device->getAddress() == address ) {
currentDevice = device;
break;
}
auto iter = std::find_if(std::cbegin(m_devices), std::cend(m_devices), [&address](const QBluetoothDeviceInfo &device){
return device.address().toString() == address;
});
if (iter == std::cend(m_devices))
{
qWarning() << "could not find address" << address;
setError(tr("could not find address %0").arg(address));
return;
}
if (currentDevice)
m_deviceHandler->setDevice(currentDevice);
if (!m_handler)
{
qWarning() << "no valid handler!";
setError(tr("no valid handler!"));
return;
}
m_handler->setDevice(*iter);
clearMessages();
}
bool DeviceFinder::scanning() const
{
return m_deviceDiscoveryAgent->isActive();
}
QVariant DeviceFinder::devices()
{
return QVariant::fromValue(m_devices);
}

View File

@ -1,48 +1,74 @@
#ifndef DEVICEFINDER_H
#define DEVICEFINDER_H
#pragma once
#include "bluetoothbaseclass.h"
// system includes
#include <memory>
#include <vector>
// Qt includes
#include <QAbstractItemModel>
#include <QTimer>
#include <QVariant>
#include <QBluetoothDeviceDiscoveryAgent>
#include <QBluetoothDeviceInfo>
#include <QtQml/qqml.h>
class DeviceInfo;
// forward declares
class DeviceHandler;
class DeviceFinder: public BluetoothBaseClass
class DeviceFinder : public QAbstractItemModel
{
Q_OBJECT
Q_PROPERTY(bool scanning READ scanning NOTIFY scanningChanged)
Q_PROPERTY(QVariant devices READ devices NOTIFY devicesChanged)
Q_PROPERTY(DeviceHandler* handler READ handler WRITE setHandler NOTIFY handlerChanged)
Q_PROPERTY(QString error READ error WRITE setError NOTIFY errorChanged)
Q_PROPERTY(QString info READ info WRITE setInfo NOTIFY infoChanged)
QML_ELEMENT
public:
DeviceFinder(DeviceHandler *handler, QObject *parent = nullptr);
~DeviceFinder();
DeviceFinder(QObject *parent = nullptr);
bool scanning() const;
QVariant devices();
bool scanning() const { return m_deviceDiscoveryAgent.isActive(); }
DeviceHandler* handler() { return m_handler; }
const DeviceHandler* handler() const { return m_handler; }
void setHandler(DeviceHandler* handler) { if (m_handler == handler) return; m_handler = handler; emit handlerChanged(); }
QString error() const { return m_error; }
void setError(const QString& error) { if (m_error == error) return; m_error = error; emit errorChanged(); }
QString info() const { return m_info; }
void setInfo(const QString& info) { if (m_info == info) return; m_info = info; emit infoChanged(); }
void clearMessages() { setInfo(""); setError(""); }
// QAbstractItemModel interface
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
QModelIndex parent(const QModelIndex &child) const override;
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QMap<int, QVariant> itemData(const QModelIndex &index) const override;
QHash<int, QByteArray> roleNames() const override;
signals:
void scanningChanged();
void handlerChanged();
void errorChanged();
void infoChanged();
public slots:
void startSearch();
void connectToService(const QString &address);
private slots:
void addDevice(const QBluetoothDeviceInfo&);
void addDevice(const QBluetoothDeviceInfo &);
void scanError(QBluetoothDeviceDiscoveryAgent::Error error);
void scanFinished();
signals:
void scanningChanged();
void devicesChanged();
private:
DeviceHandler *m_deviceHandler;
QBluetoothDeviceDiscoveryAgent *m_deviceDiscoveryAgent;
QList<QObject*> m_devices;
DeviceHandler *m_handler{};
QBluetoothDeviceDiscoveryAgent m_deviceDiscoveryAgent;
std::vector<QBluetoothDeviceInfo> m_devices;
QString m_error;
QString m_info;
};
#endif // DEVICEFINDER_H

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) :
@ -24,7 +27,7 @@ DeviceHandler::DeviceHandler(QObject *parent) :
{
}
void DeviceHandler::setDevice(DeviceInfo *device)
void DeviceHandler::setDevice(const QBluetoothDeviceInfo &device)
{
clearMessages();
m_currentDevice = device;
@ -38,14 +41,12 @@ void DeviceHandler::setDevice(DeviceInfo *device)
}
// Create new controller and connect it if device available
if (m_currentDevice)
if (m_currentDevice.isValid())
{
// Make connections
//! [Connect-Signals-1]
m_control = QLowEnergyController::createCentral(m_currentDevice->getDevice(), this);
//! [Connect-Signals-1]
m_control = QLowEnergyController::createCentral(m_currentDevice, this);
m_control->setRemoteAddressType(m_addressType);
//! [Connect-Signals-2]
connect(m_control, &QLowEnergyController::serviceDiscovered,
this, &DeviceHandler::serviceDiscovered);
connect(m_control, &QLowEnergyController::discoveryFinished,
@ -66,13 +67,13 @@ void DeviceHandler::setDevice(DeviceInfo *device)
// Connect
m_control->connectToDevice();
//! [Connect-Signals-2]
}
}
void DeviceHandler::setAddressType(AddressType type)
{
switch (type) {
switch (type)
{
case DeviceHandler::AddressType::PublicAddress:
m_addressType = QLowEnergyController::PublicAddress;
break;
@ -348,6 +349,7 @@ void DeviceHandler::confirmedDescriptorWrite(const QLowEnergyDescriptor &d, cons
void DeviceHandler::confirmedCharacteristicWrite(const QLowEnergyCharacteristic &info, const QByteArray &value)
{
Q_UNUSED(value)
qDebug() << "confirmedCharacteristicWrite";
if (info == m_remotecontrolCharacteristic)

View File

@ -1,15 +1,15 @@
#ifndef DEVICEHANDLER_H
#define DEVICEHANDLER_H
#include "bluetoothbaseclass.h"
#pragma once
// Qt includes
#include <QDateTime>
#include <QTimer>
#include <QVector>
#include <QLowEnergyController>
#include <QLowEnergyService>
// local includes
#include "bluetoothbaseclass.h"
class DeviceInfo;
class DeviceHandler : public BluetoothBaseClass
@ -49,7 +49,7 @@ public:
DeviceHandler(QObject *parent = nullptr);
void setDevice(DeviceInfo *device);
void setDevice(const QBluetoothDeviceInfo &device);
void setAddressType(AddressType type);
AddressType addressType() const;
@ -131,7 +131,7 @@ private:
QLowEnergyService *m_service = nullptr;
QLowEnergyDescriptor m_notificationDescLivestats;
QLowEnergyCharacteristic m_remotecontrolCharacteristic;
DeviceInfo *m_currentDevice{};
QBluetoothDeviceInfo m_currentDevice;
bool m_foundBobbycarService{};
@ -161,5 +161,3 @@ private:
bool m_waitingForWrite{};
};
#endif // DEVICEHANDLER_H

View File

@ -15,13 +15,11 @@ int main(int argc, char *argv[])
ConnectionHandler connectionHandler;
DeviceHandler deviceHandler;
DeviceFinder deviceFinder(&deviceHandler);
qmlRegisterUncreatableType<DeviceHandler>("Shared", 1, 0, "AddressType", "Enum is not a type");
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("connectionHandler", &connectionHandler);
engine.rootContext()->setContextProperty("deviceFinder", &deviceFinder);
engine.rootContext()->setContextProperty("deviceHandler", &deviceHandler);
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));

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,7 +1,16 @@
import QtQuick 2.15
import Shared 1.0
import bobbycar 1.0
GamePage {
DeviceFinder {
id: deviceFinder
handler: deviceHandler
}
function init() {
deviceFinder.startSearch()
}
errorMessage: deviceFinder.error
infoMessage: deviceFinder.info
@ -44,7 +53,7 @@ GamePage {
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.top: title.bottom
model: deviceFinder.devices
model: deviceFinder
clip: true
delegate: Rectangle {
@ -56,15 +65,15 @@ GamePage {
MouseArea {
anchors.fill: parent
onClicked: {
deviceFinder.connectToService(modelData.deviceAddress);
deviceFinder.connectToService(deviceAddress);
app.showPage("Livedata.qml")
}
}
Text {
id: device
//id: device
font.pixelSize: GameSettings.smallFontSize
text: modelData.deviceName
text: deviceName
anchors.top: parent.top
anchors.topMargin: parent.height * 0.1
anchors.leftMargin: parent.height * 0.1
@ -73,9 +82,9 @@ GamePage {
}
Text {
id: deviceAddress
//id: deviceAddress
font.pixelSize: GameSettings.smallFontSize
text: modelData.deviceAddress
text: deviceAddress
anchors.bottom: parent.bottom
anchors.bottomMargin: parent.height * 0.1
anchors.rightMargin: parent.height * 0.1

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