Add plugin storage
This commit is contained in:
parent
7f0f2d1d09
commit
836cd625a3
@ -110,6 +110,7 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
/*! DevicePlugin constructor. DevicePlugins will be instantiated by the DeviceManager, its \a parent. */
|
/*! DevicePlugin constructor. DevicePlugins will be instantiated by the DeviceManager, its \a parent. */
|
||||||
DevicePlugin::DevicePlugin(QObject *parent):
|
DevicePlugin::DevicePlugin(QObject *parent):
|
||||||
@ -340,7 +341,7 @@ void DevicePlugin::initPlugin(const PluginMetadata &metadata, DeviceManager *dev
|
|||||||
m_metaData = metadata;
|
m_metaData = metadata;
|
||||||
m_deviceManager = deviceManager;
|
m_deviceManager = deviceManager;
|
||||||
m_hardwareManager = hardwareManager;
|
m_hardwareManager = hardwareManager;
|
||||||
|
m_storage = new QSettings(NymeaSettings::settingsPath() + "/pluginconfig-" + pluginId().toString().remove(QRegExp("[{}]")) + ".conf", QSettings::IniFormat, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Returns a map containing the plugin configuration.
|
/*! Returns a map containing the plugin configuration.
|
||||||
@ -432,6 +433,14 @@ HardwareManager *DevicePlugin::hardwareManager() const
|
|||||||
return m_hardwareManager;
|
return m_hardwareManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns a pointer to a QSettings object which is reserved for this plugin.
|
||||||
|
The plugin can store arbitrary data in this.
|
||||||
|
*/
|
||||||
|
QSettings* DevicePlugin::pluginStorage() const
|
||||||
|
{
|
||||||
|
return m_storage;
|
||||||
|
}
|
||||||
|
|
||||||
void DevicePlugin::setMetaData(const PluginMetadata &metaData)
|
void DevicePlugin::setMetaData(const PluginMetadata &metaData)
|
||||||
{
|
{
|
||||||
m_metaData = metaData;
|
m_metaData = metaData;
|
||||||
|
|||||||
@ -54,6 +54,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
class DeviceManager;
|
class DeviceManager;
|
||||||
|
|
||||||
@ -111,6 +112,7 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
Devices myDevices() const;
|
Devices myDevices() const;
|
||||||
HardwareManager *hardwareManager() const;
|
HardwareManager *hardwareManager() const;
|
||||||
|
QSettings *pluginStorage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setMetaData(const PluginMetadata &metaData);
|
void setMetaData(const PluginMetadata &metaData);
|
||||||
@ -127,6 +129,7 @@ private:
|
|||||||
|
|
||||||
DeviceManager *m_deviceManager = nullptr;
|
DeviceManager *m_deviceManager = nullptr;
|
||||||
HardwareManager *m_hardwareManager = nullptr;
|
HardwareManager *m_hardwareManager = nullptr;
|
||||||
|
QSettings *m_storage = nullptr;
|
||||||
|
|
||||||
PluginMetadata m_metaData;
|
PluginMetadata m_metaData;
|
||||||
ParamList m_config;
|
ParamList m_config;
|
||||||
|
|||||||
Reference in New Issue
Block a user