From 3e69f65d1cfba0891987b1f1ee8a5faac558f0a8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 24 Oct 2025 12:15:44 +0300 Subject: [PATCH] Moved menu toggle from top to action button in profile top bar. --- .../Resources/icons/profile/profile_more.png | Bin 0 -> 352 bytes .../icons/profile/profile_more@2x.png | Bin 0 -> 442 bytes .../icons/profile/profile_more@3x.png | Bin 0 -> 818 bytes Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/info/info.style | 13 +- .../info/profile/info_profile_top_bar.cpp | 120 +++++++----------- .../info/profile/info_profile_top_bar.h | 6 +- 7 files changed, 55 insertions(+), 85 deletions(-) create mode 100644 Telegram/Resources/icons/profile/profile_more.png create mode 100644 Telegram/Resources/icons/profile/profile_more@2x.png create mode 100644 Telegram/Resources/icons/profile/profile_more@3x.png diff --git a/Telegram/Resources/icons/profile/profile_more.png b/Telegram/Resources/icons/profile/profile_more.png new file mode 100644 index 0000000000000000000000000000000000000000..a35e32ff9580cf391e1d5d75ef69f4578ea4b32a GIT binary patch literal 352 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uv49!D1}S`GTDlfUo$_>X46zV= zJ7FVlivf?TBCn7tuZQ3U=duI_l`akLr77H6D#sSIiS7syDe2(bcdlJCuko_xy104! zdkX}9d=mfho?Bz-v&wth&PJWCU$wPvFZTf<#v=m9I8L)K%d~pGY86+nif7+r1@;5N zLTjx{lUkm$21iai;~LnoS*LqZhl+x4@Q3oA<#rdg>DFe&hOcQ5b?SNSA=IF*62&p$ z2uD7rJlEk}>pt7O|9#KW-L5Y=nPgTe~DWM4fALDM_ literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/profile/profile_more@2x.png b/Telegram/Resources/icons/profile/profile_more@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c7ceb94e5875f069f869d5b9fde5aebc2df02cf1 GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1SD@Hu6rQzZK zKQyv2%5zR&KtczebGihET>rXB=XhbyXq*51dg@`U-Mu5nMr3n8(2Kx=z$+g9pg#=jD1`9A9;ep&C}J-Wt~$(698~vop1mE literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/profile/profile_more@3x.png b/Telegram/Resources/icons/profile/profile_more@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..3851073ed9f03b47095967749bf5e3d4bd4cbe24 GIT binary patch literal 818 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1SD_us|Wxo#^NA%Cx&(BWL^R}E~ycoX}-P; zT0k}j17mw80}DtA5K93u0|WB{Mh0de%?J`(zyz1|Sip>6gA`6MbbHUhz%<9x#W5s< z_3gC%>k?icvE7v`s%Ca@42~i6svj`3*K6&8I{b?)0k+J7Jp;bSv9v`BG(fP zI$V_AJ*=_YAGhB1i?CAO&h$VT-4wCI2`b;;yxy&$=&hY2>}aU+&L7t{FAZAx`KL~|)zq@xxiWl{eU}F>4_=qJq0lk%Wx19F&tu8x{bJR7 z=WU)=SZg(xsj*>AsNVG6I^P!Gv_OGW)8%)PY-Wa@;@>){J8P?!t8b^<;#Ma|;f-G> zwXO|Xc_L?HgiGYg?5=9=?d;xalcRJWU&}D=GRoVcD#ZD6N|)j4oIL)roiS6+rxxyw zdwTbMN-yjGEv>hkYinvw6wPW{Z+GwRtd6zQ*PQ)kqnP6B`|*a8_upG)QoKJWU!C%? zBFE!b&Bll`PhT>tXOnLy@uh6Osl#*oZJF8ZyLslbBQJm4INeKiPR_%E9|aZ)yYIg@ j<=?L2z=R+DXKd8pKg~1w{Cam0PbP0l+XkKrEW!S literal 0 HcmV?d00001 diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index f98913bf9c..c217c95383 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1679,6 +1679,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_profile_action_short_join" = "Join"; "lng_profile_action_short_report" = "Report"; "lng_profile_action_short_leave" = "Leave"; +"lng_profile_action_short_more" = "More"; "lng_media_type_photos" = "Photos"; "lng_media_type_gifs" = "GIFs"; diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index 385c712062..892fb0e8b4 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -394,16 +394,6 @@ infoTopBarBlackClose: IconButton(infoTopBarClose) { iconOver: icon {{ "info/info_close", windowBoldFg }}; ripple: universalRippleAnimation; } -infoTopBarBlackMenu: IconButton(infoTopBarMenu) { - icon: icon {{ "title_menu_dots", windowBoldFg }}; - iconOver: icon {{ "title_menu_dots", windowBoldFg }}; - ripple: universalRippleAnimation; -} -infoLayerTopBarBlackMenu: IconButton(infoLayerTopBarMenu) { - icon: icon {{ "title_menu_dots", windowBoldFg }}; - iconOver: icon {{ "title_menu_dots", windowBoldFg }}; - ripple: universalRippleAnimation; -} infoTopBarBlackEdit: IconButton(infoTopBarEdit) { icon: icon {{ "menu/edit", windowBoldFg }}; iconOver: icon {{ "menu/edit", windowBoldFg }}; @@ -451,6 +441,8 @@ infoProfileTopBarStep1: infoProfileTopBarStep2 - infoProfileTopBarActionButtonsH infoProfileTopBarNoActionsHeightMax: infoProfileTopBarHeightMax - infoProfileTopBarActionButtonSize; +infoProfileTopBarActionMenuSkip: 10px; + infoProfileTopBarActionMessage: icon{{ "profile/message-22x22", windowBoldFg }}; infoProfileTopBarActionMute: icon{{ "profile/mute-22x22", windowBoldFg }}; infoProfileTopBarActionUnmute: icon{{ "profile/unmute-22x22", windowBoldFg }}; @@ -459,6 +451,7 @@ infoProfileTopBarActionGift: icon{{ "profile/gift-22x22", windowBoldFg }}; infoProfileTopBarActionJoin: icon{{ "profile/join-22x22", windowBoldFg }}; infoProfileTopBarActionReport: icon{{ "profile/report-22x22", windowBoldFg }}; infoProfileTopBarActionLeave: icon{{ "profile/leave-22x22", windowBoldFg }}; +infoProfileTopBarActionMore: icon{{ "profile/profile_more", windowBoldFg }}; infoMinimalWidth: 324px; infoDesiredWidth: 392px; diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp index cdf8b7018a..9d76d4a3e5 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp @@ -647,6 +647,26 @@ void TopBar::setupActions(not_null controller) { _actions->add(leaveButton); buttons.push_back(leaveButton); } + if ([&]() -> bool { + if (controller->wrap() == Wrap::Side) { + return false; + } + const auto guard = gsl::finally([&] { _peerMenu = nullptr; }); + showTopBarMenu(controller, true); + return _peerMenu; + }()) { + const auto navigation = controller->parentController(); + const auto moreButton = Ui::CreateChild( + this, + tr::lng_profile_action_short_more(tr::now), + st::infoProfileTopBarActionMore); + moreButton->setClickedCallback([=] { + showTopBarMenu(controller, false); + }); + _actionMore = moreButton; + _actions->add(moreButton); + buttons.push_back(moreButton); + } _edgeColor.value() | rpl::map(mapped) | rpl::start_with_next([=]( TopBarActionButtonStyle st) { for (const auto &button : buttons) { @@ -864,8 +884,8 @@ void TopBar::updateLabelsPosition() { if (_close) { rightButtonsWidth += _close->width(); } - if (_topBarMenuToggle) { - rightButtonsWidth += _topBarMenuToggle->width(); + if (_topBarButton) { + rightButtonsWidth += _topBarButton->width(); } const auto reservedRight = anim::interpolate( @@ -1178,67 +1198,18 @@ void TopBar::setupButtons( } if (wrap != Wrap::Side) { - if (source == Source::Profile) { - addTopBarMenuButton(controller, wrap, shouldUseColored); - } else if (source == Source::Stories) { + if (source == Source::Stories) { addTopBarEditButton(controller, wrap, shouldUseColored); } } }, lifetime()); } -void TopBar::addTopBarMenuButton( - not_null controller, - Wrap wrap, - bool shouldUseColored) { - { - const auto guard = gsl::finally([&] { _topBarMenu = nullptr; }); - showTopBarMenu(controller, true); - if (!_topBarMenu) { - return; - } - } - _topBarMenuToggle = base::make_unique_q( - this, - ((wrap == Wrap::Layer) - ? (shouldUseColored - ? st::infoLayerTopBarColoredMenu - : st::infoLayerTopBarBlackMenu) - : (shouldUseColored - ? st::infoTopBarColoredMenu - : st::infoTopBarBlackMenu))); - _topBarMenuToggle->show(); - _topBarMenuToggle->addClickHandler([=] { - showTopBarMenu(controller, false); - }); - - widthValue() | rpl::start_with_next([=] { - if (_close) { - _topBarMenuToggle->moveToRight(_close->width(), 0); - } else { - _topBarMenuToggle->moveToRight(0, 0); - } - }, _topBarMenuToggle->lifetime()); - - Shortcuts::Requests( - ) | rpl::filter([=] { - return (controller->section().type() == Section::Type::Profile); - }) | rpl::start_with_next([=](not_null request) { - using Command = Shortcuts::Command; - - request->check(Command::ShowChatMenu, 1) && request->handle([=] { - Window::ActivateWindow(controller->parentController()); - showTopBarMenu(controller, false); - return true; - }); - }, _topBarMenuToggle->lifetime()); -} - void TopBar::addTopBarEditButton( not_null controller, Wrap wrap, bool shouldUseColored) { - _topBarMenuToggle = base::make_unique_q( + _topBarButton = base::make_unique_q( this, ((wrap == Wrap::Layer) ? (shouldUseColored @@ -1247,51 +1218,54 @@ void TopBar::addTopBarEditButton( : (shouldUseColored ? st::infoTopBarColoredEdit : st::infoTopBarBlackEdit))); - _topBarMenuToggle->show(); - _topBarMenuToggle->addClickHandler([=] { + _topBarButton->show(); + _topBarButton->addClickHandler([=] { controller->showSettings(::Settings::Information::Id()); }); widthValue() | rpl::start_with_next([=] { if (_close) { - _topBarMenuToggle->moveToRight(_close->width(), 0); + _topBarButton->moveToRight(_close->width(), 0); } else { - _topBarMenuToggle->moveToRight(0, 0); + _topBarButton->moveToRight(0, 0); } - }, _topBarMenuToggle->lifetime()); + }, _topBarButton->lifetime()); } void TopBar::showTopBarMenu( not_null controller, bool check) { - if (_topBarMenu) { - _topBarMenu->hideMenu(true); + if (_peerMenu) { + _peerMenu->hideMenu(true); return; } - _topBarMenu = base::make_unique_q( + _peerMenu = base::make_unique_q( QWidget::window(), st::popupMenuExpandedSeparator); - _topBarMenu->setDestroyedCallback([this] { - InvokeQueued(this, [this] { _topBarMenu = nullptr; }); - if (auto toggle = _topBarMenuToggle.get()) { - toggle->setForceRippled(false); - } + _peerMenu->setDestroyedCallback([this] { + InvokeQueued(this, [this] { _peerMenu = nullptr; }); + // if (auto toggle = _topBarMenuToggle.get()) { + // toggle->setForceRippled(false); + // } }); fillTopBarMenu( controller, - Ui::Menu::CreateAddActionCallback(_topBarMenu)); - if (_topBarMenu->empty()) { - _topBarMenu = nullptr; + Ui::Menu::CreateAddActionCallback(_peerMenu)); + if (_peerMenu->empty()) { + _peerMenu = nullptr; return; } else if (check) { return; } - _topBarMenu->setForcedOrigin(Ui::PanelAnimation::Origin::TopRight); - _topBarMenuToggle->setForceRippled(true); - _topBarMenu->popup(_topBarMenuToggle->mapToGlobal( - st::infoLayerTopBarMenuPosition)); + _peerMenu->setForcedOrigin(Ui::PanelAnimation::Origin::TopRight); + _peerMenu->popup(_actionMore + ? _actionMore->mapToGlobal( + QPoint( + _actionMore->width(), + _actionMore->height() + st::infoProfileTopBarActionMenuSkip)) + : QCursor::pos()); } void TopBar::fillTopBarMenu( diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h index dc61d465a7..6d21201d56 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h @@ -226,8 +226,10 @@ private: base::unique_qptr _close; base::unique_qptr> _back; - base::unique_qptr _topBarMenuToggle; - base::unique_qptr _topBarMenu; + base::unique_qptr _topBarButton; + base::unique_qptr _peerMenu; + + Ui::RpWidget *_actionMore = nullptr; base::unique_qptr _userpicButton;