/*! * \author Anders Fernström * \date 2006-02-10 */ void CellDocument::hoverOverUrl( const QUrl &link ) { QString filelink = link.path(); if( !link.fragment().isEmpty() ) filelink += QString("#") + link.fragment(); if( !filelink.isEmpty() && !link.path().isEmpty() ) { if( filename_.isEmpty() || filename_.isEmpty() ) { // replace '\' with '/' in the link path filelink.replace( "\\", "/" ); QDir dir; filelink = dir.absolutePath() + "/" + filelink; } else { // replace '\' with '/' in the link path filelink.replace( "\\", "/" ); filelink = QFileInfo(filename_).absolutePath() + "/" + filelink; } } emit hoverOverFile( filelink ); }
void DocumentBrowser::linkClicked(QUrl url) { if (url.path().isEmpty() && !url.fragment().isEmpty()) { m_liteApp->mainWindow()->statusBar()->clearMessage(); //m_textBrowser->scrollToAnchor(url.fragment()); this->scrollToAnchor(url.fragment()); return; } emit requestUrl(url); }
Future<void> GitCloneStep::perform(const ActionContext &ctxt) { return async([this, ctxt](Notifier notifier) { QUrl url = m_url; url.setFragment(QString()); Git::GitRepo *repo = notifier.await(Git::GitRepo::clone(ctxt.get<InstallContextItem>().buildDir, url)); if (!url.fragment().isEmpty()) { notifier.await(repo->checkout(url.fragment())); } }); }
void TextBrowserHelpViewer::setSource(const QUrl &url) { if (launchWithExternalApp(url)) return; slotLoadStarted(); m_textBrowser->setSource(url); QTimer::singleShot(0, this, [this, url]() { if (!url.fragment().isEmpty()) m_textBrowser->scrollToAnchor(url.fragment()); if (QScrollBar *hScrollBar = m_textBrowser->horizontalScrollBar()) hScrollBar->setValue(0); slotLoadFinished(); }); }
void VKAuth::slotLinkChanged(QUrl url) { if ("/blank.html" == url.path()) { QRegExp regexp("access_token=([^,]+)&expires_in=([^,]+)&user_id=([^,]+)"); QString str= url.fragment(); if( -1 != regexp.indexIn(str) ){ QString access_token = regexp.cap(1); QString expires_in = regexp.cap(2); QString user_id = regexp.cap(3); QUrl request(QString("https://api.vk.com/method/%1.xml?").arg("friends.get")); request.addQueryItem("user_id", user_id); request.addQueryItem("fields", "online"); request.addQueryItem("v", "5.2"); request.addQueryItem("access_token", access_token); QNetworkAccessManager *manager = new QNetworkAccessManager(this); m_http = manager->get(QNetworkRequest(request)); QObject::connect(m_http, SIGNAL(finished()), this, SLOT(slotDone())); } } else if("/api/login_failure.html" == url.path()){ emit unsuccess(); } }
void VKApi::loginUrlChanged(const QUrl& url) { qDebug() << "login url filename: \n" << url.fileName() << "\n"; if (url.fileName() == "blank.html") { QUrlQuery q(url.fragment()); accessToken = q.queryItemValue("access_token"); qDebug() << "got access token: " << accessToken << "\n"; QMap<QString, QString> params; method("users.get", params, [this]( const QJsonDocument* json, QNetworkReply::NetworkError) { loginView->close(); loginView = 0; if (json) { auto obj = json->object(); qDebug() << obj.keys().join(","); user->_name = obj["first_name"].toString() + " " + obj["last_name"].toString(); user->_uid = QString::number( obj["uid"].toInt() ); } else { this->logout(); this->login(); } emit loginStatusChanged(); }); loginView->setVisible(false); } }
QString QUrlProto::fragment() const { QUrl *item = qscriptvalue_cast<QUrl*>(thisObject()); if (item) return item->fragment(); return QString(); }
void DocumentBrowser::setUrlHtml(const QUrl &url,const QString &data) { const HistoryEntry &historyEntry = createHistoryEntry(); if (!data.isEmpty()) { m_htmlWidget->setHtml(data,url); } m_url = url; if (!url.fragment().isEmpty()) { m_htmlWidget->scrollToAnchor(url.fragment()); } else { m_htmlWidget->setScrollBarValue(Qt::Horizontal,0); m_htmlWidget->setScrollBarValue(Qt::Vertical,0); } m_urlComboBox->blockSignals(true); int index = m_urlComboBox->findText(m_url.toString()); if (index == -1) { m_urlComboBox->addItem(m_url.toString()); index = m_urlComboBox->count()-1; } m_urlComboBox->setCurrentIndex(index); m_urlComboBox->blockSignals(false); if (!m_backwardStack.isEmpty() && url == m_backwardStack.top().url) { // restoreHistoryEntry(m_backwardStack.top()); return; } if (!m_backwardStack.isEmpty()) { m_backwardStack.top() = historyEntry; } HistoryEntry entry; entry.url = url; m_backwardStack.push(entry); emit backwardAvailable(m_backwardStack.count() > 1); if (!m_forwardStack.isEmpty() && url == m_forwardStack.top().url) { m_forwardStack.pop(); emit forwardAvailable(m_forwardStack.count() > 0); } else { m_forwardStack.clear(); emit forwardAvailable(false); } }
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(); }
void LoginDialog::urlChanged(const QUrl &url) { qDebug() << "[LoginDialog::urlChanged]" << url.toString(); QSettings settings; QStringList list = url.fragment().split("="); if (list[0] == "access_token") { settings.setValue("access_token", list[1]); QDialog::accept(); emit loggedIn(); } }
QImage SvgElementProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize) { // Resolve URL QUrl url = QUrl(id); if (url.isRelative() && !mBaseUrl.isEmpty()) url = mBaseUrl.resolved(url); if (!url.isValid()) return placeholder(QString("Invalid URL\nBase: %1\nInput: %2").arg(mBaseUrl.toString()).arg(id), requestedSize); // Make a filename from the given URL QString imagepath = QQmlFile::urlToLocalFileOrQrc(url); // Fragment is used to specify SVG element QString elementId = url.fragment(); // Load image QSvgRenderer renderer; if (!renderer.load(imagepath)) { qWarning() << "Unable to load image:" << imagepath; return placeholder(QStringLiteral("Unable to load image:\n") + imagepath, requestedSize); } // Check whether requested element exists if (!elementId.isEmpty() && !renderer.elementExists(elementId)) return placeholder(QStringLiteral("Unable to find element:\n") + elementId + "\nin image:\n" + imagepath, requestedSize); // Get image or element size QSize itemSize = elementId.isEmpty() ? renderer.defaultSize() : renderer.boundsOnElement(elementId).size().toSize(); if (size) *size = itemSize; // Create image QImage image(requestedSize.width() > 0 ? requestedSize.width() : itemSize.width(), requestedSize.height() > 0 ? requestedSize.height() : itemSize.height(), QImage::Format_ARGB32_Premultiplied); image.fill(Qt::transparent); // Paint svg or element QPainter p(&image); if (elementId.isEmpty()) renderer.render(&p); else renderer.render(&p, elementId); return image; }
QString QzTools::urlEncodeQueryString(const QUrl &url) { QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment); if (url.hasQuery()) { returnString += QLatin1Char('?') + url.query(QUrl::FullyEncoded); } if (url.hasFragment()) { returnString += QLatin1Char('#') + url.fragment(QUrl::FullyEncoded); } returnString.replace(QLatin1Char(' '), QLatin1String("%20")); return returnString; }
/** \param url **/ void ResumCtaWidget::alink ( const QUrl &url ) { BL_FUNC_DEBUG QString linker = url.fragment(); ///TODO: REVISAR ESTA FUNCION QUE NO HACE BIEN SU TRABAJO. if ( linker == "ver" ) { // TODO } else if ( linker == "asiento" ) { //QString ordenasiento = l.right(l.length() - 2); //( ( BcCompany * ) mainCompany() ) ->intapuntsempresa(); } else { BcAsientoView *view = g_asiento; bool ok; view->muestraAsiento ( linker.toInt ( &ok ) ); } // endif }
void QtWebKitHelpViewer::setSource(const QUrl &url) { QUrl oldWithoutFragment = source(); oldWithoutFragment.setFragment(QString()); m_webView->load(url); // if the new url only changes the anchor, // then webkit does not send loadStarted nor loadFinished, // so we should do that manually in that case QUrl newWithoutFragment = url; newWithoutFragment.setFragment(QString()); if (oldWithoutFragment == newWithoutFragment) { m_webView->page()->mainFrame()->scrollToAnchor(url.fragment()); slotLoadStarted(); slotLoadFinished(); } }
void WizardDialog::textBrowser_anchorClicked(const QUrl & url) { QString name = url.fragment(); // std::cout << name.toUtf8().data() << std::endl; CopasiUI3Window * pMainWindow = dynamic_cast<CopasiUI3Window *>(copasiMainWindow); if (name == "Model Settings") { if (pMainWindow) pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::Model, std::string()); } else if (name == "Reaction Overview") { if (pMainWindow) pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::Reactions, std::string()); } else if (name == "Report Definition") { if (pMainWindow) pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::ReportTemplates, std::string()); } else if (name == "Step 1") { buttonGroup->button(0)->setChecked(true); buttonGroup2_clicked(this->buttonGroup->checkedId()); } else if (name == "Time Course") { if (pMainWindow) pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::TimeCourse, std::string()); } else if (name == "Plot Definition Overview") { if (pMainWindow) pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::Plots, std::string()); } else { CQMessageBox::information(this, "Error", "Link not found", QMessageBox::Ok, QMessageBox::Ok); } }
void OnlineDataNodeOSF::initialise() { startInit(); QUrl url = QUrl(_path); _subPath = url.fragment().split('#'); if (_subPath.last().startsWith("file://")) _kind = OnlineDataNode::File; else if (_subPath.last().startsWith("folder://")) _kind = OnlineDataNode::Folder; else _kind = OnlineDataNode::Unknown; if (_kind == OnlineDataNode::File || _kind == OnlineDataNode::Folder) _expectedName = _path.right(_path.length() - _path.lastIndexOf("/") - 1); processUrl(url); }
void HelpWindow::setSource(const QUrl &name) { if (name.isValid()) { if (name.scheme() == QLatin1String("http") || name.scheme() == QLatin1String("ftp") || name.scheme() == QLatin1String("mailto") || name.path().endsWith(QLatin1String("pdf"))) { bool launched = QDesktopServices::openUrl(name); if (!launched) { QMessageBox::information(mw, tr("Help"), tr("Unable to launch web browser.\n"), tr("OK")); } return; } QFileInfo fi(name.toLocalFile()); if (name.scheme() == QLatin1String("file") && fi.exists()) { if (newWindow || (shiftPressed && hasFocus())) { shiftPressed = false; mw->saveSettings(); MainWindow *nmw = new MainWindow; nmw->move(mw->geometry().topLeft()); nmw->show(); if (mw->isMaximized()) nmw->showMaximized(); nmw->setup(); nmw->showLink(name.toString()); } else { QTextBrowser::setSource(name); QTextBrowser::scrollToAnchor(name.fragment()); } return; } } mw->statusBar()->showMessage(tr("Failed to open link: '%1'").arg(name.toString()), 5000); setHtml(tr("<div align=\"center\"><h1>The page could not be found</h1><br>" "<h3>'%1'</h3></div>").arg(name.toString())); mw->browsers()->updateTitle(tr("Error...")); }
void MainWindow::on_webView_urlChanged(const QUrl &arg1) { if ("/blank.html" == arg1.path()) { QRegExp regexp("access_token=([^,]+)&expires_in=([^,]+)&user_id=([^,]+)"); QString str=arg1.fragment(); if( -1 != regexp.indexIn(str) ) { m_access_token = regexp.cap(1); m_expires_in = regexp.cap(2); m_user_id = regexp.cap(3); ui->statusBar->clearMessage(); ui->statusBar->showMessage("Авторизирован. Можно начинать рассылку",10000); can_do_message=true; } } else if("/api/login_failure.html" == arg1.path()){ msg.setText("Errrror. Не получил token"); msg.exec(); can_do_message=false; } }
void TableOfContents::ItemClickedHandler(const QModelIndex &index) { QUrl url = m_NCXModel->GetUrlForIndex(index); QString filename = QFileInfo(url.path()).fileName(); int line = -1; // If no id, go to the top of the page if (url.fragment().isEmpty()) { line = 1; } try { Resource *resource = m_Book->GetFolderKeeper()->GetResourceByFilename(filename); emit OpenResourceRequest(resource, line, -1, QString(), MainWindow::ViewState_Unknown, url.fragment()); } catch (ResourceDoesNotExist) { Utility::DisplayStdErrorDialog( tr("The file \"%1\" does not exist.") .arg(filename) ); } }
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(); } }
QString QzTools::urlEncodeQueryString(const QUrl &url) { QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment); if (url.hasQuery()) { #if QT_VERSION >= 0x050000 returnString += QLatin1Char('?') + url.query(QUrl::FullyEncoded); #else returnString += QLatin1Char('?') + url.encodedQuery(); #endif } if (url.hasFragment()) { #if QT_VERSION >= 0x050000 returnString += QLatin1Char('#') + url.fragment(QUrl::FullyEncoded); #else returnString += QLatin1Char('#') + url.encodedFragment(); #endif } returnString.replace(QLatin1Char(' '), QLatin1String("%20")); return returnString; }
void dlgMyBrowser::slotLinkClicked(const QUrl &url) { if(opt.arg_debug) printf("dlgMyBrowser:slotLinkClicked(%s)\n", (const char *) url.toString().toUtf8()); if(url.isEmpty()) return; #ifdef USE_WEBKIT QString text = url.toString(); QStringList list = text.split("#"); // split anchor anchor = url.fragment(); if(opt.arg_debug) printf("dlgMyBrowser::slotLinkClicked url=%s fragment=%s\n", (const char *) text.toUtf8(), (const char *) anchor.toUtf8()); QString webpath = url.host() + url.path(); anchor = url.fragment(); mainWindow->urlComboBox->setEditText(text); if(text.startsWith("pv:") || text.startsWith("pvssh:")) { return mainWindow->slotUrl(text); } else if(text.endsWith(".pdf") || text.endsWith(".PDF")) { QString cmd = opt.view_pdf; cmd += " "; text.replace(" ","%20"); cmd += text; //#ifndef PVWIN32 // cmd += " &"; //#endif mysystem(cmd.toUtf8()); return; } else if(text.endsWith(".mp3", Qt::CaseInsensitive) || text.endsWith(".ogg", Qt::CaseInsensitive) || text.endsWith(".m3u", Qt::CaseInsensitive) || text.endsWith(".asx", Qt::CaseInsensitive) || text.contains(".pls?", Qt::CaseInsensitive) || text.contains("mp3e", Qt::CaseInsensitive) || text.startsWith("http://www.youtube.com/watch?") ) { QString cmd = opt.view_audio; cmd += " "; text.replace(" ","%20"); cmd += text; //#ifndef PVWIN32 // cmd += " &"; //#endif mysystem(cmd.toUtf8()); } else if(text.endsWith(".mp4", Qt::CaseInsensitive) || text.endsWith(".mov", Qt::CaseInsensitive) || text.endsWith(".ogv", Qt::CaseInsensitive) || text.endsWith(".avi", Qt::CaseInsensitive) ) { QString cmd = opt.view_video; cmd += " "; text.replace(" ","%20"); cmd += text; //#ifndef PVWIN32 // cmd += " &"; //#endif mysystem(cmd.toUtf8()); } else if(webpath == homepath) { QString u = list.at(0); form->browser->setUrl(QUrl(u)); } else { QString u = list.at(0); form->browser->load(QUrl(u)); homepath = webpath; } #endif }
void ColoringMessageHandler::handleMessage(QtMsgType type, const QString &description, const QUrl &identifier, const QSourceLocation &sourceLocation) { const bool hasLine = sourceLocation.line() != -1; switch(type) { case QtWarningMsg: { if(hasLine) { writeUncolored(QXmlPatternistCLI::tr("Warning in %1, at line %2, column %3: %4").arg(sourceLocation.uri().toString(), QString::number(sourceLocation.line()), QString::number(sourceLocation.column()), colorifyDescription(description))); } else { writeUncolored(QXmlPatternistCLI::tr("Warning in %1: %2").arg(sourceLocation.uri().toString(), colorifyDescription(description))); } break; } case QtFatalMsg: { const QString errorCode(identifier.fragment()); Q_ASSERT(!errorCode.isEmpty()); QUrl uri(identifier); uri.setFragment(QString()); QString location; if(sourceLocation.isNull()) location = QXmlPatternistCLI::tr("Unknown location"); else location = sourceLocation.uri().toString(); QString errorId; /* If it's a standard error code, we don't want to output the * whole URI. */ if(uri.toString() == QLatin1String("http://www.w3.org/2005/xqt-errors")) errorId = errorCode; else errorId = identifier.toString(); if(hasLine) { writeUncolored(QXmlPatternistCLI::tr("Error %1 in %2, at line %3, column %4: %5").arg(colorify(errorId, ErrorCode), colorify(location, Location), colorify(QString::number(sourceLocation.line()), Location), colorify(QString::number(sourceLocation.column()), Location), colorifyDescription(description))); } else { writeUncolored(QXmlPatternistCLI::tr("Error %1 in %2: %3").arg(colorify(errorId, ErrorCode), colorify(location, Location), colorifyDescription(description))); } break; } case QtCriticalMsg: /* Fallthrough. */ case QtDebugMsg: { Q_ASSERT_X(false, Q_FUNC_INFO, "message() is not supposed to receive QtCriticalMsg or QtDebugMsg."); return; } } }
bool KWebKitPart::openUrl(const QUrl &_u) { QUrl u (_u); kDebug() << u; // Ignore empty requests... if (u.isEmpty()) return false; // If the URL given is a supported local protocol, e.g. "bookmark" but lacks // a path component, we set the path to "/" here so that the security context // will properly allow access to local resources. if (u.host().isEmpty() && u.path().isEmpty() && KProtocolInfo::protocolClass(u.scheme()) == QL1S(":local")) { u.setPath(QL1S("/")); } // Do not emit update history when url is typed in since the embedding part // should handle that automatically itself. At least Konqueror does that. m_emitOpenUrlNotify = false; // Pointer to the page object... WebPage* p = page(); Q_ASSERT(p); // Handle error conditions... if (u.scheme() == QL1S("error")) { /** * The format of the error url is that two variables are passed in the query: * error = int kio error code, errText = QString error text from kio * and the URL where the error happened is passed as a sub URL. */ const QUrl mainUrl(u.fragment()); if (mainUrl.isValid()) { QString query = u.query(QUrl::FullyDecoded); QRegularExpression pattern("error=(\\d+)&errText=(.*)"); QRegularExpressionMatch match = pattern.match(query); int error = match.captured(1).toInt(); // error=0 isn't a valid error code, so 0 means it's missing from the URL if (error == 0) { error = KIO::ERR_UNKNOWN; } const QString errorText = match.captured(2); emit m_browserExtension->setLocationBarUrl(mainUrl.toDisplayString()); if (p) { m_webView->setHtml(p->errorPage(error, errorText, mainUrl)); return true; } } return false; } KParts::BrowserArguments bargs (m_browserExtension->browserArguments()); KParts::OpenUrlArguments args (arguments()); if (u != *globalBlankUrl) { // Get the SSL information sent, if any... if (args.metaData().contains(QL1S("ssl_in_use"))) { WebSslInfo sslInfo; sslInfo.restoreFrom(KIO::MetaData(args.metaData()).toVariant()); sslInfo.setUrl(u); p->setSslInfo(sslInfo); } } // Set URL in KParts before emitting started; konq plugins rely on that. setUrl(u); m_doLoadFinishedActions = true; m_webView->loadUrl(u, args, bargs); return true; }
int Url::fragment ( lua_State * L )// const : QString { QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 ); lua_pushstring(L, lhs->fragment().toLatin1() ); return 1; }
void HelpDialog::clickLink( const QUrl &url ) { emit linkClicked( url.fragment() ); }
void CodeNavigator::goTo(const QUrl& url) { goTo(url.path(), url.fragment().toInt()); }