Skip to content

Commit

Permalink
[aboutsettings] Add a softwareVersionId property to AboutSettings. Co…
Browse files Browse the repository at this point in the history
…ntributes to JB#33941
  • Loading branch information
adenexter committed Jan 25, 2016
1 parent 1b4980d commit 48d1293
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/aboutsettings.cpp
Expand Up @@ -49,9 +49,11 @@
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:
// http://www.freedesktop.org/software/systemd/man/os-release.html
Expand Down Expand Up @@ -109,13 +111,11 @@ QMap<QString, QString> parseReleaseFile(const QString &filename)
// following shell style."
value = value.replace(QRegularExpression("\\\\(.)"), "\\1");

result[key] = value;
(*result)[key] = value;
}

release.close();
}

return result;
}

struct StorageInfo {
Expand Down Expand Up @@ -238,12 +238,23 @@ QString AboutSettings::serial() 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
{
return parseReleaseFile("/etc/hw-release")["VERSION_ID"];
parseReleaseFile(QStringLiteral("/etc/hw-release"), &m_hardwareRelease);

return m_hardwareRelease["VERSION_ID"];
}

void AboutSettings::refreshStorageModels()
Expand Down
4 changes: 4 additions & 0 deletions src/aboutsettings.h
Expand Up @@ -47,6 +47,7 @@ class AboutSettings: public QObject
Q_PROPERTY(QString imei READ imei CONSTANT)
Q_PROPERTY(QString serial READ serial CONSTANT)
Q_PROPERTY(QString softwareVersion READ softwareVersion CONSTANT)
Q_PROPERTY(QString softwareVersionId READ softwareVersionId CONSTANT)
Q_PROPERTY(QString adaptationVersion READ adaptationVersion CONSTANT)

Q_PROPERTY(QVariant internalStorageUsageModel READ diskUsageModel NOTIFY storageChanged)
Expand Down Expand Up @@ -77,6 +78,7 @@ class AboutSettings: public QObject
QString imei() const;
QString serial() const;
QString softwareVersion() const;
QString softwareVersionId() const;
QString adaptationVersion() const;

signals:
Expand All @@ -89,6 +91,8 @@ class AboutSettings: public QObject

QVariantList m_internalStorage;
QVariantList m_externalStorage;
mutable QMap<QString, QString> m_osRelease;
mutable QMap<QString, QString> m_hardwareRelease;
};

#endif

0 comments on commit 48d1293

Please sign in to comment.