dictwebview.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*****************************************************************************
  2. * dictwebview.h - DictionaryStar, stardict dictionary for MeeGo Harmattan *
  3. * Copyright (C) 2012 Jari P.T. Alhonen *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 3 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License along *
  16. * with this program; if not, see <http://www.gnu.org/licenses/>. *
  17. *****************************************************************************/
  18. #ifndef DICTWEBVIEW_H
  19. #define DICTWEBVIEW_H
  20. #include <QWebView>
  21. #include <QGraphicsProxyWidget>
  22. #include <QFile>
  23. #include <QtNetwork/QNetworkRequest>
  24. #include <QtNetwork/QNetworkReply>
  25. #include <QProgressDialog>
  26. class DictWebView : public QGraphicsProxyWidget
  27. {
  28. Q_OBJECT
  29. Q_PROPERTY(QUrl url READ url WRITE setUrl)
  30. Q_PROPERTY(int contentHeight READ contentHeight WRITE setContentHeight)
  31. Q_PROPERTY(int contentWidth READ contentWidth WRITE setContentWidth)
  32. Q_PROPERTY(qreal preferredHeight READ preferredHeight WRITE setPreferredHeight)
  33. Q_PROPERTY(qreal preferredWidth READ preferredWidth WRITE setPreferredWidth)
  34. Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
  35. public:
  36. explicit DictWebView(QGraphicsProxyWidget *parent = 0);
  37. Q_INVOKABLE void load(const QString& url);
  38. QUrl url() const;
  39. void setUrl(const QUrl& url);
  40. int contentHeight() const;
  41. void setContentHeight(int);
  42. int contentWidth() const;
  43. void setContentWidth(int);
  44. qreal zoomFactor() const;
  45. void setZoomFactor(qreal);
  46. signals:
  47. void downloadProgress(qint64 current, qint64 total);
  48. void importCompleted(const QString& dicts);
  49. void contentSizeChanged();
  50. void linkClicked();
  51. void loadFinished();
  52. void movePage(bool back); //! back with true, forward with false
  53. void hideButton(bool back); //! back button is true, forward is false
  54. public slots:
  55. void followLink(const QUrl &);
  56. void extractFile();
  57. void handleContent(QNetworkReply*);
  58. void handleContent(const QNetworkRequest&);
  59. void handleMove(bool);
  60. private:
  61. void downloadFile(const QUrl&);
  62. QNetworkReply* m_Reply;
  63. QWebView* webView;
  64. };
  65. #endif // DICTWEBVIEW_H