OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / libs / utils / checkablemessagebox.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
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
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
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.
24 **
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.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef CHECKABLEMESSAGEBOX_H
35 #define CHECKABLEMESSAGEBOX_H
36
37 #include "utils_global.h"
38
39 #include <QtGui/QDialogButtonBox>
40 #include <QtGui/QMessageBox>
41 #include <QtGui/QDialog>
42
43 namespace Utils {
44
45 struct CheckableMessageBoxPrivate;
46
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. */
50
51 class QTCREATOR_UTILS_EXPORT CheckableMessageBox : public QDialog
52 {
53     Q_OBJECT
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)
60 public:
61     explicit CheckableMessageBox(QWidget *parent);
62     virtual ~CheckableMessageBox();
63
64     static QDialogButtonBox::StandardButton
65         question(QWidget *parent,
66                  const QString &title,
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);
72
73     QString text() const;
74     void setText(const QString &);
75
76     bool isChecked() const;
77     void setChecked(bool s);
78
79     QString checkBoxText() const;
80     void setCheckBoxText(const QString &);
81
82    QDialogButtonBox::StandardButtons standardButtons() const;
83    void setStandardButtons(QDialogButtonBox::StandardButtons s);
84
85    QDialogButtonBox::StandardButton defaultButton() const;
86    void setDefaultButton(QDialogButtonBox::StandardButton s);
87
88     // see static QMessageBox::standardPixmap()
89     QPixmap iconPixmap() const;
90     void setIconPixmap (const QPixmap &p);
91
92    // Query the result
93    QAbstractButton *clickedButton() const;
94    QDialogButtonBox::StandardButton clickedStandardButton() const;
95
96    // Conversion convenience
97    static QMessageBox::StandardButton dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton);
98
99 private slots:
100    void slotClicked(QAbstractButton *b);
101
102 private:
103    CheckableMessageBoxPrivate *m_d;
104 };
105
106 } // namespace Utils
107
108 #endif // CHECKABLEMESSAGEBOX_H