Commit db1d21f8 authored by Andrew den Exter's avatar Andrew den Exter

Merge branch 'jb33941' into 'master'

[aboutsettings] Add a softwareVersionId property to AboutSettings. Contributes to JB#33941



See merge request !4
parents 1b4980da 48d1293b
...@@ -49,9 +49,11 @@ ...@@ -49,9 +49,11 @@
namespace namespace
{ {
QMap<QString, QString> parseReleaseFile(const QString &filename) void parseReleaseFile(const QString &filename, QMap<QString, QString> *result)
{ {
QMap<QString, QString> result; if (!result->isEmpty()) {
return;
}
// Specification of the format: // Specification of the format:
// http://www.freedesktop.org/software/systemd/man/os-release.html // http://www.freedesktop.org/software/systemd/man/os-release.html
...@@ -109,13 +111,11 @@ QMap<QString, QString> parseReleaseFile(const QString &filename) ...@@ -109,13 +111,11 @@ QMap<QString, QString> parseReleaseFile(const QString &filename)
// following shell style." // following shell style."
value = value.replace(QRegularExpression("\\\\(.)"), "\\1"); value = value.replace(QRegularExpression("\\\\(.)"), "\\1");
result[key] = value; (*result)[key] = value;
} }
release.close(); release.close();
} }
return result;
} }
struct StorageInfo { struct StorageInfo {
...@@ -238,12 +238,23 @@ QString AboutSettings::serial() const ...@@ -238,12 +238,23 @@ QString AboutSettings::serial() const
QString AboutSettings::softwareVersion() const QString AboutSettings::softwareVersion() const
{ {
return parseReleaseFile("/etc/os-release")["VERSION"]; parseReleaseFile(QStringLiteral("/etc/os-release"), &m_osRelease);
return m_osRelease["VERSION"];
}
QString AboutSettings::softwareVersionId() const
{
parseReleaseFile(QStringLiteral("/etc/os-release"), &m_osRelease);
return m_osRelease["VERSION_ID"];
} }
QString AboutSettings::adaptationVersion() const QString AboutSettings::adaptationVersion() const
{ {
return parseReleaseFile("/etc/hw-release")["VERSION_ID"]; parseReleaseFile(QStringLiteral("/etc/hw-release"), &m_hardwareRelease);
return m_hardwareRelease["VERSION_ID"];
} }
void AboutSettings::refreshStorageModels() void AboutSettings::refreshStorageModels()
......
...@@ -47,6 +47,7 @@ class AboutSettings: public QObject ...@@ -47,6 +47,7 @@ class AboutSettings: public QObject
Q_PROPERTY(QString imei READ imei CONSTANT) Q_PROPERTY(QString imei READ imei CONSTANT)
Q_PROPERTY(QString serial READ serial CONSTANT) Q_PROPERTY(QString serial READ serial CONSTANT)
Q_PROPERTY(QString softwareVersion READ softwareVersion CONSTANT) Q_PROPERTY(QString softwareVersion READ softwareVersion CONSTANT)
Q_PROPERTY(QString softwareVersionId READ softwareVersionId CONSTANT)
Q_PROPERTY(QString adaptationVersion READ adaptationVersion CONSTANT) Q_PROPERTY(QString adaptationVersion READ adaptationVersion CONSTANT)
Q_PROPERTY(QVariant internalStorageUsageModel READ diskUsageModel NOTIFY storageChanged) Q_PROPERTY(QVariant internalStorageUsageModel READ diskUsageModel NOTIFY storageChanged)
...@@ -77,6 +78,7 @@ public: ...@@ -77,6 +78,7 @@ public:
QString imei() const; QString imei() const;
QString serial() const; QString serial() const;
QString softwareVersion() const; QString softwareVersion() const;
QString softwareVersionId() const;
QString adaptationVersion() const; QString adaptationVersion() const;
signals: signals:
...@@ -89,6 +91,8 @@ private: ...@@ -89,6 +91,8 @@ private:
QVariantList m_internalStorage; QVariantList m_internalStorage;
QVariantList m_externalStorage; QVariantList m_externalStorage;
mutable QMap<QString, QString> m_osRelease;
mutable QMap<QString, QString> m_hardwareRelease;
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment