1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtGui module of the Qt Toolkit.
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 Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
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 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
45
#include <QtWidgets/qdialog.h>
52
#ifndef QT_NO_MESSAGEBOX
55
class QMessageBoxPrivate;
56
class QAbstractButton;
58
class Q_WIDGETS_EXPORT QMessageBox : public QDialog
62
Q_FLAGS(StandardButtons)
63
Q_PROPERTY(QString text READ text WRITE setText)
64
Q_PROPERTY(Icon icon READ icon WRITE setIcon)
65
Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
66
Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
67
Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
68
#ifndef QT_NO_TEXTEDIT
69
Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText)
71
Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText)
83
// keep this in sync with QDialogButtonBox::ButtonRole
99
// keep this in sync with QDialogButtonBox::StandardButton
100
NoButton = 0x00000000,
103
SaveAll = 0x00001000,
106
YesToAll = 0x00008000,
108
NoToAll = 0x00020000,
114
Discard = 0x00800000,
118
RestoreDefaults = 0x08000000,
120
FirstButton = Ok, // internal
121
LastButton = RestoreDefaults, // internal
123
YesAll = YesToAll, // obsolete
124
NoAll = NoToAll, // obsolete
126
Default = 0x00000100, // obsolete
127
Escape = 0x00000200, // obsolete
128
FlagMask = 0x00000300, // obsolete
129
ButtonMask = ~FlagMask // obsolete
131
typedef StandardButton Button; // obsolete
133
Q_DECLARE_FLAGS(StandardButtons, StandardButton)
135
explicit QMessageBox(QWidget *parent = 0);
136
QMessageBox(Icon icon, const QString &title, const QString &text,
137
StandardButtons buttons = NoButton, QWidget *parent = 0,
138
Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
141
void addButton(QAbstractButton *button, ButtonRole role);
142
QPushButton *addButton(const QString &text, ButtonRole role);
143
QPushButton *addButton(StandardButton button);
144
void removeButton(QAbstractButton *button);
147
void setVisible(bool visible);
150
#ifdef Q_NO_USING_KEYWORD
152
void open() { QDialog::open(); }
157
void open(QObject *receiver, const char *member);
159
QList<QAbstractButton *> buttons() const;
160
ButtonRole buttonRole(QAbstractButton *button) const;
162
void setStandardButtons(StandardButtons buttons);
163
StandardButtons standardButtons() const;
164
StandardButton standardButton(QAbstractButton *button) const;
165
QAbstractButton *button(StandardButton which) const;
167
QPushButton *defaultButton() const;
168
void setDefaultButton(QPushButton *button);
169
void setDefaultButton(StandardButton button);
171
QAbstractButton *escapeButton() const;
172
void setEscapeButton(QAbstractButton *button);
173
void setEscapeButton(StandardButton button);
175
QAbstractButton *clickedButton() const;
177
QString text() const;
178
void setText(const QString &text);
183
QPixmap iconPixmap() const;
184
void setIconPixmap(const QPixmap &pixmap);
186
Qt::TextFormat textFormat() const;
187
void setTextFormat(Qt::TextFormat format);
189
static StandardButton information(QWidget *parent, const QString &title,
190
const QString &text, StandardButtons buttons = Ok,
191
StandardButton defaultButton = NoButton);
192
static StandardButton question(QWidget *parent, const QString &title,
193
const QString &text, StandardButtons buttons = StandardButtons(Yes | No),
194
StandardButton defaultButton = NoButton);
195
static StandardButton warning(QWidget *parent, const QString &title,
196
const QString &text, StandardButtons buttons = Ok,
197
StandardButton defaultButton = NoButton);
198
static StandardButton critical(QWidget *parent, const QString &title,
199
const QString &text, StandardButtons buttons = Ok,
200
StandardButton defaultButton = NoButton);
201
static void about(QWidget *parent, const QString &title, const QString &text);
202
static void aboutQt(QWidget *parent, const QString &title = QString());
204
// the following functions are obsolete:
206
QMessageBox(const QString &title, const QString &text, Icon icon,
207
int button0, int button1, int button2,
209
Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
211
static int information(QWidget *parent, const QString &title,
213
int button0, int button1 = 0, int button2 = 0);
214
static int information(QWidget *parent, const QString &title,
216
const QString& button0Text,
217
const QString& button1Text = QString(),
218
const QString& button2Text = QString(),
219
int defaultButtonNumber = 0,
220
int escapeButtonNumber = -1);
221
inline static StandardButton information(QWidget *parent, const QString &title,
223
StandardButton button0, StandardButton button1 = NoButton)
224
{ return information(parent, title, text, StandardButtons(button0), button1); }
226
static int question(QWidget *parent, const QString &title,
228
int button0, int button1 = 0, int button2 = 0);
229
static int question(QWidget *parent, const QString &title,
231
const QString& button0Text,
232
const QString& button1Text = QString(),
233
const QString& button2Text = QString(),
234
int defaultButtonNumber = 0,
235
int escapeButtonNumber = -1);
236
inline static int question(QWidget *parent, const QString &title,
238
StandardButton button0, StandardButton button1)
239
{ return question(parent, title, text, StandardButtons(button0), button1); }
241
static int warning(QWidget *parent, const QString &title,
243
int button0, int button1, int button2 = 0);
244
static int warning(QWidget *parent, const QString &title,
246
const QString& button0Text,
247
const QString& button1Text = QString(),
248
const QString& button2Text = QString(),
249
int defaultButtonNumber = 0,
250
int escapeButtonNumber = -1);
251
inline static int warning(QWidget *parent, const QString &title,
253
StandardButton button0, StandardButton button1)
254
{ return warning(parent, title, text, StandardButtons(button0), button1); }
256
static int critical(QWidget *parent, const QString &title,
258
int button0, int button1, int button2 = 0);
259
static int critical(QWidget *parent, const QString &title,
261
const QString& button0Text,
262
const QString& button1Text = QString(),
263
const QString& button2Text = QString(),
264
int defaultButtonNumber = 0,
265
int escapeButtonNumber = -1);
266
inline static int critical(QWidget *parent, const QString &title,
268
StandardButton button0, StandardButton button1)
269
{ return critical(parent, title, text, StandardButtons(button0), button1); }
271
QString buttonText(int button) const;
272
void setButtonText(int button, const QString &text);
274
QString informativeText() const;
275
void setInformativeText(const QString &text);
277
#ifndef QT_NO_TEXTEDIT
278
QString detailedText() const;
279
void setDetailedText(const QString &text);
282
void setWindowTitle(const QString &title);
283
void setWindowModality(Qt::WindowModality windowModality);
286
static QPixmap standardIcon(Icon icon);
289
void buttonClicked(QAbstractButton *button);
297
bool event(QEvent *e);
298
void resizeEvent(QResizeEvent *event);
299
void showEvent(QShowEvent *event);
300
void closeEvent(QCloseEvent *event);
301
void keyPressEvent(QKeyEvent *event);
302
void changeEvent(QEvent *event);
305
Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked(QAbstractButton *))
307
Q_DISABLE_COPY(QMessageBox)
308
Q_DECLARE_PRIVATE(QMessageBox)
311
Q_DECLARE_OPERATORS_FOR_FLAGS(QMessageBox::StandardButtons)
313
#define QT_REQUIRE_VERSION(argc, argv, str) { QString s = QString::fromLatin1(str);\
314
QString sq = QString::fromLatin1(qVersion()); \
315
if ((sq.section(QChar::fromLatin1('.'),0,0).toInt()<<16)+\
316
(sq.section(QChar::fromLatin1('.'),1,1).toInt()<<8)+\
317
sq.section(QChar::fromLatin1('.'),2,2).toInt()<(s.section(QChar::fromLatin1('.'),0,0).toInt()<<16)+\
318
(s.section(QChar::fromLatin1('.'),1,1).toInt()<<8)+\
319
s.section(QChar::fromLatin1('.'),2,2).toInt()) { \
321
new QApplication(argc,argv); \
323
QString s = QApplication::tr("Executable '%1' requires Qt "\
324
"%2, found Qt %3.").arg(qAppName()).arg(QString::fromLatin1(\
325
str)).arg(QString::fromLatin1(qVersion())); QMessageBox::critical(0, QApplication::tr(\
326
"Incompatible Qt Library Error"), s, QMessageBox::Abort, 0); qFatal("%s", s.toLatin1().data()); }}
328
#endif // QT_NO_MESSAGEBOX
334
#endif // QMESSAGEBOX_H