#ifndef ETIMER_H
#define ETIMER_H

#include <QTimer>
#include <QColor>
#include <QDateTime>
#include "eobject.h"

class eTimer : public eObject
{
    Q_OBJECT
public:
    struct Data {
        int       xWard;
        QDateTime targetDateTime;
        bool      day;
        bool      hour;
        bool      min;
        bool      sec;
        QString   text;
        bool      multiline;
        QString   fontFamily;
        int       fontSize;
        bool      fontBold;
        bool      fontItalics;
        bool      fontUnderline;
        QColor    textColor;
        QColor    backgroundColor;
        int       playDuration=10;
    };

public:
    explicit eTimer(QRectF rectInit,InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
    explicit eTimer(const QJsonObject &json, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);

private:
    void init();

public:
    static void setElement(const QJsonObject &json, Data &attr);

public:
    virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
    virtual int type() const override { return eObject::Timer; }
    virtual QWidget* wAttr() override;
    virtual QWidget* wAttrElement() override;
    virtual QJsonObject save(const QString &pRoot) override { Q_UNUSED(pRoot); return elementJson(); }
    virtual QJsonObject elementJson() const override;

signals:

public slots:
    void onAttrChanged(const eTimer::Data &data);

private:
    Data   m_attr;
};

#endif // ETIMER_H
