blob: de87500a1bbfd736bb70b4ac350796b6a9778316 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#ifndef WEBSCRAP_H
#define WEBSCRAP_H
#include <QWebView>
#include <QGraphicsWebView>
#include <QLinearGradient>
#include <QToolButton>
#include <QGraphicsScale>
#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
|