44 lines
865 B
C
44 lines
865 B
C
|
#ifndef MESSAGE_H
|
||
|
#define MESSAGE_H
|
||
|
|
||
|
#include <QLabel>
|
||
|
#include <QPair>
|
||
|
#include <QPushButton>
|
||
|
#include <QTimer>
|
||
|
#include <QWidget>
|
||
|
|
||
|
class Message : public QWidget {
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
enum Level {
|
||
|
Success,
|
||
|
Error,
|
||
|
Info,
|
||
|
Warning
|
||
|
};
|
||
|
explicit Message(QWidget* parent = 0);
|
||
|
~Message();
|
||
|
|
||
|
void success(QString content, int duration);
|
||
|
void error(QString content, int duration);
|
||
|
void info(QString content, int duration);
|
||
|
void warning(QString content, int duration);
|
||
|
|
||
|
private:
|
||
|
Level level = Info;
|
||
|
bool isShow = false;
|
||
|
|
||
|
int count = 0;
|
||
|
int maxCount = 5;
|
||
|
QList<QPair<QPushButton*, QTimer*>> contentList;
|
||
|
|
||
|
QString btnStyle;
|
||
|
|
||
|
private:
|
||
|
void showMessage(QString content, int duration, Level level);
|
||
|
QPushButton* generateButton(QString content, Level level);
|
||
|
};
|
||
|
|
||
|
#endif // MESSAGE_H
|