summaryrefslogtreecommitdiffstats
path: root/webscrap.h
blob: 1174b7bfddfa72519b638da1017e4249c48cecc4 (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
#ifndef WEBSCRAP_H
#define WEBSCRAP_H

#include <QWebView>
#include <QGraphicsWebView>
#include <QLinearGradient>

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;

public slots:
    void onLoad();
    void onRefresh();
    void setScrapRect(QRect rect);
    void openUrlInExternalBrowser(QUrl url);

private:
    QRect m_scrapRect;
    int m_refreshInterval;
    QTimer *m_refreshTimer;
    QLinearGradient m_loadingGradient, m_overlayGradient;
    QPointF m_savedPos;
};

class WebScrapContainer : public QGraphicsWidget {
    Q_OBJECT
public:
    WebScrapContainer(WebScrap *scrap, QGraphicsScene *scene);

public slots:
    void setTitle(const QString& title);

protected:
    bool sceneEventFilter(QGraphicsItem *watched, QEvent* event);

signals:
    void frameClicked();

public:
    QGraphicsPathItem *m_frame;
    QGraphicsTextItem *m_titlebar;
};
#endif // WEBSCRAP_H