diff options
author | Pier Luigi Fiorini <pierluigi.fiorini@liri.io> | 2016-12-31 00:07:50 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-05-23 19:25:20 +0000 |
commit | c158ca8be49a75026e83751dfd825c5bdd63189a (patch) | |
tree | a4754f0e8d62d4a4ddec234c18e303f1edbb470b | |
parent | e6c0595b2138929f5cb6199cde9c3d79d549e0ae (diff) |
Add screen product information
Add information such as manufacturer, model and serial number that is
now available on QScreen to the Screen attached property.
[ChangeLog][QtQuick][Screen] Add manufacturer, model and serial number.
Change-Id: If8f33dffa5eff33111f93212249424b9092250b8
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r-- | examples/quick/window/CurrentScreen.qml | 11 | ||||
-rw-r--r-- | src/quick/items/qquickscreen.cpp | 48 | ||||
-rw-r--r-- | src/quick/items/qquickscreen_p.h | 9 | ||||
-rw-r--r-- | src/quick/items/qquickwindowmodule.cpp | 1 | ||||
-rw-r--r-- | tests/auto/quick/qquickscreen/tst_qquickscreen.cpp | 3 |
5 files changed, 71 insertions, 1 deletions
diff --git a/examples/quick/window/CurrentScreen.qml b/examples/quick/window/CurrentScreen.qml index 09fbce9a74..5a23cd7e29 100644 --- a/examples/quick/window/CurrentScreen.qml +++ b/examples/quick/window/CurrentScreen.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.3 -import QtQuick.Window 2.1 +import QtQuick.Window 2.10 import "../shared" as Shared Item { @@ -77,6 +77,15 @@ Item { } Item { width: 1; height: 1 } // spacer + Shared.Label { text: "manufacturer" } + Shared.Label { text: Screen.manufacturer ? Screen.manufacturer : "unknown" } + + Shared.Label { text: "model" } + Shared.Label { text: Screen.model ? Screen.model : "unknown" } + + Shared.Label { text: "serial number" } + Shared.Label { text: Screen.serialNumber ? Screen.serialNumber : "unknown" } + Shared.Label { text: "dimensions" } Shared.Label { text: Screen.width + "x" + Screen.height } diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp index 9b54b7fba9..6a3eab957e 100644 --- a/src/quick/items/qquickscreen.cpp +++ b/src/quick/items/qquickscreen.cpp @@ -100,6 +100,27 @@ QT_BEGIN_NAMESPACE The y coordinate of the screen within the virtual desktop. */ /*! + \qmlattachedproperty string Screen::manufacturer + \readonly + \since 5.10 + + The manufacturer of the screen. +*/ +/*! + \qmlattachedproperty string Screen::model + \readonly + \since 5.10 + + The model of the screen. +*/ +/*! + \qmlattachedproperty string Screen::serialNumber + \readonly + \since 5.10 + + The serial number of the screen. +*/ +/*! \qmlattachedproperty int Screen::width \readonly @@ -234,6 +255,27 @@ QString QQuickScreenInfo::name() const return m_screen->name(); } +QString QQuickScreenInfo::manufacturer() const +{ + if (!m_screen) + return QString(); + return m_screen->manufacturer(); +} + +QString QQuickScreenInfo::model() const +{ + if (!m_screen) + return QString(); + return m_screen->model(); +} + +QString QQuickScreenInfo::serialNumber() const +{ + if (!m_screen) + return QString(); + return m_screen->serialNumber(); +} + int QQuickScreenInfo::width() const { if (!m_screen) @@ -335,6 +377,12 @@ void QQuickScreenInfo::setWrappedScreen(QScreen *screen) } if (!oldScreen || screen->name() != oldScreen->name()) emit nameChanged(); + if (!oldScreen || screen->manufacturer() != oldScreen->manufacturer()) + emit manufacturerChanged(); + if (!oldScreen || screen->model() != oldScreen->model()) + emit modelChanged(); + if (!oldScreen || screen->serialNumber() != oldScreen->serialNumber()) + emit serialNumberChanged(); if (!oldScreen || screen->orientation() != oldScreen->orientation()) emit orientationChanged(); if (!oldScreen || screen->primaryOrientation() != oldScreen->primaryOrientation()) diff --git a/src/quick/items/qquickscreen_p.h b/src/quick/items/qquickscreen_p.h index 99e1466631..e9db07d14c 100644 --- a/src/quick/items/qquickscreen_p.h +++ b/src/quick/items/qquickscreen_p.h @@ -68,6 +68,9 @@ class Q_AUTOTEST_EXPORT QQuickScreenInfo : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name NOTIFY nameChanged) + Q_PROPERTY(QString manufacturer READ manufacturer NOTIFY manufacturerChanged REVISION 10) + Q_PROPERTY(QString model READ model NOTIFY modelChanged REVISION 10) + Q_PROPERTY(QString serialNumber READ serialNumber NOTIFY serialNumberChanged REVISION 10) Q_PROPERTY(int width READ width NOTIFY widthChanged) Q_PROPERTY(int height READ height NOTIFY heightChanged) Q_PROPERTY(int desktopAvailableWidth READ desktopAvailableWidth NOTIFY desktopGeometryChanged) @@ -87,6 +90,9 @@ public: QQuickScreenInfo(QObject *parent = nullptr, QScreen *wrappedScreen = nullptr); QString name() const; + QString manufacturer() const; + QString model() const; + QString serialNumber() const; int width() const; int height() const; int desktopAvailableWidth() const; @@ -104,6 +110,9 @@ public: Q_SIGNALS: void nameChanged(); + Q_REVISION(10) void manufacturerChanged(); + Q_REVISION(10) void modelChanged(); + Q_REVISION(10) void serialNumberChanged(); void widthChanged(); void heightChanged(); void desktopGeometryChanged(); diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp index a5234d4f77..a7f45534c4 100644 --- a/src/quick/items/qquickwindowmodule.cpp +++ b/src/quick/items/qquickwindowmodule.cpp @@ -200,6 +200,7 @@ void QQuickWindowModule::defineModule() qmlRegisterUncreatableType<QQuickScreen>(uri, 2, 0, "Screen", QStringLiteral("Screen can only be used via the attached property.")); qmlRegisterUncreatableType<QQuickScreen,1>(uri, 2, 3, "Screen", QStringLiteral("Screen can only be used via the attached property.")); qmlRegisterUncreatableType<QQuickScreenInfo,2>(uri, 2, 3, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property.")); + qmlRegisterUncreatableType<QQuickScreenInfo,10>(uri, 2, 10, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property.")); } QT_END_NAMESPACE diff --git a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp index 26b687a4a6..0a3796402a 100644 --- a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp +++ b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp @@ -113,6 +113,9 @@ void tst_qquickscreen::fullScreenList() QQuickScreenInfo *info = qobject_cast<QQuickScreenInfo *>(screensArray.property(i).toQObject()); QVERIFY(info != nullptr); QCOMPARE(screenList[i]->name(), info->name()); + QCOMPARE(screenList[i]->manufacturer(), info->manufacturer()); + QCOMPARE(screenList[i]->model(), info->model()); + QCOMPARE(screenList[i]->serialNumber(), info->serialNumber()); QCOMPARE(screenList[i]->size().width(), info->width()); QCOMPARE(screenList[i]->size().height(), info->height()); QCOMPARE(screenList[i]->availableVirtualGeometry().width(), info->desktopAvailableWidth()); |