better init visuals
This commit is contained in:
parent
bfd197a016
commit
613cea8c6f
@ -43,6 +43,8 @@ void DeviceManager::clear()
|
|||||||
|
|
||||||
void DeviceManager::init()
|
void DeviceManager::init()
|
||||||
{
|
{
|
||||||
|
m_fetchingData = true;
|
||||||
|
emit fetchingDataChanged();
|
||||||
m_jsonClient->sendCommand("Devices.GetPlugins", this, "getPluginsResponse");
|
m_jsonClient->sendCommand("Devices.GetPlugins", this, "getPluginsResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +73,11 @@ DeviceClasses *DeviceManager::deviceClasses() const
|
|||||||
return m_deviceClasses;
|
return m_deviceClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DeviceManager::fetchingData() const
|
||||||
|
{
|
||||||
|
return m_fetchingData;
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceManager::addDevice(const QUuid &deviceClassId, const QString &name, const QVariantList &deviceParams)
|
void DeviceManager::addDevice(const QUuid &deviceClassId, const QString &name, const QVariantList &deviceParams)
|
||||||
{
|
{
|
||||||
qDebug() << "add device " << deviceClassId.toString();
|
qDebug() << "add device " << deviceClassId.toString();
|
||||||
@ -218,6 +225,8 @@ void DeviceManager::getConfiguredDevicesResponse(const QVariantMap ¶ms)
|
|||||||
Engine::instance()->deviceManager()->devices()->addDevice(device);
|
Engine::instance()->deviceManager()->devices()->addDevice(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_fetchingData = false;
|
||||||
|
emit fetchingDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::addDeviceResponse(const QVariantMap ¶ms)
|
void DeviceManager::addDeviceResponse(const QVariantMap ¶ms)
|
||||||
|
|||||||
@ -38,6 +38,8 @@ class DeviceManager : public JsonHandler
|
|||||||
Q_PROPERTY(Devices *devices READ devices CONSTANT)
|
Q_PROPERTY(Devices *devices READ devices CONSTANT)
|
||||||
Q_PROPERTY(DeviceClasses *deviceClasses READ deviceClasses CONSTANT)
|
Q_PROPERTY(DeviceClasses *deviceClasses READ deviceClasses CONSTANT)
|
||||||
|
|
||||||
|
Q_PROPERTY(bool fetchingData READ fetchingData NOTIFY fetchingDataChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeviceManager(JsonRpcClient *jsonclient, QObject *parent = 0);
|
explicit DeviceManager(JsonRpcClient *jsonclient, QObject *parent = 0);
|
||||||
|
|
||||||
@ -51,6 +53,8 @@ public:
|
|||||||
Devices *devices() const;
|
Devices *devices() const;
|
||||||
DeviceClasses *deviceClasses() const;
|
DeviceClasses *deviceClasses() const;
|
||||||
|
|
||||||
|
bool fetchingData() const;
|
||||||
|
|
||||||
Q_INVOKABLE void addDevice(const QUuid &deviceClassId, const QString &name, const QVariantList &deviceParams);
|
Q_INVOKABLE void addDevice(const QUuid &deviceClassId, const QString &name, const QVariantList &deviceParams);
|
||||||
Q_INVOKABLE void addDiscoveredDevice(const QUuid &deviceClassId, const QUuid &deviceDescriptorId, const QString &name);
|
Q_INVOKABLE void addDiscoveredDevice(const QUuid &deviceClassId, const QUuid &deviceDescriptorId, const QString &name);
|
||||||
Q_INVOKABLE void pairDevice(const QUuid &deviceClassId, const QUuid &deviceDescriptorId, const QString &name);
|
Q_INVOKABLE void pairDevice(const QUuid &deviceClassId, const QUuid &deviceDescriptorId, const QString &name);
|
||||||
@ -80,6 +84,7 @@ signals:
|
|||||||
void addDeviceReply(const QVariantMap ¶ms);
|
void addDeviceReply(const QVariantMap ¶ms);
|
||||||
void removeDeviceReply(const QVariantMap ¶ms);
|
void removeDeviceReply(const QVariantMap ¶ms);
|
||||||
void savePluginConfigReply(const QVariantMap ¶ms);
|
void savePluginConfigReply(const QVariantMap ¶ms);
|
||||||
|
void fetchingDataChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vendors *m_vendors;
|
Vendors *m_vendors;
|
||||||
@ -87,6 +92,8 @@ private:
|
|||||||
Devices *m_devices;
|
Devices *m_devices;
|
||||||
DeviceClasses *m_deviceClasses;
|
DeviceClasses *m_deviceClasses;
|
||||||
|
|
||||||
|
bool m_fetchingData = false;
|
||||||
|
|
||||||
int m_currentGetConfigIndex = 0;
|
int m_currentGetConfigIndex = 0;
|
||||||
|
|
||||||
JsonRpcClient *m_jsonClient = nullptr;
|
JsonRpcClient *m_jsonClient = nullptr;
|
||||||
|
|||||||
@ -35,11 +35,6 @@ QList<Device *> Devices::devices()
|
|||||||
return m_devices;
|
return m_devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Devices::count() const
|
|
||||||
{
|
|
||||||
return m_devices.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
Device *Devices::get(int index) const
|
Device *Devices::get(int index) const
|
||||||
{
|
{
|
||||||
return m_devices.at(index);
|
return m_devices.at(index);
|
||||||
@ -95,6 +90,7 @@ void Devices::addDevice(Device *device)
|
|||||||
// qDebug() << "Devices: add device" << device->name();
|
// qDebug() << "Devices: add device" << device->name();
|
||||||
m_devices.append(device);
|
m_devices.append(device);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Devices::removeDevice(Device *device)
|
void Devices::removeDevice(Device *device)
|
||||||
@ -104,6 +100,7 @@ void Devices::removeDevice(Device *device)
|
|||||||
qDebug() << "Devices: removed device" << device->name();
|
qDebug() << "Devices: removed device" << device->name();
|
||||||
m_devices.removeAt(index);
|
m_devices.removeAt(index);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Devices::clearModel()
|
void Devices::clearModel()
|
||||||
@ -113,6 +110,7 @@ void Devices::clearModel()
|
|||||||
qDeleteAll(m_devices);
|
qDeleteAll(m_devices);
|
||||||
m_devices.clear();
|
m_devices.clear();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> Devices::roleNames() const
|
QHash<int, QByteArray> Devices::roleNames() const
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
class Devices : public QAbstractListModel
|
class Devices : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||||
public:
|
public:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
RoleName,
|
RoleName,
|
||||||
@ -47,7 +48,6 @@ public:
|
|||||||
|
|
||||||
QList<Device *> devices();
|
QList<Device *> devices();
|
||||||
|
|
||||||
Q_INVOKABLE int count() const;
|
|
||||||
Q_INVOKABLE Device *get(int index) const;
|
Q_INVOKABLE Device *get(int index) const;
|
||||||
Q_INVOKABLE Device *getDevice(const QUuid &deviceId) const;
|
Q_INVOKABLE Device *getDevice(const QUuid &deviceId) const;
|
||||||
|
|
||||||
@ -64,6 +64,9 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
QHash<int, QByteArray> roleNames() const;
|
QHash<int, QByteArray> roleNames() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void countChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Device *> m_devices;
|
QList<Device *> m_devices;
|
||||||
|
|
||||||
|
|||||||
@ -188,7 +188,7 @@ void DevicesBasicTagsModel::syncTags()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<DeviceClass::BasicTag> tagsInSource;
|
QList<DeviceClass::BasicTag> tagsInSource;
|
||||||
for (int i = 0; i < m_devices->count(); i++) {
|
for (int i = 0; i < m_devices->rowCount(); i++) {
|
||||||
DeviceClass *dc = Engine::instance()->deviceManager()->deviceClasses()->getDeviceClass(m_devices->get(i)->deviceClassId());
|
DeviceClass *dc = Engine::instance()->deviceManager()->deviceClasses()->getDeviceClass(m_devices->get(i)->deviceClassId());
|
||||||
foreach (DeviceClass::BasicTag tag, dc->basicTags()) {
|
foreach (DeviceClass::BasicTag tag, dc->basicTags()) {
|
||||||
if (!tagsInSource.contains(tag)) {
|
if (!tagsInSource.contains(tag)) {
|
||||||
|
|||||||
@ -68,7 +68,7 @@ void InterfacesModel::syncInterfaces()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList interfacesInSource;
|
QStringList interfacesInSource;
|
||||||
for (int i = 0; i < m_devices->count(); i++) {
|
for (int i = 0; i < m_devices->rowCount(); i++) {
|
||||||
DeviceClass *dc = Engine::instance()->deviceManager()->deviceClasses()->getDeviceClass(m_devices->get(i)->deviceClassId());
|
DeviceClass *dc = Engine::instance()->deviceManager()->deviceClasses()->getDeviceClass(m_devices->get(i)->deviceClassId());
|
||||||
// qDebug() << "device" <<dc->name() << "has interfaces" << dc->interfaces();
|
// qDebug() << "device" <<dc->name() << "has interfaces" << dc->interfaces();
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
#include <QtQml/QQmlContext>
|
#include <QtQml/QQmlContext>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QtQuickControls2>
|
#include <QtQuickControls2>
|
||||||
|
#include <QSysInfo>
|
||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "vendorsproxy.h"
|
#include "vendorsproxy.h"
|
||||||
@ -79,10 +80,13 @@ int main(int argc, char *argv[])
|
|||||||
applicationFont.setWeight(QFont::Normal);
|
applicationFont.setWeight(QFont::Normal);
|
||||||
QGuiApplication::setFont(applicationFont);
|
QGuiApplication::setFont(applicationFont);
|
||||||
|
|
||||||
QQuickStyle::setStyle("Material");
|
QSettings settings;
|
||||||
|
QQuickStyle::setStyle(settings.value("style", "Material").toString());
|
||||||
|
|
||||||
const char uri[] = "Mea";
|
const char uri[] = "Mea";
|
||||||
|
|
||||||
|
qDebug() << "Running on" << QSysInfo::machineHostName() << QSysInfo::prettyProductName() << QSysInfo::productType() << QSysInfo::productVersion();
|
||||||
|
|
||||||
qmlRegisterSingletonType<Engine>(uri, 1, 0, "Engine", Engine::qmlInstance);
|
qmlRegisterSingletonType<Engine>(uri, 1, 0, "Engine", Engine::qmlInstance);
|
||||||
|
|
||||||
qmlRegisterUncreatableType<DeviceManager>(uri, 1, 0, "DeviceManager", "Can't create this in QML. Get it from the Core.");
|
qmlRegisterUncreatableType<DeviceManager>(uri, 1, 0, "DeviceManager", "Can't create this in QML. Get it from the Core.");
|
||||||
|
|||||||
@ -103,7 +103,24 @@ Page {
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: app.margins }
|
anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: app.margins }
|
||||||
spacing: app.margins
|
spacing: app.margins
|
||||||
visible: Engine.deviceManager.devices.count === 0
|
visible: Engine.deviceManager.fetchingData
|
||||||
|
BusyIndicator {
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
running: parent.visible
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
text: "Loading data..."
|
||||||
|
font.pixelSize: app.largeFont
|
||||||
|
Layout.fillWidth: true
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: app.margins }
|
||||||
|
spacing: app.margins
|
||||||
|
visible: Engine.deviceManager.devices.count === 0 && !Engine.deviceManager.fetchingData
|
||||||
Label {
|
Label {
|
||||||
text: "Welcome to nymea!"
|
text: "Welcome to nymea!"
|
||||||
font.pixelSize: app.largeFont
|
font.pixelSize: app.largeFont
|
||||||
|
|||||||
@ -59,6 +59,7 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Label {
|
Label {
|
||||||
|
|||||||
@ -91,6 +91,13 @@ ApplicationWindow {
|
|||||||
initialItem: Page {}
|
initialItem: Page {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClosing: {
|
||||||
|
if (Qt.platform.os == "android") {
|
||||||
|
close.accepted = false;
|
||||||
|
if (pageStack.depth > 1) pageStack.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NymeaDiscovery {
|
NymeaDiscovery {
|
||||||
id: discovery
|
id: discovery
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user