2 ******************************************************************************
4 * @file checkablemessagebox.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
8 * @see The GNU Public License (GPL) Version 3
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef CHECKABLEMESSAGEBOX_H
30 #define CHECKABLEMESSAGEBOX_H
32 #include "utils_global.h"
34 #include <QDialogButtonBox>
35 #include <QMessageBox>
39 struct CheckableMessageBoxPrivate
;
41 /* A messagebox suitable for questions with a
42 * "Do not ask me again" checkbox. Emulates the QMessageBox API with
43 * static conveniences. */
45 class QTCREATOR_UTILS_EXPORT CheckableMessageBox
: public QDialog
{
46 Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText
)
47 Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap
)
48 Q_PROPERTY(bool isChecked READ isChecked WRITE setChecked
)
49 Q_PROPERTY(QString checkBoxText READ checkBoxText WRITE setCheckBoxText
)
50 Q_PROPERTY(QDialogButtonBox::StandardButtons buttons READ standardButtons WRITE setStandardButtons
)
51 Q_PROPERTY(QDialogButtonBox::StandardButton defaultButton READ defaultButton WRITE setDefaultButton
)
53 explicit CheckableMessageBox(QWidget
*parent
);
54 virtual ~CheckableMessageBox();
56 static QDialogButtonBox::StandardButton
question(QWidget
*parent
,
58 const QString
&question
,
59 const QString
&checkBoxText
,
60 bool *checkBoxSetting
,
61 QDialogButtonBox::StandardButtons buttons
= QDialogButtonBox::Yes
| QDialogButtonBox::No
,
62 QDialogButtonBox::StandardButton defaultButton
= QDialogButtonBox::No
);
65 void setText(const QString
&);
67 bool isChecked() const;
68 void setChecked(bool s
);
70 QString
checkBoxText() const;
71 void setCheckBoxText(const QString
&);
73 QDialogButtonBox::StandardButtons
standardButtons() const;
74 void setStandardButtons(QDialogButtonBox::StandardButtons s
);
76 QDialogButtonBox::StandardButton
defaultButton() const;
77 void setDefaultButton(QDialogButtonBox::StandardButton s
);
79 // see static QMessageBox::standardPixmap()
80 QPixmap
iconPixmap() const;
81 void setIconPixmap(const QPixmap
&p
);
84 QAbstractButton
*clickedButton() const;
85 QDialogButtonBox::StandardButton
clickedStandardButton() const;
87 // Conversion convenience
88 static QMessageBox::StandardButton
dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton
);
91 void slotClicked(QAbstractButton
*b
);
94 CheckableMessageBoxPrivate
*m_d
;
98 #endif // CHECKABLEMESSAGEBOX_H