X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fwebpreviewitem.cpp;h=7ee73922a07ea527fef1f18955bd533a6bc6c8b8;hp=8f49032b8b351d14441773027b2d578fc552d267;hb=f04db2cb802b1296ca739c823495930c71d3b4ab;hpb=f824db0e31b54969e0b7fa0b5405b1e9173d482c diff --git a/src/qtui/webpreviewitem.cpp b/src/qtui/webpreviewitem.cpp index 8f49032b..7ee73922 100644 --- a/src/qtui/webpreviewitem.cpp +++ b/src/qtui/webpreviewitem.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-2013 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "webpreviewitem.h" @@ -25,35 +25,40 @@ #include #include #include +#include -WebPreviewItem::WebPreviewItem(const QString &url) - : QGraphicsItem(0), // needs to be a top level item as we otherwise cannot guarantee that it's on top of other chatlines +WebPreviewItem::WebPreviewItem(const QUrl &url) + : QGraphicsItem(0), // needs to be a top level item as we otherwise cannot guarantee that it's on top of other chatlines _boundingRect(0, 0, 400, 300) { - qreal frameWidth = 5; + qreal frameWidth = 5; - QWebView *webView = new QWebView; - webView->load(url); - webView->resize(1000, 750); - QGraphicsProxyWidget *proxyItem = new QGraphicsProxyWidget(this); - proxyItem->setWidget(webView); - proxyItem->setAcceptHoverEvents(false); + QWebView *webView = new QWebView; + webView->settings()->setAttribute(QWebSettings::JavascriptEnabled, false); + webView->load(url); + webView->resize(1000, 750); + QGraphicsProxyWidget *proxyItem = new QGraphicsProxyWidget(this); + proxyItem->setWidget(webView); + proxyItem->setAcceptHoverEvents(false); - qreal xScale = (_boundingRect.width() - 2 * frameWidth) / webView->width(); - qreal yScale = (_boundingRect.height() - 2 * frameWidth) / webView->height(); - proxyItem->scale(xScale, yScale); - proxyItem->setPos(frameWidth, frameWidth); + qreal xScale = (_boundingRect.width() - 2 * frameWidth) / webView->width(); + qreal yScale = (_boundingRect.height() - 2 * frameWidth) / webView->height(); + proxyItem->scale(xScale, yScale); + proxyItem->setPos(frameWidth, frameWidth); - setZValue(30); + setZValue(30); } -void WebPreviewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - Q_UNUSED(option); Q_UNUSED(widget); - painter->setClipRect(boundingRect()); - painter->setPen(QPen(Qt::black, 5)); - painter->setBrush(Qt::black); - painter->setRenderHints(QPainter::Antialiasing); - painter->drawRoundedRect(boundingRect(), 10, 10); + +void WebPreviewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option); Q_UNUSED(widget); + painter->setClipRect(boundingRect()); + painter->setPen(QPen(Qt::black, 5)); + painter->setBrush(Qt::black); + painter->setRenderHints(QPainter::Antialiasing); + painter->drawRoundedRect(boundingRect(), 10, 10); } + #endif //#ifdef HAVE_WEBKIT