diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 1934e0a3f..a4f02b1a4 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1449,6 +1449,7 @@ PRIVATE window/window_section_common.h window/window_session_controller.cpp window/window_session_controller.h + window/window_session_controller_link_info.h window/window_slide_animation.cpp window/window_slide_animation.h window/window_top_bar_wrap.h diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_reactions.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_reactions.cpp index b52fbf718..cb7c1183e 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_reactions.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_reactions.cpp @@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/peers/edit_peer_reactions.h" #include "base/event_filter.h" -#include "boxes/reactions_settings_box.h" // AddReactionAnimatedIcon #include "chat_helpers/tabbed_panel.h" #include "chat_helpers/tabbed_selector.h" #include "data/data_message_reactions.h" @@ -30,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/slide_wrap.h" #include "ui/vertical_list.h" #include "window/window_session_controller.h" +#include "window/window_session_controller_link_info.h" #include "styles/style_chat_helpers.h" #include "styles/style_info.h" #include "styles/style_settings.h" @@ -492,7 +492,7 @@ void AddReactionsText( const auto count = inner->lifetime().make_state>( std::move(customCountValue)); - auto outer = container->add( + container->add( object_ptr( container, std::move(ownedInner), @@ -510,8 +510,7 @@ void AddReactionsText( const auto weak = base::make_weak(navigation); label->setClickHandlerFilter([=](const auto &...) { if (const auto strong = weak.get()) { - using Info = Window::SessionNavigation::PeerByLinkInfo; - strong->showPeerByLink(Info{ + strong->showPeerByLink(Window::PeerByLinkInfo{ .usernameOrId = u"stickers"_q, .resolveType = Window::ResolveType::Mention, }); @@ -563,7 +562,6 @@ void EditAllowedReactionsBox( using namespace Data; using namespace rpl::mappers; - const auto iconHeight = st::editPeerReactionsPreview; box->setTitle(tr::lng_manage_peer_reactions()); box->setWidth(st::boxWideWidth); @@ -707,7 +705,6 @@ void EditAllowedReactionsBox( state->customCount.value(), args.askForBoosts); } - const auto total = int(all.size()); const auto collect = [=] { auto result = AllowedReactions(); if (isGroup diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index f79661971..7dfaedac8 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "window/window_controller.h" #include "window/window_session_controller.h" +#include "window/window_session_controller_link_info.h" #include "styles/style_layers.h" namespace { @@ -209,8 +210,7 @@ void MentionClickHandler::onClick(ClickContext context) const { ? Core::App().activeWindow()->sessionController() : nullptr; if (use) { - using Info = Window::SessionNavigation::PeerByLinkInfo; - use->showPeerByLink(Info{ + use->showPeerByLink(Window::PeerByLinkInfo{ .usernameOrId = _tag.mid(1), .resolveType = Window::ResolveType::Mention, }); diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index f21b16396..3ae95884e 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/sessions_box.h" #include "boxes/language_box.h" #include "passport/passport_form_controller.h" -#include "window/window_session_controller.h" #include "ui/toast/toast.h" #include "data/data_session.h" #include "data/data_document.h" @@ -38,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "media/player/media_player_instance.h" #include "media/view/media_view_open_common.h" #include "window/window_session_controller.h" +#include "window/window_session_controller_link_info.h" #include "window/window_controller.h" #include "window/window_peer_menu.h" #include "window/themes/window_theme_editor_box.h" // GenerateSlug. @@ -57,7 +57,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "inline_bots/bot_attach_web_view.h" #include "history/history.h" #include "history/history_item.h" -#include "base/qt/qt_common_adapters.h" #include "apiwrap.h" #include @@ -286,7 +285,7 @@ bool ShowWallPaper( const auto params = url_parse_params( match->captured(1), qthelp::UrlParamNameTransform::ToLower); - const auto bg = params.value(u"bg_color"_q); + // const auto bg = params.value(u"bg_color"_q); const auto color = params.value(u"color"_q); const auto gradient = params.value(u"gradient"_q); const auto result = BackgroundPreviewBox::Start( @@ -418,22 +417,21 @@ bool ResolveUsernameOrPhone( } } const auto myContext = context.value(); - using Navigation = Window::SessionNavigation; controller->window().activate(); - controller->showPeerByLink(Navigation::PeerByLinkInfo{ + controller->showPeerByLink(Window::PeerByLinkInfo{ .usernameOrId = domain, .phone = phone, .messageId = post, .storyId = storyId, .repliesInfo = commentId - ? Navigation::RepliesByLinkInfo{ - Navigation::CommentId{ commentId } + ? Window::RepliesByLinkInfo{ + Window::CommentId{ commentId } } : threadId - ? Navigation::RepliesByLinkInfo{ - Navigation::ThreadId{ threadId } + ? Window::RepliesByLinkInfo{ + Window::ThreadId{ threadId } } - : Navigation::RepliesByLinkInfo{ v::null }, + : Window::RepliesByLinkInfo{ v::null }, .resolveType = resolveType, .startToken = startToken, .startAdminRights = adminRights, @@ -486,19 +484,18 @@ bool ResolvePrivatePost( return false; } const auto my = context.value(); - using Navigation = Window::SessionNavigation; - controller->showPeerByLink(Navigation::PeerByLinkInfo{ + controller->showPeerByLink(Window::PeerByLinkInfo{ .usernameOrId = channelId, .messageId = msgId, .repliesInfo = commentId - ? Navigation::RepliesByLinkInfo{ - Navigation::CommentId{ commentId } + ? Window::RepliesByLinkInfo{ + Window::CommentId{ commentId } } : threadId - ? Navigation::RepliesByLinkInfo{ - Navigation::ThreadId{ threadId } + ? Window::RepliesByLinkInfo{ + Window::ThreadId{ threadId } } - : Navigation::RepliesByLinkInfo{ v::null }, + : Window::RepliesByLinkInfo{ v::null }, .clickFromMessageId = my.itemId, .clickFromAttachBotWebviewUrl = my.attachBotWebviewUrl, }); @@ -877,9 +874,8 @@ bool ResolveBoost( : params.value(u"channel"_q); const auto myContext = context.value(); - using Navigation = Window::SessionNavigation; controller->window().activate(); - controller->showPeerByLink(Navigation::PeerByLinkInfo{ + controller->showPeerByLink(Window::PeerByLinkInfo{ .usernameOrId = (!domainParam.isEmpty() ? std::variant(domainParam) : ChannelId(BareId(channelParam.toULongLong()))), diff --git a/Telegram/SourceFiles/settings/settings_premium.cpp b/Telegram/SourceFiles/settings/settings_premium.cpp index d149c3230..3f03a6264 100644 --- a/Telegram/SourceFiles/settings/settings_premium.cpp +++ b/Telegram/SourceFiles/settings/settings_premium.cpp @@ -52,10 +52,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/vertical_list.h" #include "window/window_controller.h" #include "window/window_session_controller.h" +#include "window/window_session_controller_link_info.h" #include "base/unixtime.h" #include "apiwrap.h" #include "api/api_premium.h" -#include "styles/style_boxes.h" #include "styles/style_premium.h" #include "styles/style_info.h" #include "styles/style_intro.h" @@ -104,8 +104,8 @@ namespace Gift { struct Data { PeerId peerId; - int months; - bool me; + int months = 0; + bool me = false; explicit operator bool() const { return peerId != 0; @@ -1448,7 +1448,7 @@ void StartPremiumPayment( "premium_invoice_slug", QString()); if (!username.isEmpty()) { - controller->showPeerByLink(Window::SessionNavigation::PeerByLinkInfo{ + controller->showPeerByLink(Window::PeerByLinkInfo{ .usernameOrId = username, .resolveType = Window::ResolveType::BotStart, .startToken = ref, diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index b36291d4d..c63714db2 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -83,6 +83,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/file_upload.h" #include "window/themes/window_theme.h" #include "window/window_peer_menu.h" +#include "window/window_session_controller_link_info.h" #include "settings/settings_main.h" #include "settings/settings_premium.h" #include "settings/settings_privacy_security.h" diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 3a8eddbbe..2106cbc9f 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -93,16 +93,7 @@ class SectionMemento; class Controller; class FiltersMenu; -enum class ResolveType { - Default, - BotApp, - BotStart, - AddToGroup, - AddToChannel, - ShareGame, - Mention, - Boost, -}; +struct PeerByLinkInfo; struct PeerThemeOverride { PeerData *peer = nullptr; @@ -195,33 +186,6 @@ public: const SectionShow ¶ms = SectionShow()) = 0; virtual not_null parentController() = 0; - struct CommentId { - MsgId id = 0; - }; - struct ThreadId { - MsgId id = 0; - }; - using RepliesByLinkInfo = std::variant; - struct PeerByLinkInfo { - std::variant usernameOrId; - QString phone; - MsgId messageId = ShowAtUnreadMsgId; - StoryId storyId = 0; - RepliesByLinkInfo repliesInfo; - ResolveType resolveType = ResolveType::Default; - QString startToken; - ChatAdminRights startAdminRights; - bool startAutoSubmit = false; - QString botAppName; - bool botAppForceConfirmation = false; - QString attachBotUsername; - std::optional attachBotToggleCommand; - bool attachBotMenuOpen = false; - InlineBots::PeerTypes attachBotChooseTypes; - std::optional voicechatHash; - FullMsgId clickFromMessageId; - QString clickFromAttachBotWebviewUrl; - }; void showPeerByLink(const PeerByLinkInfo &info); void showRepliesForMessage( diff --git a/Telegram/SourceFiles/window/window_session_controller_link_info.h b/Telegram/SourceFiles/window/window_session_controller_link_info.h new file mode 100644 index 000000000..927185e5a --- /dev/null +++ b/Telegram/SourceFiles/window/window_session_controller_link_info.h @@ -0,0 +1,52 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +namespace Window { + +enum class ResolveType { + Default, + BotApp, + BotStart, + AddToGroup, + AddToChannel, + ShareGame, + Mention, + Boost, +}; + +struct CommentId { + MsgId id = 0; +}; +struct ThreadId { + MsgId id = 0; +}; +using RepliesByLinkInfo = std::variant; + +struct PeerByLinkInfo { + std::variant usernameOrId; + QString phone; + MsgId messageId = ShowAtUnreadMsgId; + StoryId storyId = 0; + RepliesByLinkInfo repliesInfo; + ResolveType resolveType = ResolveType::Default; + QString startToken; + ChatAdminRights startAdminRights; + bool startAutoSubmit = false; + QString botAppName; + bool botAppForceConfirmation = false; + QString attachBotUsername; + std::optional attachBotToggleCommand; + bool attachBotMenuOpen = false; + InlineBots::PeerTypes attachBotChooseTypes; + std::optional voicechatHash; + FullMsgId clickFromMessageId; + QString clickFromAttachBotWebviewUrl; +}; + +} // namespace Window