#ifndef ETEMP_H
#define ETEMP_H

#include "eobject.h"

class eTemp : public eObject
{
    Q_OBJECT
public:
    struct Data {
        bool    bTitle;
        QString labelTitle;

        bool    bTemperature;
        int     temperatureType;
        QString labelTemperature;
        int     compensation;

        bool    bHumidity;
        QString labelHumidity;

        bool    bNoise;
        QString labelNoise;

        bool    bWindSpeed;
        QString labelWindSpeed;

        bool    bWindDirection;
        QString labelWindDirectiton;

        bool    bPM25;
        QString labelPm25;

        bool    bPM10;
        QString labelPm10;

        QString fontFamily;
        int     fontSize;
        bool    fontBold;
        bool    fontItalics;
        bool    fontUnderline;
        QColor  textColor;
        int     iAlignType;
        int     playRefresh;
        int     playDuration=10;
        bool    bSingleScroll;
        int     iScrollSpeed=10;
        QColor  cBackground;

    };

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

private:
    void init();
    void CreateAllWordPic(QString strPath);
    void CreateWordPic(QString strWord,QString strFileName,QString strPath,int iPicHeight);
    void CreatePreviewPic(QString strPath);
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::Temp; }
    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 eTemp::Data &data);
    void TimerOutPro();
    void onBackgroundColorChanged(const QColor& color) { m_attr.cBackground = color;     updateGeometry();  }
    void OnRectChanged();
private:
    Data m_attr;
        QTimer *m_pScrollTimer=nullptr;
        int m_iScrollOffset=0;
        QPixmap *m_pRenderPixmap=nullptr;
};

#endif // ETEMP_H
