the-libs/lib/ttoast.h

62 lines
1.2 KiB
C
Raw Normal View History

2017-01-19 22:07:44 +11:00
#ifndef TTOAST_H
#define TTOAST_H
#include <QObject>
#include <QTimer>
#include <QBoxLayout>
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QPainter>
#include <QPaintEvent>
#include "tpropertyanimation.h"
2018-08-03 22:31:27 +10:00
class THELIBSSHARED_EXPORT tToast : public QObject
2017-01-19 22:07:44 +11:00
{
Q_OBJECT
public:
explicit tToast(QObject *parent = 0);
~tToast();
void setTitle(QString title);
QString title();
void setText(QString text);
QString text();
void setActions(QMap<QString, QString> actions);
QMap<QString, QString> actions();
2017-01-21 16:37:10 +11:00
void setTimeout(int milliseconds);
int timeout();
2017-01-19 22:07:44 +11:00
signals:
void actionClicked(QString key);
void dismissed();
2017-01-21 16:37:10 +11:00
void doDefaultOption();
2017-01-19 22:07:44 +11:00
public slots:
void show(QWidget* parent);
2017-01-21 16:37:10 +11:00
void announceAction(QString text);
2017-01-19 22:07:44 +11:00
void dismiss();
private:
QMap<QString, QString> actn;
2017-01-21 16:37:10 +11:00
QWidget *toastWidget, *announceActionWidget;
QLabel *titleLabel, *textLabel, *announceActionLabel;
2017-01-19 22:07:44 +11:00
QBoxLayout* buttons;
2017-01-21 16:37:10 +11:00
tVariantAnimation* hideTimer;
int currentAnimationValue;
bool canAnnounceAction = false;
bool announcingAction = false;
bool timerStopped = false;
2017-01-19 22:07:44 +11:00
bool eventFilter(QObject *watched, QEvent *event);
};
#endif // TTOAST_H