qt/LedOK/program/eaclock.h

59 lines
1.9 KiB
C
Raw Permalink Normal View History

2023-04-18 14:14:46 +08:00
#ifndef EACLOCK_H
#define EACLOCK_H
#include "ebase.h"
#include <QTimeZone>
2023-04-27 15:06:24 +08:00
#include "gutil/qgui.h"
2023-04-18 14:14:46 +08:00
class EAClock : public EBase {
Q_OBJECT
public:
struct Data {
QTimeZone timeZone;
int hourMark{0};//时针
int hourMarkSize{5};//时针大小
QColor hourMarkColor{Qt::green};//时针颜色
int minMark{1};//分针
int minMarkSize{2};//分针大小
QColor minMarkColor{Qt::yellow};//分针颜色
QColor hourHandColor;//秒针
QColor minHandColor;//秒针大小
QColor secHandColor;//秒针颜色
int hhLen{50}, mhLen{75}, shLen{100};
int hhWidth{15}, mhWidth{10}, shWidth{5};
QString text;//标题
2023-04-27 15:06:24 +08:00
QFont textFont = qfont("Arial", 12);//标题字体
2023-04-18 14:14:46 +08:00
QColor textColor;//标题字体颜色
QString path;
QString name;
bool hasDialImg{false};
bool showSecHand{true};
};
explicit EAClock(EBase *multiWin = nullptr);
2023-10-23 14:58:29 +08:00
explicit EAClock(const JObj &json, EBase *multiWin = nullptr);
2023-04-18 14:14:46 +08:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
int type() const override { return EBase::AClock; }
QWidget* attrWgt() override;
bool save(const QString &pRoot) override;
2023-10-23 14:58:29 +08:00
JObj attrJson() const override;
2023-04-18 14:14:46 +08:00
protected:
void timerEvent(QTimerEvent *) override;
void drawMarkCircular (QPainter *painter, const QPointF &pos, const QColor &color, qreal diameter);
void drawMarkRectangle(QPainter *painter, const QPointF &pos, const QColor &color, qreal len, qreal rotate);
void drawMarkNumber (QPainter *painter, const QPointF &pos, const QColor &color, qreal len, int num);
void paintDial(QPainter *painter);
void paintText(QPainter *painter);
void cal();
Data m_attr;
QImage dial_img;
double hAngle, mAngle, sAngle;
int timerId{0};
};
#endif // EACLOCK_H