diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index e34c4a29f..37b7de590 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -270,6 +270,8 @@ PRIVATE calls/calls_group_common.h calls/calls_group_members.cpp calls/calls_group_members.h + calls/calls_group_menu.cpp + calls/calls_group_menu.h calls/calls_group_panel.cpp calls/calls_group_panel.h calls/calls_group_settings.cpp diff --git a/Telegram/SourceFiles/calls/calls.style b/Telegram/SourceFiles/calls/calls.style index ec36dfa2b..8c48427d2 100644 --- a/Telegram/SourceFiles/calls/calls.style +++ b/Telegram/SourceFiles/calls/calls.style @@ -407,7 +407,7 @@ groupCallMenu: Menu(defaultMenu) { itemFgShortcutOver: groupCallMemberNotJoinedStatus; itemFgShortcutDisabled: groupCallMemberNotJoinedStatus; - separatorFg: groupCallMemberNotJoinedStatus; + separatorFg: groupCallMenuBgOver; arrow: icon {{ "dropdown_submenu_arrow", groupCallMemberNotJoinedStatus }}; diff --git a/Telegram/SourceFiles/calls/calls_choose_join_as.cpp b/Telegram/SourceFiles/calls/calls_choose_join_as.cpp index 4acc8628a..2a4620764 100644 --- a/Telegram/SourceFiles/calls/calls_choose_join_as.cpp +++ b/Telegram/SourceFiles/calls/calls_choose_join_as.cpp @@ -147,7 +147,10 @@ void ChooseJoinAsBox( style::margins()); delegate->setContent(content); controller->setDelegate(delegate); - box->addButton(tr::lng_continue(), [=] { + auto next = (context == Context::Switch) + ? tr::lng_settings_save() + : tr::lng_continue(); + box->addButton(std::move(next), [=] { auto copy = info; copy.joinAs = controller->selected(); done(std::move(copy)); @@ -230,8 +233,7 @@ void ChooseJoinAsProcess::start( return list; }); if (list.empty()) { - // #TODO calls in case of anonymous group admin show lng_group_call_no_anonymous - _request->showToast("No way to join this voice chat :("); + _request->showToast(Lang::Hard::ServerError()); return; } else if (list.size() == 1 && list.front() == self diff --git a/Telegram/SourceFiles/calls/calls_group_call.cpp b/Telegram/SourceFiles/calls/calls_group_call.cpp index 05c6a3e48..4e6f5deb9 100644 --- a/Telegram/SourceFiles/calls/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/calls_group_call.cpp @@ -313,6 +313,12 @@ void GroupCall::playConnectingSoundOnce() { _delegate->groupCallPlaySound(Delegate::GroupCallSound::Connecting); } +bool GroupCall::showChooseJoinAs() const { + return (_possibleJoinAs.size() > 1) + || (_possibleJoinAs.size() == 1 + && !_possibleJoinAs.front()->isSelf()); +} + void GroupCall::start() { _createRequestId = _api.request(MTPphone_CreateGroupCall( _peer->input, diff --git a/Telegram/SourceFiles/calls/calls_group_call.h b/Telegram/SourceFiles/calls/calls_group_call.h index 8e30dfb1c..0571d1787 100644 --- a/Telegram/SourceFiles/calls/calls_group_call.h +++ b/Telegram/SourceFiles/calls/calls_group_call.h @@ -107,10 +107,7 @@ public: [[nodiscard]] not_null joinAs() const { return _joinAs; } - [[nodiscard]] auto possibleJoinAs() const - -> const std::vector>& { - return _possibleJoinAs; - } + [[nodiscard]] bool showChooseJoinAs() const; void start(); void hangup(); diff --git a/Telegram/SourceFiles/calls/calls_group_members.cpp b/Telegram/SourceFiles/calls/calls_group_members.cpp index 7f826e59e..70253264b 100644 --- a/Telegram/SourceFiles/calls/calls_group_members.cpp +++ b/Telegram/SourceFiles/calls/calls_group_members.cpp @@ -1838,12 +1838,6 @@ rpl::producer GroupMembers::fullCountValue() const { _listController.get())->fullCountValue(); } -//tr::lng_chat_status_members( -// lt_count_decimal, -// controller->fullCountValue() | tr::to_count(), -// Ui::Text::Upper -//), - void GroupMembers::setupList() { _listController->setStyleOverrides(&st::groupCallMembersList); _list = _scroll->setOwnedWidget(object_ptr( diff --git a/Telegram/SourceFiles/calls/calls_group_menu.cpp b/Telegram/SourceFiles/calls/calls_group_menu.cpp new file mode 100644 index 000000000..426f40c6e --- /dev/null +++ b/Telegram/SourceFiles/calls/calls_group_menu.cpp @@ -0,0 +1,291 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "calls/calls_group_menu.h" + +#include "calls/calls_group_call.h" +#include "calls/calls_group_settings.h" +#include "calls/calls_group_panel.h" +#include "data/data_peer.h" +#include "data/data_group_call.h" +#include "ui/widgets/dropdown_menu.h" +#include "ui/widgets/labels.h" +#include "ui/widgets/checkbox.h" +#include "ui/widgets/input_fields.h" +#include "ui/layers/generic_box.h" +#include "lang/lang_keys.h" +#include "base/unixtime.h" +#include "base/timer_rpl.h" +#include "styles/style_calls.h" +#include "styles/style_layers.h" +#include "styles/style_boxes.h" + +namespace Calls::Group { +namespace { + +void EditGroupCallTitleBox( + not_null box, + const QString &placeholder, + const QString &title, + Fn done) { + box->setTitle(tr::lng_group_call_edit_title()); + const auto input = box->addRow(object_ptr( + box, + st::groupCallField, + rpl::single(placeholder), + title)); + box->setFocusCallback([=] { + input->setFocusFast(); + }); + box->addButton(tr::lng_settings_save(), [=] { + const auto result = input->getLastText().trimmed(); + box->closeBox(); + done(result); + }); + box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); +} + +void StartGroupCallRecordingBox( + not_null box, + const QString &title, + Fn done) { + box->setTitle(tr::lng_group_call_recording_start()); + + box->addRow( + object_ptr( + box.get(), + tr::lng_group_call_recording_start_sure(), + st::groupCallBoxLabel)); + + const auto input = box->addRow(object_ptr( + box, + st::groupCallField, + tr::lng_group_call_recording_start_field(), + title)); + box->setFocusCallback([=] { + input->setFocusFast(); + }); + box->addButton(tr::lng_group_call_recording_start_button(), [=] { + const auto result = input->getLastText().trimmed(); + if (result.isEmpty()) { + input->showError(); + return; + } + box->closeBox(); + done(result); + }); + box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); +} + +void StopGroupCallRecordingBox( + not_null box, + Fn done) { + box->addRow( + object_ptr( + box.get(), + tr::lng_group_call_recording_stop_sure(), + st::groupCallBoxLabel), + style::margins( + st::boxRowPadding.left(), + st::boxPadding.top(), + st::boxRowPadding.right(), + st::boxPadding.bottom())); + + box->addButton(tr::lng_box_ok(), [=] { + box->closeBox(); + done(QString()); + }); + box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); +} + +[[nodiscard]] auto ToDurationFrom(TimeId startDate) { + return [=] { + const auto now = base::unixtime::now(); + const auto elapsed = std::max(now - startDate, 0); + const auto hours = elapsed / 3600; + const auto minutes = (elapsed % 3600) / 60; + const auto seconds = (elapsed % 60); + return hours + ? QString("%1:%2:%3" + ).arg(hours + ).arg(minutes, 2, 10, QChar('0') + ).arg(seconds, 2, 10, QChar('0')) + : QString("%1:%2" + ).arg(minutes + ).arg(seconds, 2, 10, QChar('0')); + }; +} + +[[nodiscard]] rpl::producer ToRecordDuration(TimeId startDate) { + return !startDate + ? (rpl::single(QString()) | rpl::type_erased()) + : rpl::single( + rpl::empty_value() + ) | rpl::then(base::timer_each( + crl::time(1000) + )) | rpl::map(ToDurationFrom(startDate)); +} + +} // namespace + +void LeaveBox( + not_null box, + not_null call, + bool discardChecked, + BoxContext context) { + box->setTitle(tr::lng_group_call_leave_title()); + const auto inCall = (context == BoxContext::GroupCallPanel); + box->addRow(object_ptr( + box.get(), + tr::lng_group_call_leave_sure(), + (inCall ? st::groupCallBoxLabel : st::boxLabel))); + const auto discard = call->peer()->canManageGroupCall() + ? box->addRow(object_ptr( + box.get(), + tr::lng_group_call_end(), + discardChecked, + (inCall ? st::groupCallCheckbox : st::defaultBoxCheckbox), + (inCall ? st::groupCallCheck : st::defaultCheck)), + style::margins( + st::boxRowPadding.left(), + st::boxRowPadding.left(), + st::boxRowPadding.right(), + st::boxRowPadding.bottom())) + : nullptr; + const auto weak = base::make_weak(call.get()); + box->addButton(tr::lng_group_call_leave(), [=] { + const auto discardCall = (discard && discard->checked()); + box->closeBox(); + + if (!weak) { + return; + } else if (discardCall) { + call->discard(); + } else { + call->hangup(); + } + }); + box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); +} + +void ConfirmBox( + not_null box, + const QString &text, + rpl::producer button, + Fn callback) { + box->addRow( + object_ptr( + box.get(), + text, + st::groupCallBoxLabel), + st::boxPadding); + box->addButton(std::move(button), callback); + box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); +} + +void FillMenu( + not_null menu, + not_null peer, + not_null call, + Fn chooseJoinAs, + Fn)> showBox) { + const auto weak = base::make_weak(call.get()); + const auto resolveReal = [=] { + const auto real = peer->groupCall(); + const auto strong = weak.get(); + return (real && strong && (real->id() == strong->id())) + ? real + : nullptr; + }; + const auto real = resolveReal(); + if (!real) { + return; + } + + const auto addEditJoinAs = call->showChooseJoinAs(); + const auto addEditTitle = peer->canManageGroupCall(); + const auto addEditRecording = peer->canManageGroupCall(); + if (addEditJoinAs) { + menu->addAction( + tr::lng_group_call_display_as_header(tr::now), + chooseJoinAs); + menu->addSeparator(); + } + if (addEditTitle) { + menu->addAction(tr::lng_group_call_edit_title(tr::now), [=] { + const auto done = [=](const QString &title) { + if (const auto strong = weak.get()) { + strong->changeTitle(title); + } + }; + if (const auto real = resolveReal()) { + showBox(Box( + EditGroupCallTitleBox, + peer->name, + real->title(), + done)); + } + }); + } + if (addEditRecording) { + const auto label = (real->recordStartDate() != 0) + ? tr::lng_group_call_recording_stop(tr::now) + : tr::lng_group_call_recording_start(tr::now); + const auto action = menu->addAction(label, [=] { + const auto real = resolveReal(); + if (!real) { + return; + } + const auto recordStartDate = real->recordStartDate(); + const auto done = [=](QString title) { + if (const auto strong = weak.get()) { + strong->toggleRecording(!recordStartDate, title); + } + }; + if (recordStartDate) { + showBox(Box( + StopGroupCallRecordingBox, + done)); + } else { + showBox(Box( + StartGroupCallRecordingBox, + real->title(), + done)); + } + }); + rpl::combine( + real->recordStartDateValue(), + tr::lng_group_call_recording_stop(), + tr::lng_group_call_recording_start() + ) | rpl::map([=](TimeId startDate, QString stop, QString start) { + using namespace rpl::mappers; + return startDate + ? ToRecordDuration( + startDate + ) | rpl::map(stop + '\t' + _1) : rpl::single(start); + }) | rpl::flatten_latest() | rpl::start_with_next([=](QString text) { + action->setText(text); + }, menu->lifetime()); + } + menu->addAction(tr::lng_group_call_settings(tr::now), [=] { + if (const auto strong = weak.get()) { + showBox(Box(SettingsBox, strong)); + } + }); + menu->addAction(tr::lng_group_call_end(tr::now), [=] { + if (const auto strong = weak.get()) { + showBox(Box( + LeaveBox, + strong, + true, + BoxContext::GroupCallPanel)); + } + }); + +} + +} // namespace Calls::Group diff --git a/Telegram/SourceFiles/calls/calls_group_menu.h b/Telegram/SourceFiles/calls/calls_group_menu.h new file mode 100644 index 000000000..ac306dea6 --- /dev/null +++ b/Telegram/SourceFiles/calls/calls_group_menu.h @@ -0,0 +1,48 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +#include "base/object_ptr.h" + +namespace Ui { +class DropdownMenu; +class GenericBox; +class BoxContent; +} // namespace Ui + +namespace Calls { +class GroupCall; +} // namespace Calls + +namespace Calls::Group { + +enum class BoxContext { + GroupCallPanel, + MainWindow, +}; + +void LeaveBox( + not_null box, + not_null call, + bool discardChecked, + BoxContext context); + +void ConfirmBox( + not_null box, + const QString &text, + rpl::producer button, + Fn callback); + +void FillMenu( + not_null menu, + not_null peer, + not_null call, + Fn chooseJoinAs, + Fn)> showBox); + +} // namespace Calls::Group diff --git a/Telegram/SourceFiles/calls/calls_group_panel.cpp b/Telegram/SourceFiles/calls/calls_group_panel.cpp index 449b97d32..7c191e217 100644 --- a/Telegram/SourceFiles/calls/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_group_panel.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "calls/calls_group_common.h" #include "calls/calls_group_members.h" #include "calls/calls_group_settings.h" +#include "calls/calls_group_menu.h" #include "ui/platform/ui_platform_window_title.h" #include "ui/widgets/buttons.h" #include "ui/widgets/window.h" @@ -34,8 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_changes.h" #include "main/main_session.h" #include "base/event_filter.h" -#include "base/unixtime.h" -#include "base/timer_rpl.h" #include "boxes/peers/edit_participants_box.h" #include "boxes/peers/add_participants_box.h" #include "boxes/peer_lists_box.h" @@ -142,81 +141,6 @@ private: return result; } -void EditGroupCallTitleBox( - not_null box, - const QString &placeholder, - const QString &title, - Fn done) { - box->setTitle(tr::lng_group_call_edit_title()); - const auto input = box->addRow(object_ptr( - box, - st::groupCallField, - rpl::single(placeholder), - title)); - box->setFocusCallback([=] { - input->setFocusFast(); - }); - box->addButton(tr::lng_settings_save(), [=] { - const auto result = input->getLastText().trimmed(); - box->closeBox(); - done(result); - }); - box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); -} - -void StartGroupCallRecordingBox( - not_null box, - const QString &title, - Fn done) { - box->setTitle(tr::lng_group_call_recording_start()); - - box->addRow( - object_ptr( - box.get(), - tr::lng_group_call_recording_start_sure(), - st::groupCallBoxLabel)); - - const auto input = box->addRow(object_ptr( - box, - st::groupCallField, - tr::lng_group_call_recording_start_field(), - title)); - box->setFocusCallback([=] { - input->setFocusFast(); - }); - box->addButton(tr::lng_group_call_recording_start_button(), [=] { - const auto result = input->getLastText().trimmed(); - if (result.isEmpty()) { - input->showError(); - return; - } - box->closeBox(); - done(result); - }); - box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); -} - -void StopGroupCallRecordingBox( - not_null box, - Fn done) { - box->addRow( - object_ptr( - box.get(), - tr::lng_group_call_recording_stop_sure(), - st::groupCallBoxLabel), - style::margins( - st::boxRowPadding.left(), - st::boxPadding.top(), - st::boxRowPadding.right(), - st::boxPadding.bottom())); - - box->addButton(tr::lng_box_ok(), [=] { - box->closeBox(); - done(QString()); - }); - box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); -} - InviteController::InviteController( not_null peer, base::flat_set> alreadyIn) @@ -322,61 +246,6 @@ std::unique_ptr InviteContactsController::createRow( } // namespace -void LeaveGroupCallBox( - not_null box, - not_null call, - bool discardChecked, - BoxContext context) { - box->setTitle(tr::lng_group_call_leave_title()); - const auto inCall = (context == BoxContext::GroupCallPanel); - box->addRow(object_ptr( - box.get(), - tr::lng_group_call_leave_sure(), - (inCall ? st::groupCallBoxLabel : st::boxLabel))); - const auto discard = call->peer()->canManageGroupCall() - ? box->addRow(object_ptr( - box.get(), - tr::lng_group_call_end(), - discardChecked, - (inCall ? st::groupCallCheckbox : st::defaultBoxCheckbox), - (inCall ? st::groupCallCheck : st::defaultCheck)), - style::margins( - st::boxRowPadding.left(), - st::boxRowPadding.left(), - st::boxRowPadding.right(), - st::boxRowPadding.bottom())) - : nullptr; - const auto weak = base::make_weak(call.get()); - box->addButton(tr::lng_group_call_leave(), [=] { - const auto discardCall = (discard && discard->checked()); - box->closeBox(); - - if (!weak) { - return; - } else if (discardCall) { - call->discard(); - } else { - call->hangup(); - } - }); - box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); -} - -void GroupCallConfirmBox( - not_null box, - const QString &text, - rpl::producer button, - Fn callback) { - box->addRow( - object_ptr( - box.get(), - text, - st::groupCallBoxLabel), - st::boxPadding); - box->addButton(std::move(button), callback); - box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); -} - GroupPanel::GroupPanel(not_null call) : _call(call) , _peer(call->peer()) @@ -540,10 +409,10 @@ void GroupPanel::endCall() { return; } _layerBg->showBox(Box( - LeaveGroupCallBox, + Group::LeaveBox, _call, false, - BoxContext::GroupCallPanel)); + Group::BoxContext::GroupCallPanel)); } void GroupPanel::initControls() { @@ -565,7 +434,7 @@ void GroupPanel::initControls() { _hangup->setClickedCallback([=] { endCall(); }); _settings->setClickedCallback([=] { if (_call) { - _layerBg->showBox(Box(GroupCallSettingsBox, _call)); + _layerBg->showBox(Box(Group::SettingsBox, _call)); } }); @@ -716,8 +585,7 @@ void GroupPanel::subscribeToChanges(not_null real) { validateRecordingMark(real->recordStartDate() != 0); const auto showMenu = _peer->canManageGroupCall(); - const auto showUserpic = !showMenu - && (_call->possibleJoinAs().size() > 1); // #TODO calls when to show + const auto showUserpic = !showMenu && _call->showChooseJoinAs(); if (showMenu) { _joinAsToggle.destroy(); if (!_menuToggle) { @@ -775,11 +643,17 @@ void GroupPanel::chooseJoinAs() { } void GroupPanel::showMainMenu() { - const auto real = _peer->groupCall(); - if (_menu || !_call || !real || real->id() != _call->id()) { + if (_menu || !_call) { return; } _menu.create(widget(), st::groupCallDropdownMenu); + Group::FillMenu( + _menu.data(), + _peer, + _call, + [=] { chooseJoinAs(); }, + [=](auto box) { _layerBg->showBox(std::move(box)); }); + const auto raw = _menu.data(); raw->setHiddenCallback([=] { raw->deleteLater(); @@ -800,109 +674,6 @@ void GroupPanel::showMainMenu() { }); _menuToggle->installEventFilter(_menu); - const auto addEditJoinAs = (_call->possibleJoinAs().size() > 1); // #TODO calls when to show - const auto addEditTitle = _peer->canManageGroupCall(); - const auto addEditRecording = _peer->canManageGroupCall(); - if (addEditJoinAs) { - _menu->addAction(tr::lng_group_call_display_as_header(tr::now), [=] { - chooseJoinAs(); - }); - } - if (addEditTitle) { - _menu->addAction(tr::lng_group_call_edit_title(tr::now), [=] { - const auto done = [=](const QString &title) { - if (_call) { - _call->changeTitle(title); - } - }; - _layerBg->showBox(Box( - EditGroupCallTitleBox, - _peer->name, - real->title(), - done)); - }); - } - if (addEditRecording) { - const auto action = _menu->addAction((real->recordStartDate() != 0) - ? tr::lng_group_call_recording_stop(tr::now) - : tr::lng_group_call_recording_start(tr::now), [=] { - const auto real = _peer->groupCall(); - const auto id = _call ? _call->id() : 0; - if (!real || real->id() != id) { - return; - } - const auto recordStartDate = real->recordStartDate(); - const auto done = [=](QString title) { - if (_call) { - _call->toggleRecording(!recordStartDate, title); - } - }; - if (recordStartDate) { - _layerBg->showBox(Box( - StopGroupCallRecordingBox, - done)); - } else { - _layerBg->showBox(Box( - StartGroupCallRecordingBox, - real->title(), - done)); - } - }); - static const auto ToDurationFrom = [](TimeId startDate) { - return [=] { - const auto now = base::unixtime::now(); - const auto elapsed = std::max(now - startDate, 0); - const auto hours = elapsed / 3600; - const auto minutes = (elapsed % 3600) / 60; - const auto seconds = (elapsed % 60); - return hours - ? QString("%1:%2:%3" - ).arg(hours - ).arg(minutes, 2, 10, QChar('0') - ).arg(seconds, 2, 10, QChar('0')) - : QString("%1:%2" - ).arg(minutes - ).arg(seconds, 2, 10, QChar('0')); - }; - }; - static const auto ToRecordDuration = [](TimeId startDate) { - return !startDate - ? (rpl::single(QString()) | rpl::type_erased()) - : rpl::single( - rpl::empty_value() - ) | rpl::then(base::timer_each( - crl::time(1000) - )) | rpl::map(ToDurationFrom(startDate)); - }; - rpl::combine( - real->recordStartDateValue(), - tr::lng_group_call_recording_stop(), - tr::lng_group_call_recording_start() - ) | rpl::map([=](TimeId startDate, QString stop, QString start) { - using namespace rpl::mappers; - return startDate - ? ToRecordDuration( - startDate - ) | rpl::map(stop + '\t' + _1) : rpl::single(start); - }) | rpl::flatten_latest() | rpl::start_with_next([=](QString text) { - action->setText(text); - }, _menu->lifetime()); - } - _menu->addAction(tr::lng_group_call_settings(tr::now), [=] { - if (_call) { - _layerBg->showBox(Box(GroupCallSettingsBox, _call)); - } - }); - _menu->addAction(tr::lng_group_call_end(tr::now), [=] { - if (_call) { - _layerBg->showBox(Box( - LeaveGroupCallBox, - _call, - true, - BoxContext::GroupCallPanel)); - } - }); - const auto x = st::groupCallMenuPosition.x(); const auto y = st::groupCallMenuPosition.y(); if (_menuToggle->x() > widget()->width() / 2) { @@ -1014,7 +785,7 @@ void GroupPanel::addMembers() { finish(); }; auto box = Box( - GroupCallConfirmBox, + Group::ConfirmBox, text, tr::lng_participant_invite(), [=] { inviteWithAdd(users, nonMembers, finishWithConfirm); }); diff --git a/Telegram/SourceFiles/calls/calls_group_panel.h b/Telegram/SourceFiles/calls/calls_group_panel.h index 85fe6fe69..8adc64513 100644 --- a/Telegram/SourceFiles/calls/calls_group_panel.h +++ b/Telegram/SourceFiles/calls/calls_group_panel.h @@ -55,17 +55,6 @@ class SignalBars; class GroupMembers; -enum class BoxContext { - GroupCallPanel, - MainWindow, -}; - -void LeaveGroupCallBox( - not_null box, - not_null call, - bool discardChecked, - BoxContext context); - class GroupPanel final { public: GroupPanel(not_null call); diff --git a/Telegram/SourceFiles/calls/calls_group_settings.cpp b/Telegram/SourceFiles/calls/calls_group_settings.cpp index c03c9bb8b..42d7c9993 100644 --- a/Telegram/SourceFiles/calls/calls_group_settings.cpp +++ b/Telegram/SourceFiles/calls/calls_group_settings.cpp @@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "calls/calls_group_settings.h" #include "calls/calls_group_call.h" -#include "calls/calls_group_panel.h" // LeaveGroupCallBox. +#include "calls/calls_group_menu.h" // LeaveBox. #include "calls/calls_group_common.h" #include "calls/calls_instance.h" #include "calls/calls_choose_join_as.h" @@ -44,7 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include -namespace Calls { +namespace Calls::Group { namespace { constexpr auto kDelaysCount = 201; @@ -88,7 +88,7 @@ void SaveCallJoinMuted( } // namespace -void GroupCallSettingsBox( +void SettingsBox( not_null box, not_null call) { using namespace Settings; @@ -462,7 +462,7 @@ void GroupCallSettingsBox( )->addClickHandler([=] { if (const auto call = weakCall.get()) { box->getDelegate()->show(Box( - LeaveGroupCallBox, + LeaveBox, call, true, BoxContext::GroupCallPanel)); @@ -495,4 +495,4 @@ void GroupCallSettingsBox( }); } -} // namespace Calls +} // namespace Calls::Group diff --git a/Telegram/SourceFiles/calls/calls_group_settings.h b/Telegram/SourceFiles/calls/calls_group_settings.h index fe7b98fb6..fae25d53c 100644 --- a/Telegram/SourceFiles/calls/calls_group_settings.h +++ b/Telegram/SourceFiles/calls/calls_group_settings.h @@ -10,11 +10,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/layers/generic_box.h" namespace Calls { - class GroupCall; +} // namespace Calls -void GroupCallSettingsBox( +namespace Calls::Group { + +void SettingsBox( not_null box, not_null call); -} // namespace Calls +} // namespace Calls::Group diff --git a/Telegram/SourceFiles/calls/calls_top_bar.cpp b/Telegram/SourceFiles/calls/calls_top_bar.cpp index 0f33e2b51..3e8467e94 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.cpp +++ b/Telegram/SourceFiles/calls/calls_top_bar.cpp @@ -22,7 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "calls/calls_call.h" #include "calls/calls_instance.h" #include "calls/calls_signal_bars.h" -#include "calls/calls_group_panel.h" // LeaveGroupCallBox. +#include "calls/calls_group_menu.h" // Group::LeaveBox. #include "history/view/history_view_group_call_tracker.h" // ContentByCall. #include "data/data_user.h" #include "data/data_group_call.h" @@ -396,10 +396,10 @@ void TopBar::initControls() { group->hangup(); } else { Ui::show(Box( - LeaveGroupCallBox, + Group::LeaveBox, group, false, - BoxContext::MainWindow)); + Group::BoxContext::MainWindow)); } } });