UBToolWidget.h 1.87 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1
/*
Claudio Valerio's avatar
Claudio Valerio committed
2 3
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
Claudio Valerio's avatar
Claudio Valerio committed
4
 * the Free Software Foundation, either version 2 of the License, or
Claudio Valerio's avatar
Claudio Valerio committed
5
 * (at your option) any later version.
Claudio Valerio's avatar
Claudio Valerio committed
6
 *
Claudio Valerio's avatar
Claudio Valerio committed
7 8 9 10 11 12 13
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Claudio Valerio's avatar
Claudio Valerio committed
14 15 16 17 18 19 20
 */

#ifndef UBTOOLWIDGET_H_
#define UBTOOLWIDGET_H_

#include <QtGui>

21
class UBGraphicsWidgetItem;
22 23 24
class QWidget;
class UBGraphicsScene;
class QWebView;
Claudio Valerio's avatar
Claudio Valerio committed
25

26
class UBToolWidget : public QWidget
Claudio Valerio's avatar
Claudio Valerio committed
27
{
28
    Q_OBJECT;
Claudio Valerio's avatar
Claudio Valerio committed
29 30

    public:
31 32
        UBToolWidget(const QUrl& pUrl, QWidget* pParent = 0);
        UBToolWidget(UBGraphicsWidgetItem* pWidget, QWidget* pParent = 0);
Claudio Valerio's avatar
Claudio Valerio committed
33 34
        virtual ~UBToolWidget();

35
        void remove();
36
        void centerOn(const QPoint& pos);
Claudio Valerio's avatar
Claudio Valerio committed
37

38
        QPoint naturalCenter() const;
39

40
        UBGraphicsWidgetItem *toolWidget() const;
Claudio Valerio's avatar
Claudio Valerio committed
41 42 43

    protected:
        void initialize();
44 45 46 47 48
        virtual void paintEvent(QPaintEvent *event);

        virtual void mousePressEvent(QMouseEvent *event);
        virtual void mouseMoveEvent(QMouseEvent *event);
        virtual void mouseReleaseEvent(QMouseEvent *event);
Claudio Valerio's avatar
Claudio Valerio committed
49

50
        virtual bool eventFilter(QObject *obj, QEvent *event);
Claudio Valerio's avatar
Claudio Valerio committed
51 52 53 54 55

    private slots:
        void javaScriptWindowObjectCleared();

    protected:
56 57
        QWebView *mWebView;
        UBGraphicsWidgetItem *mToolWidget;
58 59 60

        static QPixmap *sClosePixmap;
        static QPixmap *sUnpinPixmap;
61 62 63 64 65

        QPoint mMousePressPos;
        bool mShouldMoveWidget;
        int mContentMargin;
        int mFrameWidth;
Claudio Valerio's avatar
Claudio Valerio committed
66 67 68
};

#endif /* UBTOOLWIDGET_H_ */