-
Notifications
You must be signed in to change notification settings - Fork 364
/
mywindow.h
57 lines (44 loc) · 1.51 KB
/
mywindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <qscreen.h>
#include <private/qtquickglobal_p.h>
#include <qquickwindow.h>
#include <qqmlparserstatus.h>
#include "mywindowattached.h"
class MyQuickWindowPrivate;
class MyQuickWindow : public QQuickWindow, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged)
Q_PROPERTY(QObject *screen READ screen WRITE setScreen NOTIFY screenChanged)
Q_PROPERTY(qreal dpiRatio READ dpiRatio NOTIFY dpiRatioChanged)
QML_ATTACHED(MyQuickWindowAttached)
public:
MyQuickWindow(QWindow *parent = nullptr);
void setVisible(bool visible);
void setVisibility(Visibility visibility);
QObject *screen() const;
void setScreen(QObject *screen);
qreal dpiRatio();
void setDpiRatio(qreal ratio);
static MyQuickWindowAttached *qmlAttachedProperties(QObject *object);
Q_SIGNALS:
void visibleChanged(bool arg);
void visibilityChanged(QWindow::Visibility visibility);
void screenChanged();
void dpiRatioChanged(qreal ratio);
protected:
void classBegin() override;
void componentComplete() override;
private Q_SLOTS:
void setWindowVisibility();
private:
bool transientParentVisible();
void onScreenChange(QScreen *screen);
void calcDpi();
private:
Q_DISABLE_COPY(MyQuickWindow)
Q_DECLARE_PRIVATE(MyQuickWindow)
};
QML_DECLARE_TYPE(MyQuickWindow)