void QDeclarativeWebView::setPage(QWebPage* page) { if (d->view->page() == page) return; d->view->setPage(page); updateContentsSize(); page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); connect(page->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(pageUrlChanged())); connect(page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); connect(page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(iconChanged())); connect(page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout())); connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SIGNAL(contentsSizeChanged(QSize))); connect(page, SIGNAL(loadStarted()), this, SLOT(doLoadStarted())); connect(page, SIGNAL(loadProgress(int)), this, SLOT(doLoadProgress(int))); connect(page, SIGNAL(loadFinished(bool)), this, SLOT(doLoadFinished(bool))); connect(page, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusText(QString))); connect(page->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(windowObjectCleared())); page->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); }
Dialog::Dialog(const Application* application, const QString& userId, QWidget* parent) : QWidget(parent), ui(new Ui::Dialog), application(application), userId(userId) { unreadInList = QStringList(); setupUi(); connect(ui->textEdit , SIGNAL(focusIn()) , this , SLOT(markInboxRead())); connect(ui->webView->page()->mainFrame() , SIGNAL(contentsSizeChanged(QSize)) , this , SLOT(scrollToBottom(QSize))); loadHistory(20); connect(&application->getLongPollExecutor() , SIGNAL(messageRecieved(QString,bool, bool,QString,uint,QString)) , this , SLOT(insertMessage(QString,bool, bool,QString,uint,QString))); connect(&application->getLongPollExecutor() , SIGNAL(messageIsRead(QString)) , this , SLOT(markMessageIsRead(QString))); connect(ui->textEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage())); connect(ui->pushButton, SIGNAL(released()), this, SLOT(sendMessage())); ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(openAttachment(QUrl))); }
lmcMessageLog::lmcMessageLog(QWidget *parent) : QWebView(parent) { connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(log_linkClicked(QUrl))); connect(this->page()->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(log_contentsSizeChanged(QSize))); connect(this->page(), SIGNAL(linkHovered(QString, QString, QString)), this, SLOT(log_linkHovered(QString, QString, QString))); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); setRenderHints(QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); createContextMenu(); participantAvatars.clear(); hasData = false; messageTime = false; messageDate = false; allowLinks = false; pathToLink = false; trimMessage = true; fontSizeVal = 0; sendFileMap.clear(); receiveFileMap.clear(); lastId = QString::null; messageLog.clear(); linkHovered = false; outStyle = false; autoScroll = true; }
void QGraphicsWebViewPrivate::updateResizesToContentsForPage() { ASSERT(page); if (resizesToContents) { // resizes to contents mode requires preferred contents size to be set if (!page->preferredContentsSize().isValid()) page->setPreferredContentsSize(QSize(960, 800)); #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) QObject::connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), q, SLOT(_q_contentsSizeChanged(const QSize&)), Qt::UniqueConnection); #else QObject::connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), q, SLOT(_q_contentsSizeChanged(const QSize&))); #endif } else {
/*! Sets the size of the contents to the given \a size. \sa contentsSize() */ void QDeclarativePaintedItem::setContentsSize(const QSize &size) { Q_D(QDeclarativePaintedItem); if (d->contentsSize == size) return; prepareGeometryChange(); d->contentsSize = size; clearCache(); update(); emit contentsSizeChanged(); }
WebViewHtmlWidget::WebViewHtmlWidget(QObject *parent) : IHtmlWidget(parent) { m_widget = new QWebView; m_widget->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); connect(m_widget,SIGNAL(linkClicked(QUrl)),this,SIGNAL(linkClicked(QUrl))); connect(m_widget->page(),SIGNAL(linkHovered(QString,QString,QString)),this,SLOT(webLinkHovered(QString,QString,QString))); connect(m_widget->page(),SIGNAL(loadFinished(bool)),this,SIGNAL(loadFinished(bool))); connect(m_widget->page()->mainFrame(),SIGNAL(contentsSizeChanged(QSize)),this,SIGNAL(contentsSizeChanged())); }
/*! Sets the size of the contents to the given \a size. \sa contentsSize() */ void QDeclarativePaintedItem::setContentsSize(const QSize &size) { Q_D(QDeclarativePaintedItem); if (d->contentsSize == size) return; d->contentsSize = size; setImplicitWidth(size.width()*d->contentsScale); setImplicitHeight(size.height()*d->contentsScale); clearCache(); update(); emit contentsSizeChanged(); }
void QQuickPaintedItem::setContentsSize(const QSize &size) { Q_D(QQuickPaintedItem); if (d->contentsSize == size) return; d->contentsSize = size; update(); emit contentsSizeChanged(); }
ItemWeb::ItemWeb(const QString &html, QWidget *parent) : QWebView(parent) , ItemWidget(this) { QWebFrame *frame = page()->mainFrame(); frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); const QFont &defaultFont = font(); settings()->setFontFamily(QWebSettings::StandardFont, defaultFont.family()); // DPI resolution can be different than the one used by this widget. QWidget* window = QApplication::desktop()->screen(); int dpi = window->logicalDpiX(); int pt = defaultFont.pointSize(); settings()->setFontSize(QWebSettings::DefaultFontSize, pt * dpi / 72); history()->setMaximumItemCount(0); QPalette pal(palette()); pal.setBrush(QPalette::Base, Qt::transparent); page()->setPalette(pal); setAttribute(Qt::WA_OpaquePaintEvent, false); connect( frame, SIGNAL(loadFinished(bool)), this, SLOT(onItemChanged()) ); connect( frame, SIGNAL(contentsSizeChanged(QSize)), this, SLOT(onItemChanged()) ); connect( frame, SIGNAL(loadFinished(bool)), this, SLOT(onItemChanged()) ); connect( frame, SIGNAL(contentsSizeChanged(QSize)), this, SLOT(onItemChanged()) ); // Selecting text copies it to clipboard. connect( this, SIGNAL(selectionChanged()), SLOT(onSelectionChanged()) ); setHtml(html); updateSize(); updateItem(); }
EmbeddedWebView::EmbeddedWebView(QWidget *parent, QNetworkAccessManager *networkManager): QWebView(parent), m_scrollParent(0L), m_resizeInProgress(0) { // set to expanding, ie. "freely" - this is important so the widget will attempt to shrink below the sizehint! setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setFocusPolicy(Qt::StrongFocus); // not by the wheel setPage(new ErrorCheckingPage(this)); page()->setNetworkAccessManager(networkManager); QWebSettings *s = settings(); s->setAttribute(QWebSettings::JavascriptEnabled, false); s->setAttribute(QWebSettings::JavaEnabled, false); s->setAttribute(QWebSettings::PluginsEnabled, false); s->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); s->setAttribute(QWebSettings::JavaEnabled, false); s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, false); s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, false); s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, false); s->clearMemoryCaches(); page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(slotLinkClicked(QUrl))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(handlePageLoadFinished())); connect(page()->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(handlePageLoadFinished())); // Scrolling is implemented on upper layers page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); // Setup shortcuts for standard actions QAction *copyAction = page()->action(QWebPage::Copy); copyAction->setShortcut(tr("Ctrl+C")); addAction(copyAction); // Redmine#3, the QWebView uses black text color when rendering stuff on dark background QPalette palette = QApplication::palette(); if (palette.background().color().lightness() < 50) { QStyle *style = QStyleFactory::create(QLatin1String("windows")); Q_ASSERT(style); palette = style->standardPalette(); setPalette(palette); } setContextMenuPolicy(Qt::NoContextMenu); findScrollParent(); }
void TextBrowserHtmlWidget::setHtml(const QString &html, const QUrl &url) { m_widget->setHtml(html); m_url = url; if (!url.isEmpty()) { QString file = url.toLocalFile(); if (!file.isEmpty()) { QFileInfo info(file); QStringList paths = m_widget->searchPaths(); paths.append(info.path()); paths.removeDuplicates(); m_widget->setSearchPaths(paths); } } emit contentsSizeChanged(); emit loadFinished(true); }
int QWebFrame::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: javaScriptWindowObjectCleared(); break; case 1: provisionalLoad(); break; case 2: titleChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 3: urlChanged((*reinterpret_cast< const QUrl(*)>(_a[1]))); break; case 4: initialLayoutCompleted(); break; case 5: iconChanged(); break; case 6: contentsSizeChanged((*reinterpret_cast< const QSize(*)>(_a[1]))); break; case 7: loadStarted(); break; case 8: loadFinished((*reinterpret_cast< bool(*)>(_a[1]))); break; case 9: { QVariant _r = evaluateJavaScript((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QVariant*>(_a[0]) = _r; } break; case 10: print((*reinterpret_cast< QPrinter*(*)>(_a[1]))); break; default: ; } _id -= 11; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< qreal*>(_v) = textSizeMultiplier(); break; case 1: *reinterpret_cast< qreal*>(_v) = zoomFactor(); break; case 2: *reinterpret_cast< QString*>(_v) = title(); break; case 3: *reinterpret_cast< QUrl*>(_v) = url(); break; case 4: *reinterpret_cast< QUrl*>(_v) = requestedUrl(); break; case 5: *reinterpret_cast< QUrl*>(_v) = baseUrl(); break; case 6: *reinterpret_cast< QIcon*>(_v) = icon(); break; case 7: *reinterpret_cast< QSize*>(_v) = contentsSize(); break; case 8: *reinterpret_cast< QPoint*>(_v) = scrollPosition(); break; case 9: *reinterpret_cast< bool*>(_v) = hasFocus(); break; } _id -= 10; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setTextSizeMultiplier(*reinterpret_cast< qreal*>(_v)); break; case 1: setZoomFactor(*reinterpret_cast< qreal*>(_v)); break; case 3: setUrl(*reinterpret_cast< QUrl*>(_v)); break; case 8: setScrollPosition(*reinterpret_cast< QPoint*>(_v)); break; } _id -= 10; } else if (_c == QMetaObject::ResetProperty) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 10; } #endif // QT_NO_PROPERTIES return _id; }
ASSERT(page); if (resizesToContents) { // resizes to contents mode requires preferred contents size to be set if (!page->preferredContentsSize().isValid()) page->setPreferredContentsSize(QSize(960, 800)); #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) QObject::connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), q, SLOT(_q_contentsSizeChanged(const QSize&)), Qt::UniqueConnection); #else QObject::connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), q, SLOT(_q_contentsSizeChanged(const QSize&))); #endif } else { QObject::disconnect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), q, SLOT(_q_contentsSizeChanged(const QSize&))); } } void QGraphicsWebViewPrivate::_q_contentsSizeChanged(const QSize& size) { if (!resizesToContents) return; q->setGeometry(QRectF(q->geometry().topLeft(), size)); } void QGraphicsWebViewPrivate::_q_scaleChanged() { #if ENABLE(TILED_BACKING_STORE) updateTiledBackingStoreScale();