Exemple #1
0
void QtWebKitWebWidget::setUrl(const QUrl &url, bool typed)
{
	if (url.scheme() == QLatin1String("javascript"))
	{
		evaluateJavaScript(url.path());

		return;
	}

	if (!url.fragment().isEmpty() && url.matches(getUrl(), (QUrl::RemoveFragment | QUrl::StripTrailingSlash | QUrl::NormalizePathSegments)))
	{
		m_webView->page()->mainFrame()->scrollToAnchor(url.fragment());

		return;
	}

	m_isTyped = typed;

	if (url.isValid() && url.scheme().isEmpty() && !url.path().startsWith('/'))
	{
		QUrl httpUrl = url;
		httpUrl.setScheme(QLatin1String("http"));

		m_webView->setUrl(httpUrl);
	}
	else if (url.isValid() && (url.scheme().isEmpty() || url.scheme() == "file"))
	{
		QUrl localUrl = url;
		localUrl.setScheme(QLatin1String("file"));

		m_webView->setUrl(localUrl);
	}
	else
	{
		m_webView->setUrl(url);
	}

	notifyTitleChanged();
	notifyIconChanged();
}
Exemple #2
0
void Authorization::handleChangedUrl(QUrl const& newUrl)
{
    static QUrl const uAuthtorizationRedirectUrl(AUTHORIZATION_REDIRECT_URL);
    if(newUrl.matches(uAuthtorizationRedirectUrl,QUrl::RemoveFragment | QUrl::RemoveQuery))
    {
        if( newUrl.hasFragment() )
        {
            QUrlQuery query( newUrl.fragment() );

            QString accessToken = query.queryItemValue(QString("access_token"));
            QString userID = query.queryItemValue("user_id");
            emit success(accessToken,userID);
        }
        else
        {
            QUrlQuery query( newUrl.query() );
            QString error = query.queryItemValue(QString("error"));
            QString errorDescription = query.queryItemValue("eror_description");
            emit failure(error,errorDescription);
        }
        hide();
    }
}
Exemple #3
0
void ShowFoto::slotUpdateItemInfo()
{
    d->itemsNb = d->thumbBar->showfotoItemInfos().size();
    int index  = 0;
    QString text;

    if (d->itemsNb > 0)
    {
        index = 1;

        for (int i = 0; i < d->itemsNb; i++)
        {
            QUrl url = d->thumbBar->showfotoItemInfos().at(i).url;

            if (url.matches(d->thumbBar->currentUrl(), QUrl::None))
            {
                break;
            }

            ++index;
        }

        text = i18nc("<Image file name> (<Image number> of <Images in album>)",
                     "%1 (%2 of %3)", d->thumbBar->currentInfo().name,
                     index, d->itemsNb);

        setCaption(QDir::toNativeSeparators(d->thumbBar->currentUrl().adjusted(QUrl::RemoveFilename).toLocalFile()));
    }
    else
    {
        text = QLatin1String("");
        setCaption(QLatin1String(""));
    }

    m_nameLabel->setText(text);
    toggleNavigation(index);
}