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