diff --git a/Telegram/Resources/icons/profile/profile_more.png b/Telegram/Resources/icons/profile/profile_more.png new file mode 100644 index 0000000000..a35e32ff95 Binary files /dev/null and b/Telegram/Resources/icons/profile/profile_more.png differ 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 0000000000..c7ceb94e58 Binary files /dev/null and b/Telegram/Resources/icons/profile/profile_more@2x.png differ 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 0000000000..3851073ed9 Binary files /dev/null and b/Telegram/Resources/icons/profile/profile_more@3x.png differ 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;