source: trunk/src/gui/dialogs/qmessagebox.h@ 135

Last change on this file since 135 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 14.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QMESSAGEBOX_H
43#define QMESSAGEBOX_H
44
45#include <QtGui/qdialog.h>
46
47QT_BEGIN_HEADER
48
49QT_BEGIN_NAMESPACE
50
51QT_MODULE(Gui)
52
53#ifndef QT_NO_MESSAGEBOX
54
55class QLabel;
56class QMessageBoxPrivate;
57class QAbstractButton;
58
59class Q_GUI_EXPORT QMessageBox : public QDialog
60{
61 Q_OBJECT
62 Q_ENUMS(Icon)
63 Q_FLAGS(StandardButtons)
64 Q_PROPERTY(QString text READ text WRITE setText)
65 // ### Qt 5: Rename 'icon' 'standardIcon' and 'iconPixmap' 'icon' (and use QIcon?)
66 Q_PROPERTY(Icon icon READ icon WRITE setIcon)
67 Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
68 Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
69 Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
70#ifndef QT_NO_TEXTEDIT
71 Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText)
72#endif
73 Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText)
74
75public:
76 enum Icon {
77 NoIcon = 0,
78 Information = 1,
79 Warning = 2,
80 Critical = 3,
81 Question = 4
82 };
83
84 enum ButtonRole {
85 // keep this in sync with QDialogButtonBox::ButtonRole
86 InvalidRole = -1,
87 AcceptRole,
88 RejectRole,
89 DestructiveRole,
90 ActionRole,
91 HelpRole,
92 YesRole,
93 NoRole,
94 ResetRole,
95 ApplyRole,
96
97 NRoles
98 };
99
100 enum StandardButton {
101 // keep this in sync with QDialogButtonBox::StandardButton
102 NoButton = 0x00000000,
103 Ok = 0x00000400,
104 Save = 0x00000800,
105 SaveAll = 0x00001000,
106 Open = 0x00002000,
107 Yes = 0x00004000,
108 YesToAll = 0x00008000,
109 No = 0x00010000,
110 NoToAll = 0x00020000,
111 Abort = 0x00040000,
112 Retry = 0x00080000,
113 Ignore = 0x00100000,
114 Close = 0x00200000,
115 Cancel = 0x00400000,
116 Discard = 0x00800000,
117 Help = 0x01000000,
118 Apply = 0x02000000,
119 Reset = 0x04000000,
120 RestoreDefaults = 0x08000000,
121
122 FirstButton = Ok, // internal
123 LastButton = RestoreDefaults, // internal
124
125 YesAll = YesToAll, // obsolete
126 NoAll = NoToAll, // obsolete
127
128 Default = 0x00000100, // obsolete
129 Escape = 0x00000200, // obsolete
130 FlagMask = 0x00000300, // obsolete
131 ButtonMask = ~FlagMask // obsolete
132 };
133 typedef StandardButton Button; // obsolete
134
135 Q_DECLARE_FLAGS(StandardButtons, StandardButton)
136
137 explicit QMessageBox(QWidget *parent = 0);
138 QMessageBox(Icon icon, const QString &title, const QString &text,
139 StandardButtons buttons = NoButton, QWidget *parent = 0,
140 Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
141 ~QMessageBox();
142
143 void addButton(QAbstractButton *button, ButtonRole role);
144 QPushButton *addButton(const QString &text, ButtonRole role);
145 QPushButton *addButton(StandardButton button);
146 void removeButton(QAbstractButton *button);
147
148#ifdef Q_OS_WINCE
149 void setVisible(bool visible);
150#endif
151
152#ifdef Q_NO_USING_KEYWORD
153#ifndef Q_QDOC
154 void open() { QDialog::open(); }
155#endif
156#else
157 using QDialog::open;
158#endif
159 void open(QObject *receiver, const char *member);
160
161 QList<QAbstractButton *> buttons() const;
162 ButtonRole buttonRole(QAbstractButton *button) const;
163
164 void setStandardButtons(StandardButtons buttons);
165 StandardButtons standardButtons() const;
166 StandardButton standardButton(QAbstractButton *button) const;
167 QAbstractButton *button(StandardButton which) const;
168
169 QPushButton *defaultButton() const;
170 void setDefaultButton(QPushButton *button);
171 void setDefaultButton(StandardButton button);
172
173 QAbstractButton *escapeButton() const;
174 void setEscapeButton(QAbstractButton *button);
175 void setEscapeButton(StandardButton button);
176
177 QAbstractButton *clickedButton() const;
178
179 QString text() const;
180 void setText(const QString &text);
181
182 Icon icon() const;
183 void setIcon(Icon);
184
185 QPixmap iconPixmap() const;
186 void setIconPixmap(const QPixmap &pixmap);
187
188 Qt::TextFormat textFormat() const;
189 void setTextFormat(Qt::TextFormat format);
190
191 static StandardButton information(QWidget *parent, const QString &title,
192 const QString &text, StandardButtons buttons = Ok,
193 StandardButton defaultButton = NoButton);
194 static StandardButton question(QWidget *parent, const QString &title,
195 const QString &text, StandardButtons buttons = Ok,
196 StandardButton defaultButton = NoButton);
197 static StandardButton warning(QWidget *parent, const QString &title,
198 const QString &text, StandardButtons buttons = Ok,
199 StandardButton defaultButton = NoButton);
200 static StandardButton critical(QWidget *parent, const QString &title,
201 const QString &text, StandardButtons buttons = Ok,
202 StandardButton defaultButton = NoButton);
203 static void about(QWidget *parent, const QString &title, const QString &text);
204 static void aboutQt(QWidget *parent, const QString &title = QString());
205
206 QSize sizeHint() const;
207
208 // the following functions are obsolete:
209
210 QMessageBox(const QString &title, const QString &text, Icon icon,
211 int button0, int button1, int button2,
212 QWidget *parent = 0,
213 Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
214
215 static int information(QWidget *parent, const QString &title,
216 const QString& text,
217 int button0, int button1 = 0, int button2 = 0);
218 static int information(QWidget *parent, const QString &title,
219 const QString& text,
220 const QString& button0Text,
221 const QString& button1Text = QString(),
222 const QString& button2Text = QString(),
223 int defaultButtonNumber = 0,
224 int escapeButtonNumber = -1);
225 inline static StandardButton information(QWidget *parent, const QString &title,
226 const QString& text,