-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimatedbutton.h
More file actions
36 lines (33 loc) · 881 Bytes
/
animatedbutton.h
File metadata and controls
36 lines (33 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef ANIMATEDBUTTON_H
#define ANIMATEDBUTTON_H
#include <QPropertyAnimation>
#include <QStyleOptionButton>
#include <QGuiApplication>
#include <QStyleHints>
#include <QPushButton>
#include <QPainter>
#include <QObject>
#include <QWidget>
#include <QRect>
class AnimatedButton : public QPushButton
{
Q_OBJECT
Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
public:
explicit AnimatedButton(QWidget *parent = nullptr);
void toggleState();
qreal progress() const;
void setProgress(qreal);
signals:
void progressChanged(qreal);
protected:
void paintEvent(QPaintEvent *event) override;
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;
private:
qreal m_progress;
bool m_hovered;
QPixmap m_playPixmap;
QPixmap m_pausePixmap;
};
#endif // ANIMATEDBUTTON_H