67 lines
2.1 KiB
C
67 lines
2.1 KiB
C
|
#ifndef EACLOCK_H
|
||
|
#define EACLOCK_H
|
||
|
|
||
|
#include "ebase.h"
|
||
|
#include "base/locolorselector.h"
|
||
|
#include <QComboBox>
|
||
|
#include <QCheckBox>
|
||
|
#include <QGroupBox>
|
||
|
#include <QSpinBox>
|
||
|
#include <QFontComboBox>
|
||
|
#include <QTextEdit>
|
||
|
#include <QTime>
|
||
|
|
||
|
class eAClock : public EBase {
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
struct Data {
|
||
|
QByteArray timeZoneId;
|
||
|
int hourMark;//时针
|
||
|
int hourMarkSize;//时针大小
|
||
|
QColor hourMarkColor;//时针颜色
|
||
|
int minMark;//分针
|
||
|
int minMarkSize;//分针大小
|
||
|
QColor minMarkColor;//分针颜色
|
||
|
QColor hourHandColor;//秒针
|
||
|
QColor minHandColor;//秒针大小
|
||
|
QColor secHandColor;//秒针颜色
|
||
|
QString text;//标题
|
||
|
QFont textFont;//标题字体
|
||
|
QColor textColor;//标题字体颜色
|
||
|
int playDuration=10;//
|
||
|
QString path="";
|
||
|
QString name="";
|
||
|
QString selfCreateDialName;
|
||
|
bool hasDialImg;
|
||
|
};
|
||
|
|
||
|
explicit eAClock(EBase *multiWin = nullptr);
|
||
|
explicit eAClock(const QJsonObject &json, EBase *multiWin = nullptr);
|
||
|
|
||
|
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;
|
||
|
QJsonObject attrJson() const override;
|
||
|
|
||
|
protected:
|
||
|
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 drawHand (QPainter *painter, qreal angle, const QColor &color, qreal len, qreal base);
|
||
|
void paintDial(QPainter *painter);
|
||
|
void paintText(QPainter *painter);
|
||
|
|
||
|
qreal radiusHour() const;
|
||
|
qreal radiusMin() const;
|
||
|
qreal radius() const { return radiusHour() < radiusMin() ? radiusHour() : radiusMin(); }
|
||
|
|
||
|
void init();
|
||
|
|
||
|
Data m_attr;
|
||
|
QImage dial_img;
|
||
|
QTime time;
|
||
|
};
|
||
|
|
||
|
#endif // EACLOCK_H
|