Add screen product information

Add new methods to QPlatformScreen that platform plugins can reimplement
in order to provide more information such as vendor, model and serial
number.

Expose that information as QScreen properties.

A use-case for this feature is a Wayland compositor that maps screens
to Wayland outputs hence it needs to replicate the information.

This information can also be added to the diagnostic output of qtdiag.

[ChangeLog][QtGui][QScreen] Add manufacturer, model and serialNumber
properties.

Change-Id: Ia6945f41023340602ef9d618e0d833a0c1825ab3
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Pier Luigi Fiorini 2016-12-13 20:23:55 +01:00 committed by Pier Luigi Fiorini
parent 3b0cd13222
commit abb47fc680
4 changed files with 86 additions and 0 deletions

View File

@ -279,6 +279,45 @@ QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window
return window->screen()->handle();
}
/*!
Reimplement this function in subclass to return the manufacturer
of this screen.
The default implementation returns an empty string.
\since 5.9
*/
QString QPlatformScreen::manufacturer() const
{
return QString();
}
/*!
Reimplement this function in subclass to return the model
of this screen.
The default implementation returns an empty string.
\since 5.9
*/
QString QPlatformScreen::model() const
{
return QString();
}
/*!
Reimplement this function in subclass to return the serial number
of this screen.
The default implementation returns an empty string.
\since 5.9
*/
QString QPlatformScreen::serialNumber() const
{
return QString();
}
/*!
\class QPlatformScreen
\since 4.8

View File

@ -129,6 +129,10 @@ public:
virtual QString name() const { return QString(); }
virtual QString manufacturer() const;
virtual QString model() const;
virtual QString serialNumber() const;
virtual QPlatformCursor *cursor() const;
virtual SubpixelAntialiasingType subpixelAntialiasingTypeHint() const;

View File

@ -160,6 +160,42 @@ QString QScreen::name() const
return d->platformScreen->name();
}
/*!
\property QScreen::manufacturer
\brief the manufacturer of the screen
\since 5.9
*/
QString QScreen::manufacturer() const
{
Q_D(const QScreen);
return d->platformScreen->manufacturer();
}
/*!
\property QScreen::model
\brief the model of the screen
\since 5.9
*/
QString QScreen::model() const
{
Q_D(const QScreen);
return d->platformScreen->model();
}
/*!
\property QScreen::serialNumber
\brief the serial number of the screen
\since 5.9
*/
QString QScreen::serialNumber() const
{
Q_D(const QScreen);
return d->platformScreen->serialNumber();
}
/*!
\property QScreen::depth
\brief the color depth of the screen

View File

@ -69,6 +69,9 @@ class Q_GUI_EXPORT QScreen : public QObject
Q_DECLARE_PRIVATE(QScreen)
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(QString manufacturer READ manufacturer CONSTANT)
Q_PROPERTY(QString model READ model CONSTANT)
Q_PROPERTY(QString serialNumber READ serialNumber CONSTANT)
Q_PROPERTY(int depth READ depth CONSTANT)
Q_PROPERTY(QSize size READ size NOTIFY geometryChanged)
Q_PROPERTY(QSize availableSize READ availableSize NOTIFY availableGeometryChanged)
@ -97,6 +100,10 @@ public:
QString name() const;
QString manufacturer() const;
QString model() const;
QString serialNumber() const;
int depth() const;
QSize size() const;