From 183a9139f9d3778528bedb44195d5d19fed3e219 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 20 Dec 2024 19:25:10 +0300 Subject: [PATCH] Moved out ability to mark as read all chats from hidden shortcut. --- Telegram/Resources/langs/lang.strings | 1 + .../settings/settings_information.cpp | 15 +++----- .../SourceFiles/window/window_peer_menu.cpp | 34 ++++++++++++++++--- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 7977c29f2..afa79e2b1 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3656,6 +3656,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_context_mark_read_sure" = "Are you sure you want to mark all chats from this folder as read?"; "lng_context_mark_read_all" = "Mark all chats as read"; "lng_context_mark_read_all_sure" = "Are you sure you want to mark all chats as read?"; +"lng_context_mark_read_all_sure_2" = "**This action cannot be undone.**"; "lng_context_mark_read_mentions_all" = "Mark all mentions as read"; "lng_context_mark_read_reactions_all" = "Read all reactions"; "lng_context_archive_expand" = "Expand"; diff --git a/Telegram/SourceFiles/settings/settings_information.cpp b/Telegram/SourceFiles/settings/settings_information.cpp index cde71d622..c8c8fe4fc 100644 --- a/Telegram/SourceFiles/settings/settings_information.cpp +++ b/Telegram/SourceFiles/settings/settings_information.cpp @@ -746,17 +746,6 @@ void SetupAccountsWrap( } else if (which != Qt::RightButton) { return; } - if (!state->menu && IsAltShift(raw->clickModifiers()) && !locked) { - state->menu = base::make_unique_q( - raw, - st::popupMenuWithIcons); - Window::MenuAddMarkAsReadAllChatsAction( - session, - window->uiShow(), - Ui::Menu::CreateAddActionCallback(state->menu)); - state->menu->popup(QCursor::pos()); - return; - } if (session == &window->session() || state->menu) { return; } @@ -781,6 +770,10 @@ void SetupAccountsWrap( addAction(tr::lng_menu_activate(tr::now), [=] { callback({}); }, &st::menuIconProfile); + Window::MenuAddMarkAsReadAllChatsAction( + session, + window->uiShow(), + addAction); } auto logoutCallback = [=] { diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 108579e46..334a6fb76 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -2770,7 +2770,6 @@ void MenuAddMarkAsReadAllChatsAction( not_null session, std::shared_ptr show, const PeerMenuCallback &addAction) { - // There is no async to make weak from controller. auto callback = [=, owner = &session->data()] { auto boxCallback = [=](Fn &&close) { close(); @@ -2781,9 +2780,36 @@ void MenuAddMarkAsReadAllChatsAction( } }; show->show( - Ui::MakeConfirmBox({ - tr::lng_context_mark_read_all_sure(), - std::move(boxCallback) + Box([=](not_null box) { + Ui::AddSkip(box->verticalLayout()); + Ui::AddSkip(box->verticalLayout()); + const auto userpic = Ui::CreateChild( + box->verticalLayout(), + session->user(), + st::mainMenuUserpic); + Ui::IconWithTitle( + box->verticalLayout(), + userpic, + Ui::CreateChild( + box->verticalLayout(), + Info::Profile::NameValue(session->user()), + box->getDelegate()->style().title)); + auto text = rpl::combine( + tr::lng_context_mark_read_all_sure(), + tr::lng_context_mark_read_all_sure_2( + Ui::Text::RichLangValue) + ) | rpl::map([](QString t1, TextWithEntities t2) { + return TextWithEntities() + .append(std::move(t1)) + .append('\n') + .append('\n') + .append(std::move(t2)); + }); + Ui::ConfirmBox(box, { + .text = std::move(text), + .confirmed = std::move(boxCallback), + .confirmStyle = &st::attentionBoxButton, + }); }), Ui::LayerOption::CloseOther); };