diff --git a/Telegram/Resources/icons/top_bar_group_call.png b/Telegram/Resources/icons/top_bar_group_call.png new file mode 100644 index 0000000000..b084f255bf Binary files /dev/null and b/Telegram/Resources/icons/top_bar_group_call.png differ diff --git a/Telegram/Resources/icons/top_bar_group_call@2x.png b/Telegram/Resources/icons/top_bar_group_call@2x.png new file mode 100644 index 0000000000..12534f2247 Binary files /dev/null and b/Telegram/Resources/icons/top_bar_group_call@2x.png differ diff --git a/Telegram/Resources/icons/top_bar_group_call@3x.png b/Telegram/Resources/icons/top_bar_group_call@3x.png new file mode 100644 index 0000000000..08df3a7faa Binary files /dev/null and b/Telegram/Resources/icons/top_bar_group_call@3x.png differ 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 d57c4903b3..2fb223b15f 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -64,6 +64,7 @@ TopBarWidget::TopBarWidget( , _delete(this, tr::lng_selected_delete(), st::defaultActiveButton) , _back(this, st::historyTopBarBack) , _call(this, st::topBarCall) +, _groupCall(this, st::topBarGroupCall) , _search(this, st::topBarSearch) , _infoToggle(this, st::topBarInfo) , _menuToggle(this, st::topBarMenuToggle) @@ -83,8 +84,9 @@ TopBarWidget::TopBarWidget( _delete->setClickedCallback([=] { _deleteSelection.fire({}); }); _delete->setWidthChangedCallback([=] { updateControlsGeometry(); }); _clear->setClickedCallback([=] { _clearSelection.fire({}); }); - _call->setClickedCallback([=] { onCall(); }); - _search->setClickedCallback([=] { onSearch(); }); + _call->setClickedCallback([=] { call(); }); + _groupCall->setClickedCallback([=] { groupCall(); }); + _search->setClickedCallback([=] { search(); }); _menuToggle->setClickedCallback([=] { showMenu(); }); _infoToggle->setClickedCallback([=] { toggleInfoSection(); }); _back->addClickHandler([=] { backClicked(); }); @@ -202,21 +204,27 @@ void TopBarWidget::refreshLang() { InvokeQueued(this, [this] { updateControlsGeometry(); }); } -void TopBarWidget::onSearch() { +void TopBarWidget::search() { if (_activeChat.key) { _controller->content()->searchInChat(_activeChat.key); } } -void TopBarWidget::onCall() { +void TopBarWidget::call() { if (const auto peer = _activeChat.key.peer()) { if (const auto user = peer->asUser()) { Core::App().calls().startOutgoingCall(user, false); - } else if (const auto megagroup = peer->asMegagroup()) { + } + } +} + +void TopBarWidget::groupCall() { + if (const auto peer = _activeChat.key.peer()) { + if (const auto megagroup = peer->asMegagroup()) { if (megagroup->amAnonymous()) { Ui::ShowMultilineToast({ .text = tr::lng_group_call_no_anonymous(tr::now), - }); + }); } else if (const auto call = megagroup->call()) { Core::App().calls().joinGroupCall(megagroup, call->input()); } else { @@ -653,6 +661,7 @@ void TopBarWidget::updateControlsGeometry() { _search->moveToRight(_rightTaken, otherButtonsTop); _rightTaken += _search->width() + st::topBarCallSkip; _call->moveToRight(_rightTaken, otherButtonsTop); + _groupCall->moveToRight(_rightTaken, otherButtonsTop); _rightTaken += _call->width(); updateMembersShowArea(); @@ -713,13 +722,20 @@ void TopBarWidget::updateControlsVisibility() { if (const auto user = peer->asUser()) { return session().serverConfig().phoneCallsEnabled.current() && user->hasCalls(); - } else if (const auto megagroup = peer->asMegagroup()) { - return megagroup->canManageCall(); } } return false; }(); _call->setVisible(historyMode && callsEnabled); + const auto groupCallsEnabled = [&] { + if (const auto peer = _activeChat.key.peer()) { + if (const auto megagroup = peer->asMegagroup()) { + return megagroup->canManageCall(); + } + } + return false; + }(); + _groupCall->setVisible(historyMode && groupCallsEnabled); if (_membersShowArea) { _membersShowArea->show(); 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 988758b46d..a79b5dcc2a 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h @@ -95,8 +95,9 @@ private: void selectedShowCallback(); void updateInfoToggleActive(); - void onCall(); - void onSearch(); + void call(); + void groupCall(); + void search(); void showMenu(); void toggleInfoSection(); @@ -144,6 +145,7 @@ private: object_ptr _info = { nullptr }; object_ptr _call; + object_ptr _groupCall; object_ptr _search; object_ptr _infoToggle; object_ptr _menuToggle; diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index d311f6fe10..dcc1db0c89 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -763,6 +763,11 @@ topBarCall: IconButton(topBarSearch) { icon: icon {{ "top_bar_call", menuIconFg }}; iconOver: icon {{ "top_bar_call", menuIconFgOver }}; } +topBarGroupCall: IconButton(topBarSearch) { + icon: icon {{ "top_bar_group_call", menuIconFg }}; + iconOver: icon {{ "top_bar_group_call", menuIconFgOver }}; + iconPosition: point(8px, 15px); +} topBarInfo: IconButton(topBarSearch) { icon: icon {{ "top_bar_profile", menuIconFg }}; iconOver: icon {{ "top_bar_profile", menuIconFgOver }};