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/qtquickglobal_p.h>
58
59QT_BEGIN_NAMESPACE
60
61
62class QQuickItem;
63class QQuickWindow;
64class QScreen;
65
66
67class Q_QUICK_PRIVATE_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 Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation NOTIFY primaryOrientationChanged)
82 Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged)
83
84 Q_PROPERTY(int virtualX READ virtualX NOTIFY virtualXChanged REVISION 3)
85 Q_PROPERTY(int virtualY READ virtualY NOTIFY virtualYChanged REVISION 3)
86
87public:
88 QQuickScreenInfo(QObject *parent = nullptr, QScreen *wrappedScreen = nullptr);
89
90 QString name() const;
91 QString manufacturer() const;
92 QString model() const;
93 QString serialNumber() const;
94 int width() const;
95 int height() const;
96 int desktopAvailableWidth() const;
97 int desktopAvailableHeight() const;
98 qreal logicalPixelDensity() const;
99 qreal pixelDensity() const;
100 qreal devicePixelRatio() const;
101 Qt::ScreenOrientation primaryOrientation() const;
102 Qt::ScreenOrientation orientation() const;
103 int virtualX() const;
104 int virtualY() const;
105
106 void setWrappedScreen(QScreen *screen);
107 QScreen *wrappedScreen() const;
108
109Q_SIGNALS:
110 void nameChanged();
111 Q_REVISION(10) void manufacturerChanged();
112 Q_REVISION(10) void modelChanged();
113 Q_REVISION(10) void serialNumberChanged();
114 void widthChanged();
115 void heightChanged();
116 void desktopGeometryChanged();
117 void logicalPixelDensityChanged();
118 void pixelDensityChanged();
119 void devicePixelRatioChanged();
120 void primaryOrientationChanged();
121 void orientationChanged();
122 Q_REVISION(3) void virtualXChanged();
123 Q_REVISION(3) void virtualYChanged();
124
125protected:
126 QPointer<QScreen> m_screen;
127};
128
129class Q_QUICK_PRIVATE_EXPORT QQuickScreenAttached : public QQuickScreenInfo
130{
131 Q_OBJECT
132 Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask
133 WRITE setOrientationUpdateMask NOTIFY orientationUpdateMaskChanged)
134
135public:
136 QQuickScreenAttached(QObject* attachee);
137
138 Qt::ScreenOrientations orientationUpdateMask() const;
139 void setOrientationUpdateMask(Qt::ScreenOrientations mask);
140
141 //Treats int as Qt::ScreenOrientation, due to QTBUG-20639
142 Q_INVOKABLE int angleBetween(int a, int b);
143
144 void windowChanged(QQuickWindow*);
145
146Q_SIGNALS:
147 void orientationUpdateMaskChanged();
148
149protected Q_SLOTS:
150 void screenChanged(QScreen*);
151
152private:
153 QQuickWindow* m_window = nullptr;
154 QQuickItem* m_attachee;
155 Qt::ScreenOrientations m_updateMask;
156 bool m_updateMaskSet = false;
157};
158
159class Q_QUICK_PRIVATE_EXPORT QQuickScreen : public QObject
160{
161 Q_OBJECT
162 QML_ATTACHED(QQuickScreenAttached)
163
164public:
165 static QQuickScreenAttached *qmlAttachedProperties(QObject *object){ return new QQuickScreenAttached(object); }
166};
167
168QT_END_NAMESPACE
169
170QML_DECLARE_TYPE(QQuickScreenInfo)
171
172#endif
173

source code of qtdeclarative/src/quick/items/qquickscreen_p.h