1// Copyright (C) 2022 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 QQUICKLABSPLATFORMDIALOG_P_H
5#define QQUICKLABSPLATFORMDIALOG_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 <QtCore/qobject.h>
19#include <QtGui/qpa/qplatformtheme.h>
20#include <QtGui/qpa/qplatformdialoghelper.h>
21#include <QtQml/qqmlparserstatus.h>
22#include <QtQml/qqmllist.h>
23#include <QtQml/qqml.h>
24#include <QtCore/private/qglobal_p.h>
25
26QT_BEGIN_NAMESPACE
27
28class QWindow;
29class QPlatformDialogHelper;
30
31class QQuickLabsPlatformDialog : public QObject, public QQmlParserStatus
32{
33 Q_OBJECT
34 Q_INTERFACES(QQmlParserStatus)
35 QML_NAMED_ELEMENT(Dialog)
36 QML_UNCREATABLE("Dialog is an abstract base class")
37 Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL)
38 Q_PROPERTY(QWindow *parentWindow READ parentWindow WRITE setParentWindow NOTIFY parentWindowChanged FINAL)
39 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
40 Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFlags NOTIFY flagsChanged FINAL)
41 Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged FINAL)
42 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
43 Q_PROPERTY(int result READ result WRITE setResult NOTIFY resultChanged FINAL)
44 Q_CLASSINFO("DefaultProperty", "data")
45
46public:
47 explicit QQuickLabsPlatformDialog(QPlatformTheme::DialogType type, QObject *parent = nullptr);
48 ~QQuickLabsPlatformDialog();
49
50 QPlatformDialogHelper *handle() const;
51
52 QQmlListProperty<QObject> data();
53
54 QWindow *parentWindow() const;
55 void setParentWindow(QWindow *window);
56
57 QString title() const;
58 void setTitle(const QString &title);
59
60 Qt::WindowFlags flags() const;
61 void setFlags(Qt::WindowFlags flags);
62
63 Qt::WindowModality modality() const;
64 void setModality(Qt::WindowModality modality);
65
66 bool isVisible() const;
67 void setVisible(bool visible);
68
69 enum StandardCode { Rejected, Accepted };
70 Q_ENUM(StandardCode)
71
72 int result() const;
73 void setResult(int result);
74
75public Q_SLOTS:
76 void open();
77 void close();
78 virtual void accept();
79 virtual void reject();
80 virtual void done(int result);
81
82Q_SIGNALS:
83 void accepted();
84 void rejected();
85 void parentWindowChanged();
86 void titleChanged();
87 void flagsChanged();
88 void modalityChanged();
89 void visibleChanged();
90 void resultChanged();
91
92protected:
93 void classBegin() override;
94 void componentComplete() override;
95
96 bool create();
97 void destroy();
98
99 virtual bool useNativeDialog() const;
100 virtual void onCreate(QPlatformDialogHelper *dialog);
101 virtual void onShow(QPlatformDialogHelper *dialog);
102 virtual void onHide(QPlatformDialogHelper *dialog);
103
104 QWindow *findParentWindow() const;
105
106private:
107 bool m_visible;
108 bool m_complete;
109 int m_result;
110 QWindow *m_parentWindow;
111 QString m_title;
112 Qt::WindowFlags m_flags;
113 Qt::WindowModality m_modality;
114 QPlatformTheme::DialogType m_type;
115 QList<QObject *> m_data;
116 QPlatformDialogHelper *m_handle;
117};
118
119class QPlatformDialogHelperQuickLabsForeign
120{
121 Q_GADGET
122 QML_FOREIGN(QPlatformDialogHelper)
123 QML_NAMED_ELEMENT(StandardButton)
124 QML_UNCREATABLE("Cannot create an instance of StandardButton")
125};
126
127QT_END_NAMESPACE
128
129QML_DECLARE_TYPE(QQuickLabsPlatformDialog)
130
131#endif // QQUICKLABSPLATFORMDIALOG_P_H
132

source code of qtdeclarative/src/labs/platform/qquicklabsplatformdialog_p.h