A self-scaling widget that displays messages as separate instances of QLabel. More...
#include <importantmessageswidget.h>
Classes | |
class | Handler |
Public Slots | |
QSharedPointer< Handler > | addMessage (const QString &message) |
Adds a new message without a timestamp. | |
QSharedPointer< Handler > | addMessage (const QString &message, const QDateTime &dateTime) |
Adds a message with a timestamp. | |
QSharedPointer< Handler > | addMessage (const QString &message, unsigned timestamp) |
Adds a message with a timestamp. | |
void | clear () |
Clears all messages from the widghet. | |
void | removeOldest (int num) |
Removes a number of oldest messages from the widget. | |
void | removeOneOldest () |
Will remove one oldest message. | |
Public Member Functions | |
ImportantMessagesWidget (QWidget *pParent=nullptr) | |
unsigned | maxMessages () const |
Amount of messages that can be displayed in the widget at the same time. | |
void | setMaxMessages (unsigned num) |
Friends | |
class | Handler |
A self-scaling widget that displays messages as separate instances of QLabel.
This widget adds new messages by wrapping them in a QLabel widgets and inserting those widgets into a vertical layout. Number of QLabel widgets is limited by _maxMessages field. Old messages will be removed once their time of life exceeds MAX_MSG_KEEP_TIME_SEC . Widget will auto-hide and auto-show
Definition at line 45 of file importantmessageswidget.h.
|
slot |
Adds a new message without a timestamp.
Definition at line 95 of file importantmessageswidget.cpp.
|
slot |
Adds a message with a timestamp.
message | Message to add. |
timestamp | QDateTime object representing time. |
Definition at line 101 of file importantmessageswidget.cpp.
|
slot |
Adds a message with a timestamp.
message | Message to add. |
timestamp | Time in seconds since the epoch. |
Definition at line 132 of file importantmessageswidget.cpp.
|
slot |
Clears all messages from the widghet.
Widget will shrink itself in a way that will make it invisible.
Definition at line 142 of file importantmessageswidget.cpp.
unsigned ImportantMessagesWidget::maxMessages | ( | ) | const |
Amount of messages that can be displayed in the widget at the same time.
Definition at line 208 of file importantmessageswidget.cpp.
|
slot |
Removes a number of oldest messages from the widget.
Widget will shrink with each message removed.
num | Amount of messages to remove. If higher than the actual count of messages, will work the same as clear(). |
Definition at line 168 of file importantmessageswidget.cpp.
|
slot |
Will remove one oldest message.
Definition at line 179 of file importantmessageswidget.cpp.