OpenWalnut  1.5.0dev
WQtMessageDialog.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WQTMESSAGEDIALOG_H
26 #define WQTMESSAGEDIALOG_H
27 
28 #include <QDialog>
29 #include <QTextEdit>
30 #include <QLabel>
31 #include <QDialogButtonBox>
32 #include <QCheckBox>
33 #include <QtCore/QSettings>
34 
35 /**
36  * General purpose message dialog, able to show arbitrary content. It additionally allows the user to decide whether he wants to see this again
37  * or not.
38  */
40 {
41  Q_OBJECT
42 public:
43  /**
44  * Construct a message dialog.
45  *
46  * \param msgID the id used to check whether to show the message or not.
47  * \param title the title of the dialog
48  * \param content the widget representing the content
49  * \param settings the object storing the info about disabled messages
50  * \param parent parent window
51  */
52  WQtMessageDialog( QString msgID, QString title, QWidget* content, QSettings& settings, QWidget* parent ); // NOLINT - yes use a non-const ref
53 
54  /**
55  * Destructor.
56  */
57  virtual ~WQtMessageDialog();
58 
59  /**
60  * Shows the dialog if the user does not disabled it.
61  */
62  virtual void show();
63 
64  /**
65  * Force showing the dialog.
66  *
67  * \param force true if forced to show (even if the user marked the do not show again flag).
68  */
69  virtual void show( bool force );
70 
71 protected:
72 private slots:
73 
74  /**
75  * Dialog closed
76  */
77  virtual void reject();
78 
79  /**
80  * Dialog closed
81  */
82  virtual void accept();
83 
84 private:
85  /**
86  * Dialog buttons.
87  */
88  QDialogButtonBox* m_buttonBox;
89 
90  /**
91  * Do not show again - Checkbox
92  */
93  QCheckBox* m_checkBox;
94 
95  /**
96  * The widget showing the content
97  */
98  QWidget* m_content;
99 
100  /**
101  * The message ID
102  */
103  QString m_msgID;
104 
105  /**
106  * Settings object of the main window
107  */
108  QSettings& m_settings;
109 
110  /**
111  * Handles close and saves setting
112  */
113  void handleClose();
114 };
115 
116 #endif // WQTMESSAGEDIALOG_H
117 
General purpose message dialog, able to show arbitrary content.
virtual void accept()
Dialog closed.
QWidget * m_content
The widget showing the content.
QCheckBox * m_checkBox
Do not show again - Checkbox.
WQtMessageDialog(QString msgID, QString title, QWidget *content, QSettings &settings, QWidget *parent)
Construct a message dialog.
QSettings & m_settings
Settings object of the main window.
virtual ~WQtMessageDialog()
Destructor.
virtual void reject()
Dialog closed.
QDialogButtonBox * m_buttonBox
Dialog buttons.
void handleClose()
Handles close and saves setting.
QString m_msgID
The message ID.
virtual void show()
Shows the dialog if the user does not disabled it.