diff --git a/Telegram/Resources/icons/menu/start_stream.png b/Telegram/Resources/icons/menu/start_stream.png new file mode 100644 index 000000000..a227d9b26 Binary files /dev/null and b/Telegram/Resources/icons/menu/start_stream.png differ diff --git a/Telegram/Resources/icons/menu/start_stream@2x.png b/Telegram/Resources/icons/menu/start_stream@2x.png new file mode 100644 index 000000000..cd079f659 Binary files /dev/null and b/Telegram/Resources/icons/menu/start_stream@2x.png differ diff --git a/Telegram/Resources/icons/menu/start_stream@3x.png b/Telegram/Resources/icons/menu/start_stream@3x.png new file mode 100644 index 000000000..314aae9fe Binary files /dev/null and b/Telegram/Resources/icons/menu/start_stream@3x.png differ diff --git a/Telegram/Resources/icons/menu/start_stream_with.png b/Telegram/Resources/icons/menu/start_stream_with.png new file mode 100644 index 000000000..d6115a134 Binary files /dev/null and b/Telegram/Resources/icons/menu/start_stream_with.png differ diff --git a/Telegram/Resources/icons/menu/start_stream_with@2x.png b/Telegram/Resources/icons/menu/start_stream_with@2x.png new file mode 100644 index 000000000..be9c9ab1f Binary files /dev/null and b/Telegram/Resources/icons/menu/start_stream_with@2x.png differ diff --git a/Telegram/Resources/icons/menu/start_stream_with@3x.png b/Telegram/Resources/icons/menu/start_stream_with@3x.png new file mode 100644 index 000000000..c0c346114 Binary files /dev/null and b/Telegram/Resources/icons/menu/start_stream_with@3x.png differ diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 06fe5d795..3f8fe10b0 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2381,6 +2381,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_group_call_join_as_changed" = "Members of this voice chat will now see you as {name}"; "lng_group_call_join_as_changed_channel" = "Members of this live stream will now see you as {name}"; +"lng_menu_start_group_call" = "Start live stream"; +"lng_menu_start_group_call_scheduled" = "Schedule live stream"; +"lng_menu_start_group_call_with" = "Stream with..."; + "lng_group_call_rtmp_title" = "Stream with other apps"; "lng_group_call_rtmp_url_subtitle" = "Server URL"; "lng_group_call_rtmp_url_copy" = "Copy Server URL"; diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index f88e2d787..080f6cf17 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -63,6 +63,13 @@ namespace { constexpr auto kEmojiInteractionSeenDuration = 3 * crl::time(1000); +inline bool HasGroupCallMenu(const not_null &peer) { + return !peer->groupCall() + && peer->isChannel() + && !peer->isMegagroup() + && peer->asChannel()->amCreator(); +} + } // namespace struct TopBarWidget::EmojiInteractionSeenAnimation { @@ -240,7 +247,11 @@ void TopBarWidget::call() { void TopBarWidget::groupCall() { if (const auto peer = _activeChat.key.peer()) { - _controller->startOrJoinGroupCall(peer, {}); + if (HasGroupCallMenu(peer)) { + showGroupCallMenu(peer); + } else { + _controller->startOrJoinGroupCall(peer, {}); + } } } @@ -272,34 +283,39 @@ void TopBarWidget::setChooseForReportReason( : style::cur_default); } -bool TopBarWidget::createMenu() { +bool TopBarWidget::createMenu(not_null button) { if (!_activeChat.key || _menu) { return false; } _menu.create(parentWidget(), st::dropdownMenuWithIcons); - _menu->setHiddenCallback([weak = Ui::MakeWeak(this), menu = _menu.data()]{ + _menu->setHiddenCallback([ + weak = Ui::MakeWeak(this), + weakButton = Ui::MakeWeak(button), + menu = _menu.data()] { menu->deleteLater(); if (weak && weak->_menu == menu) { weak->_menu = nullptr; - weak->_menuToggle->setForceRippled(false); + if (weakButton) { + weakButton->setForceRippled(false); + } } }); - _menu->setShowStartCallback(crl::guard(this, [this, menu = _menu.data()]{ + _menu->setShowStartCallback(crl::guard(this, [=, menu = _menu.data()] { if (_menu == menu) { - _menuToggle->setForceRippled(true); + button->setForceRippled(true); } })); - _menu->setHideStartCallback(crl::guard(this, [this, menu = _menu.data()]{ + _menu->setHideStartCallback(crl::guard(this, [=, menu = _menu.data()] { if (_menu == menu) { - _menuToggle->setForceRippled(false); + button->setForceRippled(false); } })); - _menuToggle->installEventFilter(_menu); + button->installEventFilter(_menu); return true; } void TopBarWidget::showPeerMenu() { - const auto created = createMenu(); + const auto created = createMenu(_menuToggle); if (!created) { return; } @@ -320,6 +336,37 @@ void TopBarWidget::showPeerMenu() { } } +void TopBarWidget::showGroupCallMenu(not_null peer) { + const auto created = createMenu(_groupCall); + if (!created) { + return; + } + const auto controller = _controller; + const auto callback = [=](Calls::StartGroupCallArgs &&args) { + controller->startOrJoinGroupCall(peer, std::move(args)); + }; + _menu->addAction( + tr::lng_menu_start_group_call(tr::now), + [=] { callback({}); }, + &st::menuIconStartStream); + _menu->addAction( + tr::lng_menu_start_group_call_scheduled(tr::now), + [=] { callback({ .scheduleNeeded = true }); }, + &st::menuIconReschedule); + _menu->addAction( + tr::lng_menu_start_group_call_with(tr::now), + [=] { callback({ .rtmpNeeded = true }); }, + &st::menuIconStartStreamWith); + _menu->moveToRight( + (parentWidget()->width() - width()) + + (width() + - _groupCall->x() + - _groupCall->width() + - st::topBarMenuGroupCallSkip), + st::topBarMenuPosition.y()); + _menu->showAnimated(Ui::PanelAnimation::Origin::TopRight); +} + void TopBarWidget::toggleInfoSection() { const auto isThreeColumn = _controller->adaptive().isThreeColumn(); if (isThreeColumn diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h index bf186d2f2..edd8b00ce 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h @@ -110,9 +110,10 @@ private: void startGroupCall(not_null megagroup, bool confirmed); void search(); void showPeerMenu(); + void showGroupCallMenu(not_null peer); void toggleInfoSection(); - [[nodiscard]] bool createMenu(); + [[nodiscard]] bool createMenu(not_null button); void handleEmojiInteractionSeen(const QString &emoticon); bool paintSendAction( diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index da66567bb..b382b88d3 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -664,6 +664,7 @@ historyTopBarBack: IconButton(infoTopBarBack) { } topBarHeight: 54px; topBarMenuPosition: point(-2px, 35px); +topBarMenuGroupCallSkip: 40px; topBarDuration: 200; topBarBackward: icon {{ "title_back", menuIconFg }}; topBarForwardAlpha: 0.6; diff --git a/Telegram/SourceFiles/ui/menu_icons.style b/Telegram/SourceFiles/ui/menu_icons.style index 640369907..017f5c015 100644 --- a/Telegram/SourceFiles/ui/menu_icons.style +++ b/Telegram/SourceFiles/ui/menu_icons.style @@ -97,3 +97,6 @@ mediaMenuIconCopy: icon {{ "menu/copy", mediaviewMenuFg }}; mediaMenuIconForward: icon {{ "menu/forward", mediaviewMenuFg }}; mediaMenuIconDelete: icon {{ "menu/delete", mediaviewMenuFg }}; mediaMenuIconShowAll: icon {{ "menu/all_media", mediaviewMenuFg }}; + +menuIconStartStream: icon {{ "menu/start_stream", menuIconColor }}; +menuIconStartStreamWith: icon {{ "menu/start_stream_with", menuIconColor }};