Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qeglfsemulatorscreen.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
8
9using namespace Qt::StringLiterals;
10
11QEglFSEmulatorScreen::QEglFSEmulatorScreen(const QJsonObject &screenDescription)
13 , m_id(0)
14{
15 initFromJsonObject(screenDescription);
16}
17
19{
20 return m_geometry;
21}
22
24{
25 return QRect(QPoint(0, 0), m_geometry.size());
26}
27
29{
30 return m_depth;
31}
32
34{
35 return m_format;
36}
37
39{
40 return m_physicalSize;
41}
42
44{
45 return logicalBaseDpi();
46}
47
49{
50 return QDpi(100, 100);
51}
52
54{
55 return m_refreshRate;
56}
57
59{
60 return m_nativeOrientation;
61}
62
64{
65 return m_orientation;
66}
67
69{
70 return m_id;
71}
72
74{
75 return m_description;
76}
77
78void QEglFSEmulatorScreen::initFromJsonObject(const QJsonObject &description)
79{
80 QJsonValue value;
81
82 value = description.value("id"_L1);
83 if (!value.isUndefined() && value.isDouble())
84 m_id = value.toInt();
85
86 value = description.value("description"_L1);
87 if (!value.isUndefined() && value.isString())
88 m_description = value.toString();
89
90 value = description.value("geometry"_L1);
91 if (!value.isUndefined() && value.isObject()) {
92 QJsonObject geometryObject = value.toObject();
93 value = geometryObject.value("x"_L1);
94 if (!value.isUndefined() && value.isDouble())
95 m_geometry.setX(value.toInt());
96 value = geometryObject.value("y"_L1);
97 if (!value.isUndefined() && value.isDouble())
98 m_geometry.setY(value.toInt());
99 value = geometryObject.value("width"_L1);
100 if (!value.isUndefined() && value.isDouble())
101 m_geometry.setWidth(value.toInt());
102 value = geometryObject.value("height"_L1);
103 if (!value.isUndefined() && value.isDouble())
104 m_geometry.setHeight(value.toInt());
105 }
106
107 value = description.value("depth"_L1);
108 if (!value.isUndefined() && value.isDouble())
109 m_depth = value.toInt();
110
111 value = description.value("format"_L1);
112 if (!value.isUndefined() && value.isDouble())
113 m_format = static_cast<QImage::Format>(value.toInt());
114
115 value = description.value("physicalSize"_L1);
116 if (!value.isUndefined() && value.isObject()) {
117 QJsonObject physicalSizeObject = value.toObject();
118 value = physicalSizeObject.value("width"_L1);
119 if (!value.isUndefined() && value.isDouble())
120 m_physicalSize.setWidth(value.toInt());
121 value = physicalSizeObject.value("height"_L1);
122 if (!value.isUndefined() && value.isDouble())
123 m_physicalSize.setHeight(value.toInt());
124 }
125
126
127 value = description.value("refreshRate"_L1);
128 if (!value.isUndefined() && value.isDouble())
129 m_refreshRate = value.toDouble();
130
131 value = description.value("nativeOrientation"_L1);
132 if (!value.isUndefined() && value.isDouble())
133 m_nativeOrientation = static_cast<Qt::ScreenOrientation>(value.toInt());
134
135 value = description.value("orientation"_L1);
136 if (!value.isUndefined() && value.isDouble())
137 m_orientation = static_cast<Qt::ScreenOrientation>(value.toInt());
138}
139
140QT_END_NAMESPACE
QSizeF physicalSize() const override
Reimplement this function in subclass to return the physical size of the screen, in millimeters.
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
int depth() const override
Reimplement in subclass to return current depth of the screen.
qreal refreshRate() const override
Reimplement this function in subclass to return the vertical refresh rate of the screen,...
QDpi logicalBaseDpi() const override
Reimplement to return the base logical DPI for the platform.
Qt::ScreenOrientation orientation() const override
Reimplement this function in subclass to return the current orientation of the screen,...
Qt::ScreenOrientation nativeOrientation() const override
Reimplement this function in subclass to return the native orientation of the screen,...
QString name() const override
QDpi logicalDpi() const override
Reimplement this function in subclass to return the logical horizontal and vertical dots per inch met...
QImage::Format format() const override
Reimplement in subclass to return the image format which corresponds to the screen format.
QRect rawGeometry() const override
QEglFSEmulatorScreen(const QJsonObject &screenDescription)
Combined button and popup list for selecting options.