From cdc295c1d7fc660d9399a025c70a71096b6df9b6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 16 Jun 2020 19:10:39 +0400 Subject: [PATCH] Fix build with updated submodules. --- Telegram/SourceFiles/boxes/stickers_box.cpp | 4 +- Telegram/SourceFiles/core/ui_integration.cpp | 54 +++++++++---------- Telegram/SourceFiles/core/ui_integration.h | 15 ++++-- .../view/media/history_view_web_page.cpp | 10 +++- Telegram/SourceFiles/ui/text_options.cpp | 36 +------------ Telegram/SourceFiles/ui/text_options.h | 3 +- Telegram/lib_ui | 2 +- cmake | 2 +- 8 files changed, 54 insertions(+), 72 deletions(-) diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 9e28c43d5..8e21da0d1 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -326,7 +326,9 @@ void StickersBox::prepare() { _session->api().updateStickers(); if (_installed.widget()) { - connect(_installed.widget(), SIGNAL(draggingScrollDelta(int)), this, SLOT(onDraggingScrollDelta(int))); + connect(_installed.widget(), &Inner::draggingScrollDelta, [=](int delta) { + scrollByDraggingDelta(delta); + }); if (!_megagroupSet) { boxClosing() | rpl::start_with_next([=] { saveChanges(); diff --git a/Telegram/SourceFiles/core/ui_integration.cpp b/Telegram/SourceFiles/core/ui_integration.cpp index a5a03fa89..a249fd533 100644 --- a/Telegram/SourceFiles/core/ui_integration.cpp +++ b/Telegram/SourceFiles/core/ui_integration.cpp @@ -61,68 +61,68 @@ void UiIntegration::startFontsEnd() { } std::shared_ptr UiIntegration::createLinkHandler( - EntityType type, - const QString &text, - const QString &data, - const TextParseOptions &options) { - switch (type) { + const EntityLinkData &data, + const std::any &context) { + const auto my = std::any_cast(&context); + switch (data.type) { case EntityType::Url: - return (!data.isEmpty() && UrlClickHandler::IsSuspicious(data)) - ? std::make_shared(data) - : nullptr; + return (!data.data.isEmpty() + && UrlClickHandler::IsSuspicious(data.data)) + ? std::make_shared(data.data) + : Integration::createLinkHandler(data, context); case EntityType::CustomUrl: - return !data.isEmpty() - ? std::make_shared(data) - : nullptr; + return !data.data.isEmpty() + ? std::make_shared(data.data) + : Integration::createLinkHandler(data, context); case EntityType::BotCommand: - return std::make_shared(data); + return std::make_shared(data.data); case EntityType::Hashtag: - if (options.flags & TextTwitterMentions) { + if (my && my->type == HashtagMentionType::Twitter) { return std::make_shared( (qsl("https://twitter.com/hashtag/") - + data.mid(1) + + data.data.mid(1) + qsl("?src=hash")), true); - } else if (options.flags & TextInstagramMentions) { + } else if (my && my->type == HashtagMentionType::Instagram) { return std::make_shared( (qsl("https://instagram.com/explore/tags/") - + data.mid(1) + + data.data.mid(1) + '/'), true); } - return std::make_shared(data); + return std::make_shared(data.data); case EntityType::Cashtag: - return std::make_shared(data); + return std::make_shared(data.data); case EntityType::Mention: - if (options.flags & TextTwitterMentions) { + if (my && my->type == HashtagMentionType::Twitter) { return std::make_shared( - qsl("https://twitter.com/") + data.mid(1), + qsl("https://twitter.com/") + data.data.mid(1), true); - } else if (options.flags & TextInstagramMentions) { + } else if (my && my->type == HashtagMentionType::Instagram) { return std::make_shared( - qsl("https://instagram.com/") + data.mid(1) + '/', + qsl("https://instagram.com/") + data.data.mid(1) + '/', true); } - return std::make_shared(data); + return std::make_shared(data.data); case EntityType::MentionName: { - auto fields = TextUtilities::MentionNameDataToFields(data); + auto fields = TextUtilities::MentionNameDataToFields(data.data); if (fields.userId) { return std::make_shared( - text, + data.text, fields.userId, fields.accessHash); } else { - LOG(("Bad mention name: %1").arg(data)); + LOG(("Bad mention name: %1").arg(data.data)); } } break; } - return nullptr; + return Integration::createLinkHandler(data, context); } bool UiIntegration::handleUrlClick( diff --git a/Telegram/SourceFiles/core/ui_integration.h b/Telegram/SourceFiles/core/ui_integration.h index 3cb3e191c..f5e9ff1d9 100644 --- a/Telegram/SourceFiles/core/ui_integration.h +++ b/Telegram/SourceFiles/core/ui_integration.h @@ -13,6 +13,15 @@ namespace Core { class UiIntegration : public Ui::Integration { public: + enum class HashtagMentionType : uchar { + Telegram, + Twitter, + Instagram, + }; + struct Context { + HashtagMentionType type = HashtagMentionType::Telegram; + }; + void postponeCall(FnMut &&callable) override; void registerLeaveSubscription(not_null widget) override; void unregisterLeaveSubscription(not_null widget) override; @@ -27,10 +36,8 @@ public: void startFontsEnd() override; std::shared_ptr createLinkHandler( - EntityType type, - const QString &text, - const QString &data, - const TextParseOptions &options) override; + const EntityLinkData &data, + const std::any &context) override; bool handleUrlClick( const QString &url, const QVariant &context) override; diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index e336dbe99..fda9f4595 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "layout.h" #include "core/click_handler_types.h" +#include "core/ui_integration.h" #include "lang/lang_keys.h" #include "history/history_item_components.h" #include "history/history_item.h" @@ -199,10 +200,17 @@ QSize WebPage::countOptimalSize() { - st::msgPadding.right() - st::webPageLeft); } + auto context = Core::UiIntegration::Context(); + if (_data->siteName == qstr("Twitter")) { + context.type = Core::UiIntegration::HashtagMentionType::Twitter; + } else if (_data->siteName == qstr("Instagram")) { + context.type = Core::UiIntegration::HashtagMentionType::Instagram; + } _description.setMarkedText( st::webPageDescriptionStyle, text, - Ui::WebpageTextDescriptionOptions(_data->siteName)); + Ui::WebpageTextDescriptionOptions(), + context); } if (!displayedSiteName().isEmpty()) { _siteNameLines = 1; diff --git a/Telegram/SourceFiles/ui/text_options.cpp b/Telegram/SourceFiles/ui/text_options.cpp index 3d7c3414d..99247f568 100644 --- a/Telegram/SourceFiles/ui/text_options.cpp +++ b/Telegram/SourceFiles/ui/text_options.cpp @@ -110,32 +110,6 @@ TextParseOptions WebpageDescriptionOptions = { Qt::LayoutDirectionAuto, // dir }; -TextParseOptions TwitterDescriptionOptions = { - TextParseLinks - | TextParseMentions - | TextTwitterMentions - | TextParseHashtags - | TextTwitterHashtags - | TextParseMultiline - | TextParseRichText, // flags - 0, // maxw - 0, // maxh - Qt::LayoutDirectionAuto, // dir -}; - -TextParseOptions InstagramDescriptionOptions = { - TextParseLinks - | TextParseMentions - | TextInstagramMentions - | TextParseHashtags - | TextInstagramHashtags - | TextParseMultiline - | TextParseRichText, // flags - 0, // maxw - 0, // maxh - Qt::LayoutDirectionAuto, // dir -}; - bool UseBotTextOptions( not_null history, not_null author) { @@ -171,8 +145,6 @@ void InitTextOptions() { WebpageTitleOptions.maxh = st::webPageTitleFont->height * 2; WebpageTitleOptions.maxw = WebpageDescriptionOptions.maxw - = TwitterDescriptionOptions.maxw - = InstagramDescriptionOptions.maxw = st::msgMaxWidth - st::msgPadding.left() - st::webPageLeft @@ -204,13 +176,7 @@ const TextParseOptions &WebpageTextTitleOptions() { return WebpageTitleOptions; } -const TextParseOptions &WebpageTextDescriptionOptions( - const QString &siteName) { - if (siteName == qstr("Twitter")) { - return TwitterDescriptionOptions; - } else if (siteName == qstr("Instagram")) { - return InstagramDescriptionOptions; - } +const TextParseOptions &WebpageTextDescriptionOptions() { return WebpageDescriptionOptions; } diff --git a/Telegram/SourceFiles/ui/text_options.h b/Telegram/SourceFiles/ui/text_options.h index d40d292a1..85b0a80c3 100644 --- a/Telegram/SourceFiles/ui/text_options.h +++ b/Telegram/SourceFiles/ui/text_options.h @@ -23,8 +23,7 @@ const TextParseOptions &ItemTextBotNoMonoOptions(); const TextParseOptions &ItemTextServiceOptions(); const TextParseOptions &WebpageTextTitleOptions(); -const TextParseOptions &WebpageTextDescriptionOptions( - const QString &siteName = QString()); +const TextParseOptions &WebpageTextDescriptionOptions(); const TextParseOptions &NameTextOptions(); const TextParseOptions &DialogTextOptions(); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 4ef97b57f..4e6763d17 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 4ef97b57f6925ac9f1e3221676f49dffb4fe8c19 +Subproject commit 4e6763d1769e6305a3da158e1a332ccd6a30398a diff --git a/cmake b/cmake index b558136e6..eb97b772a 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit b558136e64edd851901ac2b48a4f186d186c1723 +Subproject commit eb97b772a330ee370ea37c753a54c6862ca96644