Allow opening top peers in a new window.

This commit is contained in:
John Preston 2024-04-11 18:05:51 +04:00
parent 4cdd939028
commit 3dbadeb232
6 changed files with 35 additions and 16 deletions

View file

@ -5094,8 +5094,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_recent_clear" = "Clear"; "lng_recent_clear" = "Clear";
"lng_recent_clear_sure" = "Do you want to clear your search history?"; "lng_recent_clear_sure" = "Do you want to clear your search history?";
"lng_recent_remove" = "Remove from Recent"; "lng_recent_remove" = "Remove from Recent";
"lng_recent_hide_top" = "Hide all"; "lng_recent_hide_top" = "Remove all & Disable";
"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_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"; "lng_recent_hide_button" = "Hide";
// Wnd specific // Wnd specific

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "dialogs/dialogs_widget.h" #include "dialogs/dialogs_widget.h"
#include "base/qt/qt_key_modifiers.h"
#include "base/options.h" #include "base/options.h"
#include "dialogs/ui/dialogs_stories_content.h" #include "dialogs/ui/dialogs_stories_content.h"
#include "dialogs/ui/dialogs_stories_list.h" #include "dialogs/ui/dialogs_stories_list.h"
@ -1123,7 +1124,12 @@ void Widget::updateSuggestions(anim::type animated) {
_suggestions->topPeerChosen( _suggestions->topPeerChosen(
) | rpl::start_with_next([=](PeerId id) { ) | 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->lifetime());
_suggestions->show(); _suggestions->show();

View file

@ -22,8 +22,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/wrap/vertical_layout.h" #include "ui/wrap/vertical_layout.h"
#include "ui/wrap/slide_wrap.h" #include "ui/wrap/slide_wrap.h"
#include "ui/delayed_activation.h"
#include "ui/dynamic_thumbnails.h" #include "ui/dynamic_thumbnails.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_peer_menu.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
@ -43,14 +45,11 @@ void FillTopPeerMenu(
const auto group = peer->isMegagroup(); const auto group = peer->isMegagroup();
const auto channel = peer->isChannel(); const auto channel = peer->isChannel();
add({ add(tr::lng_context_new_window(tr::now), [=] {
.text = tr::lng_recent_remove(tr::now), Ui::PreventDelayedActivation();
.handler = [=] { remove(peer); }, controller->showInNewWindow(peer);
.icon = &st::menuIconDeleteAttention, }, &st::menuIconNewWindow);
.isAttention = true, Window::AddSeparatorAndShiftUp(add);
});
add({ .separatorSt = &st::expandedMenuSeparator });
const auto showHistoryText = group const auto showHistoryText = group
? tr::lng_context_open_group(tr::now) ? tr::lng_context_open_group(tr::now)
@ -72,12 +71,25 @@ void FillTopPeerMenu(
add({ .separatorSt = &st::expandedMenuSeparator }); 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({ controller->show(Ui::MakeConfirmBox({
.text = tr::lng_recent_hide_sure(), .text = tr::lng_recent_hide_sure(),
.confirmed = [=](Fn<void()> close) { hideAll(); close(); } .confirmed = [=](Fn<void()> 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 } // namespace

View file

@ -52,8 +52,6 @@ private:
[[nodiscard]] object_ptr<Ui::RpWidget> setupDivider(); [[nodiscard]] object_ptr<Ui::RpWidget> setupDivider();
void updateControlsGeometry();
const std::unique_ptr<Ui::ElasticScroll> _scroll; const std::unique_ptr<Ui::ElasticScroll> _scroll;
const not_null<Ui::VerticalLayout*> _content; const not_null<Ui::VerticalLayout*> _content;
const not_null<Ui::SlideWrap<TopPeersStrip>*> _topPeersWrap; const not_null<Ui::SlideWrap<TopPeersStrip>*> _topPeersWrap;

View file

@ -192,6 +192,7 @@ menuIconDisableAttention: icon {{ "menu/disable", menuIconAttentionColor }};
menuIconReportAttention: icon {{ "menu/report", menuIconAttentionColor }}; menuIconReportAttention: icon {{ "menu/report", menuIconAttentionColor }};
menuIconRestoreAttention: icon {{ "menu/restore", menuIconAttentionColor }}; menuIconRestoreAttention: icon {{ "menu/restore", menuIconAttentionColor }};
menuIconTagRemoveAttention: icon {{ "menu/tag_remove", menuIconAttentionColor }}; menuIconTagRemoveAttention: icon {{ "menu/tag_remove", menuIconAttentionColor }};
menuIconCancelAttention: icon {{ "menu/cancel", menuIconAttentionColor }};
menuIconBlockSettings: icon {{ "menu/block", windowBgActive }}; menuIconBlockSettings: icon {{ "menu/block", windowBgActive }};
menuIconInviteSettings: icon {{ "menu/invite", windowBgActive }}; menuIconInviteSettings: icon {{ "menu/invite", windowBgActive }};

View file

@ -2608,7 +2608,9 @@ void MarkAsReadThread(not_null<Data::Thread*> thread) {
} }
void AddSeparatorAndShiftUp(const PeerMenuCallback &addAction) { void AddSeparatorAndShiftUp(const PeerMenuCallback &addAction) {
addAction({ .isSeparator = true }); addAction({
.separatorSt = &st::popupMenuExpandedSeparator.menu.separator,
});
const auto &st = st::popupMenuExpandedSeparator.menu; const auto &st = st::popupMenuExpandedSeparator.menu;
const auto shift = st::popupMenuExpandedSeparator.scrollPadding.top() const auto shift = st::popupMenuExpandedSeparator.scrollPadding.top()