qt/LedOK/program/eenviron.h

64 lines
1.7 KiB
C
Raw Normal View History

2022-08-25 18:37:24 +08:00
#ifndef EENVIRON_H
#define EENVIRON_H
#include "ebase.h"
2023-04-27 15:06:24 +08:00
#include "gutil/qgui.h"
2022-08-25 18:37:24 +08:00
class EEnviron : public EBase {
Q_OBJECT
public:
struct Data {
QString title;
QString labelTemp;
QString labelHum;
QString labelNoise;
QString labelWindSpeed;
QString labelWindDirectiton;
QString labelPm25;
QString labelPm10;
int tempType = 0;
int compensation = 0;
2023-04-27 15:06:24 +08:00
QFont font = qfont("Arial", 12);
2022-08-25 18:37:24 +08:00
QColor textColor = Qt::red;
QColor backColor = Qt::transparent;
int align = 0;
int playRefresh = 1;
int playDuration = 10;
int scrollSpeed = 33;
bool isSingleLine = false;
bool hasTemp = true;
bool hasHum = true;
bool hasNoise = true;
bool hasWindSpeed = true;
bool hasWindDirection = true;
bool hasPM25 = true;
bool hasPM10 = true;
};
static QJsonObject genProg(const QJsonObject &, const QString &, const QString &);
explicit EEnviron(EBase *multiWin = nullptr);
explicit EEnviron(const QJsonObject &json, EBase *multiWin = nullptr);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
void timerEvent(QTimerEvent *) override;
int type() const override { return EBase::Environ; }
QWidget* attrWgt() override;
bool save(const QString &pRoot) override;
QJsonObject attrJson() const override;
private:
void init();
void drawText(QPainter*, QRectF&);
void calAttr();
Data m_attr;
int scroll_width;
QString scroll_txt;
int item_cnt = 0;
int timer_id = 0;
int scroll_off = 0;
};
#endif // EENVIRON_H