Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickscreen.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
24 | ** | - | ||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
35 | ** | - | ||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||
37 | ** | - | ||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||
39 | - | |||||||||||||
40 | #include "qquickscreen_p.h" | - | ||||||||||||
41 | - | |||||||||||||
42 | #include "qquickitem.h" | - | ||||||||||||
43 | #include "qquickitem_p.h" | - | ||||||||||||
44 | #include "qquickwindow.h" | - | ||||||||||||
45 | - | |||||||||||||
46 | #include <QGuiApplication> | - | ||||||||||||
47 | #include <QScreen> | - | ||||||||||||
48 | - | |||||||||||||
49 | QT_BEGIN_NAMESPACE | - | ||||||||||||
50 | - | |||||||||||||
51 | /*! | - | ||||||||||||
52 | \qmltype Screen | - | ||||||||||||
53 | \instantiates QQuickScreenAttached | - | ||||||||||||
54 | \inqmlmodule QtQuick.Window | - | ||||||||||||
55 | \ingroup qtquick-visual-utility | - | ||||||||||||
56 | \brief The Screen attached object provides information about the Screen an Item or Window is displayed on. | - | ||||||||||||
57 | - | |||||||||||||
58 | The Screen attached object is valid inside Item or Item derived types, | - | ||||||||||||
59 | after component completion. Inside these items it refers to the screen that | - | ||||||||||||
60 | the item is currently being displayed on. | - | ||||||||||||
61 | - | |||||||||||||
62 | The attached object is also valid inside Window or Window derived types, | - | ||||||||||||
63 | after component completion. In that case it refers to the screen where the | - | ||||||||||||
64 | Window was created. It is generally better to access the Screen from the | - | ||||||||||||
65 | relevant Item instead, because on a multi-screen desktop computer, the user | - | ||||||||||||
66 | can drag a Window into a position where it spans across multiple screens. | - | ||||||||||||
67 | In that case some Items will be on one screen, and others on a different | - | ||||||||||||
68 | screen. | - | ||||||||||||
69 | - | |||||||||||||
70 | To use this type, you will need to import the module with the following line: | - | ||||||||||||
71 | \code | - | ||||||||||||
72 | import QtQuick.Window 2.2 | - | ||||||||||||
73 | \endcode | - | ||||||||||||
74 | It is a separate import in order to allow you to have a QML environment | - | ||||||||||||
75 | without access to window system features. | - | ||||||||||||
76 | - | |||||||||||||
77 | Note that the Screen type is not valid at Component.onCompleted, because | - | ||||||||||||
78 | the Item or Window has not been displayed on a screen by this time. | - | ||||||||||||
79 | */ | - | ||||||||||||
80 | - | |||||||||||||
81 | /*! | - | ||||||||||||
82 | \qmlattachedproperty string Screen::name | - | ||||||||||||
83 | \readonly | - | ||||||||||||
84 | \since 5.1 | - | ||||||||||||
85 | - | |||||||||||||
86 | The name of the screen. | - | ||||||||||||
87 | */ | - | ||||||||||||
88 | /*! | - | ||||||||||||
89 | \qmlattachedproperty int Screen::virtualX | - | ||||||||||||
90 | \readonly | - | ||||||||||||
91 | \since 5.9 | - | ||||||||||||
92 | - | |||||||||||||
93 | The x coordinate of the screen within the virtual desktop. | - | ||||||||||||
94 | */ | - | ||||||||||||
95 | /*! | - | ||||||||||||
96 | \qmlattachedproperty int Screen::virtualY | - | ||||||||||||
97 | \readonly | - | ||||||||||||
98 | \since 5.9 | - | ||||||||||||
99 | - | |||||||||||||
100 | The y coordinate of the screen within the virtual desktop. | - | ||||||||||||
101 | */ | - | ||||||||||||
102 | /*! | - | ||||||||||||
103 | \qmlattachedproperty string Screen::manufacturer | - | ||||||||||||
104 | \readonly | - | ||||||||||||
105 | \since 5.10 | - | ||||||||||||
106 | - | |||||||||||||
107 | The manufacturer of the screen. | - | ||||||||||||
108 | */ | - | ||||||||||||
109 | /*! | - | ||||||||||||
110 | \qmlattachedproperty string Screen::model | - | ||||||||||||
111 | \readonly | - | ||||||||||||
112 | \since 5.10 | - | ||||||||||||
113 | - | |||||||||||||
114 | The model of the screen. | - | ||||||||||||
115 | */ | - | ||||||||||||
116 | /*! | - | ||||||||||||
117 | \qmlattachedproperty string Screen::serialNumber | - | ||||||||||||
118 | \readonly | - | ||||||||||||
119 | \since 5.10 | - | ||||||||||||
120 | - | |||||||||||||
121 | The serial number of the screen. | - | ||||||||||||
122 | */ | - | ||||||||||||
123 | /*! | - | ||||||||||||
124 | \qmlattachedproperty int Screen::width | - | ||||||||||||
125 | \readonly | - | ||||||||||||
126 | - | |||||||||||||
127 | This contains the width of the screen in pixels. | - | ||||||||||||
128 | */ | - | ||||||||||||
129 | /*! | - | ||||||||||||
130 | \qmlattachedproperty int Screen::height | - | ||||||||||||
131 | \readonly | - | ||||||||||||
132 | - | |||||||||||||
133 | This contains the height of the screen in pixels. | - | ||||||||||||
134 | */ | - | ||||||||||||
135 | /*! | - | ||||||||||||
136 | \qmlattachedproperty int Screen::desktopAvailableWidth | - | ||||||||||||
137 | \readonly | - | ||||||||||||
138 | \since 5.1 | - | ||||||||||||
139 | - | |||||||||||||
140 | This contains the available width of the collection of screens which make | - | ||||||||||||
141 | up the virtual desktop, in pixels, excluding window manager reserved areas | - | ||||||||||||
142 | such as task bars and system menus. If you want to position a Window at | - | ||||||||||||
143 | the right of the desktop, you can bind to it like this: | - | ||||||||||||
144 | - | |||||||||||||
145 | \code | - | ||||||||||||
146 | x: Screen.desktopAvailableWidth - width | - | ||||||||||||
147 | \endcode | - | ||||||||||||
148 | */ | - | ||||||||||||
149 | /*! | - | ||||||||||||
150 | \qmlattachedproperty int Screen::desktopAvailableHeight | - | ||||||||||||
151 | \readonly | - | ||||||||||||
152 | \since 5.1 | - | ||||||||||||
153 | - | |||||||||||||
154 | This contains the available height of the collection of screens which make | - | ||||||||||||
155 | up the virtual desktop, in pixels, excluding window manager reserved areas | - | ||||||||||||
156 | such as task bars and system menus. If you want to position a Window at | - | ||||||||||||
157 | the bottom of the desktop, you can bind to it like this: | - | ||||||||||||
158 | - | |||||||||||||
159 | \code | - | ||||||||||||
160 | y: Screen.desktopAvailableHeight - height | - | ||||||||||||
161 | \endcode | - | ||||||||||||
162 | */ | - | ||||||||||||
163 | /*! | - | ||||||||||||
164 | \qmlattachedproperty real Screen::logicalPixelDensity | - | ||||||||||||
165 | \readonly | - | ||||||||||||
166 | \since 5.1 | - | ||||||||||||
167 | \deprecated | - | ||||||||||||
168 | - | |||||||||||||
169 | The number of logical pixels per millimeter. This is the effective pixel | - | ||||||||||||
170 | density provided by the platform to use in image scaling calculations. | - | ||||||||||||
171 | - | |||||||||||||
172 | Due to inconsistencies in how logical pixel density is handled across | - | ||||||||||||
173 | the various platforms Qt supports, it is recommended to | - | ||||||||||||
174 | use physical pixels instead (via the \c pixelDensity property) for | - | ||||||||||||
175 | portability. | - | ||||||||||||
176 | - | |||||||||||||
177 | \sa pixelDensity | - | ||||||||||||
178 | */ | - | ||||||||||||
179 | /*! | - | ||||||||||||
180 | \qmlattachedproperty real Screen::pixelDensity | - | ||||||||||||
181 | \readonly | - | ||||||||||||
182 | \since 5.2 | - | ||||||||||||
183 | - | |||||||||||||
184 | The number of physical pixels per millimeter. | - | ||||||||||||
185 | */ | - | ||||||||||||
186 | /*! | - | ||||||||||||
187 | \qmlattachedproperty real Screen::devicePixelRatio | - | ||||||||||||
188 | \readonly | - | ||||||||||||
189 | \since 5.4 | - | ||||||||||||
190 | - | |||||||||||||
191 | The ratio between physical pixels and device-independent pixels for the screen. | - | ||||||||||||
192 | - | |||||||||||||
193 | Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays. | - | ||||||||||||
194 | */ | - | ||||||||||||
195 | /*! | - | ||||||||||||
196 | \qmlattachedproperty Qt::ScreenOrientation Screen::primaryOrientation | - | ||||||||||||
197 | \readonly | - | ||||||||||||
198 | - | |||||||||||||
199 | This contains the primary orientation of the screen. If the | - | ||||||||||||
200 | screen's height is greater than its width, then the orientation is | - | ||||||||||||
201 | Qt.PortraitOrientation; otherwise it is Qt.LandscapeOrientation. | - | ||||||||||||
202 | - | |||||||||||||
203 | If you are designing an application which changes its layout depending on | - | ||||||||||||
204 | device orientation, you probably want to use primaryOrientation to | - | ||||||||||||
205 | determine the layout. That is because on a desktop computer, you can expect | - | ||||||||||||
206 | primaryOrientation to change when the user rotates the screen via the | - | ||||||||||||
207 | operating system's control panel, even if the computer does not contain an | - | ||||||||||||
208 | accelerometer. Likewise on most handheld computers which do have | - | ||||||||||||
209 | accelerometers, the operating system will rotate the whole screen | - | ||||||||||||
210 | automatically, so again you will see the primaryOrientation change. | - | ||||||||||||
211 | */ | - | ||||||||||||
212 | /*! | - | ||||||||||||
213 | \qmlattachedproperty Qt::ScreenOrientation Screen::orientation | - | ||||||||||||
214 | \readonly | - | ||||||||||||
215 | - | |||||||||||||
216 | This contains the current orientation of the screen, from the accelerometer | - | ||||||||||||
217 | (if any). On a desktop computer, this value typically does not change. | - | ||||||||||||
218 | - | |||||||||||||
219 | If primaryOrientation == orientation, it means that the screen | - | ||||||||||||
220 | automatically rotates all content which is displayed, depending on how you | - | ||||||||||||
221 | hold it. But if orientation changes while primaryOrientation does NOT | - | ||||||||||||
222 | change, then probably you are using a device which does not rotate its own | - | ||||||||||||
223 | display. In that case you may need to use \l {Item::rotation}{Item.rotation} or | - | ||||||||||||
224 | \l {Item::transform}{Item.transform} to rotate your content. | - | ||||||||||||
225 | - | |||||||||||||
226 | \note This property does not update unless a Screen::orientationUpdateMask | - | ||||||||||||
227 | is set to a value other than \c 0. | - | ||||||||||||
228 | */ | - | ||||||||||||
229 | /*! | - | ||||||||||||
230 | \qmlattachedmethod int Screen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) | - | ||||||||||||
231 | - | |||||||||||||
232 | Returns the rotation angle, in degrees, between the two specified angles. | - | ||||||||||||
233 | */ | - | ||||||||||||
234 | - | |||||||||||||
235 | /*! | - | ||||||||||||
236 | \qmlattachedproperty Qt::ScreenOrientations Screen::orientationUpdateMask | - | ||||||||||||
237 | \since 5.4 | - | ||||||||||||
238 | - | |||||||||||||
239 | This contains the update mask for the orientation. Screen::orientation | - | ||||||||||||
240 | only emits changes for the screen orientations matching this mask. | - | ||||||||||||
241 | - | |||||||||||||
242 | By default it is set to the value of the QScreen that the window uses. | - | ||||||||||||
243 | */ | - | ||||||||||||
244 | - | |||||||||||||
245 | QQuickScreenInfo::QQuickScreenInfo(QObject *parent, QScreen *wrappedScreen) | - | ||||||||||||
246 | : QObject(parent) | - | ||||||||||||
247 | , m_screen(wrappedScreen) | - | ||||||||||||
248 | { | - | ||||||||||||
249 | } executed 52 times by 5 tests: end of block Executed by:
| 52 | ||||||||||||
250 | - | |||||||||||||
251 | QString QQuickScreenInfo::name() const | - | ||||||||||||
252 | { | - | ||||||||||||
253 | if (!m_screen)
| 0-2 | ||||||||||||
254 | return QString(); never executed: return QString(); | 0 | ||||||||||||
255 | return m_screen->name(); executed 2 times by 1 test: return m_screen->name(); Executed by:
| 2 | ||||||||||||
256 | } | - | ||||||||||||
257 | - | |||||||||||||
258 | QString QQuickScreenInfo::manufacturer() const | - | ||||||||||||
259 | { | - | ||||||||||||
260 | if (!m_screen)
| 0-2 | ||||||||||||
261 | return QString(); never executed: return QString(); | 0 | ||||||||||||
262 | return m_screen->manufacturer(); executed 2 times by 1 test: return m_screen->manufacturer(); Executed by:
| 2 | ||||||||||||
263 | } | - | ||||||||||||
264 | - | |||||||||||||
265 | QString QQuickScreenInfo::model() const | - | ||||||||||||
266 | { | - | ||||||||||||
267 | if (!m_screen)
| 0-2 | ||||||||||||
268 | return QString(); never executed: return QString(); | 0 | ||||||||||||
269 | return m_screen->model(); executed 2 times by 1 test: return m_screen->model(); Executed by:
| 2 | ||||||||||||
270 | } | - | ||||||||||||
271 | - | |||||||||||||
272 | QString QQuickScreenInfo::serialNumber() const | - | ||||||||||||
273 | { | - | ||||||||||||
274 | if (!m_screen)
| 0-2 | ||||||||||||
275 | return QString(); never executed: return QString(); | 0 | ||||||||||||
276 | return m_screen->serialNumber(); executed 2 times by 1 test: return m_screen->serialNumber(); Executed by:
| 2 | ||||||||||||
277 | } | - | ||||||||||||
278 | - | |||||||||||||
279 | int QQuickScreenInfo::width() const | - | ||||||||||||
280 | { | - | ||||||||||||
281 | if (!m_screen)
| 0-8 | ||||||||||||
282 | return 0; never executed: return 0; | 0 | ||||||||||||
283 | return m_screen->size().width(); executed 8 times by 1 test: return m_screen->size().width(); Executed by:
| 8 | ||||||||||||
284 | } | - | ||||||||||||
285 | - | |||||||||||||
286 | int QQuickScreenInfo::height() const | - | ||||||||||||
287 | { | - | ||||||||||||
288 | if (!m_screen)
| 0-8 | ||||||||||||
289 | return 0; never executed: return 0; | 0 | ||||||||||||
290 | return m_screen->size().height(); executed 8 times by 1 test: return m_screen->size().height(); Executed by:
| 8 | ||||||||||||
291 | } | - | ||||||||||||
292 | - | |||||||||||||
293 | int QQuickScreenInfo::desktopAvailableWidth() const | - | ||||||||||||
294 | { | - | ||||||||||||
295 | if (!m_screen)
| 0-2 | ||||||||||||
296 | return 0; never executed: return 0; | 0 | ||||||||||||
297 | return m_screen->availableVirtualSize().width(); executed 2 times by 1 test: return m_screen->availableVirtualSize().width(); Executed by:
| 2 | ||||||||||||
298 | } | - | ||||||||||||
299 | - | |||||||||||||
300 | int QQuickScreenInfo::desktopAvailableHeight() const | - | ||||||||||||
301 | { | - | ||||||||||||
302 | if (!m_screen)
| 0-2 | ||||||||||||
303 | return 0; never executed: return 0; | 0 | ||||||||||||
304 | return m_screen->availableVirtualSize().height(); executed 2 times by 1 test: return m_screen->availableVirtualSize().height(); Executed by:
| 2 | ||||||||||||
305 | } | - | ||||||||||||
306 | - | |||||||||||||
307 | qreal QQuickScreenInfo::logicalPixelDensity() const | - | ||||||||||||
308 | { | - | ||||||||||||
309 | if (!m_screen)
| 0 | ||||||||||||
310 | return 0.0; never executed: return 0.0; | 0 | ||||||||||||
311 | return m_screen->logicalDotsPerInch() / 25.4; never executed: return m_screen->logicalDotsPerInch() / 25.4; | 0 | ||||||||||||
312 | } | - | ||||||||||||
313 | - | |||||||||||||
314 | qreal QQuickScreenInfo::pixelDensity() const | - | ||||||||||||
315 | { | - | ||||||||||||
316 | if (!m_screen)
| 0-120 | ||||||||||||
317 | return 0.0; never executed: return 0.0; | 0 | ||||||||||||
318 | return m_screen->physicalDotsPerInch() / 25.4; executed 120 times by 1 test: return m_screen->physicalDotsPerInch() / 25.4; Executed by:
| 120 | ||||||||||||
319 | } | - | ||||||||||||
320 | - | |||||||||||||
321 | qreal QQuickScreenInfo::devicePixelRatio() const | - | ||||||||||||
322 | { | - | ||||||||||||
323 | if (!m_screen)
| 0-16 | ||||||||||||
324 | return 1.0; never executed: return 1.0; | 0 | ||||||||||||
325 | return m_screen->devicePixelRatio(); executed 16 times by 2 tests: return m_screen->devicePixelRatio(); Executed by:
| 16 | ||||||||||||
326 | } | - | ||||||||||||
327 | - | |||||||||||||
328 | Qt::ScreenOrientation QQuickScreenInfo::primaryOrientation() const | - | ||||||||||||
329 | { | - | ||||||||||||
330 | if (!m_screen)
| 0-6 | ||||||||||||
331 | return Qt::PrimaryOrientation; never executed: return Qt::PrimaryOrientation; | 0 | ||||||||||||
332 | return m_screen->primaryOrientation(); executed 6 times by 1 test: return m_screen->primaryOrientation(); Executed by:
| 6 | ||||||||||||
333 | } | - | ||||||||||||
334 | - | |||||||||||||
335 | Qt::ScreenOrientation QQuickScreenInfo::orientation() const | - | ||||||||||||
336 | { | - | ||||||||||||
337 | if (!m_screen)
| 0-6 | ||||||||||||
338 | return Qt::PrimaryOrientation; never executed: return Qt::PrimaryOrientation; | 0 | ||||||||||||
339 | return m_screen->orientation(); executed 6 times by 1 test: return m_screen->orientation(); Executed by:
| 6 | ||||||||||||
340 | } | - | ||||||||||||
341 | - | |||||||||||||
342 | int QQuickScreenInfo::virtualX() const | - | ||||||||||||
343 | { | - | ||||||||||||
344 | if (!m_screen)
| 0-8 | ||||||||||||
345 | return 0; never executed: return 0; | 0 | ||||||||||||
346 | return m_screen->geometry().topLeft().x(); executed 8 times by 1 test: return m_screen->geometry().topLeft().x(); Executed by:
| 8 | ||||||||||||
347 | } | - | ||||||||||||
348 | - | |||||||||||||
349 | int QQuickScreenInfo::virtualY() const | - | ||||||||||||
350 | { | - | ||||||||||||
351 | if (!m_screen)
| 0-8 | ||||||||||||
352 | return 0; never executed: return 0; | 0 | ||||||||||||
353 | return m_screen->geometry().topLeft().y(); executed 8 times by 1 test: return m_screen->geometry().topLeft().y(); Executed by:
| 8 | ||||||||||||
354 | } | - | ||||||||||||
355 | - | |||||||||||||
356 | void QQuickScreenInfo::setWrappedScreen(QScreen *screen) | - | ||||||||||||
357 | { | - | ||||||||||||
358 | if (screen == m_screen)
| 0-90 | ||||||||||||
359 | return; never executed: return; | 0 | ||||||||||||
360 | - | |||||||||||||
361 | QScreen *oldScreen = m_screen; | - | ||||||||||||
362 | m_screen = screen; | - | ||||||||||||
363 | - | |||||||||||||
364 | if (oldScreen)
| 38-52 | ||||||||||||
365 | oldScreen->disconnect(this); executed 38 times by 3 tests: oldScreen->disconnect(this); Executed by:
| 38 | ||||||||||||
366 | - | |||||||||||||
367 | if (!screen) //Don't bother emitting signals, because the new values are garbage anyways
| 38-52 | ||||||||||||
368 | return; executed 38 times by 3 tests: return; Executed by:
| 38 | ||||||||||||
369 | - | |||||||||||||
370 | if (!oldScreen || screen->geometry() != oldScreen->geometry()) {
| 0-52 | ||||||||||||
371 | emit virtualXChanged(); | - | ||||||||||||
372 | emit virtualYChanged(); | - | ||||||||||||
373 | } executed 52 times by 5 tests: end of block Executed by:
| 52 | ||||||||||||
374 | if (!oldScreen || screen->size() != oldScreen->size()) {
| 0-52 | ||||||||||||
375 | emit widthChanged(); | - | ||||||||||||
376 | emit heightChanged(); | - | ||||||||||||
377 | } executed 52 times by 5 tests: end of block Executed by:
| 52 | ||||||||||||
378 | if (!oldScreen || screen->name() != oldScreen->name())
| 0-52 | ||||||||||||
379 | emit nameChanged(); executed 52 times by 5 tests: nameChanged(); Executed by:
| 52 | ||||||||||||
380 | if (!oldScreen || screen->manufacturer() != oldScreen->manufacturer())
| 0-52 | ||||||||||||
381 | emit manufacturerChanged(); executed 52 times by 5 tests: manufacturerChanged(); Executed by:
| 52 | ||||||||||||
382 | if (!oldScreen || screen->model() != oldScreen->model())
| 0-52 | ||||||||||||
383 | emit modelChanged(); executed 52 times by 5 tests: modelChanged(); Executed by:
| 52 | ||||||||||||
384 | if (!oldScreen || screen->serialNumber() != oldScreen->serialNumber())
| 0-52 | ||||||||||||
385 | emit serialNumberChanged(); executed 52 times by 5 tests: serialNumberChanged(); Executed by:
| 52 | ||||||||||||
386 | if (!oldScreen || screen->orientation() != oldScreen->orientation())
| 0-52 | ||||||||||||
387 | emit orientationChanged(); executed 52 times by 5 tests: orientationChanged(); Executed by:
| 52 | ||||||||||||
388 | if (!oldScreen || screen->primaryOrientation() != oldScreen->primaryOrientation())
| 0-52 | ||||||||||||
389 | emit primaryOrientationChanged(); executed 52 times by 5 tests: primaryOrientationChanged(); Executed by:
| 52 | ||||||||||||
390 | if (!oldScreen || screen->availableVirtualGeometry() != oldScreen->availableVirtualGeometry())
| 0-52 | ||||||||||||
391 | emit desktopGeometryChanged(); executed 52 times by 5 tests: desktopGeometryChanged(); Executed by:
| 52 | ||||||||||||
392 | if (!oldScreen || screen->logicalDotsPerInch() != oldScreen->logicalDotsPerInch())
| 0-52 | ||||||||||||
393 | emit logicalPixelDensityChanged(); executed 52 times by 5 tests: logicalPixelDensityChanged(); Executed by:
| 52 | ||||||||||||
394 | if (!oldScreen || screen->physicalDotsPerInch() != oldScreen->physicalDotsPerInch())
| 0-52 | ||||||||||||
395 | emit pixelDensityChanged(); executed 52 times by 5 tests: pixelDensityChanged(); Executed by:
| 52 | ||||||||||||
396 | if (!oldScreen || screen->devicePixelRatio() != oldScreen->devicePixelRatio())
| 0-52 | ||||||||||||
397 | emit devicePixelRatioChanged(); executed 52 times by 5 tests: devicePixelRatioChanged(); Executed by:
| 52 | ||||||||||||
398 | - | |||||||||||||
399 | connect(screen, SIGNAL(geometryChanged(QRect)), | - | ||||||||||||
400 | this, SIGNAL(widthChanged())); | - | ||||||||||||
401 | connect(screen, SIGNAL(geometryChanged(QRect)), | - | ||||||||||||
402 | this, SIGNAL(heightChanged())); | - | ||||||||||||
403 | connect(screen, SIGNAL(geometryChanged(QRect)), | - | ||||||||||||
404 | this, SIGNAL(virtualXChanged())); | - | ||||||||||||
405 | connect(screen, SIGNAL(geometryChanged(QRect)), | - | ||||||||||||
406 | this, SIGNAL(virtualYChanged())); | - | ||||||||||||
407 | connect(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), | - | ||||||||||||
408 | this, SIGNAL(orientationChanged())); | - | ||||||||||||
409 | connect(screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), | - | ||||||||||||
410 | this, SIGNAL(primaryOrientationChanged())); | - | ||||||||||||
411 | connect(screen, SIGNAL(virtualGeometryChanged(QRect)), | - | ||||||||||||
412 | this, SIGNAL(desktopGeometryChanged())); | - | ||||||||||||
413 | connect(screen, SIGNAL(logicalDotsPerInchChanged(qreal)), | - | ||||||||||||
414 | this, SIGNAL(logicalPixelDensityChanged())); | - | ||||||||||||
415 | connect(screen, SIGNAL(physicalDotsPerInchChanged(qreal)), | - | ||||||||||||
416 | this, SIGNAL(pixelDensityChanged())); | - | ||||||||||||
417 | } executed 52 times by 5 tests: end of block Executed by:
| 52 | ||||||||||||
418 | - | |||||||||||||
419 | QScreen *QQuickScreenInfo::wrappedScreen() const | - | ||||||||||||
420 | { | - | ||||||||||||
421 | return m_screen; never executed: return m_screen; | 0 | ||||||||||||
422 | } | - | ||||||||||||
423 | - | |||||||||||||
424 | QQuickScreenAttached::QQuickScreenAttached(QObject* attachee) | - | ||||||||||||
425 | : QQuickScreenInfo(attachee) | - | ||||||||||||
426 | , m_window(nullptr) | - | ||||||||||||
427 | , m_updateMask(nullptr) | - | ||||||||||||
428 | , m_updateMaskSet(false) | - | ||||||||||||
429 | { | - | ||||||||||||
430 | m_attachee = qobject_cast<QQuickItem*>(attachee); | - | ||||||||||||
431 | - | |||||||||||||
432 | if (m_attachee) {
| 0-40 | ||||||||||||
433 | QQuickItemPrivate::get(m_attachee)->extra.value().screenAttached = this; | - | ||||||||||||
434 | - | |||||||||||||
435 | if (m_attachee->window()) //It might not be assigned to a window yet
| 10-30 | ||||||||||||
436 | windowChanged(m_attachee->window()); executed 30 times by 1 test: windowChanged(m_attachee->window()); Executed by:
| 30 | ||||||||||||
437 | } else { executed 40 times by 3 tests: end of block Executed by:
| 40 | ||||||||||||
438 | QQuickWindow *window = qobject_cast<QQuickWindow*>(attachee); | - | ||||||||||||
439 | if (window)
| 0 | ||||||||||||
440 | windowChanged(window); never executed: windowChanged(window); | 0 | ||||||||||||
441 | } never executed: end of block | 0 | ||||||||||||
442 | - | |||||||||||||
443 | if (!m_screen)
| 10-30 | ||||||||||||
444 | screenChanged(QGuiApplication::primaryScreen()); executed 10 times by 2 tests: screenChanged(QGuiApplication::primaryScreen()); Executed by:
| 10 | ||||||||||||
445 | } executed 40 times by 3 tests: end of block Executed by:
| 40 | ||||||||||||
446 | - | |||||||||||||
447 | Qt::ScreenOrientations QQuickScreenAttached::orientationUpdateMask() const | - | ||||||||||||
448 | { | - | ||||||||||||
449 | return m_updateMask; executed 6 times by 1 test: return m_updateMask; Executed by:
| 6 | ||||||||||||
450 | } | - | ||||||||||||
451 | - | |||||||||||||
452 | void QQuickScreenAttached::setOrientationUpdateMask(Qt::ScreenOrientations mask) | - | ||||||||||||
453 | { | - | ||||||||||||
454 | m_updateMaskSet = true; | - | ||||||||||||
455 | if (m_updateMask == mask)
| 2-4 | ||||||||||||
456 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||
457 | - | |||||||||||||
458 | m_updateMask = mask; | - | ||||||||||||
459 | - | |||||||||||||
460 | if (m_screen)
| 0-2 | ||||||||||||
461 | m_screen->setOrientationUpdateMask(m_updateMask); executed 2 times by 1 test: m_screen->setOrientationUpdateMask(m_updateMask); Executed by:
| 2 | ||||||||||||
462 | - | |||||||||||||
463 | emit orientationUpdateMaskChanged(); | - | ||||||||||||
464 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
465 | - | |||||||||||||
466 | int QQuickScreenAttached::angleBetween(int a, int b) | - | ||||||||||||
467 | { | - | ||||||||||||
468 | if (!m_screen)
| 0 | ||||||||||||
469 | return Qt::PrimaryOrientation; never executed: return Qt::PrimaryOrientation; | 0 | ||||||||||||
470 | return m_screen->angleBetween((Qt::ScreenOrientation)a,(Qt::ScreenOrientation)b); never executed: return m_screen->angleBetween((Qt::ScreenOrientation)a,(Qt::ScreenOrientation)b); | 0 | ||||||||||||
471 | } | - | ||||||||||||
472 | - | |||||||||||||
473 | void QQuickScreenAttached::windowChanged(QQuickWindow* c) | - | ||||||||||||
474 | { | - | ||||||||||||
475 | if (m_window)
| 38 | ||||||||||||
476 | disconnect(m_window, SIGNAL(screenChanged(QScreen*)), this, SLOT(screenChanged(QScreen*))); executed 38 times by 3 tests: disconnect(m_window, qFlagLocation("2""screenChanged(QScreen*)" "\0" __FILE__ ":" "476"), this, qFlagLocation("1""screenChanged(QScreen*)" "\0" __FILE__ ":" "476")); Executed by:
| 38 | ||||||||||||
477 | m_window = c; | - | ||||||||||||
478 | screenChanged(c ? c->screen() : nullptr); | - | ||||||||||||
479 | if (c)
| 38 | ||||||||||||
480 | connect(c, SIGNAL(screenChanged(QScreen*)), this, SLOT(screenChanged(QScreen*))); executed 38 times by 3 tests: connect(c, qFlagLocation("2""screenChanged(QScreen*)" "\0" __FILE__ ":" "480"), this, qFlagLocation("1""screenChanged(QScreen*)" "\0" __FILE__ ":" "480")); Executed by:
| 38 | ||||||||||||
481 | } executed 76 times by 3 tests: end of block Executed by:
| 76 | ||||||||||||
482 | - | |||||||||||||
483 | void QQuickScreenAttached::screenChanged(QScreen *screen) | - | ||||||||||||
484 | { | - | ||||||||||||
485 | //qDebug() << "QQuickScreenAttached::screenChanged" << (screen ? screen->name() : QString::fromLatin1("null")); | - | ||||||||||||
486 | if (screen != m_screen) {
| 8-78 | ||||||||||||
487 | setWrappedScreen(screen); | - | ||||||||||||
488 | if (!m_screen)
| 38-40 | ||||||||||||
489 | return; executed 38 times by 3 tests: return; Executed by:
| 38 | ||||||||||||
490 | if (m_updateMaskSet) {
| 0-40 | ||||||||||||
491 | m_screen->setOrientationUpdateMask(m_updateMask); | - | ||||||||||||
492 | } else if (m_updateMask != m_screen->orientationUpdateMask()) { never executed: end of block
| 0-36 | ||||||||||||
493 | m_updateMask = m_screen->orientationUpdateMask(); | - | ||||||||||||
494 | emit orientationUpdateMaskChanged(); | - | ||||||||||||
495 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||
496 | } executed 40 times by 3 tests: end of block Executed by:
| 40 | ||||||||||||
497 | } executed 48 times by 3 tests: end of block Executed by:
| 48 | ||||||||||||
498 | - | |||||||||||||
499 | QT_END_NAMESPACE | - | ||||||||||||
500 | - | |||||||||||||
501 | #include "moc_qquickscreen_p.cpp" | - | ||||||||||||
Source code | Switch to Preprocessed file |