コード例 #1
0
QPoint WebkitPixelStreamer::getPointerPosition(const deflect::Event &dcEvent) const
{
    QWebPage* page = webView_.page();

    int x = dcEvent.mouseX * page->viewportSize().width();
    int y = dcEvent.mouseY * page->viewportSize().height();

    x = std::max(0, std::min(x, page->viewportSize().width()-1));
    y = std::max(0, std::min(y, page->viewportSize().height()-1));

    return QPoint(x, y);
}
コード例 #2
0
ファイル: pagescreen.cpp プロジェクト: Alternate20/qupzilla
void PageScreen::createThumbnail()
{
    QWebPage* page = m_view->page();

    const int heightLimit = 20000;
    const QPoint originalScrollPosition = page->mainFrame()->scrollPosition();
    const QSize &originalSize = page->viewportSize();
    const QSize &frameSize = page->mainFrame()->contentsSize();
    const int verticalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Vertical).width();
    const int horizontalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Horizontal).height();

    int yPosition = 0;
    bool canScroll = frameSize.height() > heightLimit;

    // We will split rendering page into smaller parts to avoid infinite loops
    // or crashes.

    do {
        int remainingHeight = frameSize.height() - yPosition;
        if (remainingHeight <= 0) {
            break;
        }

        QSize size(frameSize.width(),
                   remainingHeight > heightLimit ? heightLimit : remainingHeight);
        page->setViewportSize(size);
        page->mainFrame()->scroll(0, qMax(0, yPosition - horizontalScrollbarSize));

        QImage image(page->viewportSize().width() - verticalScrollbarSize,
                     page->viewportSize().height() - horizontalScrollbarSize,
                     QImage::Format_ARGB32_Premultiplied);
        QPainter painter(&image);
        page->mainFrame()->render(&painter);
        painter.end();

        m_pageImages.append(image);

        canScroll = remainingHeight > heightLimit;
        yPosition += size.height();
    }
    while (canScroll);

    page->setViewportSize(originalSize);
    page->mainFrame()->setScrollBarValue(Qt::Vertical, originalScrollPosition.y());
    page->mainFrame()->setScrollBarValue(Qt::Horizontal, originalScrollPosition.x());

    m_imageScaling = new QFutureWatcher<QImage>(this);
    m_imageScaling->setFuture(QtConcurrent::run(this, &PageScreen::scaleImage));
    connect(m_imageScaling, SIGNAL(finished()), SLOT(showImage()));
}
コード例 #3
0
ファイル: pagescreen.cpp プロジェクト: bubapl/QupZilla
void PageScreen::createPixmap()
{
    QWebPage* page = m_view->page();
    QSize originalSize = page->viewportSize();
    page->setViewportSize(page->mainFrame()->contentsSize());

    QImage image(page->viewportSize(), QImage::Format_ARGB32);
    QPainter painter(&image);
    page->mainFrame()->render(&painter);
    painter.end();

    m_pagePixmap = QPixmap::fromImage(image);

    page->setViewportSize(originalSize);
}
コード例 #4
0
ファイル: qwebpageproto.cpp プロジェクト: dwatson78/qt-client
QSize QWebPageProto::viewportSize() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->viewportSize();
  return QSize();
}
コード例 #5
0
void WebkitPixelStreamer::update()
{
    QMutexLocker locker(&mutex_);

    QWebPage* page = webView_.page();
    if( !page->viewportSize().isEmpty())
    {
        if (image_.size() != page->viewportSize())
            image_ = QImage( page->viewportSize(), QImage::Format_ARGB32 );

        QPainter painter( &image_ );
        page->mainFrame()->render( &painter );
        painter.end();

        emit imageUpdated(image_);
    }
}
コード例 #6
0
ファイル: pagescreen.cpp プロジェクト: Mikino89/QupZilla
void PageScreen::createThumbnail()
{
    QWebPage* page = m_view->page();
    QSize originalSize = page->viewportSize();
    page->setViewportSize(page->mainFrame()->contentsSize());

    m_pageImage = QImage(page->viewportSize(), QImage::Format_ARGB32_Premultiplied);
    QPainter painter(&m_pageImage);
    page->mainFrame()->render(&painter);
    painter.end();

    m_verticalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Vertical).width();
    m_horizontalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Horizontal).height();

    page->setViewportSize(originalSize);

    m_imageScaling = new QFutureWatcher<QImage>(this);
    connect(m_imageScaling, SIGNAL(finished()), SLOT(showImage()));

    m_imageScaling->setFuture(QtConcurrent::run(this, &PageScreen::scaleImage));
}
コード例 #7
0
void Viewer::renderPageTo(QImage* image)
{
    QWebPage *page   = webView->page();
    QWebFrame *frame = page->currentFrame();
    QSize origSize   = page->viewportSize();

    page->setViewportSize(frame->contentsSize());

    QPainter painter(image);
    frame->render(&painter);

    painter.end();
    page->setViewportSize(origSize);
}