void UserLoader::handleResponse(QString t_uuid, QNetworkReply *t_reply) { auto api = API::sharedAPI()->sharedAniListAPI(); auto url = t_reply->request().url(); auto api_part = QUrl(url.toDisplayString().split("?").first()); auto display_name = User::sharedUser()->displayName(); auto string_part = api_part.toDisplayString(); if (api_part == api->API_USER) { auto result = QJsonDocument::fromJson(t_reply->readAll()).object(); parseUser(result); } else if (api_part == api->API_USER_LIST(display_name)) { auto result = QJsonDocument::fromJson(t_reply->readAll()).object(); parseUserList(result); } else if (string_part.startsWith(api->API_ANIME("").toDisplayString()) && !string_part.startsWith( api->API_ANIME_SEARCH("").toDisplayString())) { auto result = QJsonDocument::fromJson(t_reply->readAll()).object(); parseAnime(result); } else { if (m_callbacks.contains(t_uuid)) { auto result = QJsonDocument::fromJson(t_reply->readAll()).object(); m_callbacks.value(t_uuid)(result); m_callbacks.remove(t_uuid); } } }
void HiddenUrlClickHandler::Open(QString url, QVariant context) { url = tryConvertUrlToLocal(url); if (Core::InternalPassportLink(url)) { return; } const auto open = [=] { UrlClickHandler::Open(url, context); }; if (url.startsWith(qstr("tg://"), Qt::CaseInsensitive)) { open(); } else { const auto parsedUrl = QUrl::fromUserInput(url); if (UrlRequiresConfirmation(url)) { Core::App().hideMediaView(); const auto displayUrl = parsedUrl.isValid() ? parsedUrl.toDisplayString() : url; Ui::show( Box<ConfirmBox>( lang(lng_open_this_link) + qsl("\n\n") + displayUrl, lang(lng_open_link), [=] { Ui::hideLayer(); open(); }), LayerOption::KeepOther); } else { open(); } } }
void WebEntityItem::setScriptURL(const QString& value) { withWriteLock([&] { if (_scriptURL != value) { auto newURL = QUrl::fromUserInput(value); if (newURL.isValid()) { _scriptURL = newURL.toDisplayString(); } else { qCDebug(entities) << "Not setting web entity script URL since" << value << "cannot be parsed to a valid URL."; } } }); }
UrlClickHandler::UrlClickHandler(const QString &url, bool fullDisplayed) : TextClickHandler(fullDisplayed) , _originalUrl(url) { if (isEmail()) { _readable = _originalUrl; } else { const auto original = QUrl(_originalUrl); const auto good = QUrl(original.isValid() ? original.toEncoded() : QString()); _readable = good.isValid() ? good.toDisplayString() : _originalUrl; } }
void HiddenUrlClickHandler::doOpen(QString url) { auto urlText = tryConvertUrlToLocal(url); if (urlText.startsWith(qstr("tg://"))) { App::openLocalUrl(urlText); } else { auto parsedUrl = QUrl::fromUserInput(urlText); auto displayUrl = parsedUrl.isValid() ? parsedUrl.toDisplayString() : urlText; Ui::show(Box<ConfirmBox>(lang(lng_open_this_link) + qsl("\n\n") + displayUrl, lang(lng_open_link), [urlText] { Ui::hideLayer(); UrlClickHandler::doOpen(urlText); })); } }
void handleResults(MutableArrayRef<CodeCompletionResult *> Results) override { CodeCompletionContext::sortCompletionResults(Results); for (auto Result : Results) { std::string InsertableString = toInsertableString(Result); if (StringRef(InsertableString).startswith(Completions.Prefix)) { llvm::SmallString<128> PrintedResult; { llvm::raw_svector_ostream OS(PrintedResult); toDisplayString(Result, OS); } Completions.CompletionStrings.push_back( Completions.CompletionContext.copyString(PrintedResult)); InsertableString = InsertableString.substr(Completions.Prefix.size()); Completions.CookedResults.push_back( { Completions.CompletionContext.copyString(InsertableString), Result->getNumBytesToErase() }); } } }
void ModelBaker::handleFinishedMaterialMapBaker() { auto baker = qobject_cast<MaterialBaker*>(sender()); if (baker) { if (!baker->hasErrors()) { // this MaterialBaker is done and everything went according to plan qCDebug(model_baking) << "Adding baked material to FST mapping " << baker->getBakedMaterialData(); QString materialName; { auto materialResource = baker->getNetworkMaterialResource(); if (materialResource) { auto url = materialResource->getURL(); if (!url.isEmpty()) { QString urlString = url.toDisplayString(); auto index = urlString.lastIndexOf("#"); if (index != -1) { materialName = urlString.right(urlString.length() - index); } } } } QJsonObject json; json[QString(_materialMapping.front().first.c_str())] = baker->getMaterialData() + BAKED_MATERIAL_EXTENSION + materialName; _materialMappingJSON.push_back(json); } else { // this material failed to bake - this doesn't fail the entire bake but we need to add the errors from // the material to our warnings _warningList << baker->getWarnings(); } } else { handleWarning("Failed to bake the materialMap for model with URL " + _modelURL.toString() + " and mapping target " + _materialMapping.front().first.c_str()); } _materialMapping.erase(_materialMapping.begin()); bakeMaterialMap(); }