コード例 #1
0
ファイル: UrlLoader.cpp プロジェクト: Moondee/Artemis
UrlLoader::UrlLoader(BrowserWindow* browserWindow, const QString& inputFileName, int timeoutSeconds, int extraTimeSeconds)
    : m_browserWindow(browserWindow)
    , m_stdOut(stdout)
    , m_loaded(0)
    , m_numFramesLoading(0)
{
    m_checkIfFinishedTimer.setInterval(200);
    m_checkIfFinishedTimer.setSingleShot(true);
    connect(&m_checkIfFinishedTimer, SIGNAL(timeout()), this, SLOT(checkIfFinished()));
    // loadStarted and loadFinished on QWebPage is emitted for each frame/sub-frame
    connect(m_browserWindow->webView(), SIGNAL(loadStarted()), this, SLOT(frameLoadStarted()));
    connect(m_browserWindow->webView(), SIGNAL(loadSucceeded()), this, SLOT(frameLoadFinished()));
    connect(m_browserWindow->webView(), SIGNAL(loadFailed(QDesktopWebView::ErrorType, int, const QUrl&)), this, SLOT(frameLoadFinished()));

    if (timeoutSeconds) {
        m_timeoutTimer.setInterval(timeoutSeconds * 1000);
        m_timeoutTimer.setSingleShot(true);
        connect(m_browserWindow->webView(), SIGNAL(loadStarted()), &m_timeoutTimer, SLOT(start()));
        connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(loadNext()));
    }
    if (extraTimeSeconds) {
        m_extraTimeTimer.setInterval(extraTimeSeconds * 1000);
        m_extraTimeTimer.setSingleShot(true);
        connect(this, SIGNAL(pageLoadFinished()), &m_extraTimeTimer, SLOT(start()));
        connect(&m_extraTimeTimer, SIGNAL(timeout()), this, SLOT(loadNext()));
    } else
        connect(this, SIGNAL(pageLoadFinished()), this, SLOT(loadNext()));
    loadUrlList(inputFileName);
}
コード例 #2
0
void LoadSpy::onLoadingChanged(QWebLoadRequest* loadRequest)
{
    if (loadRequest->status() == QQuickWebView::LoadSucceededStatus)
        emit loadSucceeded();
    else if (loadRequest->status() == QQuickWebView::LoadFailedStatus)
        emit loadFailed();
}
コード例 #3
0
WebViewAbstraction::WebViewAbstraction()
    : m_touchWebViewWindow(new QTouchWebView)
    , m_desktopWebViewWindow(new QDesktopWebView)
{
    QDesktopWidget* const desktopWidget = QApplication::desktop();
    const QRect mainScreenGeometry = desktopWidget->availableGeometry();

    QRect screenHalf(mainScreenGeometry.topLeft(), QSize(mainScreenGeometry.width() / 2, mainScreenGeometry.height()));
    m_touchWebViewWindow.setGeometry(screenHalf);
    m_touchWebViewWindow.setWindowTitle(QLatin1String("TouchWebView"));
    connect(touchWebView()->page(), SIGNAL(loadStarted()), this, SLOT(touchViewLoadStarted()));
    connect(touchWebView()->page(), SIGNAL(loadSucceeded()), this, SLOT(touchViewLoadSucceeded()));
    connect(touchWebView()->page(), SIGNAL(loadFailed(QTouchWebPage::ErrorType, int, const QUrl&)), this, SLOT(touchViewLoadFailed(QTouchWebPage::ErrorType, int, const QUrl&)));
    connect(touchWebView()->page(), SIGNAL(loadProgressChanged(int)), this, SLOT(touchViewLoadProgressChanged(int)));

    screenHalf.moveLeft(screenHalf.right());
    m_desktopWebViewWindow.setGeometry(screenHalf);
    m_desktopWebViewWindow.setWindowTitle(QLatin1String("DesktopWebView"));
    connect(desktopWebView(), SIGNAL(loadStarted()), this, SLOT(desktopViewLoadStarted()));
    connect(desktopWebView(), SIGNAL(loadSucceeded()), this, SLOT(desktopViewLoadSucceeded()));
    connect(desktopWebView(), SIGNAL(loadFailed(QDesktopWebView::ErrorType, int, const QUrl&)), this, SLOT(desktopViewLoadFailed(QDesktopWebView::ErrorType, int, const QUrl&)));
    connect(desktopWebView(), SIGNAL(loadProgressChanged(int)), this, SLOT(desktopViewLoadProgressChanged(int)));
}
コード例 #4
0
bool waitForLoadSucceeded(QQuickWebView* webView, int timeout)
{
    QEventLoop loop;
    LoadSpy loadSpy(webView);
    QObject::connect(&loadSpy, SIGNAL(loadSucceeded()), &loop, SLOT(quit()));
    QTimer timer;
    QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
    if (timeout > 0) {
        QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
        timer.setSingleShot(true);
        timer.start(timeout);
    }
    loop.exec();
    return timeoutSpy.isEmpty();
}
コード例 #5
0
void WebViewAbstraction::desktopViewLoadSucceeded()
{
    m_desktopViewSignalsCounter[SIGNAL(loadSucceeded())]++;
    if (m_touchViewSignalsCounter[SIGNAL(loadSucceeded())] == m_desktopViewSignalsCounter[SIGNAL(loadSucceeded())])
        emit loadSucceeded();
}