Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Commit 26f2048

Browse files
committed
[deviceinfo] Add model and manufacturer related properties. JB#42860
Allows lightweight access to model and manufacturer related information without doing D-Bus IPC potentially requiring starting of SSU daemon. Signed-off-by: Simo Piiroinen <[email protected]>
1 parent 2b8b1c6 commit 26f2048

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/deviceinfo.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class DeviceInfoPrivate
4343

4444
QSet<DeviceInfo::Feature> m_features;
4545
QSet<Qt::Key> m_keys;
46+
QString m_model;
47+
QString m_baseModel;
48+
QString m_designation;
49+
QString m_manufacturer;
50+
QString m_prettyName;
4651
};
4752

4853
DeviceInfoPrivate::DeviceInfoPrivate()
@@ -65,6 +70,13 @@ DeviceInfoPrivate::DeviceInfoPrivate()
6570
free(keys);
6671
}
6772

73+
/* Note: These queries always return non-null C string */
74+
m_model = ssusysinfo_device_model(si);
75+
m_baseModel = ssusysinfo_device_base_model(si);
76+
m_designation = ssusysinfo_device_designation(si);
77+
m_manufacturer = ssusysinfo_device_manufacturer(si);
78+
m_prettyName = ssusysinfo_device_pretty_name(si);
79+
6880
ssusysinfo_delete(si);
6981
}
7082

@@ -95,3 +107,33 @@ bool DeviceInfo::hasHardwareKey(Qt::Key key) const
95107
Q_D(const DeviceInfo);
96108
return d->m_keys.contains(key);
97109
}
110+
111+
QString DeviceInfo::model() const
112+
{
113+
Q_D(const DeviceInfo);
114+
return d->m_model;
115+
}
116+
117+
QString DeviceInfo::baseModel() const
118+
{
119+
Q_D(const DeviceInfo);
120+
return d->m_baseModel;
121+
}
122+
123+
QString DeviceInfo::designation() const
124+
{
125+
Q_D(const DeviceInfo);
126+
return d->m_designation;
127+
}
128+
129+
QString DeviceInfo::manufacturer() const
130+
{
131+
Q_D(const DeviceInfo);
132+
return d->m_manufacturer;
133+
}
134+
135+
QString DeviceInfo::prettyName() const
136+
{
137+
Q_D(const DeviceInfo);
138+
return d->m_prettyName;
139+
}

src/deviceinfo.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class DeviceInfoPrivate;
4343
class SYSTEMSETTINGS_EXPORT DeviceInfo: public QObject
4444
{
4545
Q_OBJECT
46+
Q_PROPERTY(QString model READ model CONSTANT)
47+
Q_PROPERTY(QString baseModel READ baseModel CONSTANT)
48+
Q_PROPERTY(QString designation READ designation CONSTANT)
49+
Q_PROPERTY(QString manufacturer READ manufacturer CONSTANT)
50+
Q_PROPERTY(QString prettyName READ prettyName CONSTANT)
4651

4752
public:
4853
enum Feature {
@@ -100,6 +105,12 @@ class SYSTEMSETTINGS_EXPORT DeviceInfo: public QObject
100105
Q_INVOKABLE bool hasFeature(DeviceInfo::Feature feature) const;
101106
Q_INVOKABLE bool hasHardwareKey(Qt::Key key) const;
102107

108+
QString model() const;
109+
QString baseModel() const;
110+
QString designation() const;
111+
QString manufacturer() const;
112+
QString prettyName() const;
113+
103114
private:
104115

105116
DeviceInfoPrivate *d_ptr;

0 commit comments

Comments
 (0)