OpenWalnut  1.5.0dev
WQtMessagePopup.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 WQTMESSAGEPOPUP_H
26 #define WQTMESSAGEPOPUP_H
27 
28 #include <QWidget>
29 #include <QDialog>
30 #include <QtCore/QString>
31 #include <QtCore/QTimer>
32 
33 #include "core/common/WLogEntry.h"
34 
35 /**
36  * Nice looking message popup.
37  */
38 class WQtMessagePopup: public QDialog
39 {
40  Q_OBJECT
41 public:
42  /**
43  * Describe the kind of message
44  */
45  typedef LogLevel MessageType;
46 
47  /**
48  * Constructor
49  *
50  * \param parent parent widget
51  * \param title title
52  * \param message message
53  * \param type the message type
54  */
55  WQtMessagePopup( QWidget* parent, const QString& title, const QString& message, MessageType type );
56 
57  /**
58  * Destructor.
59  */
60  virtual ~WQtMessagePopup();
61 
62  /**
63  * When set to true, the widget gets closed when loosing focus or when clicking the detail button. If not, the widget needs to be closed
64  * manually.
65  *
66  * \param autoClose close flag
67  */
68  void setAutoClose( bool autoClose = true );
69 
70  /**
71  * Show or hide the close button
72  *
73  * \param showCloseButton true to show
74  */
75  void setShowCloseButton( bool showCloseButton = true );
76 
77  /**
78  * If true, the widget moves itself to the bottom of its parent widget. As this is not useful sometimes, you can disable this by using
79  * false here.
80  *
81  * \param autoPosition false if widget should not move automatically
82  */
83  void setAutoPosition( bool autoPosition = true );
84 
85  /**
86  * Get this popups message type.
87  *
88  * \return the type
89  */
90  MessageType getType() const;
91 
92  /**
93  * Reimplement show from QWidget to be able to auto-close it.
94  */
95  void show();
96 
97 signals:
98  /**
99  * Called when closing the popup
100  *
101  * \param me the pointer to the widget getting close
102  */
104 
105 public slots:
106  /**
107  * Shows the message
108  */
109  void showMessage();
110 
111  /**
112  * Cloes this popup. Use instead of close() slot.
113  */
114  void closePopup();
115 protected:
116  /**
117  * On show. Called when opening the widget.
118  *
119  * \param event
120  */
121  virtual void showEvent( QShowEvent* event );
122 private:
123  /**
124  * Title Text
125  */
126  QString m_title;
127 
128  /**
129  * The message text.
130  */
131  QString m_message;
132 
133  /**
134  * What kind of message is this.
135  */
136  MessageType m_type;
137 
138  /**
139  * Close button
140  */
141  QPushButton* m_closeBtn;
142 
143  /**
144  * See \ref setAutoClose.
145  */
147 
148  /**
149  * See \ref setAutoPosition.
150  */
152 };
153 
154 #endif // WQTMESSAGEPOPUP_H
Nice looking message popup.
void setAutoClose(bool autoClose=true)
When set to true, the widget gets closed when loosing focus or when clicking the detail button.
MessageType getType() const
Get this popups message type.
void show()
Reimplement show from QWidget to be able to auto-close it.
void onClose(WQtMessagePopup *me)
Called when closing the popup.
void setShowCloseButton(bool showCloseButton=true)
Show or hide the close button.
virtual void showEvent(QShowEvent *event)
On show.
virtual ~WQtMessagePopup()
Destructor.
MessageType m_type
What kind of message is this.
bool m_autoMove
See setAutoPosition.
LogLevel MessageType
Describe the kind of message.
void showMessage()
Shows the message.
void closePopup()
Cloes this popup.
WQtMessagePopup(QWidget *parent, const QString &title, const QString &message, MessageType type)
Constructor.
void setAutoPosition(bool autoPosition=true)
If true, the widget moves itself to the bottom of its parent widget.
QString m_message
The message text.
bool m_autoClose
See setAutoClose.
QPushButton * m_closeBtn
Close button.
QString m_title
Title Text.