diff --git a/src/core/machineinfo.h b/src/core/machineinfo.h --- a/src/core/machineinfo.h +++ b/src/core/machineinfo.h @@ -27,6 +27,7 @@ #include #include #include +#include class ATCORE_EXPORT MachineInfo : public QObject { @@ -83,7 +84,8 @@ * @param profile: A complete machine profile or one that at very least has MachineInfo::Name and any other valid Key. * @sa storeKey() */ - Q_INVOKABLE void storeProfile(const QMap &profile) const; + void storeProfile(const QMap &profile) const; + Q_INVOKABLE void storeProfile(const QVariantMap profile) const; /** * @brief Store a key to an existing profile, Sending a key of Key::NAME will rename the profile @@ -116,6 +118,14 @@ */ Q_INVOKABLE QStringList profileNames() const; + /** + * @brief Translate a key enum to string + * @param key: name of the key to be translated. + * @return key string if successful. + */ + Q_INVOKABLE QString keyName(const MachineInfo::KEY key) const; + + signals: /** * @brief A profile has changed diff --git a/src/core/machineinfo.cpp b/src/core/machineinfo.cpp --- a/src/core/machineinfo.cpp +++ b/src/core/machineinfo.cpp @@ -168,9 +168,24 @@ emit profilesChanged(); } +void MachineInfo::storeProfile(const QVariantMap profile) const +{ + m_settings->beginGroup(profile.first().toString()); + for(auto key: profile.keys()){ + m_settings->setValue(key, profile[key]); + } + m_settings->endGroup(); + m_settings->sync(); + emit profilesChanged(); +} + QStringList MachineInfo::profileNames() const { m_settings->sync(); return m_settings->childGroups(); } +QString MachineInfo::keyName(const MachineInfo::KEY key) const +{ + return decoderMap[key].name; +}