void QGraphicsWebViewPrivate::updateCompositingScrollPosition() { if (rootGraphicsLayer && q->page() && q->page()->mainFrame()) { const QPoint scrollPosition = q->page()->mainFrame()->scrollPosition(); rootGraphicsLayer.data()->setPos(-scrollPosition); } }
void QGraphicsWebViewPrivate::setInputMethodHint(Qt::InputMethodHint hint, bool enable) { if (enable) q->setInputMethodHints(q->inputMethodHints() | hint); else q->setInputMethodHints(q->inputMethodHints() & ~hint); }
void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success) { // If the page had no title, still make sure it gets the signal if (q->title().isEmpty()) emit q->urlChanged(q->url()); emit q->loadFinished(success); }
QRect QGraphicsWebViewPrivate::geometryRelativeToOwnerWidget() const { if (!q->scene()) return QRect(); QList<QGraphicsView*> views = q->scene()->views(); if (views.isEmpty()) return QRect(); QGraphicsView* view = views.at(0); return view->mapFromScene(q->boundingRect()).boundingRect(); }
bool QGraphicsWebViewPrivate::inputMethodEnabled() const { #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) return q->flags() & QGraphicsItem::ItemAcceptsInputMethod; #else return false; #endif }
/*! Returns a pointer to the underlying web page. \sa setPage() */ QWebPage* QGraphicsWebView::page() const { if (!d->page) { QGraphicsWebView* that = const_cast<QGraphicsWebView*>(this); QWebPage* page = new QWebPage(that); // Default to not having a background, in the case // the page doesn't provide one. QPalette palette = QApplication::palette(); palette.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0)); page->setPalette(palette); that->setPage(page); } return d->page; }
QWidget* QGraphicsWebViewPrivate::ownerWidget() const { if (QGraphicsScene* scene = q->scene()) { const QList<QGraphicsView*> views = scene->views(); return views.value(0); } return 0; }
void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll) { q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll)); #if USE(ACCELERATED_COMPOSITING) updateCompositingScrollPosition(); #endif }
WId QGraphicsWebViewPrivate::winId() const { const QList<QGraphicsView*> views = q->scene()->views(); if (!views.isEmpty()) return views.at(0)->winId(); return 0; }
void QGraphicsWebViewPrivate::setRootGraphicsLayer(QGraphicsItem* layer) { if (rootGraphicsLayer) { rootGraphicsLayer.data()->setParentItem(0); q->scene()->removeItem(rootGraphicsLayer.data()); QWebFramePrivate::core(q->page()->mainFrame())->view()->syncCompositingStateRecursive(); } rootGraphicsLayer = layer ? layer->toGraphicsObject() : 0; if (layer) { layer->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); layer->setParentItem(q); layer->setZValue(RootGraphicsLayerZValue); updateCompositingScrollPosition(); } createOrDeleteOverlay(); }
void QGraphicsWebViewPrivate::syncLayers() { #if USE(ACCELERATED_COMPOSITING) if (shouldSync) { QWebFramePrivate::core(q->page()->mainFrame())->view()->syncCompositingStateRecursive(); shouldSync = false; } #endif }
void QGraphicsWebViewPrivate::_q_doLoadProgress(int progress) { if (qFuzzyCompare(this->progress, qreal(progress / 100.))) return; this->progress = progress / 100.; emit q->progressChanged(this->progress); }
void QGraphicsWebViewPrivate::_q_updateMicroFocus() { // Ideally, this should be handled by a common call to an updateMicroFocus function // in QGraphicsItem. See http://bugreports.qt.nokia.com/browse/QTBUG-7578. QList<QGraphicsView*> views = q->scene()->views(); for (int c = 0; c < views.size(); ++c) { QInputContext* ic = views.at(c)->inputContext(); if (ic) ic->update(); } }
int QGraphicsWebViewPrivate::screenNumber() const { #if defined(Q_WS_X11) const QList<QGraphicsView*> views = q->scene()->views(); if (!views.isEmpty()) return views.at(0)->x11Info().screen(); #endif return 0; }
void QGraphicsWebViewPrivate::update(const QRect & dirtyRect) { q->update(QRectF(dirtyRect)); createOrDeleteOverlay(); if (overlay) overlay->update(QRectF(dirtyRect)); #if USE(ACCELERATED_COMPOSITING) updateCompositingScrollPosition(); syncLayers(); #endif }
void QGraphicsWebViewPrivate::_q_updateMicroFocus() { #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) // Ideally, this should be handled by a common call to an updateMicroFocus function // in QGraphicsItem. See http://bugreports.qt.nokia.com/browse/QTBUG-7578. QList<QGraphicsView*> views = q->scene()->views(); for (int c = 0; c < views.size(); ++c) { QInputContext* ic = views.at(c)->inputContext(); if (ic) ic->update(); } #endif }
/*------------------------------------------------------------------------------ | main +-----------------------------------------------------------------------------*/ int main(int argc, char** argv) { qputenv("QT_QPA_EGLFS_FORCE888", "1"); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); QApplication a(argc, argv); const QStringList args = a.arguments(); if (args.size() < 2) { log_err("Video ID is missing."); return 1; } const QString videoId = args.at(1); log_info("Starting playback of video ID %s...", qPrintable(videoId)); POC_Bridge bridge(videoId); QGraphicsWebView* webItem = new QGraphicsWebView; webItem->page()->mainFrame()->addToJavaScriptWindowObject("bridge", &bridge); QOpenGLWidget* glViewport = new QOpenGLWidget; QGraphicsView* view = new QGraphicsView; view->setFrameShape(QFrame::NoFrame); view->setRenderHints(QPainter::Antialiasing); view->setScene(new QGraphicsScene); view->setViewport(glViewport); view->showFullScreen(); view->scene()->setBackgroundBrush(QBrush(Qt::red)); view->scene()->setSceneRect(QRectF(0, 0, 1920, 1080)); view->scene()->addItem(webItem); webItem->setUrl(QUrl("qrc:/player.html")); webItem->setMinimumSize(1920, 1080); return a.exec(); }
// ! [0] int main(int argc, char **argv) { QApplication app(argc, argv); const int width = 640; const int height = 480; QGraphicsScene scene; QGraphicsView view(&scene); view.setFrameShape(QFrame::NoFrame); view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QGraphicsWebView webview; webview.resize(width, height); webview.load(QUrl("http://doc.qt.nokia.com/")); scene.addItem(&webview); view.resize(width, height); view.show(); return app.exec(); }
int main(int argc, char **argv) { QApplication app(argc, argv); const int width = 1024; const int height = 768; QGraphicsScene scene; QGraphicsView view(&scene); view.setWindowTitle("Game"); view.setFrameShape(QFrame::NoFrame); view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QGraphicsWebView webview; webview.resize(width, height); webview.load(QUrl("index.html")); scene.addItem(&webview); view.resize(width, height); view.show(); return app.exec(); }
void QGraphicsWebViewPrivate::createOrDeleteOverlay() { bool useOverlay = false; if (!resizesToContents) { #if USE(ACCELERATED_COMPOSITING) useOverlay = useOverlay || rootGraphicsLayer; #endif #if ENABLE(TILED_BACKING_STORE) useOverlay = useOverlay || QWebFramePrivate::core(q->page()->mainFrame())->tiledBackingStore(); #endif } if (useOverlay == !!overlay) return; if (useOverlay) { overlay = QSharedPointer<QGraphicsWebViewOverlay>(new QGraphicsWebViewOverlay(q)); overlay->setZValue(OverlayZValue); } else overlay.clear(); }
void QGraphicsWebViewPrivate::update(const QRect & dirtyRect) { q->update(QRectF(dirtyRect)); }
void QGraphicsWebViewPrivate::setInputMethodEnabled(bool enable) { q->setAttribute(Qt::WA_InputMethodEnabled, enable); }
void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll) { q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll)); }
void QGraphicsWebViewPrivate::_q_setStatusBarMessage(const QString& s) { statusBarMessage = s; emit q->statusChanged(); }
void QGraphicsWebViewPrivate::setInputMethodEnabled(bool enable) { #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) q->setFlag(QGraphicsItem::ItemAcceptsInputMethod, enable); #endif }
QPalette QGraphicsWebViewPrivate::palette() const { return q->palette(); }
QWidget* QGraphicsWebViewPrivate::ownerWidget() const { const QList<QGraphicsView*> views = q->scene()->views(); return views.value(0); }
void QGraphicsWebViewPrivate::updateCursor(const QCursor& cursor) { q->setCursor(cursor); }
QCursor QGraphicsWebViewPrivate::cursor() const { return q->cursor(); }
void QGraphicsWebViewPrivate::_q_pageDestroyed() { page = 0; q->setPage(0); }