Merge PR #130: Add support for reconfiguring devices
This commit is contained in:
commit
8cf984fd21
@ -628,7 +628,7 @@ void AWSClient::registerPushNotificationEndpoint(const QString ®istrationId,
|
|||||||
payload.insert("mobileDeviceUuid", mobileDeviceId);
|
payload.insert("mobileDeviceUuid", mobileDeviceId);
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromVariant(payload);
|
QJsonDocument jsonDoc = QJsonDocument::fromVariant(payload);
|
||||||
|
|
||||||
qDebug() << "Registering push notification endpoint";
|
qDebug() << "Registering push notification endpoint" << mobileDeviceId;
|
||||||
// qDebug() << "POST" << url.toString();
|
// qDebug() << "POST" << url.toString();
|
||||||
// qDebug() << "HEADERS:";
|
// qDebug() << "HEADERS:";
|
||||||
// foreach (const QByteArray &hdr, request.rawHeaderList()) {
|
// foreach (const QByteArray &hdr, request.rawHeaderList()) {
|
||||||
|
|||||||
@ -22,6 +22,8 @@ QVariant DeviceDiscovery::data(const QModelIndex &index, int role) const
|
|||||||
return m_foundDevices.at(index.row())->name();
|
return m_foundDevices.at(index.row())->name();
|
||||||
case RoleDescription:
|
case RoleDescription:
|
||||||
return m_foundDevices.at(index.row())->description();
|
return m_foundDevices.at(index.row())->description();
|
||||||
|
case RoleDeviceId:
|
||||||
|
return m_foundDevices.at(index.row())->deviceId();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -31,6 +33,7 @@ QHash<int, QByteArray> DeviceDiscovery::roleNames() const
|
|||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles.insert(RoleId, "id");
|
roles.insert(RoleId, "id");
|
||||||
|
roles.insert(RoleDeviceId, "deviceId");
|
||||||
roles.insert(RoleName, "name");
|
roles.insert(RoleName, "name");
|
||||||
roles.insert(RoleDescription, "description");
|
roles.insert(RoleDescription, "description");
|
||||||
return roles;
|
return roles;
|
||||||
@ -104,6 +107,7 @@ void DeviceDiscovery::discoverDevicesResponse(const QVariantMap ¶ms)
|
|||||||
if (!contains(descriptorVariant.toMap().value("id").toUuid())) {
|
if (!contains(descriptorVariant.toMap().value("id").toUuid())) {
|
||||||
beginInsertRows(QModelIndex(), m_foundDevices.count(), m_foundDevices.count());
|
beginInsertRows(QModelIndex(), m_foundDevices.count(), m_foundDevices.count());
|
||||||
DeviceDescriptor *descriptor = new DeviceDescriptor(descriptorVariant.toMap().value("id").toUuid(),
|
DeviceDescriptor *descriptor = new DeviceDescriptor(descriptorVariant.toMap().value("id").toUuid(),
|
||||||
|
descriptorVariant.toMap().value("deviceId").toString(),
|
||||||
descriptorVariant.toMap().value("title").toString(),
|
descriptorVariant.toMap().value("title").toString(),
|
||||||
descriptorVariant.toMap().value("description").toString());
|
descriptorVariant.toMap().value("description").toString());
|
||||||
foreach (const QVariant ¶mVariant, descriptorVariant.toMap().value("deviceParams").toList()) {
|
foreach (const QVariant ¶mVariant, descriptorVariant.toMap().value("deviceParams").toList()) {
|
||||||
@ -128,9 +132,10 @@ bool DeviceDiscovery::contains(const QUuid &deviceDescriptorId) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceDescriptor::DeviceDescriptor(const QUuid &id, const QString &name, const QString &description, QObject *parent):
|
DeviceDescriptor::DeviceDescriptor(const QUuid &id, const QUuid &deviceId, const QString &name, const QString &description, QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_id(id),
|
m_id(id),
|
||||||
|
m_deviceId(deviceId),
|
||||||
m_name(name),
|
m_name(name),
|
||||||
m_description(description),
|
m_description(description),
|
||||||
m_params(new Params(this))
|
m_params(new Params(this))
|
||||||
@ -143,6 +148,11 @@ QUuid DeviceDescriptor::id() const
|
|||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUuid DeviceDescriptor::deviceId() const
|
||||||
|
{
|
||||||
|
return m_deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
QString DeviceDescriptor::name() const
|
QString DeviceDescriptor::name() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
@ -157,3 +167,92 @@ Params* DeviceDescriptor::params() const
|
|||||||
{
|
{
|
||||||
return m_params;
|
return m_params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceDiscoveryProxy::DeviceDiscoveryProxy(QObject *parent):
|
||||||
|
QSortFilterProxyModel (parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceDiscovery *DeviceDiscoveryProxy::deviceDiscovery() const
|
||||||
|
{
|
||||||
|
return m_deviceDiscovery;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceDiscoveryProxy::setDeviceDiscovery(DeviceDiscovery *deviceDiscovery)
|
||||||
|
{
|
||||||
|
if (m_deviceDiscovery != deviceDiscovery) {
|
||||||
|
m_deviceDiscovery = deviceDiscovery;
|
||||||
|
setSourceModel(deviceDiscovery);
|
||||||
|
emit deviceDiscoveryChanged();
|
||||||
|
emit countChanged();
|
||||||
|
connect(m_deviceDiscovery, &DeviceDiscovery::countChanged, this, &DeviceDiscoveryProxy::countChanged);
|
||||||
|
invalidateFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceDiscoveryProxy::showAlreadyAdded() const
|
||||||
|
{
|
||||||
|
return m_showAlreadyAdded;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceDiscoveryProxy::setShowAlreadyAdded(bool showAlreadyAdded)
|
||||||
|
{
|
||||||
|
if (m_showAlreadyAdded != showAlreadyAdded) {
|
||||||
|
m_showAlreadyAdded = showAlreadyAdded;
|
||||||
|
emit showAlreadyAddedChanged();
|
||||||
|
invalidateFilter();
|
||||||
|
emit countChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceDiscoveryProxy::showNew() const
|
||||||
|
{
|
||||||
|
return m_showNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceDiscoveryProxy::setShowNew(bool showNew)
|
||||||
|
{
|
||||||
|
if (m_showNew != showNew) {
|
||||||
|
m_showNew = showNew;
|
||||||
|
emit showNewChanged();
|
||||||
|
invalidateFilter();
|
||||||
|
emit countChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QUuid DeviceDiscoveryProxy::filterDeviceId() const
|
||||||
|
{
|
||||||
|
return m_filterDeviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceDiscoveryProxy::setFilterDeviceId(const QUuid &filterDeviceId)
|
||||||
|
{
|
||||||
|
if (m_filterDeviceId != filterDeviceId) {
|
||||||
|
m_filterDeviceId = filterDeviceId;
|
||||||
|
emit filterDeviceIdChanged();
|
||||||
|
invalidateFilter();
|
||||||
|
emit countChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceDescriptor *DeviceDiscoveryProxy::get(int index) const
|
||||||
|
{
|
||||||
|
return m_deviceDiscovery->get(mapToSource(this->index(index, 0)).row());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceDiscoveryProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(sourceParent)
|
||||||
|
DeviceDescriptor* dev = m_deviceDiscovery->get(sourceRow);
|
||||||
|
if (!m_showAlreadyAdded && !dev->deviceId().isNull()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!m_showNew && dev->deviceId().isNull()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!m_filterDeviceId.isNull() && dev->deviceId() != m_filterDeviceId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@ -9,19 +9,22 @@
|
|||||||
class DeviceDescriptor: public QObject {
|
class DeviceDescriptor: public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QUuid id READ id CONSTANT)
|
Q_PROPERTY(QUuid id READ id CONSTANT)
|
||||||
|
Q_PROPERTY(QUuid deviceId READ deviceId CONSTANT)
|
||||||
Q_PROPERTY(QString name READ name CONSTANT)
|
Q_PROPERTY(QString name READ name CONSTANT)
|
||||||
Q_PROPERTY(QString description READ description CONSTANT)
|
Q_PROPERTY(QString description READ description CONSTANT)
|
||||||
Q_PROPERTY(Params* params READ params CONSTANT)
|
Q_PROPERTY(Params* params READ params CONSTANT)
|
||||||
public:
|
public:
|
||||||
DeviceDescriptor(const QUuid &id, const QString &name, const QString &description, QObject *parent = nullptr);
|
DeviceDescriptor(const QUuid &id, const QUuid &deviceId, const QString &name, const QString &description, QObject *parent = nullptr);
|
||||||
|
|
||||||
QUuid id() const;
|
QUuid id() const;
|
||||||
|
QUuid deviceId() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
QString description() const;
|
QString description() const;
|
||||||
Params* params() const;
|
Params* params() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUuid m_id;
|
QUuid m_id;
|
||||||
|
QUuid m_deviceId;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_description;
|
QString m_description;
|
||||||
Params *m_params = nullptr;
|
Params *m_params = nullptr;
|
||||||
@ -36,6 +39,7 @@ class DeviceDiscovery : public QAbstractListModel
|
|||||||
public:
|
public:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
RoleId,
|
RoleId,
|
||||||
|
RoleDeviceId,
|
||||||
RoleName,
|
RoleName,
|
||||||
RoleDescription
|
RoleDescription
|
||||||
};
|
};
|
||||||
@ -72,4 +76,47 @@ private:
|
|||||||
QList<DeviceDescriptor*> m_foundDevices;
|
QList<DeviceDescriptor*> m_foundDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DeviceDiscoveryProxy: public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||||
|
Q_PROPERTY(DeviceDiscovery* deviceDiscovery READ deviceDiscovery WRITE setDeviceDiscovery NOTIFY deviceDiscoveryChanged)
|
||||||
|
Q_PROPERTY(bool showAlreadyAdded READ showAlreadyAdded WRITE setShowAlreadyAdded NOTIFY showAlreadyAddedChanged)
|
||||||
|
Q_PROPERTY(bool showNew READ showNew WRITE setShowNew NOTIFY showNewChanged)
|
||||||
|
Q_PROPERTY(QUuid filterDeviceId READ filterDeviceId WRITE setFilterDeviceId NOTIFY filterDeviceIdChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
DeviceDiscoveryProxy(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
DeviceDiscovery* deviceDiscovery() const;
|
||||||
|
void setDeviceDiscovery(DeviceDiscovery* deviceDiscovery);
|
||||||
|
|
||||||
|
bool showAlreadyAdded() const;
|
||||||
|
void setShowAlreadyAdded(bool showAlreadyAdded);
|
||||||
|
|
||||||
|
bool showNew() const;
|
||||||
|
void setShowNew(bool showNew);
|
||||||
|
|
||||||
|
QUuid filterDeviceId() const;
|
||||||
|
void setFilterDeviceId(const QUuid &filterDeviceId);
|
||||||
|
|
||||||
|
Q_INVOKABLE DeviceDescriptor* get(int index) const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void countChanged();
|
||||||
|
void deviceDiscoveryChanged();
|
||||||
|
void showAlreadyAddedChanged();
|
||||||
|
void showNewChanged();
|
||||||
|
void filterDeviceIdChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DeviceDiscovery* m_deviceDiscovery = nullptr;
|
||||||
|
bool m_showAlreadyAdded = false;
|
||||||
|
bool m_showNew = true;
|
||||||
|
QUuid m_filterDeviceId;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // DEVICEDISCOVERY_H
|
#endif // DEVICEDISCOVERY_H
|
||||||
|
|||||||
@ -302,6 +302,12 @@ void DeviceManager::executeActionResponse(const QVariantMap ¶ms)
|
|||||||
emit executeActionReply(params);
|
emit executeActionReply(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceManager::reconfigureDeviceResponse(const QVariantMap ¶ms)
|
||||||
|
{
|
||||||
|
qDebug() << "Reconfigure device response" << params;
|
||||||
|
emit reconfigureDeviceReply(params.value("params").toMap());
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceManager::savePluginConfig(const QUuid &pluginId)
|
void DeviceManager::savePluginConfig(const QUuid &pluginId)
|
||||||
{
|
{
|
||||||
Plugin *p = m_plugins->getPlugin(pluginId);
|
Plugin *p = m_plugins->getPlugin(pluginId);
|
||||||
@ -369,6 +375,22 @@ void DeviceManager::editDevice(const QUuid &deviceId, const QString &name)
|
|||||||
m_jsonClient->sendCommand("Devices.EditDevice", params, this, "editDeviceResponse");
|
m_jsonClient->sendCommand("Devices.EditDevice", params, this, "editDeviceResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceManager::reconfigureDevice(const QUuid &deviceId, const QVariantList &deviceParams)
|
||||||
|
{
|
||||||
|
QVariantMap params;
|
||||||
|
params.insert("deviceId", deviceId.toString());
|
||||||
|
params.insert("deviceParams", deviceParams);
|
||||||
|
m_jsonClient->sendCommand("Devices.ReconfigureDevice", params, this, "reconfigureDeviceResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceManager::reconfigureDiscoveredDevice(const QUuid &deviceId, const QUuid &deviceDescriptorId)
|
||||||
|
{
|
||||||
|
QVariantMap params;
|
||||||
|
params.insert("deviceId", deviceId.toString());
|
||||||
|
params.insert("deviceDescriptorId", deviceDescriptorId);
|
||||||
|
m_jsonClient->sendCommand("Devices.ReconfigureDevice", params, this, "reconfigureDeviceResponse");
|
||||||
|
}
|
||||||
|
|
||||||
int DeviceManager::executeAction(const QUuid &deviceId, const QUuid &actionTypeId, const QVariantList ¶ms)
|
int DeviceManager::executeAction(const QUuid &deviceId, const QUuid &actionTypeId, const QVariantList ¶ms)
|
||||||
{
|
{
|
||||||
// qDebug() << "JsonRpc: execute action " << deviceId.toString() << actionTypeId.toString() << params;
|
// qDebug() << "JsonRpc: execute action " << deviceId.toString() << actionTypeId.toString() << params;
|
||||||
|
|||||||
@ -69,6 +69,8 @@ public:
|
|||||||
Q_INVOKABLE void confirmPairing(const QUuid &pairingTransactionId, const QString &secret = QString());
|
Q_INVOKABLE void confirmPairing(const QUuid &pairingTransactionId, const QString &secret = QString());
|
||||||
Q_INVOKABLE void removeDevice(const QUuid &deviceId, RemovePolicy policy = RemovePolicyNone);
|
Q_INVOKABLE void removeDevice(const QUuid &deviceId, RemovePolicy policy = RemovePolicyNone);
|
||||||
Q_INVOKABLE void editDevice(const QUuid &deviceId, const QString &name);
|
Q_INVOKABLE void editDevice(const QUuid &deviceId, const QString &name);
|
||||||
|
Q_INVOKABLE void reconfigureDevice(const QUuid &deviceId, const QVariantList &deviceParams);
|
||||||
|
Q_INVOKABLE void reconfigureDiscoveredDevice(const QUuid &deviceId, const QUuid &deviceDescriptorId);
|
||||||
Q_INVOKABLE int executeAction(const QUuid &deviceId, const QUuid &actionTypeId, const QVariantList ¶ms = QVariantList());
|
Q_INVOKABLE int executeAction(const QUuid &deviceId, const QUuid &actionTypeId, const QVariantList ¶ms = QVariantList());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -85,6 +87,7 @@ private:
|
|||||||
Q_INVOKABLE void setPluginConfigResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void setPluginConfigResponse(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void editDeviceResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void editDeviceResponse(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void executeActionResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void executeActionResponse(const QVariantMap ¶ms);
|
||||||
|
Q_INVOKABLE void reconfigureDeviceResponse(const QVariantMap ¶ms);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void savePluginConfig(const QUuid &pluginId);
|
void savePluginConfig(const QUuid &pluginId);
|
||||||
@ -96,6 +99,7 @@ signals:
|
|||||||
void removeDeviceReply(const QVariantMap ¶ms);
|
void removeDeviceReply(const QVariantMap ¶ms);
|
||||||
void savePluginConfigReply(const QVariantMap ¶ms);
|
void savePluginConfigReply(const QVariantMap ¶ms);
|
||||||
void editDeviceReply(const QVariantMap ¶ms);
|
void editDeviceReply(const QVariantMap ¶ms);
|
||||||
|
void reconfigureDeviceReply(const QVariantMap ¶ms);
|
||||||
void executeActionReply(const QVariantMap ¶ms);
|
void executeActionReply(const QVariantMap ¶ms);
|
||||||
void fetchingDataChanged();
|
void fetchingDataChanged();
|
||||||
void notificationReceived(const QString &deviceId, const QString &eventTypeId, const QVariantList ¶ms);
|
void notificationReceived(const QString &deviceId, const QString &eventTypeId, const QVariantList ¶ms);
|
||||||
|
|||||||
@ -114,6 +114,7 @@ void registerQmlTypes() {
|
|||||||
qmlRegisterUncreatableType<DeviceClasses>(uri, 1, 0, "DeviceClasses", "Can't create this in QML. Get it from the DeviceManager.");
|
qmlRegisterUncreatableType<DeviceClasses>(uri, 1, 0, "DeviceClasses", "Can't create this in QML. Get it from the DeviceManager.");
|
||||||
qmlRegisterType<DeviceClassesProxy>(uri, 1, 0, "DeviceClassesProxy");
|
qmlRegisterType<DeviceClassesProxy>(uri, 1, 0, "DeviceClassesProxy");
|
||||||
qmlRegisterType<DeviceDiscovery>(uri, 1, 0, "DeviceDiscovery");
|
qmlRegisterType<DeviceDiscovery>(uri, 1, 0, "DeviceDiscovery");
|
||||||
|
qmlRegisterType<DeviceDiscoveryProxy>(uri, 1, 0, "DeviceDiscoveryProxy");
|
||||||
qmlRegisterUncreatableType<DeviceDescriptor>(uri, 1, 0, "DeviceDescriptor", "Get it from DeviceDiscovery");
|
qmlRegisterUncreatableType<DeviceDescriptor>(uri, 1, 0, "DeviceDescriptor", "Get it from DeviceDiscovery");
|
||||||
|
|
||||||
qmlRegisterType<DeviceModel>(uri, 1, 0, "DeviceModel");
|
qmlRegisterType<DeviceModel>(uri, 1, 0, "DeviceModel");
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
VendorsProxy::VendorsProxy(QObject *parent) : QSortFilterProxyModel(parent)
|
VendorsProxy::VendorsProxy(QObject *parent) : QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
|
setSortRole(Vendors::RoleDisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vendors *VendorsProxy::vendors()
|
Vendors *VendorsProxy::vendors()
|
||||||
@ -40,10 +40,16 @@ void VendorsProxy::setVendors(Vendors *vendors)
|
|||||||
m_vendors = vendors;
|
m_vendors = vendors;
|
||||||
setSourceModel(vendors);
|
setSourceModel(vendors);
|
||||||
emit vendorsChanged();
|
emit vendorsChanged();
|
||||||
|
connect(m_vendors, &Vendors::countChanged, this, &VendorsProxy::countChanged);
|
||||||
sort(0);
|
sort(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vendor *VendorsProxy::get(int index) const
|
||||||
|
{
|
||||||
|
return m_vendors->get(mapToSource(this->index(index, 0)).row());
|
||||||
|
}
|
||||||
|
|
||||||
bool VendorsProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
bool VendorsProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||||
{
|
{
|
||||||
QVariant leftName = sourceModel()->data(left);
|
QVariant leftName = sourceModel()->data(left);
|
||||||
|
|||||||
@ -32,6 +32,7 @@ class VendorsProxy : public QSortFilterProxyModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Vendors *vendors READ vendors WRITE setVendors NOTIFY vendorsChanged)
|
Q_PROPERTY(Vendors *vendors READ vendors WRITE setVendors NOTIFY vendorsChanged)
|
||||||
|
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VendorsProxy(QObject *parent = nullptr);
|
explicit VendorsProxy(QObject *parent = nullptr);
|
||||||
@ -39,8 +40,11 @@ public:
|
|||||||
Vendors *vendors();
|
Vendors *vendors();
|
||||||
void setVendors(Vendors *vendors);
|
void setVendors(Vendors *vendors);
|
||||||
|
|
||||||
|
Q_INVOKABLE Vendor* get(int index) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void vendorsChanged();
|
void vendorsChanged();
|
||||||
|
void countChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vendors *m_vendors;
|
Vendors *m_vendors;
|
||||||
|
|||||||
@ -78,6 +78,8 @@ int main(int argc, char *argv[])
|
|||||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||||
application.installTranslator(&qtTranslator);
|
application.installTranslator(&qtTranslator);
|
||||||
|
|
||||||
|
qDebug() << "Locale info:" << QLocale() << QLocale().name() << QLocale().language() << QLocale().system();
|
||||||
|
|
||||||
QTranslator appTranslator;
|
QTranslator appTranslator;
|
||||||
bool translationResult = appTranslator.load(QLocale(), "nymea-app", "-", ":/translations/", ".qm");
|
bool translationResult = appTranslator.load(QLocale(), "nymea-app", "-", ":/translations/", ".qm");
|
||||||
if (translationResult) {
|
if (translationResult) {
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>ui/Nymea.qml</file>
|
<file>ui/Nymea.qml</file>
|
||||||
<file>ui/NewDeviceWizard.qml</file>
|
|
||||||
<file>ui/SettingsPage.qml</file>
|
<file>ui/SettingsPage.qml</file>
|
||||||
<file>ui/LoginPage.qml</file>
|
<file>ui/LoginPage.qml</file>
|
||||||
<file>ui/MagicPage.qml</file>
|
<file>ui/MagicPage.qml</file>
|
||||||
<file>ui/EditDevicesPage.qml</file>
|
|
||||||
<file>ui/PushButtonAuthPage.qml</file>
|
<file>ui/PushButtonAuthPage.qml</file>
|
||||||
<file>ui/KeyboardLoader.qml</file>
|
<file>ui/KeyboardLoader.qml</file>
|
||||||
<file>ui/MainPage.qml</file>
|
<file>ui/MainPage.qml</file>
|
||||||
@ -42,6 +40,7 @@
|
|||||||
<file>ui/components/FancyHeader.qml</file>
|
<file>ui/components/FancyHeader.qml</file>
|
||||||
<file>ui/components/MainPageTile.qml</file>
|
<file>ui/components/MainPageTile.qml</file>
|
||||||
<file>ui/components/BusyOverlay.qml</file>
|
<file>ui/components/BusyOverlay.qml</file>
|
||||||
|
<file>ui/components/SwipeDelegateGroup.qml</file>
|
||||||
<file>ui/components/AWSPasswordTextField.qml</file>
|
<file>ui/components/AWSPasswordTextField.qml</file>
|
||||||
<file>ui/components/BrightnessSlider.qml</file>
|
<file>ui/components/BrightnessSlider.qml</file>
|
||||||
<file>ui/components/SegmentedImage.qml</file>
|
<file>ui/components/SegmentedImage.qml</file>
|
||||||
@ -69,7 +68,6 @@
|
|||||||
<file>ui/devicepages/SensorDevicePagePre110.qml</file>
|
<file>ui/devicepages/SensorDevicePagePre110.qml</file>
|
||||||
<file>ui/devicepages/SensorDevicePagePost110.qml</file>
|
<file>ui/devicepages/SensorDevicePagePost110.qml</file>
|
||||||
<file>ui/devicepages/DevicePageBase.qml</file>
|
<file>ui/devicepages/DevicePageBase.qml</file>
|
||||||
<file>ui/devicepages/ConfigureThingPage.qml</file>
|
|
||||||
<file>ui/devicepages/InputTriggerDevicePage.qml</file>
|
<file>ui/devicepages/InputTriggerDevicePage.qml</file>
|
||||||
<file>ui/devicepages/StateLogPage.qml</file>
|
<file>ui/devicepages/StateLogPage.qml</file>
|
||||||
<file>ui/devicepages/ShutterDevicePage.qml</file>
|
<file>ui/devicepages/ShutterDevicePage.qml</file>
|
||||||
@ -144,10 +142,10 @@
|
|||||||
<file>ui/system/ServerConfigurationDialog.qml</file>
|
<file>ui/system/ServerConfigurationDialog.qml</file>
|
||||||
<file>ui/system/MqttPolicyPage.qml</file>
|
<file>ui/system/MqttPolicyPage.qml</file>
|
||||||
<file>ui/devicepages/BoolSensorDevicePage.qml</file>
|
<file>ui/devicepages/BoolSensorDevicePage.qml</file>
|
||||||
|
<file>ui/devicepages/HeatingDevicePage.qml</file>
|
||||||
<file>ui/devicepages/PowersocketDevicePage.qml</file>
|
<file>ui/devicepages/PowersocketDevicePage.qml</file>
|
||||||
<file>ui/devicelistpages/PowerSocketsDeviceListPage.qml</file>
|
<file>ui/devicelistpages/PowerSocketsDeviceListPage.qml</file>
|
||||||
<file>ui/components/GroupedListView.qml</file>
|
<file>ui/components/GroupedListView.qml</file>
|
||||||
<file>ui/devicepages/HeatingDevicePage.qml</file>
|
|
||||||
<file>ui/delegates/statedelegates/LedDelegate.qml</file>
|
<file>ui/delegates/statedelegates/LedDelegate.qml</file>
|
||||||
<file>ui/delegates/statedelegates/LabelDelegate.qml</file>
|
<file>ui/delegates/statedelegates/LabelDelegate.qml</file>
|
||||||
<file>ui/delegates/statedelegates/NumberLabelDelegate.qml</file>
|
<file>ui/delegates/statedelegates/NumberLabelDelegate.qml</file>
|
||||||
@ -161,5 +159,9 @@
|
|||||||
<file>ui/delegates/statedelegates/DateTimeDelegate.qml</file>
|
<file>ui/delegates/statedelegates/DateTimeDelegate.qml</file>
|
||||||
<file>ui/components/Dial.qml</file>
|
<file>ui/components/Dial.qml</file>
|
||||||
<file>ui/delegates/statedelegates/SliderDelegate.qml</file>
|
<file>ui/delegates/statedelegates/SliderDelegate.qml</file>
|
||||||
|
<file>ui/thingconfiguration/NewThingPage.qml</file>
|
||||||
|
<file>ui/thingconfiguration/SetupWizard.qml</file>
|
||||||
|
<file>ui/thingconfiguration/EditThingsPage.qml</file>
|
||||||
|
<file>ui/thingconfiguration/ConfigureThingPage.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@ -15,7 +15,7 @@ Page {
|
|||||||
title: swipeView.currentItem.title
|
title: swipeView.currentItem.title
|
||||||
|
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
ListElement { iconSource: "../images/share.svg"; text: qsTr("Configure things"); page: "EditDevicesPage.qml" }
|
ListElement { iconSource: "../images/share.svg"; text: qsTr("Configure things"); page: "thingconfiguration/EditThingsPage.qml" }
|
||||||
ListElement { iconSource: "../images/magic.svg"; text: qsTr("Magic"); page: "MagicPage.qml" }
|
ListElement { iconSource: "../images/magic.svg"; text: qsTr("Magic"); page: "MagicPage.qml" }
|
||||||
ListElement { iconSource: "../images/stock_application.svg"; text: qsTr("App settings"); page: "appsettings/AppSettingsPage.qml" }
|
ListElement { iconSource: "../images/stock_application.svg"; text: qsTr("App settings"); page: "appsettings/AppSettingsPage.qml" }
|
||||||
ListElement { iconSource: "../images/settings.svg"; text: qsTr("Box settings"); page: "SettingsPage.qml" }
|
ListElement { iconSource: "../images/settings.svg"; text: qsTr("Box settings"); page: "SettingsPage.qml" }
|
||||||
@ -123,7 +123,7 @@ Page {
|
|||||||
imageSource: "images/starred.svg"
|
imageSource: "images/starred.svg"
|
||||||
buttonVisible: engine.deviceManager.devices.count === 0
|
buttonVisible: engine.deviceManager.devices.count === 0
|
||||||
buttonText: qsTr("Add a thing")
|
buttonText: qsTr("Add a thing")
|
||||||
onButtonClicked: pageStack.push(Qt.resolvedUrl("NewDeviceWizard.qml"))
|
onButtonClicked: pageStack.push(Qt.resolvedUrl("thingconfiguration/NewThingPage.qml"))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ Page {
|
|||||||
text: qsTr("There are no things set up yet.") + "\n" + qsTr("In order for your %1 box to be useful, go ahead and add some things.").arg(app.systemName)
|
text: qsTr("There are no things set up yet.") + "\n" + qsTr("In order for your %1 box to be useful, go ahead and add some things.").arg(app.systemName)
|
||||||
imageSource: "qrc:/styles/%1/logo.svg".arg(styleController.currentStyle)
|
imageSource: "qrc:/styles/%1/logo.svg".arg(styleController.currentStyle)
|
||||||
buttonText: qsTr("Add a thing")
|
buttonText: qsTr("Add a thing")
|
||||||
onButtonClicked: pageStack.push(Qt.resolvedUrl("NewDeviceWizard.qml"))
|
onButtonClicked: pageStack.push(Qt.resolvedUrl("thingconfiguration/NewThingPage.qml"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ Page {
|
|||||||
buttonText: engine.deviceManager.devices.count === 0 ? qsTr("Add a thing") : qsTr("Add a scene")
|
buttonText: engine.deviceManager.devices.count === 0 ? qsTr("Add a thing") : qsTr("Add a scene")
|
||||||
onButtonClicked: {
|
onButtonClicked: {
|
||||||
if (engine.deviceManager.devices.count === 0) {
|
if (engine.deviceManager.devices.count === 0) {
|
||||||
pageStack.push(Qt.resolvedUrl("NewDeviceWizard.qml"))
|
pageStack.push(Qt.resolvedUrl("thingconfiguration/NewThingPage.qml"))
|
||||||
} else {
|
} else {
|
||||||
var page = pageStack.push(Qt.resolvedUrl("MagicPage.qml"))
|
var page = pageStack.push(Qt.resolvedUrl("MagicPage.qml"))
|
||||||
page.addRule()
|
page.addRule()
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.2
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
|
id: root
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {}
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
|
||||||
@ -12,4 +13,5 @@ ListView {
|
|||||||
text: app.interfaceToString(section)
|
text: app.interfaceToString(section)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SwipeDelegateGroup {}
|
||||||
}
|
}
|
||||||
|
|||||||
47
nymea-app/ui/components/SwipeDelegateGroup.qml
Normal file
47
nymea-app/ui/components/SwipeDelegateGroup.qml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: swipeGroup
|
||||||
|
|
||||||
|
property ListView listView: parent
|
||||||
|
QtObject {
|
||||||
|
id: d
|
||||||
|
property var delegates: swipeGroup.listView.contentItem.children
|
||||||
|
property var delegateCache: []
|
||||||
|
|
||||||
|
onDelegatesChanged: {
|
||||||
|
for (var i = 0; i < d.delegates.length; i++) {
|
||||||
|
var thisItem = d.delegates[i];
|
||||||
|
if (!thisItem.hasOwnProperty("swipe")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (d.delegateCache.indexOf(thisItem) < 0) {
|
||||||
|
d.delegateCache.push(thisItem);
|
||||||
|
|
||||||
|
print("cache is now", d.delegateCache.length)
|
||||||
|
|
||||||
|
thisItem.Component.destruction.connect(function() {
|
||||||
|
print("item destroyed", thisItem)
|
||||||
|
var idx = d.delegateCache.indexOf(thisItem)
|
||||||
|
d.delegateCache.splice(idx, 1)
|
||||||
|
print("cache is now", d.delegateCache.length)
|
||||||
|
})
|
||||||
|
|
||||||
|
thisItem.swipe.opened.connect(function() {
|
||||||
|
for (var j = 0; j < d.delegates.length; j++) {
|
||||||
|
var otherItem = d.delegates[j];
|
||||||
|
if (thisItem === otherItem) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!otherItem.hasOwnProperty("swipe")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
otherItem.swipe.close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,5 +19,4 @@ MeaListItemDelegate {
|
|||||||
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
|
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
|
||||||
readonly property bool batteryCritical: deviceClass && deviceClass.interfaces.indexOf("battery") >= 0 ? device.stateValue(deviceClass.stateTypes.findByName("batteryCritical").id) === true : false
|
readonly property bool batteryCritical: deviceClass && deviceClass.interfaces.indexOf("battery") >= 0 ? device.stateValue(deviceClass.stateTypes.findByName("batteryCritical").id) === true : false
|
||||||
readonly property bool disconnected: deviceClass && deviceClass.interfaces.indexOf("connectable") >= 0 ? device.stateValue(deviceClass.stateTypes.findByName("connected").id) === false : false
|
readonly property bool disconnected: deviceClass && deviceClass.interfaces.indexOf("connectable") >= 0 ? device.stateValue(deviceClass.stateTypes.findByName("connected").id) === false : false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import "../delegates"
|
|||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: root
|
id: root
|
||||||
property var device: null
|
property Device device: null
|
||||||
readonly property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
|
readonly property DeviceClass deviceClass: device ? device.deviceClass : null
|
||||||
|
|
||||||
header: GuhHeader {
|
header: GuhHeader {
|
||||||
text: root.device.name
|
text: root.device.name
|
||||||
@ -37,6 +37,15 @@ Page {
|
|||||||
popup.open();
|
popup.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
IconMenuItem {
|
||||||
|
iconSource: "../images/configure.svg"
|
||||||
|
text: qsTr("Reconfigure Thing")
|
||||||
|
visible: root.device.deviceClass.paramTypes.count > 0
|
||||||
|
onTriggered: {
|
||||||
|
var configPage = pageStack.push(Qt.resolvedUrl("SetupWizard.qml"), {device: root.device})
|
||||||
|
configPage.done.connect(function() {pageStack.pop(root)})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
@ -149,4 +158,5 @@ Page {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import QtQuick 2.4
|
import QtQuick 2.4
|
||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.1
|
||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
import "components"
|
import "../components"
|
||||||
import "delegates"
|
import "../delegates"
|
||||||
import Nymea 1.0
|
import Nymea 1.0
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
@ -20,7 +20,7 @@ Page {
|
|||||||
|
|
||||||
HeaderButton {
|
HeaderButton {
|
||||||
imageSource: "../images/add.svg"
|
imageSource: "../images/add.svg"
|
||||||
onClicked: pageStack.push(Qt.resolvedUrl("NewDeviceWizard.qml"))
|
onClicked: pageStack.push(Qt.resolvedUrl("NewThingPage.qml"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ Page {
|
|||||||
canDelete: true
|
canDelete: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
print("clicked:", model.id)
|
print("clicked:", model.id)
|
||||||
pageStack.push(Qt.resolvedUrl("devicepages/ConfigureThingPage.qml"), {device: device})
|
pageStack.push(Qt.resolvedUrl("ConfigureThingPage.qml"), {device: device})
|
||||||
}
|
}
|
||||||
onDeleteClicked: {
|
onDeleteClicked: {
|
||||||
d.deviceToRemove = device;
|
d.deviceToRemove = device;
|
||||||
@ -96,6 +96,6 @@ Page {
|
|||||||
text: qsTr("In order for your %1 box to be useful, go ahead and add some things.").arg(app.systemName)
|
text: qsTr("In order for your %1 box to be useful, go ahead and add some things.").arg(app.systemName)
|
||||||
imageSource: "qrc:/styles/%1/logo.svg".arg(styleController.currentStyle)
|
imageSource: "qrc:/styles/%1/logo.svg".arg(styleController.currentStyle)
|
||||||
buttonText: qsTr("Add a thing")
|
buttonText: qsTr("Add a thing")
|
||||||
onButtonClicked: pageStack.push(Qt.resolvedUrl("NewDeviceWizard.qml"))
|
onButtonClicked: pageStack.push(Qt.resolvedUrl("NewThingPage.qml"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
130
nymea-app/ui/thingconfiguration/NewThingPage.qml
Normal file
130
nymea-app/ui/thingconfiguration/NewThingPage.qml
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
import QtQuick.Controls 2.1
|
||||||
|
import QtQuick.Controls.Material 2.1
|
||||||
|
import Nymea 1.0
|
||||||
|
import "../components"
|
||||||
|
import "../delegates"
|
||||||
|
|
||||||
|
Page {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
header: GuhHeader {
|
||||||
|
text: qsTr("Set up new thing")
|
||||||
|
onBackPressed: {
|
||||||
|
pageStack.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pane {
|
||||||
|
id: filterPane
|
||||||
|
anchors { left: parent.left; top: parent.top; right: parent.right }
|
||||||
|
Behavior on height { NumberAnimation { duration: 120; easing.type: Easing.InOutQuad } }
|
||||||
|
|
||||||
|
height: implicitHeight + app.margins * 2
|
||||||
|
Material.elevation: 1
|
||||||
|
z: 1
|
||||||
|
|
||||||
|
leftPadding: 0; rightPadding: 0; topPadding: 0; bottomPadding: 0
|
||||||
|
contentItem: Rectangle {
|
||||||
|
color: app.primaryColor
|
||||||
|
clip: true
|
||||||
|
GridLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: app.margins
|
||||||
|
columnSpacing: app.margins
|
||||||
|
columns: 2
|
||||||
|
Label {
|
||||||
|
text: qsTr("Vendor")
|
||||||
|
}
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
id: vendorFilterComboBox
|
||||||
|
Layout.fillWidth: true
|
||||||
|
textRole: "displayName"
|
||||||
|
VendorsProxy {
|
||||||
|
id: vendorsProxy
|
||||||
|
vendors: engine.deviceManager.vendors
|
||||||
|
}
|
||||||
|
model: ListModel {
|
||||||
|
id: vendorsFilterModel
|
||||||
|
ListElement { displayName: qsTr("All"); vendorId: "" }
|
||||||
|
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
for (var i = 0; i < vendorsProxy.count; i++) {
|
||||||
|
var vendor = vendorsProxy.get(i);
|
||||||
|
append({displayName: vendor.displayName, vendorId: vendor.id})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
text: qsTr("Type")
|
||||||
|
}
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
id: typeFilterComboBox
|
||||||
|
Layout.fillWidth: true
|
||||||
|
textRole: "displayName"
|
||||||
|
InterfacesSortModel {
|
||||||
|
id: interfacesSortModel
|
||||||
|
interfacesModel: InterfacesModel {
|
||||||
|
deviceManager: engine.deviceManager
|
||||||
|
shownInterfaces: app.supportedInterfaces
|
||||||
|
onlyConfiguredDevices: false
|
||||||
|
showUncategorized: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model: ListModel {
|
||||||
|
id: typeFilterModel
|
||||||
|
ListElement { interfaceName: ""; displayName: qsTr("All") }
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
for (var i = 0; i < interfacesSortModel.count; i++) {
|
||||||
|
append({interfaceName: interfacesSortModel.get(i), displayName: app.interfaceToString(interfacesSortModel.get(i))});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupedListView {
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
top: filterPane.bottom
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
|
||||||
|
model: DeviceClassesProxy {
|
||||||
|
id: deviceClassesProxy
|
||||||
|
vendorId: vendorsFilterModel.get(vendorFilterComboBox.currentIndex).vendorId
|
||||||
|
deviceClasses: engine.deviceManager.deviceClasses
|
||||||
|
filterInterface: typeFilterModel.get(typeFilterComboBox.currentIndex).interfaceName
|
||||||
|
groupByInterface: true
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: MeaListItemDelegate {
|
||||||
|
id: deviceClassDelegate
|
||||||
|
width: parent.width
|
||||||
|
text: model.displayName
|
||||||
|
subText: engine.deviceManager.vendors.getVendor(model.vendorId).displayName
|
||||||
|
iconName: app.interfacesToIcon(deviceClass.interfaces)
|
||||||
|
prominentSubText: false
|
||||||
|
wrapTexts: false
|
||||||
|
|
||||||
|
property var deviceClass: deviceClassesProxy.get(index)
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
var page = pageStack.push(Qt.resolvedUrl("SetupWizard.qml"), {deviceClass: deviceClassesProxy.get(index)});
|
||||||
|
page.done.connect(function() {
|
||||||
|
pageStack.pop(root, StackView.Immediate);
|
||||||
|
pageStack.pop();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,29 +3,38 @@ import QtQuick.Layouts 1.1
|
|||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.1
|
||||||
import QtQuick.Controls.Material 2.1
|
import QtQuick.Controls.Material 2.1
|
||||||
import Nymea 1.0
|
import Nymea 1.0
|
||||||
import "components"
|
import "../components"
|
||||||
import "delegates"
|
import "../delegates"
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property DeviceClass deviceClass: device ? device.deviceClass : null
|
||||||
|
|
||||||
|
// Optional: If set, it will be reconfigred, otherwise a new one will be created
|
||||||
|
property Device device: null
|
||||||
|
|
||||||
|
signal done();
|
||||||
|
|
||||||
header: GuhHeader {
|
header: GuhHeader {
|
||||||
text: qsTr("Set up new thing")
|
text: qsTr("Set up thing")
|
||||||
backButtonVisible: internalPageStack.depth > 1
|
|
||||||
onBackPressed: {
|
onBackPressed: {
|
||||||
internalPageStack.pop();
|
if (internalPageStack.depth > 1) {
|
||||||
|
internalPageStack.pop();
|
||||||
|
} else {
|
||||||
|
pageStack.pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HeaderButton {
|
HeaderButton {
|
||||||
imageSource: "../images/close.svg"
|
imageSource: "../images/close.svg"
|
||||||
onClicked: pageStack.pop();
|
onClicked: root.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
property var vendorId: null
|
property var vendorId: null
|
||||||
property DeviceClass deviceClass: null
|
|
||||||
property DeviceDescriptor deviceDescriptor: null
|
property DeviceDescriptor deviceDescriptor: null
|
||||||
property var discoveryParams: []
|
property var discoveryParams: []
|
||||||
property string deviceName: ""
|
property string deviceName: ""
|
||||||
@ -34,6 +43,19 @@ Page {
|
|||||||
property int addRequestId: 0
|
property int addRequestId: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (root.deviceClass.createMethods.indexOf("CreateMethodDiscovery") !== -1) {
|
||||||
|
if (deviceClass["discoveryParamTypes"].count > 0) {
|
||||||
|
internalPageStack.push(discoveryParamsPage)
|
||||||
|
} else {
|
||||||
|
discovery.discoverDevices(deviceClass.id)
|
||||||
|
internalPageStack.push(discoveryPage, {deviceClass: deviceClass})
|
||||||
|
}
|
||||||
|
} else if (deviceClass.createMethods.indexOf("CreateMethodUser") !== -1) {
|
||||||
|
internalPageStack.push(paramsPage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: engine.deviceManager
|
target: engine.deviceManager
|
||||||
onPairDeviceReply: {
|
onPairDeviceReply: {
|
||||||
@ -50,7 +72,6 @@ Page {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print("Setup method", params["setupMethod"], "not handled");
|
print("Setup method", params["setupMethod"], "not handled");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onConfirmPairingReply: {
|
onConfirmPairingReply: {
|
||||||
@ -61,6 +82,10 @@ Page {
|
|||||||
busyOverlay.shown = false;
|
busyOverlay.shown = false;
|
||||||
internalPageStack.push(resultsPage, {success: params["deviceError"] === "DeviceErrorNoError", deviceId: params["deviceId"]})
|
internalPageStack.push(resultsPage, {success: params["deviceError"] === "DeviceErrorNoError", deviceId: params["deviceId"]})
|
||||||
}
|
}
|
||||||
|
onReconfigureDeviceReply: {
|
||||||
|
busyOverlay.shown = false;
|
||||||
|
internalPageStack.push(resultsPage, {success: params["deviceError"] === "DeviceErrorNoError", deviceId: params["deviceId"]})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceDiscovery {
|
DeviceDiscovery {
|
||||||
@ -71,169 +96,6 @@ Page {
|
|||||||
StackView {
|
StackView {
|
||||||
id: internalPageStack
|
id: internalPageStack
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
Component.onCompleted: push(deviceClassesPage)
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: vendorsPage
|
|
||||||
Page {
|
|
||||||
ListView {
|
|
||||||
anchors.fill: parent
|
|
||||||
model: VendorsProxy {
|
|
||||||
vendors: engine.deviceManager.vendors
|
|
||||||
}
|
|
||||||
delegate: MeaListItemDelegate {
|
|
||||||
width: parent.width
|
|
||||||
text: model.displayName
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
d.vendorId = model.id
|
|
||||||
internalPageStack.push(deviceClassesPage)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: deviceClassesPage
|
|
||||||
Page {
|
|
||||||
Pane {
|
|
||||||
id: filterPane
|
|
||||||
anchors { left: parent.left; top: parent.top; right: parent.right }
|
|
||||||
Behavior on height { NumberAnimation { duration: 120; easing.type: Easing.InOutQuad } }
|
|
||||||
|
|
||||||
height: implicitHeight + app.margins * 2
|
|
||||||
Material.elevation: 1
|
|
||||||
z: 1
|
|
||||||
|
|
||||||
leftPadding: 0; rightPadding: 0; topPadding: 0; bottomPadding: 0
|
|
||||||
contentItem: Rectangle {
|
|
||||||
color: app.primaryColor
|
|
||||||
clip: true
|
|
||||||
GridLayout {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: app.margins
|
|
||||||
columnSpacing: app.margins
|
|
||||||
columns: 2
|
|
||||||
Label {
|
|
||||||
text: qsTr("Vendor")
|
|
||||||
}
|
|
||||||
|
|
||||||
ComboBox {
|
|
||||||
id: vendorFilterComboBox
|
|
||||||
Layout.fillWidth: true
|
|
||||||
textRole: "displayName"
|
|
||||||
model: ListModel {
|
|
||||||
id: vendorsFilterModel
|
|
||||||
ListElement { displayName: qsTr("All"); vendorId: "" }
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
for (var i = 0; i < engine.deviceManager.vendors.count; i++) {
|
|
||||||
var vendor = engine.deviceManager.vendors.get(i);
|
|
||||||
append({displayName: vendor.displayName, vendorId: vendor.id})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
text: qsTr("Type")
|
|
||||||
}
|
|
||||||
|
|
||||||
ComboBox {
|
|
||||||
id: typeFilterComboBox
|
|
||||||
Layout.fillWidth: true
|
|
||||||
textRole: "displayName"
|
|
||||||
InterfacesSortModel {
|
|
||||||
id: interfacesSortModel
|
|
||||||
interfacesModel: InterfacesModel {
|
|
||||||
deviceManager: engine.deviceManager
|
|
||||||
shownInterfaces: app.supportedInterfaces
|
|
||||||
onlyConfiguredDevices: false
|
|
||||||
showUncategorized: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
model: ListModel {
|
|
||||||
id: typeFilterModel
|
|
||||||
ListElement { interfaceName: ""; displayName: qsTr("All") }
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
for (var i = 0; i < interfacesSortModel.count; i++) {
|
|
||||||
append({interfaceName: interfacesSortModel.get(i), displayName: app.interfaceToString(interfacesSortModel.get(i))});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GroupedListView {
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
top: filterPane.bottom
|
|
||||||
right: parent.right
|
|
||||||
bottom: parent.bottom
|
|
||||||
}
|
|
||||||
|
|
||||||
model: DeviceClassesProxy {
|
|
||||||
id: deviceClassesProxy
|
|
||||||
vendorId: vendorsFilterModel.get(vendorFilterComboBox.currentIndex).vendorId
|
|
||||||
deviceClasses: engine.deviceManager.deviceClasses
|
|
||||||
filterInterface: typeFilterModel.get(typeFilterComboBox.currentIndex).interfaceName
|
|
||||||
groupByInterface: true
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: MeaListItemDelegate {
|
|
||||||
id: deviceClassDelegate
|
|
||||||
width: parent.width
|
|
||||||
text: model.displayName
|
|
||||||
subText: engine.deviceManager.vendors.getVendor(model.vendorId).displayName
|
|
||||||
iconName: app.interfacesToIcon(deviceClass.interfaces)
|
|
||||||
prominentSubText: false
|
|
||||||
wrapTexts: false
|
|
||||||
|
|
||||||
property var deviceClass: deviceClassesProxy.get(index)
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
d.deviceClass = deviceClass
|
|
||||||
if (deviceClass.createMethods.indexOf("CreateMethodDiscovery") !== -1) {
|
|
||||||
if (deviceClass["discoveryParamTypes"].count > 0) {
|
|
||||||
internalPageStack.push(discoveryParamsPage)
|
|
||||||
} else {
|
|
||||||
discovery.discoverDevices(deviceClass.id)
|
|
||||||
internalPageStack.push(discoveryPage, {deviceClass: deviceClass})
|
|
||||||
}
|
|
||||||
} else if (deviceClass.createMethods.indexOf("CreateMethodUser") !== -1) {
|
|
||||||
internalPageStack.push(paramsPage)
|
|
||||||
}
|
|
||||||
|
|
||||||
print("should setup", deviceClass.name, deviceClass.setupMethod, deviceClass.createMethods, deviceClass["discoveryParamTypes"].count)
|
|
||||||
}
|
|
||||||
|
|
||||||
swipe.enabled: deviceClass.createMethods.indexOf("CreateMethodUser") !== -1
|
|
||||||
swipe.right: MouseArea {
|
|
||||||
height: deviceClassDelegate.height
|
|
||||||
width: height
|
|
||||||
anchors.right: parent.right
|
|
||||||
Rectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
color: "transparent"
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorIcon {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: app.margins
|
|
||||||
name: "../images/add.svg"
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
d.deviceClass = deviceClass
|
|
||||||
internalPageStack.push(paramsPage)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
@ -254,7 +116,7 @@ Page {
|
|||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: paramRepeater
|
id: paramRepeater
|
||||||
model: d.deviceClass ? d.deviceClass["discoveryParamTypes"] : null
|
model: root.deviceClass ? root.deviceClass["discoveryParamTypes"] : null
|
||||||
Loader {
|
Loader {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
sourceComponent: searchStringEntryComponent
|
sourceComponent: searchStringEntryComponent
|
||||||
@ -266,7 +128,7 @@ Page {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: "Next"
|
text: "Next"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var paramTypes = d.deviceClass["discoveryParamTypes"];
|
var paramTypes = root.deviceClass["discoveryParamTypes"];
|
||||||
d.discoveryParams = [];
|
d.discoveryParams = [];
|
||||||
for (var i = 0; i < paramTypes.count; i++) {
|
for (var i = 0; i < paramTypes.count; i++) {
|
||||||
var param = {};
|
var param = {};
|
||||||
@ -274,8 +136,8 @@ Page {
|
|||||||
param["value"] = paramRepeater.itemAt(i).value
|
param["value"] = paramRepeater.itemAt(i).value
|
||||||
d.discoveryParams.push(param);
|
d.discoveryParams.push(param);
|
||||||
}
|
}
|
||||||
discovery.discoverDevices(d.deviceClass.id, d.discoveryParams)
|
discovery.discoverDevices(root.deviceClass.id, d.discoveryParams)
|
||||||
internalPageStack.push(discoveryPage, {deviceClass: d.deviceClass})
|
internalPageStack.push(discoveryPage, {deviceClass: root.deviceClass})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,7 +175,13 @@ Page {
|
|||||||
ListView {
|
ListView {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
model: discovery
|
model: DeviceDiscoveryProxy {
|
||||||
|
id: discoveryProxy
|
||||||
|
deviceDiscovery: discovery
|
||||||
|
showAlreadyAdded: root.device !== null
|
||||||
|
showNew: root.device === null
|
||||||
|
filterDeviceId: root.device !== null ? root.device.id : null
|
||||||
|
}
|
||||||
delegate: MeaListItemDelegate {
|
delegate: MeaListItemDelegate {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: app.delegateHeight
|
height: app.delegateHeight
|
||||||
@ -321,8 +189,29 @@ Page {
|
|||||||
subText: model.description
|
subText: model.description
|
||||||
iconName: app.interfacesToIcon(discoveryView.deviceClass.interfaces)
|
iconName: app.interfacesToIcon(discoveryView.deviceClass.interfaces)
|
||||||
onClicked: {
|
onClicked: {
|
||||||
d.deviceDescriptor = discovery.get(index);
|
d.deviceDescriptor = discoveryProxy.get(index);
|
||||||
d.deviceName = model.name;
|
d.deviceName = model.name;
|
||||||
|
|
||||||
|
// Overriding params for reconfiguring discovered devices not supported by core yet
|
||||||
|
// So if we are reconfiguring and discovering, go straight to end
|
||||||
|
|
||||||
|
if (root.device && d.deviceDescriptor) {
|
||||||
|
busyOverlay.shown = true;
|
||||||
|
|
||||||
|
switch (root.deviceClass.setupMethod) {
|
||||||
|
case 0:
|
||||||
|
engine.deviceManager.reconfigureDiscoveredDevice(root.device.id, d.deviceDescriptor.id);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
engine.deviceManager.pairDevice(root.deviceClass.id, d.deviceDescriptor.id, root.device.name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
internalPageStack.push(paramsPage)
|
internalPageStack.push(paramsPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,15 +221,15 @@ Page {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||||
text: qsTr("Search again")
|
text: qsTr("Search again")
|
||||||
onClicked: discovery.discoverDevices(d.deviceClass.id, d.discoveryParams)
|
onClicked: discovery.discoverDevices(root.deviceClass.id, d.discoveryParams)
|
||||||
visible: !discovery.busy && discovery.count > 0
|
visible: !discovery.busy && discoveryProxy.count > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
id: manualAddButton
|
id: manualAddButton
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.bottomMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.bottomMargin: app.margins
|
||||||
visible: d.deviceClass.createMethods.indexOf("CreateMethodUser") >= 0
|
visible: root.deviceClass.createMethods.indexOf("CreateMethodUser") >= 0
|
||||||
text: qsTr("Add thing manually")
|
text: qsTr("Add thing manually")
|
||||||
onClicked: internalPageStack.push(paramsPage)
|
onClicked: internalPageStack.push(paramsPage)
|
||||||
}
|
}
|
||||||
@ -367,7 +256,7 @@ Page {
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: parent.width - app.margins * 2
|
width: parent.width - app.margins * 2
|
||||||
visible: !discovery.busy && discovery.count == 0
|
visible: !discovery.busy && discoveryProxy.count === 0
|
||||||
spacing: app.margins * 2
|
spacing: app.margins * 2
|
||||||
Label {
|
Label {
|
||||||
text: qsTr("Too bad...")
|
text: qsTr("Too bad...")
|
||||||
@ -389,7 +278,7 @@ Page {
|
|||||||
text: qsTr("Try again!")
|
text: qsTr("Try again!")
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
discovery.discoverDevices(d.deviceClass.id, d.discoveryParams)
|
discovery.discoverDevices(root.deviceClass.id, d.discoveryParams)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,35 +298,38 @@ Page {
|
|||||||
id: paramsColumn
|
id: paramsColumn
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
Label {
|
ColumnLayout {
|
||||||
Layout.leftMargin: app.margins
|
visible: root.device === null
|
||||||
Layout.rightMargin: app.margins
|
Label {
|
||||||
Layout.topMargin: app.margins
|
Layout.leftMargin: app.margins
|
||||||
Layout.fillWidth: true
|
Layout.rightMargin: app.margins
|
||||||
text: qsTr("Name the thing:")
|
Layout.topMargin: app.margins
|
||||||
}
|
Layout.fillWidth: true
|
||||||
TextField {
|
text: qsTr("Name the thing:")
|
||||||
id: nameTextField
|
}
|
||||||
text: d.deviceName ? d.deviceName : ""
|
TextField {
|
||||||
Layout.fillWidth: true
|
id: nameTextField
|
||||||
Layout.leftMargin: app.margins
|
text: d.deviceName ? d.deviceName : ""
|
||||||
Layout.rightMargin: app.margins
|
Layout.fillWidth: true
|
||||||
}
|
Layout.leftMargin: app.margins
|
||||||
|
Layout.rightMargin: app.margins
|
||||||
|
}
|
||||||
|
|
||||||
ThinDivider {
|
ThinDivider {
|
||||||
visible: paramRepeater.count > 0
|
visible: paramRepeater.count > 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: paramRepeater
|
id: paramRepeater
|
||||||
model: engine.jsonRpcClient.ensureServerVersion("1.12") || d.deviceDescriptor == null ? d.deviceClass.paramTypes : null
|
model: engine.jsonRpcClient.ensureServerVersion("1.12") || d.deviceDescriptor == null ? root.deviceClass.paramTypes : null
|
||||||
delegate: ParamDelegate {
|
delegate: ParamDelegate {
|
||||||
// Layout.preferredHeight: 60
|
// Layout.preferredHeight: 60
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
paramType: d.deviceClass.paramTypes.get(index)
|
paramType: root.deviceClass.paramTypes.get(index)
|
||||||
value: d.deviceDescriptor && d.deviceDescriptor.params.getParam(paramType.id) ?
|
value: d.deviceDescriptor && d.deviceDescriptor.params.getParam(paramType.id) ?
|
||||||
d.deviceDescriptor.params.getParam(paramType.id).value :
|
d.deviceDescriptor.params.getParam(paramType.id).value :
|
||||||
d.deviceClass.paramTypes.get(index).defaultValue
|
root.deviceClass.paramTypes.get(index).defaultValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,7 +340,7 @@ Page {
|
|||||||
|
|
||||||
text: "OK"
|
text: "OK"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
print("setupMethod", d.deviceClass.setupMethod)
|
print("setupMethod", root.deviceClass.setupMethod)
|
||||||
|
|
||||||
var params = []
|
var params = []
|
||||||
for (var i = 0; i < paramRepeater.count; i++) {
|
for (var i = 0; i < paramRepeater.count; i++) {
|
||||||
@ -459,20 +351,26 @@ Page {
|
|||||||
params.push(param)
|
params.push(param)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (d.deviceClass.setupMethod) {
|
switch (root.deviceClass.setupMethod) {
|
||||||
case 0:
|
case 0:
|
||||||
if (d.deviceDescriptor) {
|
if (root.device !== null) {
|
||||||
engine.deviceManager.addDiscoveredDevice(d.deviceClass.id, d.deviceDescriptor.id, nameTextField.text, params);
|
if (d.deviceDescriptor) {
|
||||||
|
engine.deviceManager.reconfigureDiscoveredDevice(root.device.id, d.deviceDescriptor.id);
|
||||||
|
} else {
|
||||||
|
engine.deviceManager.reconfigureDevice(root.device.id, params);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (d.deviceDescriptor) {
|
||||||
engine.deviceManager.addDevice(d.deviceClass.id, nameTextField.text, params);
|
engine.deviceManager.addDiscoveredDevice(root.deviceClass.id, d.deviceDescriptor.id, nameTextField.text, params);
|
||||||
|
} else {
|
||||||
|
engine.deviceManager.addDevice(root.deviceClass.id, nameTextField.text, params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
engine.deviceManager.pairDevice(d.deviceClass.id, d.deviceDescriptor.id, nameTextField.text);
|
engine.deviceManager.pairDevice(root.deviceClass.id, d.deviceDescriptor.id, nameTextField.text);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +437,7 @@ Page {
|
|||||||
property bool success
|
property bool success
|
||||||
property string deviceId
|
property string deviceId
|
||||||
|
|
||||||
readonly property var device: engine.deviceManager.devices.getDevice(deviceId)
|
readonly property var device: root.device ? root.device : engine.deviceManager.devices.getDevice(deviceId)
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
width: parent.width - app.margins * 2
|
width: parent.width - app.margins * 2
|
||||||
@ -549,7 +447,7 @@ Page {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
text: resultsView.success ? qsTr("Thing added!") : qsTr("Uh oh")
|
text: resultsView.success ? root.device ? qsTr("Thing reconfigured!") : qsTr("Thing added!") : qsTr("Uh oh")
|
||||||
font.pixelSize: app.largeFont
|
font.pixelSize: app.largeFont
|
||||||
color: app.accentColor
|
color: app.accentColor
|
||||||
}
|
}
|
||||||
@ -563,7 +461,9 @@ Page {
|
|||||||
Button {
|
Button {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: qsTr("Ok")
|
text: qsTr("Ok")
|
||||||
onClicked: pageStack.pop();
|
onClicked: {
|
||||||
|
root.done();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user