Add QPlatformPlaceholderScreen

...and QPlatformScreen::isPlaceholder()

This class can be used to reduce the amount of boiler-plate required to create
a fake screen when there are no real screens (Qt doesn't currently support
running with no QScreens).

Change-Id: I7290406a3d010bcbaf15a1a8a84216e3abf75c78
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2019-10-09 15:24:08 +02:00
parent e85de7d787
commit b7858e9b4b

View File

@ -105,6 +105,8 @@ public:
QPlatformScreen();
virtual ~QPlatformScreen();
virtual bool isPlaceholder() const { return false; };
virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
virtual QRect geometry() const = 0;
@ -172,6 +174,16 @@ private:
friend class QScreenPrivate;
};
// Qt doesn't currently support running with no platform screen
// QPA plugins can use this class to create a fake screen
class QPlatformPlaceholderScreen : public QPlatformScreen {
bool isPlaceholder() const override { return true; };
QRect geometry() const override { return QRect(); }
QRect availableGeometry() const override { return QRect(); }
int depth() const override { return 32; }
QImage::Format format() const override { return QImage::Format::Format_RGB32; }
};
QT_END_NAMESPACE
#endif // QPLATFORMSCREEN_H