summaryrefslogtreecommitdiffstats
path: root/webview.h
blob: 8d4b3fdca5b7263cb87353624c4041fe3e552524 (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
#ifndef WEBVIEW_H
#define WEBVIEW_H

#include <QGraphicsWebView>
#include <QGraphicsSceneMouseEvent>
#include <QPushButton>
#include <QKeyEvent>
#include <QPainter>
#include <QWebPage>
#include "graphicstoolbar.h"
#include "resizeuihelper.h"

class WebView : public QGraphicsWebView
{
    Q_OBJECT
public:
    WebView(QGraphicsScene *scene, QGraphicsItem * parent = 0);
    bool scrapSelectionEnabled() const;
    void createAddScrapToolbar();
    void showAddScrapToolbar();
    void hideAddScrapToolbar();

public slots:
    void setScrapSelectionEnabled(bool enabled);
    void selectScrap();
    void unselectScrap();
    void addScrap();
    void show();
    void hide();
    void setScrapRect(QRect rect);
    void setScrolledScrapRect(QRectF rect);
    void enableCachedMode();
    void disableCachedMode();

signals:
    void scrapAdded(QUrl url, QSize pageSize, QRect scrapRect, QPoint position);

protected:
    void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
    void mousePressEvent(QGraphicsSceneMouseEvent* event);
    void keyPressEvent(QKeyEvent *event);
    void paint(QPainter* painter, const QStyleOptionGraphicsItem* options, QWidget* widget = 0);

private:
    QGraphicsScene *m_scene;
    bool m_scrapSelectionEnabled;
    QRect m_scrapRect;
    bool m_scrapSelected;

    GraphicsToolBar *m_addScrapToolbar;
    QPushButton *m_addButton, *m_cancelButton;
    ResizeUiHelper *m_resizer;
};

#endif // WEBVIEW_H