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#ifndef QQUICKSCREEN_P_H
41#define QQUICKSCREEN_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <qqml.h>
55#include <QRect>
56#include <QSize>
57#include <private/qqmlglobal_p.h>
58
59QT_BEGIN_NAMESPACE
60
61
62class QQuickItem;
63class QQuickWindow;
64class QScreen;
65
66
67class Q_AUTOTEST_EXPORT QQuickScreenInfo : public QObject
68{
69 Q_OBJECT
70 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
71 Q_PROPERTY(QString manufacturer READ manufacturer NOTIFY manufacturerChanged REVISION 10)
72 Q_PROPERTY(QString model READ model NOTIFY modelChanged REVISION 10)
73 Q_PROPERTY(QString serialNumber READ serialNumber NOTIFY serialNumberChanged REVISION 10)
74 Q_PROPERTY(int width READ width NOTIFY widthChanged)
75 Q_PROPERTY(int height READ height NOTIFY heightChanged)
76 Q_PROPERTY(int desktopAvailableWidth READ desktopAvailableWidth NOTIFY desktopGeometryChanged)
77 Q_PROPERTY(int desktopAvailableHeight READ desktopAvailableHeight NOTIFY desktopGeometryChanged)
78 Q_PROPERTY(qreal logicalPixelDensity READ logicalPixelDensity NOTIFY logicalPixelDensityChanged)
79 Q_PROPERTY(qreal pixelDensity READ pixelDensity NOTIFY pixelDensityChanged)
80 Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged)
81 // TODO Qt 6 Rename primaryOrientation to orientation
82 Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation NOTIFY primaryOrientationChanged)
83 // TODO Qt 6 Remove this orientation -> incomplete device orientation -> better use OrientationSensor
84 Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged)
85
86 Q_PROPERTY(int virtualX READ virtualX NOTIFY virtualXChanged REVISION 1)
87 Q_PROPERTY(int virtualY READ virtualY NOTIFY virtualYChanged REVISION 1)
88
89public:
90 QQuickScreenInfo(QObject *parent = nullptr, QScreen *wrappedScreen = nullptr);
91
92 QString name() const;
93 QString manufacturer() const;
94 QString model() const;
95 QString serialNumber() const;
96 int width() const;
97 int height() const;
98 int desktopAvailableWidth() const;
99 int desktopAvailableHeight() const;
100 qreal logicalPixelDensity() const;
101 qreal pixelDensity() const;
102 qreal devicePixelRatio() const;
103 Qt::ScreenOrientation primaryOrientation() const;
104 Qt::ScreenOrientation orientation() const;
105 int virtualX() const;
106 int virtualY() const;
107
108 void setWrappedScreen(QScreen *screen);
109 QScreen *wrappedScreen() const;
110
111Q_SIGNALS:
112 void nameChanged();
113 Q_REVISION(10) void manufacturerChanged();
114 Q_REVISION(10) void modelChanged();
115 Q_REVISION(10) void serialNumberChanged();
116 void widthChanged();
117 void heightChanged();
118 void desktopGeometryChanged();
119 void logicalPixelDensityChanged();
120 void pixelDensityChanged();
121 void devicePixelRatioChanged();
122 void primaryOrientationChanged();
123 void orientationChanged();
124 Q_REVISION(1) void virtualXChanged();
125 Q_REVISION(1) void virtualYChanged();
126
127protected:
128 QPointer<QScreen> m_screen;
129};
130
131class Q_AUTOTEST_EXPORT QQuickScreenAttached : public QQuickScreenInfo
132{
133 Q_OBJECT
134 Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask
135 WRITE setOrientationUpdateMask NOTIFY orientationUpdateMaskChanged)
136
137public:
138 QQuickScreenAttached(QObject* attachee);
139
140 Qt::ScreenOrientations orientationUpdateMask() const;
141 void setOrientationUpdateMask(Qt::ScreenOrientations mask);
142
143 //Treats int as Qt::ScreenOrientation, due to QTBUG-20639
144 Q_INVOKABLE int angleBetween(int a, int b);
145
146 void windowChanged(QQuickWindow*);
147
148Q_SIGNALS:
149 void orientationUpdateMaskChanged();
150
151protected Q_SLOTS:
152 void screenChanged(QScreen*);
153
154private:
155 QQuickWindow* m_window;
156 QQuickItem* m_attachee;
157 Qt::ScreenOrientations m_updateMask;
158 bool m_updateMaskSet;
159};
160
161class Q_AUTOTEST_EXPORT QQuickScreen : public QObject
162{
163 Q_OBJECT
164public:
165 static QQuickScreenAttached *qmlAttachedProperties(QObject *object){ return new QQuickScreenAttached(object); }
166};
167
168QT_END_NAMESPACE
169
170QML_DECLARE_TYPEINFO(QQuickScreen, QML_HAS_ATTACHED_PROPERTIES)
171QML_DECLARE_TYPE(QQuickScreenInfo)
172
173#endif
174