qt-material-widgets/components/flatbutton.h

35 lines
949 B
C
Raw Normal View History

2016-03-18 11:14:06 +00:00
#ifndef FLATBUTTON_H
#define FLATBUTTON_H
#include <QAbstractButton>
#include <QStyleOptionButton>
2016-03-19 11:12:14 +00:00
#include "../lib/rippleoverlay.h"
2016-03-18 11:14:06 +00:00
class FlatButton : public QAbstractButton
{
Q_OBJECT
public:
explicit FlatButton(QWidget *parent = 0);
explicit FlatButton(const QString &text, QWidget *parent = 0);
~FlatButton();
2016-03-18 14:07:20 +00:00
QSize sizeHint() const Q_DECL_OVERRIDE;
2016-03-18 14:07:20 +00:00
protected:
2016-03-18 14:36:02 +00:00
void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
2016-03-18 14:07:20 +00:00
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
2016-03-18 14:36:02 +00:00
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
2016-03-18 14:07:20 +00:00
void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
2016-03-18 14:36:02 +00:00
private:
2016-03-19 07:50:48 +00:00
inline void updateOverlayGeometry() { if (_overlay) { _overlay->setGeometry(rect()); } }
QStyleOptionButton getStyleOption() const;
2016-03-18 14:36:02 +00:00
RippleOverlay *const _overlay;
2016-03-18 11:14:06 +00:00
};
#endif // FLATBUTTON_H