mirror of https://github.com/nymea/nymea.git
Merge PR #104: Add navigation pad interfaces
commit
202e22321a
|
|
@ -334,9 +334,14 @@ DeviceManager::DeviceError DeviceManager::setPluginConfig(const PluginId &plugin
|
|||
NymeaSettings settings(NymeaSettings::SettingsRolePlugins);
|
||||
settings.beginGroup("PluginConfig");
|
||||
settings.beginGroup(plugin->pluginId().toString());
|
||||
foreach (const Param ¶m, params) {
|
||||
settings.setValue(param.paramTypeId().toString(), param.value());
|
||||
|
||||
foreach (const Param ¶m, pluginConfig) {
|
||||
settings.beginGroup(param.paramTypeId().toString());
|
||||
settings.setValue("type", static_cast<int>(param.value().type()));
|
||||
settings.setValue("value", param.value());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
emit pluginConfigChanged(plugin->pluginId(), pluginConfig);
|
||||
|
|
@ -1085,10 +1090,31 @@ void DeviceManager::loadPlugin(DevicePlugin *pluginIface)
|
|||
ParamList params;
|
||||
if (settings.childGroups().contains(pluginIface->pluginId().toString())) {
|
||||
settings.beginGroup(pluginIface->pluginId().toString());
|
||||
foreach (const QString ¶mTypeIdString, settings.allKeys()) {
|
||||
Param param(ParamTypeId(paramTypeIdString), settings.value(paramTypeIdString));
|
||||
params.append(param);
|
||||
|
||||
if (!settings.childGroups().isEmpty()) {
|
||||
// Note: since nymea 0.12.2 the param type gets saved too for better data converting
|
||||
foreach (const QString ¶mTypeIdString, settings.childGroups()) {
|
||||
ParamTypeId paramTypeId(paramTypeIdString);
|
||||
ParamType paramType = pluginIface->configurationDescription().findById(paramTypeId);
|
||||
if (!paramType.isValid()) {
|
||||
qCWarning(dcDeviceManager()) << "Skip loading Param for plugin" << pluginIface->pluginName() << "because could not find ParamType for saved Param" << ParamTypeId(paramTypeIdString).toString();
|
||||
continue;
|
||||
}
|
||||
|
||||
QVariant paramValue;
|
||||
settings.beginGroup(paramTypeIdString);
|
||||
paramValue = settings.value("value", paramType.defaultValue());
|
||||
paramValue.convert(settings.value("type").toInt());
|
||||
params.append(Param(paramTypeId, paramValue));
|
||||
settings.endGroup();
|
||||
}
|
||||
} else {
|
||||
// Note: < nymea 0.12.2
|
||||
foreach (const QString ¶mTypeIdString, settings.allKeys()) {
|
||||
params.append(Param(ParamTypeId(paramTypeIdString), settings.value(paramTypeIdString)));
|
||||
}
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
} else if (!pluginIface->configurationDescription().isEmpty()){
|
||||
// plugin requires config but none stored. Init with defaults
|
||||
|
|
@ -1121,6 +1147,7 @@ void DeviceManager::loadPlugin(DevicePlugin *pluginIface)
|
|||
|
||||
}
|
||||
|
||||
|
||||
void DeviceManager::loadConfiguredDevices()
|
||||
{
|
||||
NymeaSettings settings(NymeaSettings::SettingsRoleDevices);
|
||||
|
|
@ -1133,11 +1160,38 @@ void DeviceManager::loadConfiguredDevices()
|
|||
device->setName(settings.value("devicename").toString());
|
||||
device->setParentId(DeviceId(settings.value("parentid", QUuid()).toString()));
|
||||
|
||||
DeviceClass deviceClass = findDeviceClass(device->deviceClassId());
|
||||
if (!deviceClass.isValid()) {
|
||||
qCWarning(dcDeviceManager()) << "Skip loading device" << device << " because could not find device class for this device.";
|
||||
continue;
|
||||
}
|
||||
|
||||
ParamList params;
|
||||
settings.beginGroup("Params");
|
||||
foreach (const QString ¶mTypeIdString, settings.allKeys()) {
|
||||
params.append(Param(ParamTypeId(paramTypeIdString), settings.value(paramTypeIdString)));
|
||||
|
||||
if (!settings.childGroups().isEmpty()) {
|
||||
foreach (const QString ¶mTypeIdString, settings.childGroups()) {
|
||||
ParamTypeId paramTypeId(paramTypeIdString);
|
||||
ParamType paramType = deviceClass.paramTypes().findById(paramTypeId);
|
||||
if (!paramType.isValid()) {
|
||||
qCWarning(dcDeviceManager()) << "Skip loading Param for device" << device << "because could not find ParamType for saved Param" << ParamTypeId(paramTypeIdString).toString();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Note: since nymea 0.12.2
|
||||
QVariant paramValue;
|
||||
settings.beginGroup(paramTypeIdString);
|
||||
paramValue = settings.value("value", paramType.defaultValue());
|
||||
paramValue.convert(settings.value("type").toInt());
|
||||
params.append(Param(paramTypeId, paramValue));
|
||||
settings.endGroup();
|
||||
}
|
||||
} else {
|
||||
foreach (const QString ¶mTypeIdString, settings.allKeys()) {
|
||||
params.append(Param(ParamTypeId(paramTypeIdString), settings.value(paramTypeIdString)));
|
||||
}
|
||||
}
|
||||
|
||||
device->setParams(params);
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
|
|
@ -1174,6 +1228,8 @@ void DeviceManager::storeConfiguredDevices()
|
|||
settings.beginGroup("DeviceConfig");
|
||||
foreach (Device *device, m_configuredDevices) {
|
||||
settings.beginGroup(device->id().toString());
|
||||
// Note: clean device settings before storing it for clean up
|
||||
settings.remove("");
|
||||
settings.setValue("autoCreated", device->autoCreated());
|
||||
settings.setValue("devicename", device->name());
|
||||
settings.setValue("deviceClassId", device->deviceClassId().toString());
|
||||
|
|
@ -1183,7 +1239,10 @@ void DeviceManager::storeConfiguredDevices()
|
|||
|
||||
settings.beginGroup("Params");
|
||||
foreach (const Param ¶m, device->params()) {
|
||||
settings.setValue(param.paramTypeId().toString(), param.value());
|
||||
settings.beginGroup(param.paramTypeId().toString());
|
||||
settings.setValue("type", static_cast<int>(param.value().type()));
|
||||
settings.setValue("value", param.value());
|
||||
settings.endGroup();
|
||||
}
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
|
|
@ -1351,8 +1410,8 @@ void DeviceManager::slotPairingFinished(const PairingTransactionId &pairingTrans
|
|||
device->setName(deviceName);
|
||||
}
|
||||
} else {
|
||||
qCDebug(dcDeviceManager()) << "Reconfiguring device" << device;
|
||||
device = m_configuredDevices.value(deviceId);
|
||||
qCDebug(dcDeviceManager()) << "Reconfiguring device" << device;
|
||||
}
|
||||
emit pairingFinished(pairingTransactionId, DeviceErrorNoError, deviceId);
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,6 @@ private:
|
|||
void storeDeviceStates(Device *device);
|
||||
void loadDeviceStates(Device *device);
|
||||
|
||||
|
||||
private:
|
||||
HardwareManager *m_hardwareManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"description": "The extended media interface offers also the info and menu button of media devices.",
|
||||
"extends": "navigationpad",
|
||||
"actions": [
|
||||
{
|
||||
"name": "navigateMenu"
|
||||
},
|
||||
{
|
||||
"name": "navigateInfo"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -65,6 +65,8 @@
|
|||
<file>co2sensor.json</file>
|
||||
<file>presencesensor.json</file>
|
||||
<file>wirelessconnectable.json</file>
|
||||
<file>navigationpad.json</file>
|
||||
<file>extendednavigationpad.json</file>
|
||||
</qresource>
|
||||
<qresource prefix="/"/>
|
||||
</RCC>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"description": "Many media devices have a navigation pad for browsing a library or a menu. This interface represents a basic navigation pad.",
|
||||
"extends": "media",
|
||||
"actions": [
|
||||
{
|
||||
"name": "navigateUp"
|
||||
},
|
||||
{
|
||||
"name": "navigateDown"
|
||||
},
|
||||
{
|
||||
"name": "navigateLeft"
|
||||
},
|
||||
{
|
||||
"name": "navigateRight"
|
||||
},
|
||||
{
|
||||
"name": "navigateOk"
|
||||
},
|
||||
{
|
||||
"name": "navigateBack"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -254,7 +254,7 @@ DeviceManager::DeviceError DevicePlugin::executeAction(Device *device, const Act
|
|||
}
|
||||
|
||||
/*! Returns the configuration description of this DevicePlugin as a list of \l{ParamType}{ParamTypes}. */
|
||||
QList<ParamType> DevicePlugin::configurationDescription() const
|
||||
ParamTypes DevicePlugin::configurationDescription() const
|
||||
{
|
||||
return m_configurationDescription;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public:
|
|||
virtual DeviceManager::DeviceError executeAction(Device *device, const Action &action);
|
||||
|
||||
// Configuration
|
||||
QList<ParamType> configurationDescription() const;
|
||||
ParamTypes configurationDescription() const;
|
||||
DeviceManager::DeviceError setConfiguration(const ParamList &configuration);
|
||||
ParamList configuration() const;
|
||||
QVariant configValue(const ParamTypeId ¶mTypeId) const;
|
||||
|
|
|
|||
|
|
@ -215,27 +215,27 @@ bool DeviceClass::hasActionType(const ActionTypeId &actionTypeId)
|
|||
|
||||
/*! Returns the params description of this DeviceClass. \{Device}{Devices} created
|
||||
from this \l{DeviceClass} must have their params matching to this template. */
|
||||
QList<ParamType> DeviceClass::paramTypes() const
|
||||
ParamTypes DeviceClass::paramTypes() const
|
||||
{
|
||||
return m_paramTypes;
|
||||
}
|
||||
|
||||
/*! Set the \a params of this DeviceClass. \{Device}{Devices} created
|
||||
from this \l{DeviceClass} must have their actions matching to this template. */
|
||||
void DeviceClass::setParamTypes(const QList<ParamType> ¶ms)
|
||||
void DeviceClass::setParamTypes(const ParamTypes ¶ms)
|
||||
{
|
||||
m_paramTypes = params;
|
||||
}
|
||||
|
||||
/*! Returns the discovery params description of this DeviceClass. \{Device}{Devices} created
|
||||
from this \l{DeviceClass} must have their params matching to this template. */
|
||||
QList<ParamType> DeviceClass::discoveryParamTypes() const
|
||||
ParamTypes DeviceClass::discoveryParamTypes() const
|
||||
{
|
||||
return m_discoveryParamTypes;
|
||||
}
|
||||
/*! Set the \a params of this DeviceClass for the discovery. \{Device}{Devices} created
|
||||
from this \l{DeviceClass} must have their actions matching to this template. */
|
||||
void DeviceClass::setDiscoveryParamTypes(const QList<ParamType> ¶ms)
|
||||
void DeviceClass::setDiscoveryParamTypes(const ParamTypes ¶ms)
|
||||
{
|
||||
m_discoveryParamTypes = params;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,11 +84,11 @@ public:
|
|||
void setActionTypes(const QList<ActionType> &actionTypes);
|
||||
bool hasActionType(const ActionTypeId &actionTypeId);
|
||||
|
||||
QList<ParamType> paramTypes() const;
|
||||
void setParamTypes(const QList<ParamType> ¶mTypes);
|
||||
ParamTypes paramTypes() const;
|
||||
void setParamTypes(const ParamTypes ¶mTypes);
|
||||
|
||||
QList<ParamType> discoveryParamTypes() const;
|
||||
void setDiscoveryParamTypes(const QList<ParamType> ¶mTypes);
|
||||
ParamTypes discoveryParamTypes() const;
|
||||
void setDiscoveryParamTypes(const ParamTypes ¶mTypes);
|
||||
|
||||
CreateMethods createMethods() const;
|
||||
void setCreateMethods(CreateMethods createMethods);
|
||||
|
|
@ -113,11 +113,11 @@ private:
|
|||
PluginId m_pluginId;
|
||||
QString m_name;
|
||||
QString m_displayName;
|
||||
QList<StateType> m_stateTypes;
|
||||
QList<EventType> m_eventTypes;
|
||||
QList<ActionType> m_actionTypes;
|
||||
QList<ParamType> m_paramTypes;
|
||||
QList<ParamType> m_discoveryParamTypes;
|
||||
StateTypes m_stateTypes;
|
||||
EventTypes m_eventTypes;
|
||||
ActionTypes m_actionTypes;
|
||||
ParamTypes m_paramTypes;
|
||||
ParamTypes m_discoveryParamTypes;
|
||||
CreateMethods m_createMethods;
|
||||
SetupMethod m_setupMethod;
|
||||
QString m_pairingInfo;
|
||||
|
|
|
|||
Loading…
Reference in New Issue