qspwebbox.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef QSPWEBBOX_H
  2. #define QSPWEBBOX_H
  3. #include <QWidget>
  4. #include <QWebEngineView>
  5. #include <QString>
  6. #include <QFont>
  7. #include <QColor>
  8. #include <QVariant>
  9. #include <QUrl>
  10. #include <QWebChannel>
  11. #include <QWebEngineProfile>
  12. #include "qspwebengineurlschemehandler.h"
  13. #include "qspexecwebengineurlschemehandler.h"
  14. #include "qspwebchannel.h"
  15. namespace Ui {
  16. class QspWebBox;
  17. }
  18. class QspWebBox : public QWebEngineView
  19. {
  20. Q_OBJECT
  21. public:
  22. explicit QspWebBox(QWidget *parent = 0);
  23. ~QspWebBox();
  24. // Methods
  25. void RefreshUI(bool isScroll = false);
  26. void LoadBackImage(const QString& fileName);
  27. // Accessors
  28. void SetIsHtml(bool isHtml);
  29. void SetText(const QString& text, bool isScroll = false);
  30. void SetTextFont(const QFont& new_font);
  31. QFont GetTextFont() const { return m_font; }
  32. QString GetText() const { return m_text; }
  33. bool SetLinkColor(const QColor &color);
  34. QColor GetLinkColor() { return m_linkColor; }
  35. void SetGamePath(const QString& path);
  36. QColor GetBackgroundColor();
  37. QColor GetForegroundColor(); //text color
  38. bool SetBackgroundColor(const QColor& color);
  39. bool SetForegroundColor(const QColor& color);
  40. void SetShowPlainText(bool isPlain);
  41. void SetVideoFix(bool isFix);
  42. void SetHead(const QString &head);
  43. void SetFontType(const int fontType);
  44. void SetSizeType(const int sizeType);
  45. void SetCustomCSS(bool customCSS);
  46. void Quit();
  47. private:
  48. // Fields
  49. bool m_isUseHtml;
  50. QString m_outFormat;
  51. QString m_path;
  52. QString m_imagePath;
  53. QFont m_font;
  54. QString m_text;
  55. QString m_head;
  56. int m_posX;
  57. int m_posY;
  58. QColor m_linkColor;
  59. QColor m_backColor;
  60. QColor m_fontColor;
  61. bool showPlainText;
  62. bool m_videoFix;
  63. int m_fontType;
  64. int m_sizeType;
  65. QspWebEngineUrlSchemeHandler qweush;
  66. QspExecWebEngineUrlSchemeHandler qeweush;
  67. QWebEngineProfile profile;
  68. QWebChannel *channel;
  69. QspWebChannel qspJS;
  70. bool m_isQuit;
  71. signals:
  72. void qspLinkClicked(QUrl url);
  73. private slots:
  74. void OnQspLinkClicked(QUrl url);
  75. };
  76. #endif // QSPWEBBOX_H