~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/dialogs/qmessagebox.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the dialog module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QMESSAGEBOX_H
 
30
#define QMESSAGEBOX_H
 
31
 
 
32
#include "QtGui/qdialog.h"
 
33
 
 
34
#ifndef QT_NO_MESSAGEBOX
 
35
 
 
36
class QLabel;
 
37
class QMessageBoxPrivate;
 
38
 
 
39
class Q_GUI_EXPORT QMessageBox : public QDialog
 
40
{
 
41
    Q_OBJECT
 
42
    Q_ENUMS(Icon)
 
43
    Q_PROPERTY(QString text READ text WRITE setText)
 
44
    Q_PROPERTY(Icon icon READ icon WRITE setIcon)
 
45
    Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
 
46
    Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
 
47
 
 
48
public:
 
49
    enum Icon {
 
50
        NoIcon = 0,
 
51
        Information = 1,
 
52
        Warning = 2,
 
53
        Critical = 3,
 
54
        Question = 4
 
55
    };
 
56
 
 
57
    explicit QMessageBox(QWidget *parent = 0);
 
58
    QMessageBox(const QString &caption, const QString &text, Icon icon,
 
59
                int button0, int button1, int button2,
 
60
                QWidget *parent = 0, Qt::WFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
 
61
    ~QMessageBox();
 
62
 
 
63
    enum Button { NoButton = 0, Ok = 1, Cancel = 2, Yes = 3, No = 4, Abort = 5,
 
64
           Retry = 6, Ignore = 7, YesAll = 8, NoAll = 9, ButtonMask = 0xff,
 
65
           Default = 0x100, Escape = 0x200, FlagMask = 0x300 };
 
66
 
 
67
    QString text() const;
 
68
    void setText(const QString &);
 
69
 
 
70
    Icon icon() const;
 
71
    void setIcon(Icon);
 
72
 
 
73
    QPixmap iconPixmap() const;
 
74
    void setIconPixmap(const QPixmap &);
 
75
 
 
76
    QString buttonText(int button) const;
 
77
    void setButtonText(int button, const QString &);
 
78
 
 
79
    Qt::TextFormat textFormat() const;
 
80
    void setTextFormat(Qt::TextFormat);
 
81
 
 
82
    static int information(QWidget *parent, const QString &caption,
 
83
                            const QString& text,
 
84
                            int button0, int button1=0, int button2=0);
 
85
    static int information(QWidget *parent, const QString &caption,
 
86
                            const QString& text,
 
87
                            const QString& button0Text = QString(),
 
88
                            const QString& button1Text = QString(),
 
89
                            const QString& button2Text = QString(),
 
90
                            int defaultButtonNumber = 0,
 
91
                            int escapeButtonNumber = -1);
 
92
 
 
93
    static int question(QWidget *parent, const QString &caption,
 
94
                         const QString& text,
 
95
                         int button0, int button1=0, int button2=0);
 
96
    static int question(QWidget *parent, const QString &caption,
 
97
                         const QString& text,
 
98
                         const QString& button0Text = QString(),
 
99
                         const QString& button1Text = QString(),
 
100
                         const QString& button2Text = QString(),
 
101
                         int defaultButtonNumber = 0,
 
102
                         int escapeButtonNumber = -1);
 
103
 
 
104
    static int warning(QWidget *parent, const QString &caption,
 
105
                        const QString& text,
 
106
                        int button0, int button1, int button2=0);
 
107
    static int warning(QWidget *parent, const QString &caption,
 
108
                        const QString& text,
 
109
                        const QString& button0Text = QString(),
 
110
                        const QString& button1Text = QString(),
 
111
                        const QString& button2Text = QString(),
 
112
                        int defaultButtonNumber = 0,
 
113
                        int escapeButtonNumber = -1);
 
114
 
 
115
    static int critical(QWidget *parent, const QString &caption,
 
116
                         const QString& text,
 
117
                         int button0, int button1, int button2=0);
 
118
    static int critical(QWidget *parent, const QString &caption,
 
119
                         const QString& text,
 
120
                         const QString& button0Text = QString(),
 
121
                         const QString& button1Text = QString(),
 
122
                         const QString& button2Text = QString(),
 
123
                         int defaultButtonNumber = 0,
 
124
                         int escapeButtonNumber = -1);
 
125
 
 
126
    static void about(QWidget *parent, const QString &caption,
 
127
                       const QString& text);
 
128
 
 
129
    static void aboutQt(QWidget *parent,
 
130
                         const QString& caption=QString());
 
131
 
 
132
    QSize sizeHint() const;
 
133
 
 
134
#ifdef QT3_SUPPORT
 
135
    QT3_SUPPORT_CONSTRUCTOR QMessageBox(const QString &caption, const QString &text, Icon icon,
 
136
                                      int button0, int button1, int button2,
 
137
                                      QWidget *parent, const char *name, bool modal,
 
138
                                      Qt::WFlags f =  Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
 
139
    QT3_SUPPORT_CONSTRUCTOR QMessageBox(QWidget *parent, const char *name);
 
140
 
 
141
    static QT3_SUPPORT QPixmap standardIcon(Icon icon, Qt::GUIStyle);
 
142
    static QT3_SUPPORT int message(const QString &caption,
 
143
                                 const QString& text,
 
144
                                 const QString& buttonText=QString(),
 
145
                                 QWidget *parent=0, const char * =0) {
 
146
        return QMessageBox::information(parent, caption, text,
 
147
                                        buttonText.isEmpty()
 
148
                                     ? tr("OK") : buttonText) == 0;
 
149
    }
 
150
    static QT3_SUPPORT bool query(const QString &caption,
 
151
                                const QString& text,
 
152
                                const QString& yesButtonText=QString(),
 
153
                                const QString& noButtonText=QString(),
 
154
                                QWidget *parent=0, const char * = 0) {
 
155
        return QMessageBox::information(parent, caption, text,
 
156
                                     yesButtonText.isEmpty()
 
157
                                     ? tr("OK") : yesButtonText,
 
158
                                     noButtonText) == 0;
 
159
    }
 
160
#endif
 
161
 
 
162
    static QPixmap standardIcon(Icon icon);
 
163
 
 
164
protected:
 
165
    void        resizeEvent(QResizeEvent *);
 
166
    void        showEvent(QShowEvent *);
 
167
    void        closeEvent(QCloseEvent *);
 
168
    void        keyPressEvent(QKeyEvent *);
 
169
    void        changeEvent(QEvent *);
 
170
 
 
171
private:
 
172
    Q_PRIVATE_SLOT(d_func(), void buttonClicked())
 
173
 
 
174
    Q_DISABLE_COPY(QMessageBox)
 
175
    Q_DECLARE_PRIVATE(QMessageBox)
 
176
};
 
177
 
 
178
#define QT_REQUIRE_VERSION(argc, argv, str) { QString s=QString::fromLatin1(str);\
 
179
QString sq=QString::fromLatin1(qVersion()); if ((sq.section('.',0,0).toInt()<<16)+\
 
180
(sq.section('.',1,1).toInt()<<8)+sq.section('.',2,2).toInt()<(s.section('.',0,0).toInt()<<16)+\
 
181
(s.section('.',1,1).toInt()<<8)+s.section('.',2,2).toInt()){if (!qApp){ int c=0; new \
 
182
QApplication(argc,argv);} QString s = QApplication::tr("Executable '%1' requires Qt "\
 
183
 "%2, found Qt %3.").arg(QString::fromLatin1(qAppName())).arg(QString::fromLatin1(\
 
184
str)).arg(QString::fromLatin1(qVersion())); QMessageBox::critical(0, QApplication::tr(\
 
185
"Incompatible Qt Library Error"), s, QMessageBox::Abort,0); qFatal(s.ascii()); }}
 
186
 
 
187
 
 
188
#endif // QT_NO_MESSAGEBOX
 
189
 
 
190
#endif // QMESSAGEBOX_H