2016-03-18 11:14:06 +00:00
|
|
|
#ifndef FLATBUTTON_H
|
|
|
|
#define FLATBUTTON_H
|
|
|
|
|
2016-05-14 08:52:28 +00:00
|
|
|
#include <QPushButton>
|
2016-05-14 11:06:20 +00:00
|
|
|
#include <QScopedPointer>
|
2016-05-14 12:18:57 +00:00
|
|
|
#include "lib/theme.h"
|
2016-03-18 11:14:06 +00:00
|
|
|
|
2016-05-14 11:06:20 +00:00
|
|
|
class FlatButtonPrivate;
|
2016-05-14 09:42:15 +00:00
|
|
|
|
2016-06-12 11:03:59 +00:00
|
|
|
/*
|
|
|
|
* @TODO: implement checkable behavior
|
2016-06-20 15:47:17 +00:00
|
|
|
*
|
|
|
|
* @TODO: set default minimum height?
|
2016-06-12 11:03:59 +00:00
|
|
|
*/
|
|
|
|
|
2016-05-14 08:52:28 +00:00
|
|
|
class FlatButton : public QPushButton
|
2016-03-18 11:14:06 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2016-05-30 13:10:15 +00:00
|
|
|
Q_PROPERTY(Material::Role role WRITE setRole READ role)
|
|
|
|
Q_PROPERTY(Material::RippleStyle rippleStyle WRITE setRippleStyle READ rippleStyle)
|
2016-05-29 22:25:17 +00:00
|
|
|
Q_PROPERTY(qreal cornerRadius WRITE setCornerRadius READ cornerRadius)
|
2016-06-05 12:07:56 +00:00
|
|
|
Q_PROPERTY(Qt::BGMode backgroundMode WRITE setBackgroundMode READ backgroundMode)
|
|
|
|
Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
|
|
|
|
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
|
2016-05-30 16:03:41 +00:00
|
|
|
Q_PROPERTY(QColor disabledTextColor WRITE setDisabledTextColor READ disabledTextColor)
|
2016-05-30 23:08:52 +00:00
|
|
|
Q_PROPERTY(qreal peakOpacity WRITE setPeakOpacity READ peakOpacity)
|
2016-05-29 22:25:17 +00:00
|
|
|
|
2016-03-18 11:14:06 +00:00
|
|
|
public:
|
|
|
|
explicit FlatButton(QWidget *parent = 0);
|
|
|
|
explicit FlatButton(const QString &text, QWidget *parent = 0);
|
|
|
|
~FlatButton();
|
2016-05-14 09:10:30 +00:00
|
|
|
|
2016-06-21 09:55:38 +00:00
|
|
|
void setHasFixedRippleRadius(bool value);
|
|
|
|
bool hasFixedRippleRadius() const;
|
|
|
|
|
|
|
|
void setFixedRippleRadius(qreal radius);
|
|
|
|
|
2016-05-30 23:08:52 +00:00
|
|
|
void setRole(Material::Role role);
|
2016-05-30 13:10:15 +00:00
|
|
|
Material::Role role() const;
|
2016-05-14 12:18:57 +00:00
|
|
|
|
2016-06-05 12:07:56 +00:00
|
|
|
void setUseThemeColors(bool value);
|
|
|
|
bool useThemeColors() const;
|
|
|
|
|
2016-06-11 16:44:16 +00:00
|
|
|
void setShowHalo(bool state);
|
|
|
|
bool showHalo() const;
|
|
|
|
|
2016-05-30 08:25:02 +00:00
|
|
|
void setRippleStyle(Material::RippleStyle style);
|
2016-05-30 13:10:15 +00:00
|
|
|
Material::RippleStyle rippleStyle() const;
|
2016-05-28 08:22:43 +00:00
|
|
|
|
2016-05-29 22:25:17 +00:00
|
|
|
void setCornerRadius(qreal radius);
|
|
|
|
qreal cornerRadius() const;
|
|
|
|
|
2016-06-05 12:07:56 +00:00
|
|
|
void setBackgroundMode(Qt::BGMode mode);
|
|
|
|
Qt::BGMode backgroundMode() const;
|
2016-05-30 16:03:41 +00:00
|
|
|
|
2016-06-05 12:07:56 +00:00
|
|
|
void setTextColor(const QColor &color);
|
|
|
|
QColor textColor() const;
|
2016-05-30 16:03:41 +00:00
|
|
|
|
2016-06-05 12:07:56 +00:00
|
|
|
void setBackgroundColor(const QColor &color);
|
|
|
|
QColor backgroundColor() const;
|
2016-05-30 16:03:41 +00:00
|
|
|
|
|
|
|
void setDisabledTextColor(const QColor &color);
|
|
|
|
QColor disabledTextColor() const;
|
|
|
|
|
2016-05-30 23:08:52 +00:00
|
|
|
void setPeakOpacity(qreal opacity);
|
|
|
|
qreal peakOpacity() const;
|
|
|
|
|
2016-05-14 09:10:30 +00:00
|
|
|
protected:
|
2016-05-17 12:26:50 +00:00
|
|
|
FlatButton(FlatButtonPrivate &d, QWidget *parent = 0);
|
|
|
|
|
2016-05-14 09:42:15 +00:00
|
|
|
void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
|
2016-05-14 09:10:30 +00:00
|
|
|
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
2016-05-14 09:42:15 +00:00
|
|
|
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
|
|
|
|
2016-06-11 16:44:16 +00:00
|
|
|
void paintHalo(QPainter *painter);
|
|
|
|
|
2016-05-14 11:06:20 +00:00
|
|
|
const QScopedPointer<FlatButtonPrivate> d_ptr;
|
|
|
|
|
2016-05-14 09:42:15 +00:00
|
|
|
private:
|
2016-05-14 11:06:20 +00:00
|
|
|
Q_DISABLE_COPY(FlatButton)
|
|
|
|
Q_DECLARE_PRIVATE(FlatButton)
|
2016-03-18 11:14:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FLATBUTTON_H
|