1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** 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, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef CHECKABLEMESSAGEBOX_H
35 #define CHECKABLEMESSAGEBOX_H
37 #include "utils_global.h"
39 #include <QtGui/QDialogButtonBox>
40 #include <QtGui/QMessageBox>
41 #include <QtGui/QDialog>
45 struct CheckableMessageBoxPrivate;
47 /* A messagebox suitable for questions with a
48 * "Do not ask me again" checkbox. Emulates the QMessageBox API with
49 * static conveniences. The message label can open external URLs. */
51 class QTCREATOR_UTILS_EXPORT CheckableMessageBox : public QDialog
54 Q_PROPERTY(QString text READ text WRITE setText)
55 Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
56 Q_PROPERTY(bool isChecked READ isChecked WRITE setChecked)
57 Q_PROPERTY(QString checkBoxText READ checkBoxText WRITE setCheckBoxText)
58 Q_PROPERTY(QDialogButtonBox::StandardButtons buttons READ standardButtons WRITE setStandardButtons)
59 Q_PROPERTY(QDialogButtonBox::StandardButton defaultButton READ defaultButton WRITE setDefaultButton)
61 explicit CheckableMessageBox(QWidget *parent);
62 virtual ~CheckableMessageBox();
64 static QDialogButtonBox::StandardButton
65 question(QWidget *parent,
67 const QString &question,
68 const QString &checkBoxText,
69 bool *checkBoxSetting,
70 QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Yes|QDialogButtonBox::No,
71 QDialogButtonBox::StandardButton defaultButton = QDialogButtonBox::No);
74 void setText(const QString &);
76 bool isChecked() const;
77 void setChecked(bool s);
79 QString checkBoxText() const;
80 void setCheckBoxText(const QString &);
82 QDialogButtonBox::StandardButtons standardButtons() const;
83 void setStandardButtons(QDialogButtonBox::StandardButtons s);
85 QDialogButtonBox::StandardButton defaultButton() const;
86 void setDefaultButton(QDialogButtonBox::StandardButton s);
88 // see static QMessageBox::standardPixmap()
89 QPixmap iconPixmap() const;
90 void setIconPixmap (const QPixmap &p);
93 QAbstractButton *clickedButton() const;
94 QDialogButtonBox::StandardButton clickedStandardButton() const;
96 // Conversion convenience
97 static QMessageBox::StandardButton dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton);
100 void slotClicked(QAbstractButton *b);
103 CheckableMessageBoxPrivate *m_d;
108 #endif // CHECKABLEMESSAGEBOX_H