#ifndef WEBSCRAP_H #define WEBSCRAP_H #include #include #include #include #include #include "graphicstoolbar.h" #include "resizeuihelper.h" class WebScrap : public QGraphicsWebView { Q_OBJECT public: WebScrap(QUrl url, QRect scrapRect, QGraphicsItem * parent = 0); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* options, QWidget* widget = 0); const QTimer *refreshTimer() const; void setRefreshInterval(int msecs); int refreshInterval() const; // msecs QRect scrapRect() const; void updateGradient(QRect rect); void savePos(); QPointF savedPos() const; bool dimensionsFixed() const; public slots: void onLoad(); void onRefresh(); void setScrapRect(QRect rect); void openUrlInExternalBrowser(QUrl url); void setDimensionsFixed(bool fixed); protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *event); private: QRect m_scrapRect; int m_refreshInterval; QTimer *m_refreshTimer; QLinearGradient m_loadingGradient, m_overlayGradient; QPointF m_savedPos; QPixmap m_webshot; bool m_isDimensionsFixed; QPixmap m_loadingPix, m_adjustablePix, m_arrowPix, m_scalePix; }; class WebScrapContainer : public QGraphicsWidget { Q_OBJECT public: WebScrapContainer(WebScrap *scrap, QGraphicsScene *scene); void createToolbar(); QRectF boundingRect() const; public slots: void setTitle(const QString& title); void handleCloseButtonClicked(); void handleRectResized(QRectF rect); protected: bool sceneEventFilter(QGraphicsItem *watched, QEvent* event); signals: void frameClicked(); void removeSelf(); public: QGraphicsScene *m_scene; WebScrap *m_scrap; QGraphicsPathItem *m_frame; QGraphicsTextItem *m_titlebar; GraphicsToolBar *m_toolbar; QToolButton *m_closeButton, *m_adjustButton, *m_reloadButton; ResizeUiHelper *m_resizer; QGraphicsScale *m_scrapScale; }; #endif // WEBSCRAP_H