#ifndef EBASE_H #define EBASE_H #include #include "gutil/qjson.h" #include #include #include #include #define m_handleLen 10 class EBase : public QGraphicsObject { Q_OBJECT public: enum ElementType { Text = QGraphicsItem::UserType + 1, Image, Video, Gif, Audio, DClock, AClock, Timer, Environ, Window, Web }; Q_ENUM(ElementType) explicit EBase(EBase *multiWin = nullptr); void setBaseAttr(const JObj &); void addBaseAttr(JObj &) const; QRectF boundingRect() const override; void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override; virtual JObj attrJson() const = 0; virtual void loadFiles() {} virtual void freeFiles() {} virtual bool save(const QString &) {return true;} virtual QWidget* attrWgt() = 0; void addBaseAttrWgt(QBoxLayout *vBox); inline void setSize(qreal width, qreal height) { prepareGeometryChange(); mWidth = width; mHeight = height; emit sizeChanged(); } void fitProgSize(); QRectF innerRect() const; QRectF rect() const { return innerRect(); } int mType = -1; EBase *mMultiWin = 0; qreal mWidth = 0, mHeight = 0; int _rotate = 0; QSpinBox *fdDuration = 0; int mStartTime = 0, mDuration = 10; QString mEntryEffect, mExitEffect; int mEntryDur = 1, mExitDur = 1; double _blinkFreq = 1.0; bool _hasBlink = 0; signals: void sizeChanged(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override; void mouseMoveEvent(QGraphicsSceneMouseEvent *) override; void hoverMoveEvent(QGraphicsSceneHoverEvent *) override; void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override; QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; void timerEvent(QTimerEvent *) override; void setFrmSec(const QPointF &); void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor); void clearSnap(); QPen mSidePen; QRectF m_rL, m_rR, m_rT, m_rB, m_rLT, m_rRT, m_rRB, m_rLB; QPointF mPressRel{FLT_MAX, FLT_MAX}; Qt::WindowFrameSection mFrmSec{Qt::NoSection}; char mLRSnap{0}, mTBSnap{0}; std::vector mOtherEles; int bdImgIdx{-1}; QString bdEff{"rotate"}; int bdSpeed{2}; int bdOff{0}; int bdTimerId{0}; }; #endif // EBASE_H