From 3dbadeb23282b98080e20135aa688dafdb051394 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 11 Apr 2024 18:05:51 +0400 Subject: [PATCH] Allow opening top peers in a new window. --- Telegram/Resources/langs/lang.strings | 4 +-- .../SourceFiles/dialogs/dialogs_widget.cpp | 8 ++++- .../dialogs/ui/dialogs_suggestions.cpp | 32 +++++++++++++------ .../dialogs/ui/dialogs_suggestions.h | 2 -- Telegram/SourceFiles/ui/menu_icons.style | 1 + .../SourceFiles/window/window_peer_menu.cpp | 4 ++- 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 36c2c9393..606f8bc2a 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -5094,8 +5094,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_recent_clear" = "Clear"; "lng_recent_clear_sure" = "Do you want to clear your search history?"; "lng_recent_remove" = "Remove from Recent"; -"lng_recent_hide_top" = "Hide all"; -"lng_recent_hide_sure" = "Are you sure you want to hide frequent contacts list?\n\nYou can always return this list in Settings > Privacy > Suggest Frequent Contacts."; +"lng_recent_hide_top" = "Remove all & Disable"; +"lng_recent_hide_sure" = "Are you sure you want to clear and disable frequent contacts list?\n\nYou can always turn this feature back on in Settings > Privacy > Suggest Frequent Contacts."; "lng_recent_hide_button" = "Hide"; // Wnd specific diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 98956f32f..3e2b7a9ed 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "dialogs/dialogs_widget.h" +#include "base/qt/qt_key_modifiers.h" #include "base/options.h" #include "dialogs/ui/dialogs_stories_content.h" #include "dialogs/ui/dialogs_stories_list.h" @@ -1123,7 +1124,12 @@ void Widget::updateSuggestions(anim::type animated) { _suggestions->topPeerChosen( ) | rpl::start_with_next([=](PeerId id) { - controller()->showPeerHistory(id); + const auto peer = session().data().peer(id); + if (base::IsCtrlPressed()) { + controller()->showInNewWindow(peer); + } else { + controller()->showPeerHistory(peer); + } }, _suggestions->lifetime()); _suggestions->show(); diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp index ad5bce8d0..24c453ad3 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp @@ -22,8 +22,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/wrap/vertical_layout.h" #include "ui/wrap/slide_wrap.h" +#include "ui/delayed_activation.h" #include "ui/dynamic_thumbnails.h" #include "window/window_session_controller.h" +#include "window/window_peer_menu.h" #include "styles/style_chat.h" #include "styles/style_dialogs.h" #include "styles/style_layers.h" @@ -43,14 +45,11 @@ void FillTopPeerMenu( const auto group = peer->isMegagroup(); const auto channel = peer->isChannel(); - add({ - .text = tr::lng_recent_remove(tr::now), - .handler = [=] { remove(peer); }, - .icon = &st::menuIconDeleteAttention, - .isAttention = true, - }); - - add({ .separatorSt = &st::expandedMenuSeparator }); + add(tr::lng_context_new_window(tr::now), [=] { + Ui::PreventDelayedActivation(); + controller->showInNewWindow(peer); + }, &st::menuIconNewWindow); + Window::AddSeparatorAndShiftUp(add); const auto showHistoryText = group ? tr::lng_context_open_group(tr::now) @@ -72,12 +71,25 @@ void FillTopPeerMenu( add({ .separatorSt = &st::expandedMenuSeparator }); - add(tr::lng_recent_hide_top(tr::now), [=] { + add({ + .text = tr::lng_recent_remove(tr::now), + .handler = [=] { remove(peer); }, + .icon = &st::menuIconDeleteAttention, + .isAttention = true, + }); + + const auto hideAllConfirmed = [=] { controller->show(Ui::MakeConfirmBox({ .text = tr::lng_recent_hide_sure(), .confirmed = [=](Fn close) { hideAll(); close(); } })); - }, &st::menuIconCancel); + }; + add({ + .text = tr::lng_recent_hide_top(tr::now).replace('&', u"&&"_q), + .handler = hideAllConfirmed, + .icon = &st::menuIconCancelAttention, + .isAttention = true, + }); } } // namespace diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h index aa6491f42..dcc2a35a0 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h @@ -52,8 +52,6 @@ private: [[nodiscard]] object_ptr setupDivider(); - void updateControlsGeometry(); - const std::unique_ptr _scroll; const not_null _content; const not_null*> _topPeersWrap; diff --git a/Telegram/SourceFiles/ui/menu_icons.style b/Telegram/SourceFiles/ui/menu_icons.style index 4ec165b62..38625f769 100644 --- a/Telegram/SourceFiles/ui/menu_icons.style +++ b/Telegram/SourceFiles/ui/menu_icons.style @@ -192,6 +192,7 @@ menuIconDisableAttention: icon {{ "menu/disable", menuIconAttentionColor }}; menuIconReportAttention: icon {{ "menu/report", menuIconAttentionColor }}; menuIconRestoreAttention: icon {{ "menu/restore", menuIconAttentionColor }}; menuIconTagRemoveAttention: icon {{ "menu/tag_remove", menuIconAttentionColor }}; +menuIconCancelAttention: icon {{ "menu/cancel", menuIconAttentionColor }}; menuIconBlockSettings: icon {{ "menu/block", windowBgActive }}; menuIconInviteSettings: icon {{ "menu/invite", windowBgActive }}; diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 2d3e2a663..6860d3b0a 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -2608,7 +2608,9 @@ void MarkAsReadThread(not_null thread) { } void AddSeparatorAndShiftUp(const PeerMenuCallback &addAction) { - addAction({ .isSeparator = true }); + addAction({ + .separatorSt = &st::popupMenuExpandedSeparator.menu.separator, + }); const auto &st = st::popupMenuExpandedSeparator.menu; const auto shift = st::popupMenuExpandedSeparator.scrollPadding.top()