#ifndef EGIF_H
#define EGIF_H

#include <QMovie>
#include <QLabel>
#include <QGraphicsProxyWidget>
#include "eobject.h"
class eGif : public eObject
{
    Q_OBJECT
public:
    struct Data {
        QString name;
        QString path;
        int     playDuration=10;
        int     playTimes=1;
    };

public:
    explicit eGif(QRectF rectInit,const QString &file, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
    explicit eGif(QRectF rectInit,QSizeF DrawBoardSize,const QString &file, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
    explicit eGif(const QJsonObject &json, const QString &pRoot, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);

private:
    void init();

public:
    static void setElement(const QJsonObject &json, Data &attr);
    Data getData(){return m_attr;}
    void deleteContent();
public:
    static QString filters() { return tr("Gif(*.gif)"); }

public:
    virtual int type() const override { return eObject::Gif; }
    virtual QWidget* wAttr() override;
    virtual QWidget* wAttrElement() override;
    virtual QJsonObject save(const QString &pRoot) override;
    virtual QStringList filesList() const override;
    virtual QJsonObject elementJson() const override;

signals:

public slots:
    virtual void playElectment() override;
    virtual void stopElectment() override;
    void onResChanged(const QString &file);
    void onAttrChanged(const eGif::Data &data);
    void onAdjustMovieRect();

protected:
    void setPlayArg(int pd, int pt);

private:
    QMovie               *m_movie;

    QGraphicsProxyWidget *m_vWidget;
    Data                 m_attr;
};

#endif // EGIF_H
