30
30
*/
31
31
32
32
#include " aboutsettings.h"
33
+ #include " aboutsettings_p.h"
33
34
34
35
#include < QDebug>
35
36
#include < QStringList>
37
+
36
38
#include < QNetworkInfo>
39
+
37
40
#include < QDeviceInfo>
38
41
#include < QFile>
39
42
#include < QByteArray>
@@ -151,19 +154,33 @@ void parseLocalizationFile(const QString &filename, QMap<QString, QString> *resu
151
154
152
155
}
153
156
157
+
158
+ AboutSettingsPrivate::AboutSettingsPrivate (QObject *parent)
159
+ : QObject(parent)
160
+ {
161
+
162
+ }
163
+
164
+ AboutSettingsPrivate::~AboutSettingsPrivate ()
165
+ {
166
+
167
+ }
168
+
169
+
154
170
AboutSettings::AboutSettings (QObject *parent)
155
- : QObject(parent), m_netinfo( new QNetworkInfo( this )),
156
- m_devinfo (new QDeviceInfo (this ))
171
+ : QObject(parent)
172
+ , d_ptr (new AboutSettingsPrivate (this ))
157
173
{
174
+ Q_D (AboutSettings);
158
175
QSettings settings (QStringLiteral (" /mnt/vendor_data/vendor-data.ini" ), QSettings::IniFormat);
159
- m_vendorName = settings.value (QStringLiteral (" Name" )).toString ();
160
- m_vendorVersion = settings.value (QStringLiteral (" Version" )).toString ();
176
+ d-> vendorName = settings.value (QStringLiteral (" Name" )).toString ();
177
+ d-> vendorVersion = settings.value (QStringLiteral (" Version" )).toString ();
161
178
162
179
refreshStorageModels ();
163
180
164
- connect (&m_partitionManager , &PartitionManager::partitionAdded,
181
+ connect (&d-> partitionManager , &PartitionManager::partitionAdded,
165
182
this , &AboutSettings::partitionCountChanged);
166
- connect (&m_partitionManager , &PartitionManager::partitionRemoved,
183
+ connect (&d-> partitionManager , &PartitionManager::partitionRemoved,
167
184
this , &AboutSettings::partitionCountChanged);
168
185
}
169
186
@@ -173,27 +190,32 @@ AboutSettings::~AboutSettings()
173
190
174
191
qlonglong AboutSettings::totalDiskSpace () const
175
192
{
176
- return m_partitionManager.root ().bytesTotal ();
193
+ Q_D (const AboutSettings);
194
+ return d->partitionManager .root ().bytesTotal ();
177
195
}
178
196
179
197
qlonglong AboutSettings::availableDiskSpace () const
180
198
{
181
- return m_partitionManager.root ().bytesAvailable ();
199
+ Q_D (const AboutSettings);
200
+ return d->partitionManager .root ().bytesAvailable ();
182
201
}
183
202
184
203
QVariant AboutSettings::diskUsageModel () const
185
204
{
186
- return m_internalStorage;
205
+ Q_D (const AboutSettings);
206
+ return d->internalStorage ;
187
207
}
188
208
189
209
QString AboutSettings::wlanMacAddress () const
190
210
{
191
- return m_netinfo->macAddress (QNetworkInfo::WlanMode, 0 );
211
+ Q_D (const AboutSettings);
212
+ return d->networkInfo .macAddress (QNetworkInfo::WlanMode, 0 );
192
213
}
193
214
194
215
QString AboutSettings::imei () const
195
216
{
196
- return m_devinfo->imei (0 );
217
+ Q_D (const AboutSettings);
218
+ return d->deviceInfo .imei (0 );
197
219
}
198
220
199
221
QString AboutSettings::serial () const
@@ -224,9 +246,10 @@ QString AboutSettings::serial() const
224
246
225
247
QString AboutSettings::localizedOperatingSystemName () const
226
248
{
227
- parseLocalizationFile (QStringLiteral (" /etc/os-release-l10n" ), &m_osReleaseLocalization);
249
+ Q_D (const AboutSettings);
250
+ parseLocalizationFile (QStringLiteral (" /etc/os-release-l10n" ), &d->osReleaseLocalization );
228
251
229
- return m_osReleaseLocalization .value (" NAME" , operatingSystemName ());
252
+ return d-> osReleaseLocalization .value (" NAME" , operatingSystemName ());
230
253
}
231
254
232
255
QString AboutSettings::baseOperatingSystemName () const
@@ -240,45 +263,52 @@ QString AboutSettings::baseOperatingSystemName() const
240
263
241
264
QString AboutSettings::operatingSystemName () const
242
265
{
243
- parseReleaseFile (QStringLiteral (" /etc/os-release" ), &m_osRelease);
266
+ Q_D (const AboutSettings);
267
+ parseReleaseFile (QStringLiteral (" /etc/os-release" ), &d->osRelease );
244
268
245
- return m_osRelease [" NAME" ];
269
+ return d-> osRelease [" NAME" ];
246
270
}
247
271
248
272
QString AboutSettings::softwareVersion () const
249
273
{
250
- parseReleaseFile (QStringLiteral (" /etc/os-release" ), &m_osRelease);
274
+ Q_D (const AboutSettings);
275
+ parseReleaseFile (QStringLiteral (" /etc/os-release" ), &d->osRelease );
251
276
252
- return m_osRelease [" VERSION" ];
277
+ return d-> osRelease [" VERSION" ];
253
278
}
254
279
255
280
QString AboutSettings::softwareVersionId () const
256
281
{
257
- parseReleaseFile (QStringLiteral (" /etc/os-release" ), &m_osRelease);
282
+ Q_D (const AboutSettings);
283
+ parseReleaseFile (QStringLiteral (" /etc/os-release" ), &d->osRelease );
258
284
259
- return m_osRelease [" VERSION_ID" ];
285
+ return d-> osRelease [" VERSION_ID" ];
260
286
}
261
287
262
288
QString AboutSettings::adaptationVersion () const
263
289
{
264
- parseReleaseFile (QStringLiteral (" /etc/hw-release" ), &m_hardwareRelease);
290
+ Q_D (const AboutSettings);
291
+ parseReleaseFile (QStringLiteral (" /etc/hw-release" ), &d->hardwareRelease );
265
292
266
- return m_hardwareRelease [" VERSION_ID" ];
293
+ return d-> hardwareRelease [" VERSION_ID" ];
267
294
}
268
295
269
296
QString AboutSettings::vendorName () const
270
297
{
271
- return m_vendorName;
298
+ Q_D (const AboutSettings);
299
+ return d->vendorName ;
272
300
}
273
301
274
302
QString AboutSettings::vendorVersion () const
275
303
{
276
- return m_vendorVersion;
304
+ Q_D (const AboutSettings);
305
+ return d->vendorVersion ;
277
306
}
278
307
279
308
void AboutSettings::refreshStorageModels ()
280
309
{
281
- m_partitionManager.refresh ();
310
+ Q_D (AboutSettings);
311
+ d->partitionManager .refresh ();
282
312
283
313
partitionCountChanged ();
284
314
}
@@ -292,9 +322,10 @@ void AboutSettings::partitionCountChanged()
292
322
293
323
void AboutSettings::reloadStorageLists ()
294
324
{
295
- m_internalStorage.clear ();
325
+ Q_D (AboutSettings);
326
+ d->internalStorage .clear ();
296
327
297
- for (auto partition : m_partitionManager .partitions ()) {
328
+ for (auto partition : d-> partitionManager .partitions ()) {
298
329
QVariantMap row;
299
330
row[QStringLiteral (" mounted" )] = partition.status () == Partition::Mounted;
300
331
row[QStringLiteral (" path" )] = partition.mountPath ();
@@ -318,7 +349,7 @@ void AboutSettings::reloadStorageLists()
318
349
}();
319
350
320
351
if (partition.storageType () != Partition::External) {
321
- m_internalStorage << QVariant (row);
352
+ d-> internalStorage << QVariant (row);
322
353
}
323
354
}
324
355
0 commit comments