2008-04-04 00:48:55 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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 Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_WEBCONTENT_H
|
|
|
|
#define PLASMA_WEBCONTENT_H
|
|
|
|
|
2008-04-04 01:51:58 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
2008-06-21 11:32:15 +02:00
|
|
|
#include <QtCore/QUrl>
|
2008-05-04 08:13:17 +02:00
|
|
|
#include <QtGui/QGraphicsWidget>
|
|
|
|
|
2008-04-04 00:48:55 +02:00
|
|
|
class QWebPage;
|
|
|
|
class QWebFrame;
|
|
|
|
class QKeyEvent;
|
|
|
|
class QGraphicsSceneDragDropEvent;
|
|
|
|
class QGraphicsSceneMouseEvent;
|
|
|
|
class QGraphicsSceneWheelEvent;
|
2008-07-13 22:50:53 +02:00
|
|
|
class QRect;
|
2008-04-04 00:48:55 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
class WebContentPrivate;
|
|
|
|
|
2008-08-25 19:47:48 +02:00
|
|
|
/**
|
|
|
|
* @class WebContent plasma/widgets/webcontent.h <Plasma/Widgets/WebContent>
|
|
|
|
*
|
|
|
|
* @short Provides a widget to display html content in Plasma.
|
|
|
|
*/
|
2008-04-13 23:21:50 +02:00
|
|
|
class PLASMA_EXPORT WebContent : public QGraphicsWidget
|
2008-04-04 00:48:55 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2008-04-13 23:21:50 +02:00
|
|
|
explicit WebContent(QGraphicsItem *parent = 0);
|
2008-04-04 00:48:55 +02:00
|
|
|
~WebContent();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the URL to display. Loading may happen asynchronously.
|
|
|
|
*
|
|
|
|
* @param url the location of the content to load.
|
|
|
|
*/
|
|
|
|
void setUrl(const QUrl &url);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the html to be shown along with a base URL to be used
|
|
|
|
* to resolve relative references.
|
|
|
|
*
|
2008-06-17 19:01:08 +02:00
|
|
|
* @param html the html (in utf8) to display in the content area
|
|
|
|
* @param baseUrl the base url for relative references
|
|
|
|
*/
|
|
|
|
void setHtml(const QByteArray &html, const QUrl &baseUrl = QUrl());
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the html to be shown along with a base URL to be used
|
|
|
|
* to resolve relative references.
|
|
|
|
*
|
|
|
|
* @param html the html (in utf8) to display in the content area
|
2008-04-04 00:48:55 +02:00
|
|
|
* @param baseUrl the base url for relative references
|
|
|
|
*/
|
2008-06-17 18:42:48 +02:00
|
|
|
void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
|
2008-04-04 00:48:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reimplementation
|
|
|
|
*/
|
2008-04-24 04:56:48 +02:00
|
|
|
QRectF geometry() const;
|
2008-04-04 00:48:55 +02:00
|
|
|
|
2008-04-04 01:35:41 +02:00
|
|
|
/**
|
|
|
|
* Sets the page to use in this item. The owner of the webpage remains,
|
|
|
|
* however if this WebContent object is the owner of the current page,
|
|
|
|
* then the current page is deleted
|
|
|
|
*
|
|
|
|
* @param page the page to set in this view
|
|
|
|
*/
|
|
|
|
void setPage(QWebPage *page);
|
|
|
|
|
2008-04-04 00:48:55 +02:00
|
|
|
/**
|
|
|
|
* The QWebPage associated with this item. Useful when more
|
|
|
|
* of the features of the full QWebPage object need to be accessed.
|
|
|
|
*/
|
|
|
|
QWebPage* page() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The main web frame associated with this item.
|
|
|
|
*/
|
|
|
|
QWebFrame* mainFrame() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reimplementation
|
|
|
|
*/
|
2008-07-13 22:50:53 +02:00
|
|
|
void setGeometry(const QRectF &geometry);
|
2008-04-04 00:48:55 +02:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* During loading progress, this signal is emitted. The values
|
|
|
|
* are always between 0 and 100, inclusive.
|
|
|
|
*
|
|
|
|
* @param percent the estimated amount the loading is complete
|
|
|
|
*/
|
|
|
|
void loadProgress(int percent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This signal is emitted when loading is completed.
|
|
|
|
*
|
|
|
|
* @param success true if the content was loaded successfully,
|
|
|
|
* otherwise false
|
|
|
|
*/
|
2008-06-29 02:20:31 +02:00
|
|
|
void loadFinished(bool success);
|
2008-04-04 00:48:55 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Reimplementation
|
|
|
|
*/
|
2008-04-13 23:21:50 +02:00
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2008-04-04 00:48:55 +02:00
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
|
|
|
void wheelEvent(QGraphicsSceneWheelEvent *event);
|
|
|
|
void keyPressEvent(QKeyEvent * event);
|
|
|
|
void keyReleaseEvent(QKeyEvent * event);
|
|
|
|
void focusInEvent(QFocusEvent * event);
|
|
|
|
void focusOutEvent(QFocusEvent * event);
|
|
|
|
void dragEnterEvent(QGraphicsSceneDragDropEvent * event);
|
|
|
|
void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
|
|
|
|
void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
|
|
|
|
void dropEvent(QGraphicsSceneDragDropEvent * event);
|
|
|
|
|
|
|
|
private:
|
2008-06-29 02:20:31 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void loadingFinished(bool success))
|
2008-07-13 22:50:53 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void updateRequested(const QRect& dirtyRect))
|
2008-08-22 20:38:50 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void scrollRequested(int dx, int dy, const QRect &scrollRect))
|
2008-06-29 02:20:31 +02:00
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
WebContentPrivate * const d;
|
|
|
|
friend class WebContentPrivate;
|
2008-04-04 00:48:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif // Multiple incluson guard
|
|
|
|
|