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 {
Пример #2
0
void BrowserApi::setWebView(QWebView *view)
{
    QWebPage *page = view->page();
    m_frame = page->mainFrame();

    attachObject();
    connect(m_frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(attachObject()));
}
Пример #3
0
void SourceViewer::loadingFinished()
{
    QWebPage page;
    QByteArray response = m_reply->readAll();
    page.mainFrame()->setContent(response, QString(), m_request->url());

    /* If original request was POST or a different problem is there, fall
       back to modified version of QWebFrame.toHtml() */
    if (page.mainFrame()->toHtml() != *m_source)
        m_edit->setPlainText(*m_source);
    else
        m_edit->setPlainText(QLatin1String(response));

    m_reply->close();
    delete m_request;
    delete m_source;
}
Page* ChromeClientQt::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features)
{
    QWebPage *newPage = m_webPage->createWindow(features.dialog ? QWebPage::WebModalDialog : QWebPage::WebBrowserWindow);
    if (!newPage)
        return 0;
    newPage->mainFrame()->load(request.resourceRequest().url());
    return newPage->d->page;
}
Page* ChromeClientQt::createModalDialog(Frame*, const FrameLoadRequest& request)
{
    QWebPage *newPage = m_webPage->createWindow(QWebPage::WebModalDialog);
    if (!newPage)
        return 0;
    newPage->mainFrame()->load(request.resourceRequest().url());
    return newPage->d->page;
}
Пример #6
0
void HTMLDocument::viewModeChanged(int tabNumber)
{
    switch (tabNumber)
    {
        case 0:
        if (this->currentMode == Code)
        {
            this->code = this->editor->toPlainText();
            this->designArea->page()->mainFrame()->setHtml(this->editor->toPlainText());
        }
        else if (this->currentMode == Preview)
        {
            this->designArea->setHtml(this->code);
        }
        this->currentMode = Design;
        break;
        case 1: //going to code mode
        if (this->currentMode ==  Design)
        {
            QWebPage *page = this->designArea->page();
            this->code = page->mainFrame()->toHtml();
            this->editor->setPlainText(this->code);
            this->editor->setFocus();
        }
        else if (this->currentMode == Preview)
        {
            this->editor->setPlainText(this->code);
        }
        this->currentMode = Code;
        break;
        case 2:
        if (this->currentMode == Design)
        {
            QWebPage *page = this->designArea->page();
            this->code = page->mainFrame()->toHtml();
        }
        else if (this->currentMode == Code)
        {
            this->code = this->editor->toPlainText();
        }
        this->currentMode = Preview;
        this->previewArea->setHtml(this->code);
        break;
    }

}
Пример #7
0
void WebView::openActionUrlInNewWindow()
{
    if (QAction *action = qobject_cast<QAction*>(sender())) {
        QWebPage *page = tabWidget()->getView(TabWidget::NewWindow, this)->page();
        QNetworkRequest request(action->data().toUrl());
        request.setRawHeader("Referer", url().toEncoded());
        page->mainFrame()->load(request);
    }
}
Пример #8
0
void
message_view::prepend_body_fragment(const QString& fragment)
{
  QWebPage* page = m_bodyv->page();
  page->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
  QString js = QString("try {var b=document.getElementsByTagName('body')[0]; var p=document.createElement('div'); p.innerHTML=\"%1\"; b.insertBefore(p, b.firstChild); 1;} catch(e) { e; }").arg(escape_js_string(fragment));
  QVariant v = page->mainFrame()->evaluateJavaScript(js);
  page->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
}
Пример #9
0
// --- DIAGNOSE LOAD ---
// Verify that the page loaded successfully, else present error message.
// If successful, set other data parts and handle filters.
void MainWindow::diagnoseLoad(bool ok) {
    setReloadButton();
    if (!ok) {
        //QMessageBox::critical(this, tr("Error"), tr("Failed to load the URL")); // FIXME: triggers crash with favicon path customized due to QtWebkit bug!
        // Don't return to the event loop.
    }
    else {
        //QWidget* tab = tabWidget->currentWidget
        tabWidget->setTabText(tabWidget->currentIndex(), wv->title());
        tabWidget->setTabIcon(tabWidget->currentIndex(), wv->icon());
        addressBar->setText(wv->url().toString());
        QString title = wv->title();
        if (title.size() > 200) {
            title.resize(200);
        }

        setWindowTitle(title + " - WildFox");

        // check the page URL against the filters
        if (extFilters.size() < 1) {
            return;
        }

        QWebPage* page = (QWebPage*) sender();
        if (page == 0) {
            return;
        }
        QWebFrame* frame = page->mainFrame();
        if (frame == 0) {
            return;
        }
        QString url = frame->url().path();
        QStringList urlbit = url.split("://");
        QDir extension;
        extension.setPath(manifest.fileName());
        if (urlbit.size() > 1) {
            QString scheme = urlbit[0];
            QStringList bits = urlbit[1].split(".");
            for (int i = 0; i < extFilters.size(); ++i) {
                if (extFilters[i].scheme != scheme) {
                    continue;
                }
                for (int j = 0; extFilters[i].segments.size(); ++j) {
                    if (extFilters[i].segments[j] != bits[j] && extFilters[i].segments[j] != "*") {
                        continue;
                    }
                }

                // matched filter, inject associated scripts into the content.
                QWebElement root = frame->documentElement();
                QWebElement head = root.findFirst("head");
                head.appendOutside("<script type=\"text/javascript\" src=\"" +
                                   extension.absolutePath() + "\" />");
            }
        }
    }
}
Пример #10
0
WebCore::Frame* FrameLoaderClientQt::dispatchCreatePage()
{
    if (!m_webFrame)
        return 0;
    QWebPage *newPage = m_webFrame->page()->createWindow(QWebPage::WebBrowserWindow);
    if (!newPage)
        return 0;
    return newPage->mainFrame()->d->frame;
}
Пример #11
0
void Widget::onLoad()
{
	QWebPage *page = qobject_cast<QWebPage*>(sender());
	QElapsedTimer timer;
	timer.start();
	QStringList scripts = contentScripts();
	qDebug() << timer.elapsed(); timer.start();
	foreach (const QString &script, scripts) {
		page->mainFrame()->evaluateJavaScript(script);
	};
Пример #12
0
int main(int argc, char *argv[])
{
	struct sigaction action;
	memset(&action, 0, sizeof(struct sigaction));
	action.sa_handler = term;
	sigaction(SIGTERM, &action, NULL);

	int fps = atoi(argv[4]);
	int width = atoi(argv[2]);
	int height = atoi(argv[3]);

	init_shared_data(atoi(argv[2]), atoi(argv[3]));

	QApplication app(argc, argv);
	QWebPage page;

	QPalette palette = page.palette();
	palette.setBrush(QPalette::Base, Qt::transparent);
	page.setPalette(palette);

	page.mainFrame()->setUrl(QUrl::fromUserInput(argv[1]));
	page.setViewportSize(QSize(width, height));
	page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
	page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);

	pthread_mutex_lock(&data->mutex);
	QImage image(&data->data, width, height, QImage::Format_RGBA8888);
	QPainter painter(&image);
	pthread_mutex_unlock(&data->mutex);

	while (!done) {
		app.processEvents();

		pthread_mutex_lock(&data->mutex);
		image.fill(0);
		page.mainFrame()->render(&painter, QWebFrame::ContentsLayer);
		pthread_mutex_unlock(&data->mutex);

		usleep(1000000 / fps);
	}

	return 0;
}
Пример #13
0
void LyricsManiaAPI::onGetLyricPageResult()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(QObject::sender());

    bool found = false;
    Lyric* lyric = 0;

    if (reply->error() != QNetworkReply::NoError) {
        qCritical() << "Cannot fetch lyric";
    } else {
        QWebPage page;
        page.settings()->setAttribute(QWebSettings::AutoLoadImages, false);
        page.settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
        page.mainFrame()->setHtml(reply->readAll());

        QWebElement lyricbox = page.mainFrame()->findFirstElement("div[class=lyrics-body]");

        if (lyricbox.isNull()) {
            qCritical() << "Cannot find lyric text in HTML page";
        } else {
            // Remove the video div
            lyricbox.findFirst(QStringLiteral("div")).removeFromDocument();
            // Remove the song title
            lyricbox.findFirst(QStringLiteral("strong")).removeFromDocument();

            lyric = lyrics.take(reply);

            if (!lyric) {
                qCritical() << "Got an invalid lyric object!";
            } else {
                lyric->setText(lyricbox.toPlainText());

                found = true;
            }
        }
    }

    qDebug() << "Lyric found:" << found;
    Q_EMIT lyricFetched(lyric, found);

    reply->deleteLater();
}
Пример #14
0
void
message_view::display_commands()
{
  QWebPage* page = m_bodyv->page();
  page->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
  QString s = command_links();
  s.replace("'", "\\'");
  QString js = QString("try {var p=document.getElementById(\"manitou-commands\"); p.innerHTML='%1'; 1;} catch(e) { e; }").arg(s);
  QVariant v = page->mainFrame()->evaluateJavaScript(js);
  page->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
}
Пример #15
0
    void Editor::forceRender(QSize size)
    {
        QWebPage *page = m_webView->page();

        page->setViewportSize(size);

        QImage image(size.width(), size.height(), QImage::Format_Mono);
        QPainter painter(&image);

        page->mainFrame()->render(&painter);
    }
void WebViewLoaderLoop::onPageLoaded()
{
	disconnect(m_pages.first().data(), 0, this, 0);
	m_pages.removeFirst();
	m_htmls.removeFirst();
	if (!m_pages.isEmpty()) {
		QWebPage *page = m_pages.first().data();
		QString html = m_htmls.first();
		page->mainFrame()->setHtml(html);
	}
}
Пример #17
0
void QGraphicsWebViewPrivate::updateResizesToContentsForPage()
{
    ASSERT(page);
    pageClient()->viewResizesToContents = resizesToContents;
    if (resizesToContents) {
        // resizes to contents mode requires preferred contents size to be set
        if (!page->preferredContentsSize().isValid())
            page->setPreferredContentsSize(QSize(960, 800));

        QObject::connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)),
            q, SLOT(_q_contentsSizeChanged(const QSize&)), Qt::UniqueConnection);
    } else {
Пример #18
0
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));
}
bool HtmlBookmarksImporter::import(const QString &path)
{
#ifdef OTTER_ENABLE_QTWEBKIT
	QFile file(getSuggestedPath(path));

	if (!file.open(QIODevice::ReadOnly))
	{
		return false;
	}

	if (m_optionsWidget)
	{
		if (m_optionsWidget->hasToRemoveExisting())
		{
			removeAllBookmarks();

			if (m_optionsWidget->isImportingIntoSubfolder())
			{
				setImportFolder(BookmarksManager::addBookmark(BookmarksModel::FolderBookmark, QUrl(), m_optionsWidget->getSubfolderName()));
			}
		}
		else
		{
			setAllowDuplicates(m_optionsWidget->allowDuplicates());
			setImportFolder(m_optionsWidget->getTargetFolder());
		}
	}

	QWebPage page;
	page.mainFrame()->setHtml(file.readAll());

	processElement(page.mainFrame()->documentElement());

	file.close();

	return true;
#else
	return false;
#endif
}
Пример #20
0
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()));
}
Пример #21
0
Page* ChromeClientQt::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features)
{
    QWebPage* newPage = m_webPage->createWindow(features.dialog ? QWebPage::WebModalDialog : QWebPage::WebBrowserWindow);
    if (!newPage)
        return 0;

    // A call to QWebPage::mainFrame() implicitly creates the main frame.
    // Make sure it exists, as WebCore expects it when returning from this call.
    QWebFrame* mainFrame = newPage->mainFrame();

    if (!request.isEmpty())
        mainFrame->load(request.resourceRequest().url());
    return newPage->d->page;
}
void CommandManager::setWebView( QWebView *view, BrowserView *bview  )
{
    QWebPage *page = view->page();
    frame = page->mainFrame();
    m_bview = bview;
    m_console = new DebugConsole(view, bview);
    m_notification = new Notification();
    m_geolocation = new Geolocation(this);
    m_orientation = new Orientation(this);
    m_acceleration = new Acceleration(this);
    //m_camera = new Camera(this);

    attachObjects();
    connect( frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(attachObjects()) );
}
Пример #23
0
QString ForumProbe::getTitle(QString &html) {
    QString title;
#ifndef NO_WEBKITWIDGETS
    QWebPage *page = new QWebPage();
    QWebFrame *frame = page->mainFrame();
    frame->setHtml(html);
    title = frame->title();
    page->deleteLater();
#else
    int titleBegin = html.indexOf("<title>");
    if(titleBegin > 0) {
        int titleEnd = html.indexOf("</", titleBegin);
        title = html.mid(titleBegin + 7, titleEnd - titleBegin - 7);
    }
#endif
    return title;
}
void tst_QWebPluginDatabase::installedPlugins()
{
    QWebPage page;
    page.settings()->setAttribute(QWebSettings::PluginsEnabled, true);
    QWebFrame* frame = page.mainFrame();

    QVariantMap jsPluginsMap = frame->evaluateJavaScript("window.navigator.plugins").toMap();
    QList<QWebPluginInfo> plugins = QWebSettings::pluginDatabase()->plugins();
    QCOMPARE(plugins, QWebSettings::pluginDatabase()->plugins());

    int length = jsPluginsMap["length"].toInt();
    QCOMPARE(length, plugins.count());

    for (int i = 0; i < length; ++i) {
        QWebPluginInfo plugin = plugins.at(i);

        QVariantMap jsPlugin = frame->evaluateJavaScript(QString("window.navigator.plugins[%1]").arg(i)).toMap();
        QString name = jsPlugin["name"].toString();
        QString description = jsPlugin["description"].toString();
        QString fileName = jsPlugin["filename"].toString();

        QCOMPARE(plugin.name(), name);
        QCOMPARE(plugin.description(), description);
        QCOMPARE(QFileInfo(plugin.path()).fileName(), fileName);

        QList<MimeType> mimeTypes;
        int mimeTypesCount = jsPlugin["length"].toInt();

        for (int j = 0; j < mimeTypesCount; ++j) {
            QVariantMap jsMimeType = frame->evaluateJavaScript(QString("window.navigator.plugins[%1][%2]").arg(i).arg(j)).toMap();

            MimeType mimeType;
            mimeType.name = jsMimeType["type"].toString();
            mimeType.description = jsMimeType["description"].toString();
            mimeType.fileExtensions = jsMimeType["suffixes"].toString().split(',', QString::SkipEmptyParts);

            mimeTypes.append(mimeType);
            QVERIFY(plugin.supportsMimeType(mimeType.name));
        }

        QCOMPARE(plugin.mimeTypes(), mimeTypes);

        QVERIFY(!plugin.isNull());
        QVERIFY(plugin.isEnabled());
    }
}
Пример #25
0
//----------------------------------------------------------------
void Collection::import_paper()
{
  //we should not try to add a paper if no current library;
  if ( !_current_library )
    {
      QMessageBox::about(this, tr("Error"),
			 tr("Error: you have no Libraries defined\n"
			    "you cannot create a new paper"));
      return;
    }
  QWebPage * page = _rss_box->page();
  
  QWebFrame * frame = page->mainFrame();

  //now create a new paper and parse out the values we want.
  _parser->setData(frame->toHtml());
  _stdout << "Collection::import_paper title" << _parser->getTitle() << endl;
  _stdout << "Collection::import_paper authors" << _parser->getAuthors() << endl;

  Paper * paper = new Paper();
  paper->set_title(_parser->getTitle());
  paper->set_author(_parser->getAuthors());
  paper->set_abstract(_parser->getAbstract());
  paper->set_date(_parser->getDate());
  paper->set_arxiv_number(_parser->getNumber());

  //Download the damn thing
  _manager = new QNetworkAccessManager(this);
  _manager->get(QNetworkRequest(_parser->getDownloadLocation()));
  connect(_manager, SIGNAL(finished(QNetworkReply*)),
  	  this, SLOT(download_finished(QNetworkReply*)));

  QDir directory(_current_library->get_library_directory()+"/"+_parser->getPaperName());

  _stdout << "Collection::import_paper " <<  directory.absolutePath() << endl; 

  paper->set_file_name(directory.absolutePath());
  
  //add the entry to the library
  _current_library->add_entry(paper);

  //add the entry to the list
  add_paper_to_list(*paper,_paper_list);
  update_library_list();

}
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_);
    }
}
Пример #27
0
void WebView::applyEncoding()
{
	if (m_encoding_in_progress)
		return;

	if (webPage() && webPage()->mainWindow())
	{
		QString enc = webPage()->mainWindow()->m_currentEncoding;
		if (enc.isEmpty())
			return;

		if (enc == m_current_encoding && m_current_encoding_url == url() )
			return;

		QWebPage *page = webPage();
		if (!page)
			return;

		QWebFrame *mainframe = page->mainFrame();
		if (!mainframe)
			return;

		QString html = mainframe->toHtml();

		QTextCodec *codec = QTextCodec::codecForName( enc.toAscii() );
		if (!codec)
			return;

		QTextDecoder *decoder = codec->makeDecoder();
		if (!decoder)
			return;

		m_encoding_in_progress = true;
		m_current_encoding = enc;
		m_current_encoding_url = url();
		QString output = decoder->toUnicode(html.toAscii());
		mainframe->setHtml(output, mainframe->url());

		QList<QWebFrame *> children = mainframe->childFrames();
		foreach(QWebFrame *frame, children)
		{
			html = frame->toHtml();
			output = decoder->toUnicode(html.toAscii());
			frame->setHtml(output, frame->url());
		}
Пример #28
0
void RideWindow::loadRide()
{
    QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptEnabled, true);
    // uncommit these two lines to get the QWebInspector working.
    //    QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
    //    QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);

    QWebPage *page = view->page();
    QWebFrame *frame = page->mainFrame();

    // Signal is emitted before frame loads any web content:
    QObject::connect(frame, SIGNAL(javaScriptWindowObjectCleared()),
                            this, SLOT(addJSObjects()));
    view->setPage(page);
    // used for testing...
    RiderBridge* tr = new RealtimeRider(context);
    tr->setRide(ride);
    rider = tr;
    addJSObjects();
}
Пример #29
0
ShibbolethWebView::ShibbolethWebView(AccountPtr account, QWidget* parent)
    : QWebView(parent)
    , _account(account)
    , _accepted(false)
    , _cursorOverriden(false)
{
    // no minimize
    setWindowFlags(Qt::Dialog);
    setAttribute(Qt::WA_DeleteOnClose);

    QWebPage* page = new QWebPage(this);
    connect(page, SIGNAL(loadStarted()),
            this, SLOT(slotLoadStarted()));
    connect(page, SIGNAL(loadFinished(bool)),
            this, SLOT(slotLoadFinished(bool)));

    // Make sure to accept the same SSL certificate issues as the regular QNAM we use for syncing
    QObject::connect(page->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
            _account.data(), SLOT(slotHandleSslErrors(QNetworkReply*,QList<QSslError>)));

    // The Account keeps ownership of the cookie jar, it must outlive this webview.
    account->lendCookieJarTo(page->networkAccessManager());
    connect(page->networkAccessManager()->cookieJar(),
            SIGNAL(newCookiesForUrl (QList<QNetworkCookie>, QUrl)),
            this, SLOT(onNewCookiesForUrl (QList<QNetworkCookie>, QUrl)));
    page->mainFrame()->load(account->url());
    this->setPage(page);
    setWindowTitle(tr("%1 - Authenticate").arg(Theme::instance()->appNameGUI()));

    // If we have a valid cookie, it's most likely expired. We can use this as
    // as a criteria to tell the user why the browser window pops up
    QNetworkCookie shibCookie = ShibbolethCredentials::findShibCookie(_account.data(), ShibbolethCredentials::accountCookies(_account.data()));
    if (shibCookie != QNetworkCookie()) {
        Logger::instance()->postOptionalGuiLog(tr("Reauthentication required"), tr("Your session has expired. You need to re-login to continue to use the client."));
    }

    ConfigFile config;
    QSettings settings(config.configFile());
    resize(900, 700); // only effective the first time, later overridden by restoreGeometry
    restoreGeometry(settings.value(ShibbolethWebViewGeometryC).toByteArray());
}
Пример #30
0
bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, NavigationType type)
{
    QObject* view = parent();

    QVariant value = view->property("keyboardModifiers");

    if (!value.isNull()) {
        Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers(value.toInt());

        if (modifiers & Qt::ShiftModifier) {
            QWebPage* page = createWindow(QWebPage::WebBrowserWindow);
            page->mainFrame()->load(request);
            return false;
        }

        if (modifiers & Qt::AltModifier) {
            openUrlInDefaultBrowser(request.url());
            return false;
        }
    }

    return QWebPage::acceptNavigationRequest(frame, request, type);
}