#ifndef ETEXT_H #define ETEXT_H #include #include #include #include #include "ebase.h" #include "QTime" //这条语句害死人,加了这条语句文字就不能做到无反锯齿 MYFONT.setHintingPreference(QFont::PreferNoHinting); class txtBmpPage{ public: int index=0; QPixmap bitmap; }; class txtBmpLine{ public: int index=0; int iStart=0; int iEnd=0; QPixmap bitmap; }; class EText : public EBase { Q_OBJECT public: enum PlayStyle { Flip = 0, Scroll, Static }; enum RollingStyle { Left2Right = 0, Right2Left, Top2Bottom, Bottom2Top }; struct Turning { int playDuration{10}; int pageDuration{10}; QString effect{"no"}; int effectDuration{3}; }; struct Rolling { int playDuration{10}; int rollingStyle; int rollingSpeed; bool headTailConnected; int headTailSpacing=10; }; struct Data { QString text; QTextOption opt; int lineSpacing = 0; int letterSpacing = 0; QColor cBackground; int iPageCount=1; int playStyle; Turning turning; Rolling rolling; int playDuration{10}; }; static void setElement(const QJsonObject &json, Data &attr); explicit EText(EBase *multiWin = nullptr); explicit EText(const QJsonObject &json, EBase *multiWin = nullptr); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; int type() const override { return EBase::Text; } QWidget* attrWgt() override; bool save(const QString &pRoot) override; QJsonObject attrJson() const override; signals: void sPageCountChanged(int); public slots: // Widget void RefreshBigPixmap(); void OnPageIndexPreview(int iPageIndex); private: int ClearPixmapTopAndBottomBlack(); void MakeMuliPngToDir(int iPageIndex,QString strPngPathAndName) ; void MakeBigMoveUpOrDownOnePngToDir() ; void MakeBigMoveLeftOrRightOnePngToDir() ; void MakeBigMoveUpOrDownOnePngToDir(QString strPngPathAndName) ; void MakeBigMoveLeftOrRightOnePngToDir(QString strPngPathAndName) ; void CreateBigOnePixBmp(); int GetPagesPosList(); txtBmpPage GetFirstPagePixmap(); int GetLinePng(QPixmap bigOnePixmap) ; void ProcessLastStartEndLianJie(QPixmap bmp,QString strPngFilePathName,int iLastRightNoWordWidth); int GetWordSpaceRealInBmp(QPixmap bmp); private: // Interior QPointF m_pText; QRectF m_rClip; Data m_attr; int m_lineH; QPixmap mRenderImg; QPixmap m_bigOnePixBmp; QList m_list; qreal m_oldWidth=0; qreal m_oldHeight=0; QColor m_ImageBkColor; QString m_pRootPath; QList m_linelist; }; #endif // ETEXT_H