X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fwebpreviewitem.cpp;fp=src%2Fqtui%2Fwebpreviewitem.cpp;h=1d27c9619c21b7641d94450ef2c78e45eb3ec7a0;hp=f674166c847e476db3c5eecf5e18cee14f6b2a1d;hb=694f9bfbf7f1af19108461c7e00d133e55082bce;hpb=61c8d84d1c849373e0f115dc748ed45cff95287d diff --git a/src/qtui/webpreviewitem.cpp b/src/qtui/webpreviewitem.cpp index f674166c..1d27c961 100644 --- a/src/qtui/webpreviewitem.cpp +++ b/src/qtui/webpreviewitem.cpp @@ -28,34 +28,37 @@ #include 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 + : 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; - - 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); - - setZValue(30); + qreal frameWidth = 5; + + 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); + + 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