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