#ifndef PQTOOLBUTTON
#define PQTOOLBUTTON

#include "pqwidget.h"
#include "pqaction.h"
#include <QToolButton>

class PQToolButton;
class PQToolButton : public QToolButton {
    Q_OBJECT
    PQ_WIDGET_EX(QToolButton)

    Q_PROPERTY( QString text READ text WRITE setText )
    Q_PROPERTY( bool checkable READ isCheckable WRITE setCheckable )
    Q_PROPERTY( bool checked READ isChecked WRITE setChecked )
    Q_PROPERTY( bool autoExclusive READ autoExclusive WRITE setAutoExclusive )
    Q_PROPERTY( QString icon READ icon WRITE setIcon )
    Q_PROPERTY( int toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle )

public:
    Q_INVOKABLE explicit PQToolButton(QWidget * parent=0);
    virtual ~PQToolButton();

    Q_INVOKABLE QString text();
    Q_INVOKABLE bool isCheckable();
    Q_INVOKABLE bool isChecked();
    Q_INVOKABLE bool autoExclusive();
    Q_INVOKABLE QString icon();
    Q_INVOKABLE void setToolButtonStyle(int style);
    Q_INVOKABLE int toolButtonStyle();

public Q_SLOTS:
    Q_INVOKABLE void setText(QString text);
    Q_INVOKABLE void setCheckable(bool b);
    Q_INVOKABLE void setChecked(bool b);
    Q_INVOKABLE void setAutoExclusive(bool b);
    Q_INVOKABLE void setIcon(QString iconPath);
    Q_INVOKABLE void setIconSize(int w, int h);
    Q_INVOKABLE void click();

    void clicked_pslot(bool checked);
    void clicked_pslot();
    void pressed_pslot();
    void released_pslot();
    void toggled_pslot(bool checked);
    void triggered_pslot(QAction *action);

    PQ_ON_SIGNAL_DECL_START {
        PQ_ON_SIGNAL(clicked_pslot(bool));
        PQ_ON_SIGNAL(toggled_pslot(bool));
        PQ_ON_SIGNAL(triggered_pslot(QAction*));
        PQ_ON_SIGNAL(pressed_pslot());
        PQ_ON_SIGNAL(released_pslot());
        PQWIDGET_ON_SIGNALS();
    } PQ_ON_SIGNAL_DECL_END

private:
    QString mIconPath = "";
};

#endif // PQTOOLBUTTON

