| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2017 The Qt Company Ltd. | 
| 4 | ** Contact: http://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the Qt Labs Platform module of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL3$ | 
| 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 http://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free | 
| 28 | ** Software Foundation and appearing in the file LICENSE.GPL included in | 
| 29 | ** the packaging of this file. Please review the following information to | 
| 30 | ** ensure the GNU General Public License version 2.0 requirements will be | 
| 31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. | 
| 32 | ** | 
| 33 | ** $QT_END_LICENSE$ | 
| 34 | ** | 
| 35 | ****************************************************************************/ | 
| 36 |  | 
| 37 | #ifndef QQUICKPLATFORMDIALOG_P_H | 
| 38 | #define QQUICKPLATFORMDIALOG_P_H | 
| 39 |  | 
| 40 | // | 
| 41 | //  W A R N I N G | 
| 42 | //  ------------- | 
| 43 | // | 
| 44 | // This file is not part of the Qt API.  It exists purely as an | 
| 45 | // implementation detail.  This header file may change from version to | 
| 46 | // version without notice, or even be removed. | 
| 47 | // | 
| 48 | // We mean it. | 
| 49 | // | 
| 50 |  | 
| 51 | #include <QtCore/qobject.h> | 
| 52 | #include <QtGui/qpa/qplatformtheme.h> | 
| 53 | #include <QtGui/qpa/qplatformdialoghelper.h> | 
| 54 | #include <QtQml/qqmlparserstatus.h> | 
| 55 | #include <QtQml/qqmllist.h> | 
| 56 | #include <QtQml/qqml.h> | 
| 57 |  | 
| 58 | QT_BEGIN_NAMESPACE | 
| 59 |  | 
| 60 | class QWindow; | 
| 61 | class QPlatformDialogHelper; | 
| 62 |  | 
| 63 | class QQuickPlatformDialog : public QObject, public QQmlParserStatus | 
| 64 | { | 
| 65 |     Q_OBJECT | 
| 66 |     Q_INTERFACES(QQmlParserStatus) | 
| 67 |     Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL) | 
| 68 |     Q_PROPERTY(QWindow *parentWindow READ parentWindow WRITE setParentWindow NOTIFY parentWindowChanged FINAL) | 
| 69 |     Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) | 
| 70 |     Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFlags NOTIFY flagsChanged FINAL) | 
| 71 |     Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged FINAL) | 
| 72 |     Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) | 
| 73 |     Q_PROPERTY(int result READ result WRITE setResult NOTIFY resultChanged FINAL) | 
| 74 |     Q_CLASSINFO("DefaultProperty" , "data" ) | 
| 75 |  | 
| 76 | public: | 
| 77 |     explicit QQuickPlatformDialog(QPlatformTheme::DialogType type, QObject *parent = nullptr); | 
| 78 |     ~QQuickPlatformDialog(); | 
| 79 |  | 
| 80 |     QPlatformDialogHelper *handle() const; | 
| 81 |  | 
| 82 |     QQmlListProperty<QObject> data(); | 
| 83 |  | 
| 84 |     QWindow *parentWindow() const; | 
| 85 |     void setParentWindow(QWindow *window); | 
| 86 |  | 
| 87 |     QString title() const; | 
| 88 |     void setTitle(const QString &title); | 
| 89 |  | 
| 90 |     Qt::WindowFlags flags() const; | 
| 91 |     void setFlags(Qt::WindowFlags flags); | 
| 92 |  | 
| 93 |     Qt::WindowModality modality() const; | 
| 94 |     void setModality(Qt::WindowModality modality); | 
| 95 |  | 
| 96 |     bool isVisible() const; | 
| 97 |     void setVisible(bool visible); | 
| 98 |  | 
| 99 |     enum StandardCode { Rejected, Accepted }; | 
| 100 |     Q_ENUM(StandardCode) | 
| 101 |  | 
| 102 |     int result() const; | 
| 103 |     void setResult(int result); | 
| 104 |  | 
| 105 | public Q_SLOTS: | 
| 106 |     void open(); | 
| 107 |     void close(); | 
| 108 |     virtual void accept(); | 
| 109 |     virtual void reject(); | 
| 110 |     virtual void done(int result); | 
| 111 |  | 
| 112 | Q_SIGNALS: | 
| 113 |     void accepted(); | 
| 114 |     void rejected(); | 
| 115 |     void parentWindowChanged(); | 
| 116 |     void titleChanged(); | 
| 117 |     void flagsChanged(); | 
| 118 |     void modalityChanged(); | 
| 119 |     void visibleChanged(); | 
| 120 |     void resultChanged(); | 
| 121 |  | 
| 122 | protected: | 
| 123 |     void classBegin() override; | 
| 124 |     void componentComplete() override; | 
| 125 |  | 
| 126 |     bool create(); | 
| 127 |     void destroy(); | 
| 128 |  | 
| 129 |     virtual bool useNativeDialog() const; | 
| 130 |     virtual void onCreate(QPlatformDialogHelper *dialog); | 
| 131 |     virtual void onShow(QPlatformDialogHelper *dialog); | 
| 132 |     virtual void onHide(QPlatformDialogHelper *dialog); | 
| 133 |  | 
| 134 |     QWindow *findParentWindow() const; | 
| 135 |  | 
| 136 | private: | 
| 137 |     bool m_visible; | 
| 138 |     bool m_complete; | 
| 139 |     int m_result; | 
| 140 |     QWindow *m_parentWindow; | 
| 141 |     QString m_title; | 
| 142 |     Qt::WindowFlags m_flags; | 
| 143 |     Qt::WindowModality m_modality; | 
| 144 |     QPlatformTheme::DialogType m_type; | 
| 145 |     QList<QObject *> m_data; | 
| 146 |     QPlatformDialogHelper *m_handle; | 
| 147 | }; | 
| 148 |  | 
| 149 | QT_END_NAMESPACE | 
| 150 |  | 
| 151 | QML_DECLARE_TYPE(QQuickPlatformDialog) | 
| 152 |  | 
| 153 | #endif // QQUICKPLATFORMDIALOG_P_H | 
| 154 |  |