1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Dialogs module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
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 https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QQUICKABSTRACTMESSAGEDIALOG_P_H
41#define QQUICKABSTRACTMESSAGEDIALOG_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QQuickView>
55#include <QtGui/qpa/qplatformdialoghelper.h>
56#include <qpa/qplatformtheme.h>
57#include "qquickabstractdialog_p.h"
58
59QT_BEGIN_NAMESPACE
60
61class QQuickAbstractMessageDialog : public QQuickAbstractDialog
62{
63 Q_OBJECT
64
65 Q_ENUMS(Icon)
66
67 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
68 Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged)
69 Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText NOTIFY detailedTextChanged)
70 Q_PROPERTY(Icon icon READ icon WRITE setIcon NOTIFY iconChanged)
71 Q_PROPERTY(QUrl standardIconSource READ standardIconSource NOTIFY iconChanged)
72 Q_PROPERTY(QQuickAbstractDialog::StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged)
73 Q_PROPERTY(QQuickAbstractDialog::StandardButton clickedButton READ clickedButton NOTIFY buttonClicked)
74
75public:
76 QQuickAbstractMessageDialog(QObject *parent = 0);
77 virtual ~QQuickAbstractMessageDialog();
78
79 QString title() const override { return m_options->windowTitle(); }
80 QString text() const { return m_options->text(); }
81 QString informativeText() const { return m_options->informativeText(); }
82 QString detailedText() const { return m_options->detailedText(); }
83
84 enum Icon {
85 NoIcon = QMessageDialogOptions::NoIcon,
86 Information = QMessageDialogOptions::Information,
87 Warning = QMessageDialogOptions::Warning,
88 Critical = QMessageDialogOptions::Critical,
89 Question = QMessageDialogOptions::Question
90 };
91
92 Icon icon() const { return static_cast<Icon>(m_options->icon()); }
93
94 QUrl standardIconSource();
95
96 StandardButtons standardButtons() const { return static_cast<StandardButtons>(static_cast<int>(m_options->standardButtons())); }
97
98 StandardButton clickedButton() const { return m_clickedButton; }
99
100public Q_SLOTS:
101 void setVisible(bool v) override;
102 void setTitle(const QString &arg) override;
103 void setText(const QString &arg);
104 void setInformativeText(const QString &arg);
105 void setDetailedText(const QString &arg);
106 void setIcon(Icon icon);
107 void setStandardButtons(StandardButtons buttons);
108 void click(QQuickAbstractDialog::StandardButton button);
109
110Q_SIGNALS:
111 void textChanged();
112 void informativeTextChanged();
113 void detailedTextChanged();
114 void iconChanged();
115 void standardButtonsChanged();
116 void buttonClicked();
117 void discard();
118 void help();
119 void yes();
120 void no();
121 void apply();
122 void reset();
123
124protected Q_SLOTS:
125 void click(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole);
126
127protected:
128 QPlatformMessageDialogHelper *m_dlgHelper;
129 QSharedPointer<QMessageDialogOptions> m_options;
130 StandardButton m_clickedButton;
131
132 Q_DISABLE_COPY(QQuickAbstractMessageDialog)
133};
134
135QT_END_NAMESPACE
136
137#endif // QQUICKABSTRACTMESSAGEDIALOG_P_H
138

source code of qtquickcontrols/src/dialogs/qquickabstractmessagedialog_p.h