diff options
-rw-r--r-- | src/core/qqmlsysteminformation.cpp | 10 | ||||
-rw-r--r-- | src/core/qqmlsysteminformation_p.h | 7 | ||||
-rw-r--r-- | tests/auto/core/data/tst_systeminformation.qml | 2 | ||||
-rw-r--r-- | tests/auto/core/tst_core.cpp | 2 |
4 files changed, 21 insertions, 0 deletions
diff --git a/src/core/qqmlsysteminformation.cpp b/src/core/qqmlsysteminformation.cpp index b067c6eb2b..589a40858e 100644 --- a/src/core/qqmlsysteminformation.cpp +++ b/src/core/qqmlsysteminformation.cpp @@ -27,6 +27,16 @@ QQmlSystemInformation::QQmlSystemInformation(QObject *parent) : QObject(parent) { } +int QQmlSystemInformation::wordSize() const +{ + return QSysInfo::WordSize; +} + +QQmlSystemInformation::Endian QQmlSystemInformation::byteOrder() const +{ + return static_cast<Endian>(QSysInfo::ByteOrder); +} + QString QQmlSystemInformation::buildCpuArchitecture() const { return QSysInfo::buildCpuArchitecture(); diff --git a/src/core/qqmlsysteminformation_p.h b/src/core/qqmlsysteminformation_p.h index 919d1e73eb..868bce1823 100644 --- a/src/core/qqmlsysteminformation_p.h +++ b/src/core/qqmlsysteminformation_p.h @@ -27,6 +27,8 @@ class Q_QMLCORE_PRIVATE_EXPORT QQmlSystemInformation : public QObject QML_NAMED_ELEMENT(SystemInformation) QML_ADDED_IN_VERSION(6, 4) + Q_PROPERTY(int wordSize READ wordSize CONSTANT FINAL) + Q_PROPERTY(QQmlSystemInformation::Endian byteOrder READ byteOrder CONSTANT FINAL) Q_PROPERTY(QString buildCpuArchitecture READ buildCpuArchitecture CONSTANT FINAL) Q_PROPERTY(QString currentCpuArchitecture READ currentCpuArchitecture CONSTANT FINAL) Q_PROPERTY(QString buildAbi READ buildAbi CONSTANT FINAL) @@ -40,8 +42,13 @@ class Q_QMLCORE_PRIVATE_EXPORT QQmlSystemInformation : public QObject Q_PROPERTY(QByteArray bootUniqueId READ bootUniqueId CONSTANT FINAL) public: + enum class Endian { Big, Little }; + Q_ENUM(Endian) + explicit QQmlSystemInformation(QObject *parent = nullptr); + int wordSize() const; + Endian byteOrder() const; QString buildCpuArchitecture() const; QString currentCpuArchitecture() const; QString buildAbi() const; diff --git a/tests/auto/core/data/tst_systeminformation.qml b/tests/auto/core/data/tst_systeminformation.qml index 41b80293a6..afc53dde54 100644 --- a/tests/auto/core/data/tst_systeminformation.qml +++ b/tests/auto/core/data/tst_systeminformation.qml @@ -5,6 +5,8 @@ import QtQml import QtCore QtObject { + property int wordSize: SystemInformation.wordSize + property int byteOrder: SystemInformation.byteOrder property string buildCpuArchitecture: SystemInformation.buildCpuArchitecture property string currentCpuArchitecture: SystemInformation.currentCpuArchitecture property string buildAbi: SystemInformation.buildAbi diff --git a/tests/auto/core/tst_core.cpp b/tests/auto/core/tst_core.cpp index 262eceb550..18e54448cc 100644 --- a/tests/auto/core/tst_core.cpp +++ b/tests/auto/core/tst_core.cpp @@ -25,6 +25,8 @@ void tst_core::systemInformation() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); + QCOMPARE(object->property("wordSize").toInt(), QSysInfo::WordSize); + QCOMPARE(object->property("byteOrder").toInt(), QSysInfo::ByteOrder); QCOMPARE(object->property("buildCpuArchitecture").toString(), QSysInfo::buildCpuArchitecture()); QCOMPARE(object->property("currentCpuArchitecture").toString(), QSysInfo::currentCpuArchitecture()); QCOMPARE(object->property("buildAbi").toString(), QSysInfo::buildAbi()); |