OpenMW
apps/launcher/utils/checkablemessagebox.hpp
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
00004 ** Contact: http://www.qt-project.org/legal
00005 **
00006 ** This file is part of Qt Creator.
00007 **
00008 ** Commercial License Usage
00009 ** Licensees holding valid commercial Qt licenses may use this file in
00010 ** accordance with the commercial license agreement provided with the
00011 ** Software or, alternatively, in accordance with the terms contained in
00012 ** a written agreement between you and Digia.  For licensing terms and
00013 ** conditions see http://qt.digia.com/licensing.  For further information
00014 ** use the contact form at http://qt.digia.com/contact-us.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Digia gives you certain additional
00025 ** rights.  These rights are described in the Digia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
00027 **
00028 ****************************************************************************/
00029 
00030 #ifndef CHECKABLEMESSAGEBOX_HPP
00031 #define CHECKABLEMESSAGEBOX_HPP
00032 
00033 #include <QDialogButtonBox>
00034 #include <QMessageBox>
00035 #include <QDialog>
00036 
00037 class QCheckBox;
00038 
00039 namespace Launcher
00040 {
00041     class CheckableMessageBoxPrivate
00042     {
00043     public:
00044 
00045         QLabel *pixmapLabel;
00046         QLabel *messageLabel;
00047         QCheckBox *checkBox;
00048         QDialogButtonBox *buttonBox;
00049         QAbstractButton *clickedButton;
00050 
00051     public:
00052         CheckableMessageBoxPrivate(QDialog *q);
00053     };
00054 
00055     class CheckableMessageBox : public QDialog
00056     {
00057         Q_OBJECT
00058         Q_PROPERTY(QString text READ text WRITE setText)
00059         Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
00060         Q_PROPERTY(bool isChecked READ isChecked WRITE setChecked)
00061         Q_PROPERTY(QString checkBoxText READ checkBoxText WRITE setCheckBoxText)
00062         Q_PROPERTY(QDialogButtonBox::StandardButtons buttons READ standardButtons WRITE setStandardButtons)
00063         Q_PROPERTY(QDialogButtonBox::StandardButton defaultButton READ defaultButton WRITE setDefaultButton)
00064 
00065     public:
00066         explicit CheckableMessageBox(QWidget *parent);
00067         virtual ~CheckableMessageBox();
00068 
00069         static QDialogButtonBox::StandardButton
00070             question(QWidget *parent,
00071                      const QString &title,
00072                      const QString &question,
00073                      const QString &checkBoxText,
00074                      bool *checkBoxSetting,
00075                      QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Yes|QDialogButtonBox::No,
00076                      QDialogButtonBox::StandardButton defaultButton = QDialogButtonBox::No);
00077 
00078         QString text() const;
00079         void setText(const QString &);
00080 
00081         bool isChecked() const;
00082         void setChecked(bool s);
00083 
00084         QString checkBoxText() const;
00085         void setCheckBoxText(const QString &);
00086 
00087         bool isCheckBoxVisible() const;
00088         void setCheckBoxVisible(bool);
00089 
00090         QDialogButtonBox::StandardButtons standardButtons() const;
00091         void setStandardButtons(QDialogButtonBox::StandardButtons s);
00092         QPushButton *button(QDialogButtonBox::StandardButton b) const;
00093         QPushButton *addButton(const QString &text, QDialogButtonBox::ButtonRole role);
00094 
00095         QDialogButtonBox::StandardButton defaultButton() const;
00096         void setDefaultButton(QDialogButtonBox::StandardButton s);
00097 
00098         // See static QMessageBox::standardPixmap()
00099         QPixmap iconPixmap() const;
00100         void setIconPixmap (const QPixmap &p);
00101 
00102         // Query the result
00103         QAbstractButton *clickedButton() const;
00104         QDialogButtonBox::StandardButton clickedStandardButton() const;
00105 
00106         // Conversion convenience
00107         static QMessageBox::StandardButton dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton);
00108 
00109     private slots:
00110         void slotClicked(QAbstractButton *b);
00111 
00112     private:
00113         CheckableMessageBoxPrivate *d;
00114     };
00115 }
00116 #endif // CHECKABLEMESSAGEBOX_HPP