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
4#ifndef QQUICKSCREEN_P_H
5#define QQUICKSCREEN_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQml/qqml.h>
19#include <QtQuick/private/qtquickglobal_p.h>
20
21QT_BEGIN_NAMESPACE
22
23
24class QQuickItem;
25class QQuickWindow;
26class QScreen;
27
28
29class Q_QUICK_PRIVATE_EXPORT QQuickScreenInfo : public QObject
30{
31 Q_OBJECT
32 Q_PROPERTY(QString name READ name NOTIFY nameChanged FINAL)
33 Q_PROPERTY(QString manufacturer READ manufacturer NOTIFY manufacturerChanged REVISION(2, 10) FINAL)
34 Q_PROPERTY(QString model READ model NOTIFY modelChanged REVISION(2, 10) FINAL)
35 Q_PROPERTY(QString serialNumber READ serialNumber NOTIFY serialNumberChanged REVISION(2, 10) FINAL)
36 Q_PROPERTY(int width READ width NOTIFY widthChanged FINAL)
37 Q_PROPERTY(int height READ height NOTIFY heightChanged FINAL)
38 Q_PROPERTY(int desktopAvailableWidth READ desktopAvailableWidth NOTIFY desktopGeometryChanged FINAL)
39 Q_PROPERTY(int desktopAvailableHeight READ desktopAvailableHeight NOTIFY desktopGeometryChanged FINAL)
40 Q_PROPERTY(qreal logicalPixelDensity READ logicalPixelDensity NOTIFY logicalPixelDensityChanged FINAL)
41 Q_PROPERTY(qreal pixelDensity READ pixelDensity NOTIFY pixelDensityChanged FINAL)
42 Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged FINAL)
43 Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation NOTIFY primaryOrientationChanged FINAL)
44 Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged FINAL)
45
46 Q_PROPERTY(int virtualX READ virtualX NOTIFY virtualXChanged REVISION(2, 3) FINAL)
47 Q_PROPERTY(int virtualY READ virtualY NOTIFY virtualYChanged REVISION(2, 3) FINAL)
48 QML_NAMED_ELEMENT(ScreenInfo)
49 QML_ADDED_IN_VERSION(2, 3)
50 QML_UNCREATABLE("ScreenInfo can only be used via the attached property.")
51
52public:
53 QQuickScreenInfo(QObject *parent = nullptr, QScreen *wrappedScreen = nullptr);
54
55 QString name() const;
56 QString manufacturer() const;
57 QString model() const;
58 QString serialNumber() const;
59 int width() const;
60 int height() const;
61 int desktopAvailableWidth() const;
62 int desktopAvailableHeight() const;
63 qreal logicalPixelDensity() const;
64 qreal pixelDensity() const;
65 qreal devicePixelRatio() const;
66 Qt::ScreenOrientation primaryOrientation() const;
67 Qt::ScreenOrientation orientation() const;
68 int virtualX() const;
69 int virtualY() const;
70
71 void setWrappedScreen(QScreen *screen);
72 QScreen *wrappedScreen() const;
73
74Q_SIGNALS:
75 void nameChanged();
76 Q_REVISION(2, 10) void manufacturerChanged();
77 Q_REVISION(2, 10) void modelChanged();
78 Q_REVISION(2, 10) void serialNumberChanged();
79 void widthChanged();
80 void heightChanged();
81 void desktopGeometryChanged();
82 void logicalPixelDensityChanged();
83 void pixelDensityChanged();
84 void devicePixelRatioChanged();
85 void primaryOrientationChanged();
86 void orientationChanged();
87 Q_REVISION(2, 3) void virtualXChanged();
88 Q_REVISION(2, 3) void virtualYChanged();
89
90protected:
91 QPointer<QScreen> m_screen;
92};
93
94class Q_QUICK_PRIVATE_EXPORT QQuickScreenAttached : public QQuickScreenInfo
95{
96 Q_OBJECT
97
98 QML_ANONYMOUS
99 QML_ADDED_IN_VERSION(2, 0)
100
101public:
102 QQuickScreenAttached(QObject* attachee);
103
104 //Treats int as Qt::ScreenOrientation, due to QTBUG-20639
105 Q_INVOKABLE int angleBetween(int a, int b);
106
107 void windowChanged(QQuickWindow*);
108
109protected Q_SLOTS:
110 void screenChanged(QScreen*);
111
112private:
113 QQuickWindow* m_window = nullptr;
114 QQuickItem* m_attachee;
115};
116
117class Q_QUICK_PRIVATE_EXPORT QQuickScreen : public QObject
118{
119 Q_OBJECT
120 QML_ATTACHED(QQuickScreenAttached)
121 QML_NAMED_ELEMENT(Screen)
122 QML_ADDED_IN_VERSION(2, 0)
123 QML_UNCREATABLE("Screen can only be used via the attached property.")
124
125public:
126 static QQuickScreenAttached *qmlAttachedProperties(QObject *object){ return new QQuickScreenAttached(object); }
127};
128
129QT_END_NAMESPACE
130
131QML_DECLARE_TYPE(QQuickScreenInfo)
132
133#endif
134

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